Package com.sun.messaging.jmq.jmsserver.service.imq

Examples of com.sun.messaging.jmq.jmsserver.service.imq.IMQConnection


                    // notify client
                    List l = Globals.getConnectionManager()
                              .getConnectionList(null);
                    Iterator itr = l.iterator();
                    while (itr.hasNext()) {
                        IMQConnection c = (IMQConnection)itr.next();
                        if (!c.isAdminConnection() &&
                            c.getClientProtocolVersion() >=
                                  Connection.HAWK_PROTOCOL) {
                             InfoRequestHandler.sendInfoPacket(
                                   InfoRequestHandler.REQUEST_STATUS_INFO, c, 0);
                        }
                    }
View Full Code Here


       void notifyClients() {
            List l = Globals.getConnectionManager()
                              .getConnectionList(null);
            Iterator itr = l.iterator();
            while (itr.hasNext()) {
                IMQConnection c = (IMQConnection)itr.next();
                if (!c.isAdminConnection() && 
                        c.getClientProtocolVersion() >=
                        Connection.HAWK_PROTOCOL) {
                    InfoRequestHandler.sendInfoPacket(
                        InfoRequestHandler.REQUEST_CLUSTER_INFO,
                        c, 0);
                }
View Full Code Here

                if (DEBUG) {
                    logger.log(logger.INFO, "Processing "+o);
                }
                if (o instanceof ConsumerAddedEvent) {
                    ConsumerAddedEvent e =  (ConsumerAddedEvent)o;
                    IMQConnection conn =  (IMQConnection)cm.getConnection(e.connid);
                    if (e.dest.getAllActiveConsumerCount() > 0) {
                        if (conn == null || conn.isConnectionStarted()) {
                            notifications.put(e.dest.getDestinationUID(),
                                              new ConsumerInfoNotification(
                                              e.dest.getDestinationUID(),
                                              e.dest.getType(), CONSUMER_READY));
                        } else {
                            pendingEvents.add(o);
                            continue;
                        }
                    } else {
                        notifications.put(e.dest.getDestinationUID(),
                                          new ConsumerInfoNotification(
                                          e.dest.getDestinationUID(),
                                          e.dest.getType(), CONSUMER_NOT_READY));
                    }
                    eventQueue.remove(o);
                    pendingEvents.remove(o);
                    continue;
                }
                if (o instanceof RemoteConsumerAddedEvent) {
                    RemoteConsumerAddedEvent e =  (RemoteConsumerAddedEvent)o;
                    if (e.dest.getAllActiveConsumerCount() > 0) {
                        notifications.put(e.dest.getDestinationUID(),
                                          new ConsumerInfoNotification(
                                          e.dest.getDestinationUID(),
                                          e.dest.getType(), CONSUMER_READY));
                    } else {
                        notifications.put(e.dest.getDestinationUID(),
                                          new ConsumerInfoNotification(
                                          e.dest.getDestinationUID(),
                                          e.dest.getType(), CONSUMER_NOT_READY));
                    }
                    eventQueue.remove(o);
                    continue;

                }
                if (o instanceof ConsumerRemovedEvent) {
                    ConsumerRemovedEvent e =  (ConsumerRemovedEvent)o;
                    if (e.dest.getAllActiveConsumerCount() == 0) {
                        notifications.put(e.dest.getDestinationUID(),
                                          new ConsumerInfoNotification(
                                          e.dest.getDestinationUID(),
                                          e.dest.getType(), CONSUMER_NOT_READY));
                    }
                    eventQueue.remove(o);
                    continue;
                }
                if (o instanceof ConnectionStartedEvent) {
                    ConnectionStartedEvent e =  (ConnectionStartedEvent)o;
                    for (int j = 0; j < events.length && !shutdown; j++) {
                        Object oo = events[j];
                        if (oo instanceof ConsumerAddedEvent) {
                            ConsumerAddedEvent ee =  (ConsumerAddedEvent)oo;
                            IMQConnection conn =  (IMQConnection)cm.getConnection(ee.connid);
                            if (conn != null && conn == e.conn &&
                                ee.dest.getAllActiveConsumerCount() > 0) {
                                notifications.put(ee.dest.getDestinationUID(),
                                                  new ConsumerInfoNotification(
                                                  ee.dest.getDestinationUID(),
                                                  ee.dest.getType(), CONSUMER_READY));
                                pendingEvents.remove(ee);
                            }
                        }  
                    }
                    eventQueue.remove(e);
                    continue;
                }
                if (o instanceof ConsumerInfoRequestEvent) {
                    boolean foundmatch = false;
                    boolean hasconsumer = false;
                    boolean notifyadded = false;
                    ConsumerInfoRequestEvent e =  (ConsumerInfoRequestEvent)o;
                    Iterator itr = Destination.getAllDestinations();
                    while (itr.hasNext()) {
                        Destination d = (Destination)itr.next();
                        if (d.isInternal()) {
                            continue;
                        }
                        if ((!e.duid.isWildcard() && d.getDestinationUID().equals(e.duid))) {
                            foundmatch = true;
                            if (d.getAllActiveConsumerCount() == 0) {
                                notifications.put(d.getDestinationUID(),
                                                  new ConsumerInfoNotification(
                                                  d.getDestinationUID(),
                                                  d.getType(), CONSUMER_NOT_READY,
                                                  ((ConsumerInfoRequestEvent)o).infoType, true));
                                notifyadded = true;
                                break;
                            }
                            hasconsumer = true;
                            Iterator itrr = d.getAllActiveConsumers().iterator();
                            while (itrr.hasNext()) {
                                Consumer c = (Consumer)itrr.next();
                                IMQConnection conn = (IMQConnection)cm.getConnection(c.getConnectionUID());
                                BrokerAddress ba = c.getConsumerUID().getBrokerAddress();
                                if ((conn != null && conn.isConnectionStarted()) ||
                                     (ba != null && ba != Globals.getMyAddress())) {
                                    notifications.put(d.getDestinationUID(),
                                                      new ConsumerInfoNotification(
                                                      d.getDestinationUID(),
                                                      d.getType(), CONSUMER_READY,
                                                      ((ConsumerInfoRequestEvent)o).infoType, true));
                                    notifyadded = true;
                                    break;
                                }
                            }
                            break;
                        }
                        if (e.duid.isWildcard() && DestinationUID.match(d.getDestinationUID(), e.duid)) {
                            foundmatch = true;
                            if (d.getAllActiveConsumerCount() == 0) {
                                continue;
                            }
                            hasconsumer = true;
                            Iterator itrr = d.getAllActiveConsumers().iterator();
                            while (itrr.hasNext()) {
                                Consumer c = (Consumer)itrr.next();
                                IMQConnection conn = (IMQConnection)cm.getConnection(c.getConnectionUID());
                                BrokerAddress ba = c.getConsumerUID().getBrokerAddress();
                                if ((conn != null && conn.isConnectionStarted()) ||
                                     (ba != null && ba != Globals.getMyAddress())) {
                                    notifications.put(d.getDestinationUID(),
                                                  new ConsumerInfoNotification(
                                                  d.getDestinationUID(),
                                                  e.destType, CONSUMER_READY,
View Full Code Here

  }

        if (status == Status.OK) {

            ConnectionInfo cxnInfo = null;
            IMQConnection  cxn = null;
            if (cxnId != null) {

                logger.log(Logger.INFO, BrokerResources.I_DESTROY_CXN,
                       String.valueOf(cxnId.longValue()));
                // Get info for one connection
                cxn = (IMQConnection)cm.getConnection(
                                new ConnectionUID(cxnId.longValue()));
                if (cxn != null) {
                    if (DEBUG) {
                        cxn.dump();
                    }
                    cxn.destroyConnection(true, GoodbyeReason.ADMIN_KILLED_CON,
                       Globals.getBrokerResources().getKString(
                       BrokerResources.M_ADMIN_REQ_CLOSE));
                } else {
                    status = Status.NOT_FOUND;
                    errMsg = rb.getString(rb.E_NO_SUCH_CONNECTION,
View Full Code Here

        if (cuid == null) {
            logger.log(Logger.DEBUG,"cant resume flow[no con_uid] " + this);
            return;
        }

        IMQConnection con =(IMQConnection)Globals.getConnectionManager()
                                                 .getConnection(cuid);

        if (reason == null) reason = "Resuming " + this;

        Hashtable hm = new Hashtable();
        hm.put("JMQSize", rfs.size);
        hm.put("JMQBytes", new Long(rfs.bytes));
        hm.put("JMQMaxMsgBytes", new Long(rfs.mbytes));
        if (con != null) {
            Packet pkt = new Packet(con.useDirectBuffers());
            pkt.setPacketType(PacketType.RESUME_FLOW);
            hm.put("JMQProducerID", new Long(getProducerUID().longValue()));
            hm.put("JMQDestinationID", duid.toString());
            hm.put("Reason", reason);
            pkt.setProperties(hm);
            con.sendControlMessage(pkt);
        }
    }
View Full Code Here

            }
        } else if (ref.getMessageDeliveredAck(uid)) {
            HashMap props = null;
            ConnectionUID cuid = getConnectionUID();
            if (cuid != null) {
                IMQConnection con = (IMQConnection)Globals.getConnectionManager().
                                                         getConnection(cuid);
                if (con != null) {
                    props = new HashMap();
                    props.put(Consumer.PREFETCH,
                              new Integer(con.getFlowCount()));
                }
            }
            try {
                Globals.getClusterBroadcast().acknowledgeMessage(
                    ref.getAddress(), ref.getSysMessageID(),
View Full Code Here

                      msg = "No consumers on the broker";
                  }
                  while (itr.hasNext()) {
                      Consumer c = (Consumer)itr.next();
                      if ( c == null) continue;
                      IMQConnection cxn = (IMQConnection)
                          Globals.getConnectionManager()
                              .getConnection(c.getConnectionUID());
                      ConsumerUID cuid = c.getConsumerUID();
                      ConnectionUID cxuid = c.getConnectionUID();
                      debugHash.put(String.valueOf(
                             (cuid == null ? 0 : cuid.longValue())),
                             (cxn == null ? "none" : cxn.getRemoteConnectionString())
                            + " ["
                            +  String.valueOf( (cxuid == null ? 0 :
                                 cxuid.longValue())) + "]");
                  }
              } else if (targetType == null) {
                  msg = "Please supply targetType if you are supplying a target ";
                  status = Status.ERROR;
              } else if (targetType.equals("t") || targetType.equals("q")) {
                  try {
                      boolean isQueue = false;
                      if (targetType.equals("q")) {
                          isQueue = true;
                      }
                      DestinationUID uid = null;
                      Destination d = null;
                     
                      if (status != Status.ERROR) {
                          uid = DestinationUID.getUID(target,isQueue);
                          d = Destination.getDestination(uid);
                      }
                      if (status != Status.ERROR && d == null) {
                          status = Status.ERROR;
                          msg = "Error listing consumers on destination  " + target +
                             " unknown destination";
                      } else if (status != Status.ERROR) {
                          Iterator itr = d.getConsumers();
                          if (!itr.hasNext()) {
                              status = Status.ERROR;
                              msg = "No consumers on destination  " + target ;
                          }
     
                          while (itr.hasNext()) {
                              Consumer c = (Consumer)itr.next();
                              IMQConnection cxn = (IMQConnection)
                              Globals.getConnectionManager()
                                  .getConnection(c.getConnectionUID());
                              debugHash.put(String.valueOf(
                                  c.getConsumerUID().longValue()),
                                  (cxn == null ? "" : cxn.getRemoteConnectionString())  + " ["
                                  + String.valueOf((c.getConnectionUID() == null ?
                                                    "none":c.getConnectionUID().longValue())) + "]");
                          }
                      }
                   } catch (Exception ex) {
                       status = Status.ERROR;
                       msg = "Error listing consumers on connection  " + target +
                         " because " + ex.toString();
                      logger.logStack(Logger.INFO,msg, ex);
                   }
              } else if (targetType.equals("ses")) {
                  try {
                      SessionUID uid = new SessionUID(
                          Long.parseLong(target));
                      Session ses = Session.getSession(uid);
                      if (ses == null) {
                          status = Status.ERROR;
                          msg = "Error listing consumers on session  "
                             + target + " unknown sessionUID";
                      } else {
                          Iterator itr = ses.getConsumers();
                          if (!itr.hasNext()) {
                              status = Status.ERROR;
                              msg = "No consumers on session  " + target ;
                          }
                          while (ses != null && itr.hasNext()) {
                              Consumer c = (Consumer)itr.next();
                              if (uid.equals(c.getConnectionUID())) {
                                  debugHash.put(String.valueOf(
                                        c.getConsumerUID().longValue()),
                                        c.getDestinationUID().toString());
                              }
                          }
                      }
                } catch (Exception ex) {
                    status = Status.ERROR;
                    msg = "Error listing consumers on connection  " + target +
                         " because " + ex.toString();
                    logger.logStack(Logger.INFO,msg, ex);
                }
              } else if (targetType.equals("cxn")) {
                  try {
                      ConnectionUID uid = new ConnectionUID(
                          Long.parseLong(target));
                      IMQConnection cxn = (IMQConnection)
                          Globals.getConnectionManager()
                                  .getConnection(uid);
                      if (cxn == null) {
                          status = Status.ERROR;
                          msg = "Error listing consumers on connection  " + target +
                             " unknown connectionUID";
                      } else {
                          Iterator itr = Consumer.getAllConsumers();
                          while (cxn != null && itr.hasNext()) {
                              Consumer c = (Consumer)itr.next();
                              if (uid.equals(c.getConnectionUID())) {
                                  debugHash.put(String.valueOf(
                                        c.getConsumerUID().longValue()),
                                        c.getDestinationUID().toString());
                              }
                          }
                      }
                } catch (Exception ex) {
                    status = Status.ERROR;
                    msg = "Error listing consumers on connection  " + target +
                         " because " + ex.toString();
                    logger.logStack(Logger.INFO,msg, ex);
                }
              } else  {
                  status = Status.ERROR;
                  msg = "Unknown targetType (-t) " + target
                        + "\n Valid formats are of the form: "
                        + "[q|t|ses|cxn]";
              }
            } else if (cmdarg.equals("prd")) {
           debugHash = new Hashtable();
             
              if (target == null) { // all
                  Iterator itr = Producer.getAllProducers();
                  while (itr.hasNext()) {
                      Producer c = (Producer)itr.next();
                      IMQConnection cxn = (IMQConnection)
                          Globals.getConnectionManager()
                              .getConnection(c.getConnectionUID());
                      debugHash.put(String.valueOf(
                             c.getProducerUID().longValue()),
                             cxn.getRemoteConnectionString()  + " ["
                            +  String.valueOf(c.getConnectionUID()
                                 .longValue()) + "]");
                  }
              } else if (targetType == null) {
                  msg = "Please supply targetType if you are supplying a target ";
                  status = Status.ERROR;
              } else if (targetType.equals("t") || targetType.equals("q")) {
                  // destination
                  boolean isQueue = false;
                  if (targetType.equals("q")) {
                     isQueue = true;
                  }
                  try {
                      DestinationUID uid = DestinationUID.getUID(target, isQueue);
                      Destination d = Destination.getDestination(uid);
                      if (d == null) {
                          status = Status.ERROR;
                          msg = "Error listing producers on destination  " + target +
                             " unknown destination";
                      } else {
                          Iterator itr = d.getProducers();
                          while (itr.hasNext()) {
                              Producer c = (Producer)itr.next();
                              IMQConnection cxn = (IMQConnection)
                              Globals.getConnectionManager()
                                  .getConnection(c.getConnectionUID());
                              debugHash.put(String.valueOf(
                                  c.getProducerUID().longValue()),
                                  cxn.getRemoteConnectionString()  + " ["
                                  + String.valueOf(c.getConnectionUID()
                                     .longValue()) + "]");
                          }
                      }
                   } catch (Exception ex) {
                       status = Status.ERROR;
                       msg = "Error listing producers on connection  " + target +
                         " because " + ex.toString();
                      logger.logStack(Logger.INFO,msg, ex);
                   }
              } else if (targetType.equals("cxn")) {
                  try {
                      ConnectionUID uid = new ConnectionUID(
                          Long.parseLong(target));
                      IMQConnection cxn = (IMQConnection)
                          Globals.getConnectionManager()
                                  .getConnection(uid);
                      if (cxn == null) {
                          status = Status.ERROR;
                          msg = "Error listing producers on connection  " + target +
                             " unknown connectionUID";
                      } else {
                          Iterator itr = Producer.getAllProducers();
                          while (cxn != null && itr.hasNext()) {
                              Producer c = (Producer)itr.next();
                              if (uid.equals(c.getConnectionUID())) {
                                  debugHash.put(String.valueOf(
                                        c.getProducerUID().longValue()),
                                        c.getDestinationUID().toString());
                              }
                          }
                      }
                } catch (Exception ex) {
                    status = Status.ERROR;
                    msg = "Error listing producers on connection  " + target +
                         " because " + ex.toString();
                    logger.logStack(Logger.INFO,msg, ex);
                }
              } else  {
                  status = Status.ERROR;
                  msg = "Unknown targetType (-t) " + targetType
                        + "\n Valid formats are of the form: "
                        + "[t|q|cxn]";
              }
            } else {
                status = Status.ERROR;
                msg = "Unknown argument " + cmdarg;
            }
               
        } else if (cmd.equals("debug")) {
            String debugStr = (String) p.get("enable");

            if (debugStr != null && !debugStr.equalsIgnoreCase("true")
                 && !debugStr.equalsIgnoreCase("false")) {
                status = Status.ERROR;
                msg = "bad enable flag setting " +
                   debugStr + " defauling to false";
            }
            boolean debugOn=(debugStr == null) ? true :
                      Boolean.valueOf(debugStr).booleanValue();
            if (cmdarg.equals("reset")) {
                if (targetType == null) {
                    msg = "Please supply targetType (-t)\n Valid formats are of the form: [metrics|jdbcconnpool]";
                    status = Status.ERROR;
                } else if (targetType.equalsIgnoreCase("jdbcconnpool")) {
                    try {
                        if (Globals.getStore().isJDBCStore()) {
                            com.sun.messaging.jmq.jmsserver.persist.jdbc.DBManager.getDBManager().resetConnectionPool();
                        } else {
                            status = Status.ERROR;
                            msg = "Operation is not applicable for a file-based data store.";                           
                        }
                    } catch (Exception ex) {
                        status = Status.ERROR;
                        msg = "Error resetting JDBC connection pool because " +
                            ex.toString();
                        logger.logStack(Logger.INFO, msg, ex);
                    }
                } else if (targetType.equalsIgnoreCase("metrics")) {
                    com.sun.messaging.jmq.jmsserver.data.handlers.admin.ResetMetricsHandler.resetAllMetrics();
                }
            } else if (cmdarg.equals("fault")) {

                // handle fault injection
                String faultName = (String)p.get("name");
                if (faultName == null)
                    faultName = target;
                String faultSelector = (String)p.get("selector");
                FaultInjection fi = FaultInjection.getInjection();
                boolean faultOn = true;

                // ok only turn off fault injection if no name pair
                if (debugStr != null && debugStr.equalsIgnoreCase("false")) {
                    if (faultName == null) {
                        fi.setFaultInjection(false);
                    } else {
                        fi.unsetFault(faultName);
                    }
                } else {
                    fi.setFaultInjection(true);
                    if (faultName != null) {
                        try {
                            fi.setFault(faultName, faultSelector, p);
                        } catch (Exception ex) {
                          status = Status.ERROR;
                          msg = "Bad Selector " + faultSelector;
                        }
                    }
                }

            } else if (cmdarg.equals("gc")) {
                logger.log(Logger.INFO,"GC'ing the system");
                com.sun.messaging.jmq.jmsserver.Broker.runGC();
                long usedMem = (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory());
                msg = "Used memory is " +
                    (usedMem/1024l) + "k, "  +
                   " this is " + (usedMem*100/Runtime.getRuntime().maxMemory())
                    + "% of " + (Runtime.getRuntime().maxMemory()/1024l)
                     + "k";
                logger.log(Logger.INFO,msg);
                if (debugHash == null) debugHash = new Hashtable();
                debugHash.put("Memory", msg);
                debugHash.put("Used", (usedMem/1024l)+"k");
                debugHash.put("Total", ((Runtime.getRuntime().totalMemory()/1024l)+"k"));
                debugHash.put("Free", ((Runtime.getRuntime().freeMemory()/1024l)+"k"));
                debugHash.put("Max", ((Runtime.getRuntime().maxMemory()/1024l)+"k"));
            } else if (cmdarg.equals("threads")) {
                // log
                try {
                    debugHash = new Hashtable();
                    debugHash.put("threads", "dumped to log");
                } catch (Exception ex) {
                    status = Status.ERROR;
                    msg = "Error "+cmd+"ing " + cmdarg + " because "
                         + ex.getMessage() + "";
                    logger.logStack(Logger.INFO,msg, ex);
                }
                logger.log(Logger.INFO,"Dumping threads:\n" + SupportUtil.getAllStackTraces("\t"));
            } else if (cmdarg.equals("pkt")) {
                IMQBasicConnection.dumpPacket(debugOn);
            } else if (cmdarg.equals("pktin")) {
                IMQBasicConnection.dumpInPacket(debugOn);
            } else if (cmdarg.equals("pktout")) {
                IMQBasicConnection.dumpOutPacket(debugOn);
            } else if (cmdarg.equals("class")) {
                try {
                    Class cl = Class.forName(target);
                    Field[] fields = cl.getDeclaredFields();
                    boolean found = false;
                    for (int i = 0; i < fields.length; i++) {
                         if (fields[i].getName().equals(Debug.debugFieldName)) {
                             fields[i].setAccessible(true);
                             fields[i].setBoolean(null, debugOn);
                             found = true;
                             break;
                         }
                    }
                    if (!found) throw new NoSuchFieldException(Debug.debugFieldName);
                } catch (Exception ex) {
                   status = Status.ERROR;
                   msg = "Unable to set DEBUG on class " + target +
                         " because " + ex.toString();
                   logger.logStack(Logger.INFO,msg, ex);
                }
            } else {
                status = Status.ERROR;
                msg = "Unknown debug argument " + cmdarg;           
            }
        } else if (cmd.equals("resume")) {
            // session, connection, consumerUID, producer
            if (cmdarg.equals("prd")) {
                try {
                    ProducerUID pid = new ProducerUID(
                        Long.parseLong(target));
                    Producer pr = Producer.getProducer(pid);
                    Destination d = Destination.getDestination(
                          pr.getDestinationUID());
                    logger.log(Logger.INFO,"Resuming " + pr);
                    d.forceResumeFlow(pr);
                   
                } catch (Exception ex) {
                    status = Status.ERROR;
                    msg = "Error resuming flow from producer  " + target +
                         " because " + ex.toString();
                   logger.logStack(Logger.INFO,msg, ex);
                }
            } else if (cmdarg.equals("cxn")) {
                try {
                    ConnectionUID uid = new ConnectionUID(
                        Long.parseLong(target));
                    IMQConnection cxn = (IMQConnection)
                        Globals.getConnectionManager()
                                .getConnection(uid);
                    cxn.resumeFlow(-1);
                   
                } catch (Exception ex) {
                    status = Status.ERROR;
                    msg = "Error resuming flow on connection  " + target +
                         " because " + ex.toString();
                   logger.logStack(Logger.INFO,msg, ex);
                }
            } else if (cmdarg.equals("con")) {
                try {
                    ConsumerUID cid = new ConsumerUID(
                        Long.parseLong(target));
                    Consumer cxn = (Consumer)
                        Consumer.getConsumer(cid);
                    cxn.resume("admin debug");
                } catch (Exception ex) {
                    status = Status.ERROR;
                    msg = "Error resuming flow to consumer  " + target +
                         " because " + ex.toString();
                   logger.logStack(Logger.INFO,msg, ex);
                }
            } else if (cmdarg.equals("ses")) {
                try {
                    SessionUID sid = new SessionUID(
                        Long.parseLong(target));
                    Session session = (Session)
                        Session.getSession(sid);
                    session.resume("admin debug");
                } catch (Exception ex) {
                    status = Status.ERROR;
                    msg = "Error resuming flow to session  " + target +
                         " because " + ex.toString();
                   logger.logStack(Logger.INFO,msg, ex);
                }
            } else {
                status = Status.ERROR;
                msg = "Unknown resume argument " + cmdarg;           
            }
        } else if (cmd.equals("send")) {
            if (cmdarg.equals("cxn")) {
                try {
                    if (target == null) {
                        status = Status.ERROR;
                        msg = "Missing connectionUID ";
                    } else {
                        ConnectionUID uid = new ConnectionUID(
                            Long.parseLong(target));
                        IMQConnection cxn = (IMQConnection)
                            Globals.getConnectionManager()
                                    .getConnection(uid);
                        if (cxn == null) {
                            status = Status.ERROR;
                            msg = "Unknown connectionUID " + uid;
                        } else {
                            Packet pkt = new Packet(false);
                            pkt.setPacketType(PacketType.DEBUG);
                            Hashtable hash = new Hashtable(cmd_props);
                            ByteArrayOutputStream bos = new ByteArrayOutputStream();
                            ObjectOutputStream oos = new ObjectOutputStream(bos);
                            oos.writeObject(p);
                            oos.flush();
                            bos.flush();
                            pkt.setMessageBody(bos.toByteArray());
                            //hash.putAll(p);
                            pkt.setProperties(hash);
                            cxn.sendControlMessage(pkt);
                        }
                    }
                } catch (Exception ex) {
                    status = Status.ERROR;
                    msg = "Error notifying consumer  " + target +
                         " because " + ex.toString();
                    logger.logStack(Logger.INFO,msg, ex);
                }
            } else if (cmdarg.equals("bkr") || cmdarg.equals("svc")) {
                Service s = null;
                if (target != null) {
                    s = Globals.getServiceManager().getService(
                        target);
                    if (s == null) {
                        msg = "Unknown service " + target ;
                        status = Status.ERROR;
                    }
                }

                Iterator itr = Globals.getConnectionManager().
                       getConnectionList(s).iterator();
                try {
                    while (itr.hasNext()) {
                        IMQConnection cxn = (IMQConnection)itr.next();
                        Packet pkt = new Packet(false);
                        pkt.setPacketType(PacketType.DEBUG);
                        Hashtable hash = new Hashtable(cmd_props);
                        ByteArrayOutputStream bos = new ByteArrayOutputStream();
                        ObjectOutputStream oos = new ObjectOutputStream(bos);
                        oos.writeObject(p);
                        oos.flush();
                        bos.flush();
                        pkt.setMessageBody(bos.toByteArray());
                        pkt.setProperties(hash);
                        cxn.sendControlMessage(pkt);
                    }
                } catch (Exception ex) {
                    status = Status.ERROR;
                    msg = "Error notifying consumer  " + target +
                         " because " + ex.toString();
                    logger.logStack(Logger.INFO,msg, ex);
                }
                 
            } else {
                status = Status.ERROR;
                msg = "Unknown send argument " + cmdarg;           
            }
        } else if (cmd.equals("kill")) {
            if (cmdarg.equals("cxn")) {
                try {
                    ConnectionUID uid = new ConnectionUID(
                        Long.parseLong(target));
                    IMQConnection cxn = (IMQConnection)
                        Globals.getConnectionManager()
                                .getConnection(uid);
                    cxn.destroyConnection(true, GoodbyeReason.ADMIN_KILLED_CON,
                            "kill cnx");

                } catch (Exception ex) {
                    status = Status.ERROR;
                    msg = "Error killing connection  " + target +
View Full Code Here

            if (target == null) {
                throw new Exception("Please specify connectionUID" );
            }
            ConnectionUID uid = new ConnectionUID(
                      Long.parseLong(target));
            IMQConnection cxn = (IMQConnection)
                Globals.getConnectionManager()
                .getConnection(uid);
            if (cxn == null)
                throw new Exception("Can not find connection " + uid);
            ht.put(target,cxn.getDebugMessages(full));
        } else if (type.equals("ses")) {
            ht.put("Dump acks ", target);
            if (target == null) {
                throw new Exception("Please specify SessionUID" );
            }
View Full Code Here

            debugHash.put("threadPool", getThreadPoolInfo(svc));
            debugHash.put("threads", SupportUtil.getAllStackTraces(""));
        }
        Iterator itr = Globals.getConnectionManager().getConnectionList(s).iterator();
        while (itr.hasNext()) {
            IMQConnection c = (IMQConnection) itr.next();
            debugHash.put(c.getRemoteConnectionString(), c.getDebugState());
        }
        return debugHash;
    }
View Full Code Here


    private Hashtable getCxnInfo(ConnectionUID uid)
        throws Exception
    {
        IMQConnection cxn = (IMQConnection)
                Globals.getConnectionManager()
                .getConnection(uid);
        if (cxn == null)
            throw new Exception("Can not find uid " + uid);

        return cxn.getDebugState();
    }
View Full Code Here

TOP

Related Classes of com.sun.messaging.jmq.jmsserver.service.imq.IMQConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.