Package org.apache.activemq.util

Examples of org.apache.activemq.util.ServiceStopper


        discoveryAgent.start();
        next.start();
    }

    public void stop() throws Exception {
        ServiceStopper ss = new ServiceStopper();
        ss.stop(discoveryAgent);
        ss.stop(next);
        ss.throwFirstException();
    }
View Full Code Here


                    });
                    if (!sendShutdown.await(10, TimeUnit.SECONDS)) {
                        LOG.info("Network Could not shutdown in a timely manner");
                    }
                } finally {
                    ServiceStopper ss = new ServiceStopper();
                    ss.stop(remoteBroker);
                    ss.stop(localBroker);
                    // Release the started Latch since another thread could be
                    // stuck waiting for it to start up.
                    startedLatch.countDown();
                    startedLatch.countDown();
                    localStartedLatch.countDown();
                    ss.throwFirstException();
                }
            }
            LOG.info(configuration.getBrokerName() + " bridge to " + remoteBrokerName + " stopped");
            remoteBrokerNameKnownLatch.countDown();
        }
View Full Code Here

          }.start();
        }
       
        LOG.info("ActiveMQ Message Broker (" + getBrokerName() + ", " + brokerId + ") is shutting down");
        removeShutdownHook();
        ServiceStopper stopper = new ServiceStopper();
        if (services != null) {
            for (Service service : services) {
                stopper.stop(service);
            }
        }
        stopAllConnectors(stopper);
        // remove any VMTransports connected
        // this has to be done after services are stopped,
        // to avoid timimg issue with discovery (spinning up a new instance)
        BrokerRegistry.getInstance().unbind(getBrokerName());
        VMTransportFactory.stopped(getBrokerName());
        if (broker != null) {
            stopper.stop(broker);
            broker = null;
        }
       
        if (tempDataStore != null) {
            tempDataStore.stop();
            tempDataStore = null;
        }
        stopper.stop(persistenceAdapter);
        persistenceAdapter = null;
        slave = true;
        if (isUseJmx()) {
            stopper.stop(getManagementContext());
            managementContext = null;
        }
        // Clear SelectorParser cache to free memory
        SelectorParser.clearCache();
        stopped.set(true);
        stoppedLatch.countDown();
        if (masterConnectorURI == null) {
            // master start has not finished yet
            if (slaveStartSignal.getCount() == 1) {
                started.set(false);
                slaveStartSignal.countDown();
            }
        } else {
            for (Service service : services) {
                if (service instanceof MasterConnector) {
                    MasterConnector mConnector = (MasterConnector) service;
                    if (!mConnector.isSlave()) {
                        // means should be slave but not connected to master yet
                        started.set(false);
                        mConnector.stopBeforeConnected();
                    }
                }
            }
        }
        if (this.taskRunnerFactory != null) {
            this.taskRunnerFactory.shutdown();
            this.taskRunnerFactory = null;
        }
        if (this.scheduler != null) {
            this.scheduler.stop();
            this.scheduler = null;
        }
        if (this.executor != null) {
            this.executor.shutdownNow();
            this.executor = null;
        }
       
        this.destinationInterceptors = null;
        this.destinationFactory = null;
       
        LOG.info("ActiveMQ JMS Message Broker (" + getBrokerName() + ", " + brokerId + ") stopped");
        synchronized (shutdownHooks) {
            for (Runnable hook : shutdownHooks) {
                try {
                    hook.run();
                } catch (Throwable e) {
                    stopper.onException(hook, e);
                }
            }
        }
       
        stopper.throwFirstException();
    }
View Full Code Here

    @Override
    public void stop() throws Exception {
        started = false;
        this.scheduler.cancel(purgeInactiveDestinationsTask);
        ServiceStopper ss = new ServiceStopper();
        doStop(ss);
        ss.throwFirstException();
        // clear the state
        clientIdSet.clear();
        connections.clear();
        destinations.clear();
        brokerInfos.clear();
View Full Code Here

    @Override
    public void stop() throws Exception {
        started = false;
        this.scheduler.cancel(purgeInactiveDestinationsTask);
        ServiceStopper ss = new ServiceStopper();
        doStop(ss);
        ss.throwFirstException();
        // clear the state
        clientIdSet.clear();
        connections.clear();
        destinations.clear();
        brokerInfos.clear();
View Full Code Here

        }
        return publishableConnectString;
    }

    public void stop() throws Exception {
        ServiceStopper ss = new ServiceStopper();
        if (discoveryAgent != null) {
            ss.stop(discoveryAgent);
        }
        if (server != null) {
            ss.stop(server);
        }
        if (this.statusDector != null) {
            this.statusDector.stop();
        }

        for (TransportConnection connection : connections) {
            ss.stop(connection);
        }
        server = null;
        ss.throwFirstException();
        LOG.info("Connector " + getName() + " Stopped");
    }
