Search in sources :

Example 1 with MultiThrowable

use of org.apache.tomcat.util.MultiThrowable in project tomcat by apache.

the class ContainerBase method startInternal.

/**
 * Start this component and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected synchronized void startInternal() throws LifecycleException {
    // Start our subordinate components, if any
    logger = null;
    getLogger();
    Cluster cluster = getClusterInternal();
    if (cluster instanceof Lifecycle) {
        ((Lifecycle) cluster).start();
    }
    Realm realm = getRealmInternal();
    if (realm instanceof Lifecycle) {
        ((Lifecycle) realm).start();
    }
    // Start our child containers, if any
    Container[] children = findChildren();
    List<Future<Void>> results = new ArrayList<>();
    for (Container child : children) {
        results.add(startStopExecutor.submit(new StartChild(child)));
    }
    MultiThrowable multiThrowable = null;
    for (Future<Void> result : results) {
        try {
            result.get();
        } catch (Throwable e) {
            log.error(sm.getString("containerBase.threadedStartFailed"), e);
            if (multiThrowable == null) {
                multiThrowable = new MultiThrowable();
            }
            multiThrowable.add(e);
        }
    }
    if (multiThrowable != null) {
        throw new LifecycleException(sm.getString("containerBase.threadedStartFailed"), multiThrowable.getThrowable());
    }
    // Start the Valves in our pipeline (including the basic), if any
    if (pipeline instanceof Lifecycle) {
        ((Lifecycle) pipeline).start();
    }
    setState(LifecycleState.STARTING);
    // Start our thread
    if (backgroundProcessorDelay > 0) {
        monitorFuture = Container.getService(ContainerBase.this).getServer().getUtilityExecutor().scheduleWithFixedDelay(new ContainerBackgroundProcessorMonitor(), 0, 60, TimeUnit.SECONDS);
    }
}
Also used : LifecycleException(org.apache.catalina.LifecycleException) MultiThrowable(org.apache.tomcat.util.MultiThrowable) Lifecycle(org.apache.catalina.Lifecycle) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Cluster(org.apache.catalina.Cluster) Container(org.apache.catalina.Container) ScheduledFuture(java.util.concurrent.ScheduledFuture) Future(java.util.concurrent.Future) MultiThrowable(org.apache.tomcat.util.MultiThrowable) Realm(org.apache.catalina.Realm)

Aggregations

ArrayList (java.util.ArrayList)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 Future (java.util.concurrent.Future)1 ScheduledFuture (java.util.concurrent.ScheduledFuture)1 Cluster (org.apache.catalina.Cluster)1 Container (org.apache.catalina.Container)1 Lifecycle (org.apache.catalina.Lifecycle)1 LifecycleException (org.apache.catalina.LifecycleException)1 Realm (org.apache.catalina.Realm)1 MultiThrowable (org.apache.tomcat.util.MultiThrowable)1