org.apache.catalina.Cluster Java Examples
The following examples show how to use
org.apache.catalina.Cluster.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TomcatWebAppBuilder.java From tomee with Apache License 2.0 | 6 votes |
private void manageCluster(final Cluster cluster) { if (cluster == null || cluster instanceof SimpleTomEETcpCluster) { return; } Cluster current = cluster; if (cluster instanceof SimpleTcpCluster) { final Container container = cluster.getContainer(); current = new SimpleTomEETcpCluster((SimpleTcpCluster) cluster); container.setCluster(current); } if (current instanceof CatalinaCluster) { final CatalinaCluster haCluster = (CatalinaCluster) current; TomEEClusterListener listener = SystemInstance.get().getComponent(TomEEClusterListener.class); if (listener == null) { listener = new TomEEClusterListener(); SystemInstance.get().setComponent(TomEEClusterListener.class, listener); } haCluster.addClusterListener(listener); // better to be a singleton clusters.add(haCluster); } }
Example #2
Source File: JvmRouteBinderValve.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * 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 { if (cluster == null) { Cluster containerCluster = getContainer().getCluster(); if (containerCluster instanceof CatalinaCluster) { setCluster((CatalinaCluster)containerCluster); } } if (log.isInfoEnabled()) { log.info(sm.getString("jvmRoute.valve.started")); if (cluster == null) { log.info(sm.getString("jvmRoute.noCluster")); } } super.startInternal(); }
Example #3
Source File: ContainerBase.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * Return the Cluster with which this Container is associated. If there is * no associated Cluster, return the Cluster associated with our parent * Container (if any); otherwise return <code>null</code>. */ @Override public Cluster getCluster() { Lock readLock = clusterLock.readLock(); readLock.lock(); try { if (cluster != null) return cluster; if (parent != null) return parent.getCluster(); return null; } finally { readLock.unlock(); } }
Example #4
Source File: ClusterManagerBase.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Override protected void startInternal() throws LifecycleException { super.startInternal(); if (getCluster() == null) { Cluster cluster = getContainer().getCluster(); if (cluster instanceof CatalinaCluster) { setCluster((CatalinaCluster)cluster); } } if (cluster != null) cluster.registerManager(this); }
Example #5
Source File: ReplicationValve.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * 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 { if (cluster == null) { Cluster containerCluster = getContainer().getCluster(); if (containerCluster instanceof CatalinaCluster) { setCluster((CatalinaCluster)containerCluster); } else { if (log.isWarnEnabled()) { log.warn(sm.getString("ReplicationValve.nocluster")); } } } super.startInternal(); }
Example #6
Source File: ClusterManagerBase.java From tomcatsrc with Apache License 2.0 | 5 votes |
@Override protected void startInternal() throws LifecycleException { super.startInternal(); if (getCluster() == null) { Cluster cluster = getContainer().getCluster(); if (cluster instanceof CatalinaCluster) { setCluster((CatalinaCluster)cluster); } } if (cluster != null) cluster.registerManager(this); }
Example #7
Source File: ContainerBase.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * Return the Cluster with which this Container is associated. If there is * no associated Cluster, return the Cluster associated with our parent * Container (if any); otherwise return <code>null</code>. */ @Override public Cluster getCluster() { if (cluster != null) return (cluster); if (parent != null) return (parent.getCluster()); return (null); }
Example #8
Source File: ReplicationValve.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * 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 { if (cluster == null) { Cluster containerCluster = getContainer().getCluster(); if (containerCluster instanceof CatalinaCluster) { setCluster((CatalinaCluster)containerCluster); } else { if (log.isWarnEnabled()) { log.warn(sm.getString("ReplicationValve.nocluster")); } } } super.startInternal(); }
Example #9
Source File: ContainerBase.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Override protected void destroyInternal() throws LifecycleException { Realm realm = getRealmInternal(); if (realm instanceof Lifecycle) { ((Lifecycle) realm).destroy(); } Cluster cluster = getClusterInternal(); if (cluster instanceof Lifecycle) { ((Lifecycle) cluster).destroy(); } // Stop the Valves in our pipeline (including the basic), if any if (pipeline instanceof Lifecycle) { ((Lifecycle) pipeline).destroy(); } // Remove children now this container is being destroyed for (Container child : findChildren()) { removeChild(child); } // Required if the child is destroyed directly. if (parent != null) { parent.removeChild(this); } // If init fails, this may be null if (startStopExecutor != null) { startStopExecutor.shutdownNow(); } super.destroyInternal(); }
Example #10
Source File: ClusterManagerBase.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Override protected void startInternal() throws LifecycleException { super.startInternal(); if (getCluster() == null) { Cluster cluster = getContext().getCluster(); if (cluster instanceof CatalinaCluster) { setCluster((CatalinaCluster)cluster); } } if (cluster != null) cluster.registerManager(this); }
Example #11
Source File: ContainerBase.java From Tomcat8-Source-Read with MIT License | 5 votes |
protected Cluster getClusterInternal() { Lock readLock = clusterLock.readLock(); readLock.lock(); try { return cluster; } finally { readLock.unlock(); } }
Example #12
Source File: ReplicationValve.java From Tomcat8-Source-Read with MIT License | 5 votes |
/** * 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 { if (cluster == null) { Cluster containerCluster = getContainer().getCluster(); if (containerCluster instanceof CatalinaCluster) { setCluster((CatalinaCluster)containerCluster); } else { if (log.isWarnEnabled()) { log.warn(sm.getString("ReplicationValve.nocluster")); } } } super.startInternal(); }
Example #13
Source File: FailedContext.java From Tomcat8-Source-Read with MIT License | 4 votes |
@Override public void setCluster(Cluster cluster) { /* NO-OP */ }
Example #14
Source File: TesterHost.java From tomcatsrc with Apache License 2.0 | 4 votes |
@Override public void setCluster(Cluster cluster) { // NO-OP }
Example #15
Source File: TesterHost.java From tomcatsrc with Apache License 2.0 | 4 votes |
@Override public Cluster getCluster() { return null; }
Example #16
Source File: TesterContext.java From tomcatsrc with Apache License 2.0 | 4 votes |
@Override public void setCluster(Cluster cluster) { // NO-OP }
Example #17
Source File: TesterContext.java From tomcatsrc with Apache License 2.0 | 4 votes |
@Override public Cluster getCluster() { return null; }
Example #18
Source File: FailedContext.java From tomcatsrc with Apache License 2.0 | 4 votes |
@Override public void setCluster(Cluster cluster) { /* NO-OP */ }
Example #19
Source File: FailedContext.java From tomcatsrc with Apache License 2.0 | 4 votes |
@Override public Cluster getCluster() { return null; }
Example #20
Source File: FailedContext.java From Tomcat8-Source-Read with MIT License | 4 votes |
@Override public Cluster getCluster() { return null; }
Example #21
Source File: TesterContext.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
@Override public void setCluster(Cluster cluster) { // NO-OP }
Example #22
Source File: TesterContext.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
@Override public Cluster getCluster() { return null; }
Example #23
Source File: ContainerBase.java From Tomcat8-Source-Read with MIT License | 4 votes |
/** 1.BootStrap反射调用Catalina的start。 * 2.Catalina去调用了StandardServer的start方法。 * 3.StandardServer调用StandardService的start方法。 * 4.StandardService调用StandarEngine的start方法。 * 5.StandarEngine调用ContainerBase的start方法。(重点) * 6.ContainerBase的start方法: * 6.1 日志。 * 6.2 安全。 * 6.3 启动所有子容器(ChildList Future框架启动线程池去启动子结点)。启动子结点重点。 * (Engin -> Host -> Context-> Wrapper 层级调用。 * 共享父类的方法,针对不同的容器处理不同。) * HostConfig类添加所有的Context结点。 * 然后在此类中进行启动。包括StandardContext结点。 * StandardContext结点通过Web.xml文件,用ContextConfig添加了 * 所有的子节点。 * 然后在StandardContext去启动了StandardWrapper。 * StandardWrapper load and start。 * 6.4 Pipeline的启动。 * 6.5 激发HostConfig监听器。 * (HostConfig ->t添加Host。) {@link HostConfig#start()} * 6.6 启动后台线程。 * * 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(); //tomcat集群相关。 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 (int i = 0; i < children.length; i++) { results.add(startStopExecutor.submit(new StartChild(children[i]))); } 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 threadStart(); }
Example #24
Source File: FailedContext.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
@Override public void setCluster(Cluster cluster) { /* NO-OP */ }
Example #25
Source File: FailedContext.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
@Override public Cluster getCluster() { return null; }
Example #26
Source File: StandardHostSF.java From Tomcat8-Source-Read with MIT License | 4 votes |
/** * Store the specified Host properties and children * (Listener,Alias,Realm,Valve,Cluster, Context) * * @param aWriter * PrintWriter to which we are storing * @param indent * Number of spaces to indent this element * @param aHost * Host whose properties are being stored * * @exception Exception * if an exception occurs while storing */ @Override public void storeChildren(PrintWriter aWriter, int indent, Object aHost, StoreDescription parentDesc) throws Exception { if (aHost instanceof StandardHost) { StandardHost host = (StandardHost) aHost; // Store nested <Listener> elements LifecycleListener listeners[] = ((Lifecycle) host) .findLifecycleListeners(); storeElementArray(aWriter, indent, listeners); // Store nested <Alias> elements String aliases[] = host.findAliases(); getStoreAppender().printTagArray(aWriter, "Alias", indent + 2, aliases); // Store nested <Realm> element Realm realm = host.getRealm(); if (realm != null) { Realm parentRealm = null; if (host.getParent() != null) { parentRealm = host.getParent().getRealm(); } if (realm != parentRealm) { storeElement(aWriter, indent, realm); } } // Store nested <Valve> elements Valve valves[] = host.getPipeline().getValves(); if(valves != null && valves.length > 0 ) { List<Valve> hostValves = new ArrayList<>() ; for(int i = 0 ; i < valves.length ; i++ ) { if(!( valves[i] instanceof ClusterValve)) hostValves.add(valves[i]); } storeElementArray(aWriter, indent, hostValves.toArray()); } // store all <Cluster> elements Cluster cluster = host.getCluster(); if (cluster != null) { Cluster parentCluster = null; if (host.getParent() != null) { parentCluster = host.getParent().getCluster(); } if (cluster != parentCluster) { storeElement(aWriter, indent, cluster); } } // store all <Context> elements Container children[] = host.findChildren(); storeElementArray(aWriter, indent, children); } }
Example #27
Source File: StandardEngineSF.java From Tomcat8-Source-Read with MIT License | 4 votes |
/** * Store the specified Engine properties. * * @param aWriter * PrintWriter to which we are storing * @param indent * Number of spaces to indent this element * @param aEngine * Object whose properties are being stored * * @exception Exception * if an exception occurs while storing */ @Override public void storeChildren(PrintWriter aWriter, int indent, Object aEngine, StoreDescription parentDesc) throws Exception { if (aEngine instanceof StandardEngine) { StandardEngine engine = (StandardEngine) aEngine; // Store nested <Listener> elements LifecycleListener listeners[] = ((Lifecycle) engine) .findLifecycleListeners(); storeElementArray(aWriter, indent, listeners); // Store nested <Realm> element Realm realm = engine.getRealm(); Realm parentRealm = null; // TODO is this case possible? (see it a old Server 5.0 impl) if (engine.getParent() != null) { parentRealm = engine.getParent().getRealm(); } if (realm != parentRealm) { storeElement(aWriter, indent, realm); } // Store nested <Valve> elements Valve valves[] = engine.getPipeline().getValves(); if(valves != null && valves.length > 0 ) { List<Valve> engineValves = new ArrayList<>() ; for(int i = 0 ; i < valves.length ; i++ ) { if(!( valves[i] instanceof ClusterValve)) engineValves.add(valves[i]); } storeElementArray(aWriter, indent, engineValves.toArray()); } // store all <Cluster> elements Cluster cluster = engine.getCluster(); if (cluster != null) { storeElement(aWriter, indent, cluster); } // store all <Host> elements Container children[] = engine.findChildren(); storeElementArray(aWriter, indent, children); } }
Example #28
Source File: TesterHost.java From Tomcat8-Source-Read with MIT License | 4 votes |
@Override public void setCluster(Cluster cluster) { // NO-OP }
Example #29
Source File: TesterHost.java From Tomcat8-Source-Read with MIT License | 4 votes |
@Override public Cluster getCluster() { return null; }
Example #30
Source File: TesterContext.java From Tomcat8-Source-Read with MIT License | 4 votes |
@Override public void setCluster(Cluster cluster) { // NO-OP }