View Full Code Here

        removeShutdownHook();
        if (this.scheduler != null) {
            this.scheduler.stop();
            this.scheduler = null;
        }
        ServiceStopper stopper = new ServiceStopper();
        if (services != null) {
            for (Service service : services) {
                stopper.stop(service);
            }
        }
        stopAllConnectors(stopper);
        // remove any VMTransports connected
        // this has to be done after services are stopped,
        // to avoid timing issue with discovery (spinning up a new instance)
        BrokerRegistry.getInstance().unbind(getBrokerName());
        VMTransportFactory.stopped(getBrokerName());
        if (broker != null) {
            stopper.stop(broker);
            broker = null;
        }

        if (tempDataStore != null) {
            tempDataStore.stop();
            tempDataStore = null;
        }
        try {
            stopper.stop(persistenceAdapter);
            persistenceAdapter = null;
            slave = true;
            if (isUseJmx()) {
                stopper.stop(getManagementContext());
                managementContext = null;
            }
            // Clear SelectorParser cache to free memory
            SelectorParser.clearCache();
        } finally {
            stopped.set(true);
            stoppedLatch.countDown();
        }
        if (masterConnectorURI == null) {
            // master start has not finished yet
            if (slaveStartSignal.getCount() == 1) {
                started.set(false);
                slaveStartSignal.countDown();
            }
        } else {
            for (Service service : services) {
                if (service instanceof MasterConnector) {
                    MasterConnector mConnector = (MasterConnector) service;
                    if (!mConnector.isSlave()) {
                        // means should be slave but not connected to master yet
                        started.set(false);
                        mConnector.stopBeforeConnected();
                    }
                }
            }
        }
        if (this.taskRunnerFactory != null) {
            this.taskRunnerFactory.shutdown();
            this.taskRunnerFactory = null;
        }
        if (this.executor != null) {
            ThreadPoolUtils.shutdownNow(executor);
            this.executor = null;
        }

        this.destinationInterceptors = null;
        this.destinationFactory = null;

        if (LOG.isInfoEnabled()) {
            if (startDate != null) {
                LOG.info("Apache ActiveMQ " + getBrokerVersion() + " ("
                        + getBrokerName() + ", " + brokerId + ") uptime " + getUptime());
            }
            LOG.info("Apache ActiveMQ " + getBrokerVersion() + " ("
                    + getBrokerName() + ", " + brokerId + ") is shutdown");
        }

        synchronized (shutdownHooks) {
            for (Runnable hook : shutdownHooks) {
                try {
                    hook.run();
                } catch (Throwable e) {
                    stopper.onException(hook, e);
                }
            }
        }

        MDC.remove("activemq.broker");

        // and clear start date
        startDate = null;

        stopper.throwFirstException();
    }
View Full Code Here

                    if (!sendShutdown.await(10, TimeUnit.SECONDS)) {
                        LOG.info("Network Could not shutdown in a timely manner");
                    }
                } finally {
                    ServiceStopper ss = new ServiceStopper();
                    ss.stop(remoteBroker);
                    ss.stop(localBroker);
                    // Release the started Latch since another thread could be
                    // stuck waiting for it to start up.
                    startedLatch.countDown();
                    startedLatch.countDown();
                    localStartedLatch.countDown();

                    ss.throwFirstException();
                }
            }

            if (remoteBrokerInfo != null) {
                brokerService.getBroker().removeBroker(null, remoteBrokerInfo);
View Full Code Here

            IOExceptionSupport.create(e);
        }
    }

    public void stop() throws Exception {
        ServiceStopper stopper = new ServiceStopper();
        for (Iterator iter = cache.values().iterator(); iter.hasNext();) {
            ConnectionPool connection = (ConnectionPool) iter.next();
            try {
                connection.close();
            }
            catch (JMSException e) {
                stopper.onException(this, e);
            }
        }
        stopper.throwFirstException();
    }
View Full Code Here

        remoteBroker.oneway(new ShutdownInfo());
       
      } catch (IOException e) {
        log.debug("Caught exception stopping", e);
      } finally {
        ServiceStopper ss = new ServiceStopper();
        ss.stop(localBroker);
        ss.stop(remoteBroker);
        ss.throwFirstException();
      }
    }
        log.debug(localBrokerName+ " bridge to " + remoteBrokerName + " stopped");
    }
View Full Code Here

TOP

Related Classes of org.apache.activemq.util.ServiceStopper

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.