Package com.sun.messaging.jmq.jmsserver.management.agent

Examples of com.sun.messaging.jmq.jmsserver.management.agent.Agent$ClusterStateListener


                return;
            }
            shutdownStarted = true;
        }

  Agent agent = Globals.getAgent();
  if (agent != null)  {
      agent.notifyShutdownStart();
  }

        if (time > 0) {
            targetShutdownTime = System.currentTimeMillis() +
                         time;
View Full Code Here


            throws BrokerException
        {
            logger.log(Logger.INFO,
                BrokerResources.I_QUIESCE_START);

      Agent agent = Globals.getAgent();
      if (agent != null)  {
          agent.notifyQuiesceStart();
      }

            try {
                ClusteredBroker cb = Globals.getClusterManager().getLocalBroker();
                cb.setState(BrokerState.QUIESCE_STARTED);
View Full Code Here

               }
               logger.log(Logger.INFO, BrokerResources.I_QUIESCE_DONE);
               synchronized(this) {
                    qrun = null; // we are done
                }
         Agent agent = Globals.getAgent();
         if (agent != null)  {
             agent.notifyQuiesceComplete();
         }

            } catch (Exception ex) {
                Globals.getLogger().logStack(
                    Logger.WARNING, BrokerResources.E_INTERNAL_BROKER_ERROR,
View Full Code Here

                    tlist.destroy();
                }

             // stop JMX connectors
                if (cleanupJMX) {
              Agent agent = Globals.getAgent();
              if (agent != null)  {
                  agent.stop();
            agent.unloadMBeans();
              }
                } else {
                    Globals.getLogger().log(Logger.INFO,
                        BrokerResources.I_JMX_NO_SHUTDOWN);
                }
View Full Code Here

           Subscription.clearSubscriptions();
           LockFile.clearLock();
           TLSProtocol.destroy();

        // stop JMX connectors
     Agent agent = Globals.getAgent();
     if (agent != null)  {
         agent.stop();
         agent.unloadMBeans();
     }
      
           PortMapper pm = Globals.getPortMapper();
    
           pm.destroy();
View Full Code Here

        }

  // Initialize the JMX Agent
  try  {
            Class c = Class.forName("javax.management.MBeanServer");
      Agent agent = new Agent();
      Globals.setAgent(agent);
      agent.start();
        } catch (Exception e)  {
            logger.log(Logger.WARNING,
                "JMX classes not present - JMX Agent is not created.");
        }

        /*
         * Check if we should support old (pre 3.0.1SP2) selector
         * type conversions (which violated the JMS spec).
         */
        Selector.setConvertTypes(conf.getBooleanProperty(Globals.IMQ +
            ".selector.convertTypes", false));
        /*
         * By default the selector code short circuits boolean expression
         * evaluation. This is a back door to disable that in case there
         * is a flaw in the implementation.
         */
        Selector.setShortCircuit(conf.getBooleanProperty(Globals.IMQ +
            ".selector.shortCircuit", true));


        // create the handlers - these handle the message
        // processing
        pktrtr = new PacketRouter();

        Globals.setProtocol( new ProtocolImpl(pktrtr));
        HelloHandler hello = new HelloHandler(cmgr);
        GetLicenseHandler getLicense = new GetLicenseHandler();
        GoodbyeHandler goodbye = new GoodbyeHandler(cmgr);

        // XXX - REVISIT 2/25/00
        // we may want to load these from properties in the future
        //
        StartStopHandler startstop = new StartStopHandler();
        ConsumerHandler conhdlr = new ConsumerHandler();
        ProducerHandler prodhandler = new ProducerHandler();
        DestinationHandler desthandler = new DestinationHandler();
        QBrowseHandler qbrowserhdlr = new QBrowseHandler();
        AuthHandler authenticate = new AuthHandler(cmgr);
        SessionHandler sessionhdlr = new SessionHandler();
        PingHandler pinghandler = new PingHandler();

        DataHandler datahdrl = new DataHandler(tlist);

        AckHandler ackhandler = new AckHandler(tlist);
        RedeliverHandler redeliverhdlr =
                                new RedeliverHandler();

        DeliverHandler deliverhdlr = new DeliverHandler();
        TransactionHandler thandler =
                                new TransactionHandler(tlist);
        VerifyDestinationHandler vdhandler = new VerifyDestinationHandler();
        ClientIDHandler clienthandler = new ClientIDHandler();

        FlowHandler flowhdlr = new FlowHandler();
        FlowPausedHandler fphandler = new FlowPausedHandler();

        GenerateUIDHandler genUIDhandler = new GenerateUIDHandler();

        InfoRequestHandler infohandler = new InfoRequestHandler();
        VerifyTransactionHandler vthandler = new VerifyTransactionHandler(tlist);


        // Map message handles -> messages
        try {

            pktrtr.addHandler(PacketType.HELLO, hello);
            pktrtr.addHandler(PacketType.AUTHENTICATE, authenticate);
            pktrtr.addHandler(PacketType.GET_LICENSE, getLicense);
            pktrtr.addHandler(PacketType.ADD_CONSUMER, conhdlr);
            pktrtr.addHandler(PacketType.DELETE_CONSUMER, conhdlr);
            pktrtr.addHandler(PacketType.ADD_PRODUCER, prodhandler);
            pktrtr.addHandler(PacketType.START, startstop);
            pktrtr.addHandler(PacketType.STOP, startstop);
            pktrtr.addHandler(PacketType.ACKNOWLEDGE, ackhandler);
            pktrtr.addHandler(PacketType.BROWSE, qbrowserhdlr);
            pktrtr.addHandler(PacketType.GOODBYE, goodbye);
            pktrtr.addHandler(PacketType.REDELIVER, redeliverhdlr);
            pktrtr.addHandler(PacketType.CREATE_DESTINATION, desthandler);
            pktrtr.addHandler(PacketType.DESTROY_DESTINATION, desthandler);
            pktrtr.addHandler(PacketType.VERIFY_DESTINATION, vdhandler);
            pktrtr.addHandler(PacketType.DELIVER, deliverhdlr);
            pktrtr.addHandler(PacketType.START_TRANSACTION, thandler);
            pktrtr.addHandler(PacketType.COMMIT_TRANSACTION, thandler);
            pktrtr.addHandler(PacketType.ROLLBACK_TRANSACTION, thandler);
            pktrtr.addHandler(PacketType.PREPARE_TRANSACTION, thandler);
            pktrtr.addHandler(PacketType.END_TRANSACTION, thandler);
            pktrtr.addHandler(PacketType.RECOVER_TRANSACTION, thandler);
            pktrtr.addHandler(PacketType.SET_CLIENTID, clienthandler);
            pktrtr.addHandler(PacketType.GENERATE_UID, genUIDhandler);
            pktrtr.addHandler(PacketType.MAP_MESSAGE, datahdrl);
            pktrtr.addHandler(PacketType.BYTES_MESSAGE, datahdrl);
            pktrtr.addHandler(PacketType.MESSAGE, datahdrl);
            pktrtr.addHandler(PacketType.MESSAGE_SET, datahdrl);
            pktrtr.addHandler(PacketType.OBJECT_MESSAGE, datahdrl);
            pktrtr.addHandler(PacketType.STREAM_MESSAGE, datahdrl);
            pktrtr.addHandler(PacketType.TEXT_MESSAGE, datahdrl);
            pktrtr.addHandler(PacketType.RESUME_FLOW, flowhdlr);
            pktrtr.addHandler(PacketType.FLOW_PAUSED, fphandler);

            pktrtr.addHandler(PacketType.CREATE_SESSION,sessionhdlr);
            pktrtr.addHandler(PacketType.DELETE_PRODUCER,prodhandler);
            pktrtr.addHandler(PacketType.DESTROY_SESSION,sessionhdlr);
            pktrtr.addHandler(PacketType.PING,pinghandler);

            pktrtr.addHandler(PacketType.INFO_REQUEST,infohandler);
            pktrtr.addHandler(PacketType.VERIFY_TRANSACTION,vthandler);

        } catch (Exception ex) {
            logger.logStack(Logger.WARNING,
                            BrokerResources.E_INTERNAL_BROKER_ERROR,
                            "adding packet handlers", ex);
        }


        // set up the admin packet router
        admin_pktrtr = new PacketRouter();
        AdminDataHandler admin_datahdrl = new
            AdminDataHandler(tlist);
        // Map message handles -> messages. For the admin service this
        // is just like the regular JMS service except we have a specialized
        // data handler
        try {
            admin_pktrtr.addHandler(PacketType.HELLO, hello);
            admin_pktrtr.addHandler(PacketType.AUTHENTICATE, authenticate);
            admin_pktrtr.addHandler(PacketType.GET_LICENSE, getLicense);
            admin_pktrtr.addHandler(PacketType.ADD_CONSUMER, conhdlr);
            admin_pktrtr.addHandler(PacketType.DELETE_CONSUMER, conhdlr);
            admin_pktrtr.addHandler(PacketType.ADD_PRODUCER, prodhandler);
            admin_pktrtr.addHandler(PacketType.START, startstop);
            admin_pktrtr.addHandler(PacketType.STOP, startstop);
            admin_pktrtr.addHandler(PacketType.ACKNOWLEDGE, ackhandler);
            admin_pktrtr.addHandler(PacketType.BROWSE, qbrowserhdlr);
            admin_pktrtr.addHandler(PacketType.GOODBYE, goodbye);
            admin_pktrtr.addHandler(PacketType.REDELIVER, redeliverhdlr);
            admin_pktrtr.addHandler(PacketType.CREATE_DESTINATION, desthandler);
            admin_pktrtr.addHandler(PacketType.DESTROY_DESTINATION,
                                                                desthandler);
            admin_pktrtr.addHandler(PacketType.VERIFY_DESTINATION, vdhandler);
            admin_pktrtr.addHandler(PacketType.DELIVER, deliverhdlr);
            admin_pktrtr.addHandler(PacketType.START_TRANSACTION, thandler);
            admin_pktrtr.addHandler(PacketType.COMMIT_TRANSACTION, thandler);
            admin_pktrtr.addHandler(PacketType.ROLLBACK_TRANSACTION, thandler);
            admin_pktrtr.addHandler(PacketType.PREPARE_TRANSACTION, thandler);
            admin_pktrtr.addHandler(PacketType.END_TRANSACTION, thandler);
            admin_pktrtr.addHandler(PacketType.RECOVER_TRANSACTION, thandler);
            admin_pktrtr.addHandler(PacketType.SET_CLIENTID, clienthandler);
            admin_pktrtr.addHandler(PacketType.GENERATE_UID, genUIDhandler);

            admin_pktrtr.addHandler(PacketType.MAP_MESSAGE, admin_datahdrl);
            admin_pktrtr.addHandler(PacketType.BYTES_MESSAGE, admin_datahdrl);
            admin_pktrtr.addHandler(PacketType.MESSAGE, admin_datahdrl);
            admin_pktrtr.addHandler(PacketType.MESSAGE_SET, admin_datahdrl);
            admin_pktrtr.addHandler(PacketType.OBJECT_MESSAGE, admin_datahdrl);
            admin_pktrtr.addHandler(PacketType.STREAM_MESSAGE, admin_datahdrl);
            admin_pktrtr.addHandler(PacketType.TEXT_MESSAGE, admin_datahdrl);
            admin_pktrtr.addHandler(PacketType.RESUME_FLOW, flowhdlr);
            admin_pktrtr.addHandler(PacketType.FLOW_PAUSED, fphandler);

            admin_pktrtr.addHandler(PacketType.CREATE_SESSION,sessionhdlr);
            admin_pktrtr.addHandler(PacketType.DELETE_PRODUCER,prodhandler);
            admin_pktrtr.addHandler(PacketType.DESTROY_SESSION,sessionhdlr);
        } catch (Exception ex) {
            logger.logStack(Logger.WARNING,
                            BrokerResources.E_INTERNAL_BROKER_ERROR,
                            "adding packet handlers to admin packet router",
                            ex);
        }

        // The admin message handlers may need to locate standard packet
        // handlers, so we give it a reference to the PacketRouter.
        admin_datahdrl.setPacketRouter(admin_pktrtr);


        PacketRouter routers[] = {pktrtr, admin_pktrtr};
        Globals.setPacketRouters(routers);

        if (mbus instanceof com.sun.messaging.jmq.jmsserver.core.cluster.ClusterBroadcaster) {
            if (Globals.useSharedConfigRecord()) {
                try {
                ((com.sun.messaging.jmq.jmsserver.core.cluster.ClusterBroadcaster)mbus).
                    getRealClusterBroadcaster().syncChangeRecordOnStartup();
                } catch (Exception e) {
                    logger.logStack(Logger.ERROR, rb.getKString(
                    rb.E_SHARCC_SYNC_ON_STARTUP_FAILED, Globals.getClusterID(),
                    e.getMessage()), e);
                    return (1);
                }
            }
        }

        TLSProtocol.init();
        ServiceManager sm = new ServiceManager(cmgr);
        Globals.setServiceManager(sm);

        sm.updateServiceList(sm.getAllActiveServiceNames(),
            ServiceType.ADMIN, false);

        /*
         * Check if we need to pause the normal services until
         * MessageBus syncs with the config server. The services
         * will be resumed by the MessageManager when it gets
         * a notification from the MessageBus
         */
        if (mbus.waitForConfigSync()) {
            sm.updateServiceList(sm.getAllActiveServiceNames(),
                                 ServiceType.NORMAL, true /* pause */);
            if (Globals.nowaitForMasterBroker()) {
                sm.addServiceRestriction(ServiceType.NORMAL,
                   ServiceRestriction.NO_SYNC_WITH_MASTERBROKER);
                logger.log(Logger.WARNING, rb.I_MBUS_LIMITEDJMS);
                try {
                sm.resumeAllActiveServices(ServiceType.NORMAL);
                } catch (BrokerException e) {
                logger.logStack(Logger.ERROR,  e.getMessage(), e);
                }
            } else {
                logger.log(Logger.ERROR, rb.I_MBUS_PAUSING);
            }
        } else {
            sm.updateServiceList(sm.getAllActiveServiceNames(),
                ServiceType.NORMAL, false /* dont pause */);
        }

        // OK, create the BrokerStateHandler
        Globals.setBrokerStateHandler(new BrokerStateHandler());

       
        // provide an option not to add shutdown hook.
        // This makes it easier to test restarts after ungraceful exits
        boolean noShutdownHook = Boolean.getBoolean (Globals.IMQ+".noShutdownHook");
       
       
        // Add the shutdownHook. The hook gets called when the VM exits
        // and gives us a chance to cleanup. This is new in JDK1.3.
       
                      
        if (inProcess || noShutdownHook || (shutdownHook = addShutdownHook()) == null) {
            // Couldn't add shutdown hook. Probably because running against 1.2
            logger.log(Logger.DEBUG, rb.I_NO_SHUTDOWN_HOOK);
        } else {
            logger.log(Logger.DEBUG, rb.I_SHUTDOWN_HOOK);
        }

        // start the memory manager
        if (!inProcess) {
            Globals.getMemManager().startManagement();
        } else {
            Globals.setMemMgrOn(false);
        }

        // Initialize the metric manager. This is the module that
        // generates performance data reports
        MetricManager mm = new MetricManager();
        Globals.setMetricManager(mm);
        mm.setParameters(Globals.getConfig());

        /*
         * Set the list of properties that must be matched before
         * accepting connections from other brokers.
         */
        Properties matchProps = new Properties();

        matchProps.setProperty(Globals.IMQ + ".autocreate.queue",
            Globals.getConfig().getProperty(Globals.IMQ +
                                            ".autocreate.queue", "false"));

        matchProps.setProperty(Globals.IMQ + ".autocreate.topic",
            Globals.getConfig().getProperty(Globals.IMQ +
                                            ".autocreate.topic", "false"));

        //
        // "imq.queue.deliverypolicy" was used as one of the
        // "matchProps" in the 3.0.1 clusters. So even if this
        // property is now obsolete we still need to pretend that it
        // exists for cluster protocol compatibility..
        //
        int active =
            Queue.getDefaultMaxActiveConsumers();

        int failover =
            Queue.getDefaultMaxFailoverConsumers();

        if (active == 1 && failover == 0) {
            matchProps.setProperty(Globals.IMQ + ".queue.deliverypolicy",
                "single");
        }
        if (active == 1 && failover != 0) {
            matchProps.setProperty(Globals.IMQ + ".queue.deliverypolicy",
                "failover");
        }
        if ((active == Queue.UNLIMITED || active > 1) && failover == 0) {
            matchProps.setProperty(Globals.IMQ + ".queue.deliverypolicy",
                "round-robin");
        }

        if (Globals.getClusterID() != null) {
            matchProps.setProperty(Globals.IMQ + ".cluster.clusterid",
                                   Globals.getClusterID());
        }
        if (isHA) {
            matchProps.setProperty(Globals.IMQ + ".cluster.ha",
              Globals.getConfig().getProperty(Globals.IMQ +".cluster.ha")); //must true
            matchProps.setProperty(Globals.IMQ + ".cluster.monitor.interval",
                                   String.valueOf(haMonitor.getMonitorInterval()));
            matchProps.setProperty(Globals.IMQ + ".cluster.heartbeat.class",
              Globals.getConfig().getProperty(Globals.IMQ +".cluster.heartbeat.class"));
            matchProps.setProperty(Globals.IMQ + ".service.activelist",
              Globals.getConfig().getProperty(Globals.IMQ +".service.activelist"));
            matchProps.setProperty(Globals.IMQ + ".bridge.enabled",
              Globals.getConfig().getProperty(Globals.IMQ +".bridge.enabled", "false"));

        } else if (Globals.isNewTxnLogEnabled()) {
            matchProps.setProperty(StoreManager.NEW_TXNLOG_ENABLED_PROP, "true");
        }

        if (Globals.getClusterManager().getMasterBroker() != null && Globals.nowaitForMasterBroker()) {
            matchProps.setProperty(Globals.NOWAIT_MASTERBROKER_PROP, "true");
        }
        if (Globals.useMasterBroker() && Globals.dynamicChangeMasterBrokerEnabled()) {
            matchProps.setProperty(Globals.DYNAMIC_CHANGE_MASTERBROKER_ENABLED_PROP, "true");
        }
        if (Globals.useSharedConfigRecord()) {
            matchProps.setProperty(Globals.NO_MASTERBROKER_PROP, "true");
        }
        mbus.setMatchProps(matchProps);

        /*
         * Start talking to other brokers now that all the handlers are
         * initialized and ready to process callbacks from MessageBus
         */
        mbus.startClusterIO();

        /**
         * services are up and running (although we may be paused)
         */
        startupComplete = true;

        // audit logging of broker startup
        Globals.getAuditSession().brokerOperation(null, null, MQAuditSession.BROKER_STARTUP);

        Object[] sargs = { Globals.getConfigName() + "@" +
                (pm.getHostname() == null || pm.getHostname().equals("") ?
                Globals.getMQAddress().getHostName() : pm.getMQAddress().getHostName()) + ":" +
        String.valueOf(pm.getPort())};
        logger.logToAll(Logger.INFO, rb.I_BROKER_READY, sargs);



  // Load MQ Mbeans in JMX agent
  Agent agent = Globals.getAgent();
  if (agent != null)  {
      agent.loadMBeans();
  }

    if (BridgeBaseContextAdapter.bridgeEnabled() && bridgeManager != null) {
        try {
             logger.log(Logger.INFO,
View Full Code Here

  if ( DEBUG ) {
            logger.log(Logger.DEBUG, this.getClass().getName() + ": " +
                "GetJMXConnectorsHandler: " + cmd_props);
        }

        Agent agent = Globals.getAgent();
  ConnectorServerManager csm;
  Vector v = null;
        int status = Status.OK;
        String errMsg = null;

  if (agent != null)  {
      csm = agent.getConnectorServerManager();

      if (csm != null)  {
          v = csm.getConnectorInfo();
      }
  }
View Full Code Here

        try {
            /*
           * Can't really call the JMX notification code at the end of doCommit()
           * because the call to translist.removeTransactionID(id) removes the MBean.
           */
          Agent agent = Globals.getAgent();
          if (agent != null)  {
            agent.notifyTransactionCommit(id);
          }
        } catch (Exception e) {
            logger.log(Logger.WARNING, "JMX agent notify transaction committed failed:"+e.getMessage());
        }

View Full Code Here

      /*
       * Can't really call the JMX notification code at the end of doRollback()
       * because the call to translist.removeTransactionID(id) removes the MBean.
       */
      Agent agent = Globals.getAgent();
      if (agent != null)  {
          agent.notifyTransactionRollback(id);
      }
      
        try {
            ts.setState(s);
            cacheSetState(id, ts, con);
View Full Code Here

                }
            }
            translist.updateState(id, s, onephasePrepare, persist);
            prepared = true;
            try {
                Agent agent = Globals.getAgent();
                if (agent != null) agent.notifyTransactionPrepare(id);
            } catch (Throwable t ) {
                logger.log(Logger.WARNING,
                "XXXI18N - JMX agent notify transaction prepared failed: "+t.getMessage());
            }
        } finally {
View Full Code Here

TOP

Related Classes of com.sun.messaging.jmq.jmsserver.management.agent.Agent$ClusterStateListener

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.