org.apache.catalina.ha.tcp.SimpleTcpCluster Java Examples
The following examples show how to use
org.apache.catalina.ha.tcp.SimpleTcpCluster.
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: TestStandardSessionIntegration.java From Tomcat8-Source-Read with MIT License | 6 votes |
private void doTestInvalidate(boolean useClustering) throws Exception { // Setup Tomcat instance Tomcat tomcat = getTomcatInstance(); // No file system docBase required Context ctx = tomcat.addContext("", null); Tomcat.addServlet(ctx, "bug56578", new Bug56578Servlet()); ctx.addServletMappingDecoded("/bug56578", "bug56578"); if (useClustering) { tomcat.getEngine().setCluster(new SimpleTcpCluster()); ctx.setDistributable(true); ctx.setManager(ctx.getCluster().createManager("")); } tomcat.start(); ByteChunk res = getUrl("http://localhost:" + getPort() + "/bug56578"); Assert.assertEquals("PASS", res.toString()); }
Example #2
Source File: TestStandardSessionIntegration.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
private void doTestInvalidate(boolean useClustering) throws Exception { // Setup Tomcat instance Tomcat tomcat = getTomcatInstance(); // No file system docBase required Context ctx = tomcat.addContext("", null); Tomcat.addServlet(ctx, "bug56578", new Bug56578Servlet()); ctx.addServletMapping("/bug56578", "bug56578"); if (useClustering) { tomcat.getEngine().setCluster(new SimpleTcpCluster()); ctx.setDistributable(true); ctx.setManager(ctx.getCluster().createManager("")); } tomcat.start(); ByteChunk res = getUrl("http://localhost:" + getPort() + "/bug56578"); Assert.assertEquals("PASS", res.toString()); }
Example #3
Source File: TestStandardSessionIntegration.java From tomcatsrc with Apache License 2.0 | 6 votes |
private void doTestInvalidate(boolean useClustering) throws Exception { // Setup Tomcat instance Tomcat tomcat = getTomcatInstance(); // No file system docBase required Context ctx = tomcat.addContext("", null); Tomcat.addServlet(ctx, "bug56578", new Bug56578Servlet()); ctx.addServletMapping("/bug56578", "bug56578"); if (useClustering) { tomcat.getEngine().setCluster(new SimpleTcpCluster()); ctx.setDistributable(true); ctx.setManager(ctx.getCluster().createManager("")); } tomcat.start(); ByteChunk res = getUrl("http://localhost:" + getPort() + "/bug56578"); Assert.assertEquals("PASS", res.toString()); }
Example #4
Source File: SimpleTomEETcpCluster.java From tomee with Apache License 2.0 | 6 votes |
public SimpleTomEETcpCluster(final SimpleTcpCluster from) { clusterListeners.addAll(Arrays.asList(from.findClusterListeners())); setClusterName(from.getClusterName()); setContainer(from.getContainer()); setNotifyLifecycleListenerOnFailure(from.isNotifyLifecycleListenerOnFailure()); setChannelSendOptions(from.getChannelSendOptions()); setChannelStartOptions(from.getChannelStartOptions()); setHeartbeatBackgroundEnabled(from.isHeartbeatBackgroundEnabled()); setChannel(from.getChannel()); getManagers().putAll(from.getManagers()); setManagerTemplate(from.getManagerTemplate()); setClusterDeployer(from.getClusterDeployer()); for (final Valve valve : from.getValves()) { addValve(valve); } }
Example #5
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 #6
Source File: ClusterJmxHelper.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
public static boolean registerDefaultCluster(SimpleTcpCluster cluster) { try { initDefaultCluster(); ObjectName clusterName = getDefaultClusterName(cluster); if (!getMBeanServer().isRegistered(clusterName)) { getMBeanServer().registerMBean(getManagedBean(cluster), clusterName); } return true; }catch ( Exception x ) { log.warn("Unable to register default cluster implementation with JMX",x); return false; } }
Example #7
Source File: ClusterJmxHelper.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
public static boolean unregisterDefaultCluster(SimpleTcpCluster cluster) { try { ObjectName clusterName = getDefaultClusterName(cluster); if (getMBeanServer().isRegistered(clusterName)) { getMBeanServer().unregisterMBean(clusterName); } return true; }catch ( Exception x ) { log.warn("Unable to unregister default cluster implementation with JMX",x); return false; } }
Example #8
Source File: ClusterJmxHelper.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
private static ObjectName getDefaultClusterName(SimpleTcpCluster cluster) throws Exception { String domain = getMBeanServer().getDefaultDomain(); String type = ":type="; String clusterType= type+"Cluster"; if (cluster.getContainer() instanceof StandardHost) { domain = ((StandardHost) cluster.getContainer()).getDomain(); clusterType += ",host=" + cluster.getContainer().getName(); } else { if (cluster.getContainer() instanceof StandardEngine) { domain = ((StandardEngine) cluster.getContainer()).getDomain(); } } ObjectName clusterName = new ObjectName(domain + clusterType); return clusterName; }
Example #9
Source File: ClusterJmxHelper.java From tomcatsrc with Apache License 2.0 | 5 votes |
public static boolean registerDefaultCluster(SimpleTcpCluster cluster) { try { initDefaultCluster(); ObjectName clusterName = getDefaultClusterName(cluster); if (!getMBeanServer().isRegistered(clusterName)) { getMBeanServer().registerMBean(getManagedBean(cluster), clusterName); } return true; }catch ( Exception x ) { log.warn("Unable to register default cluster implementation with JMX",x); return false; } }
Example #10
Source File: ClusterJmxHelper.java From tomcatsrc with Apache License 2.0 | 5 votes |
public static boolean unregisterDefaultCluster(SimpleTcpCluster cluster) { try { ObjectName clusterName = getDefaultClusterName(cluster); if (getMBeanServer().isRegistered(clusterName)) { getMBeanServer().unregisterMBean(clusterName); } return true; }catch ( Exception x ) { log.warn("Unable to unregister default cluster implementation with JMX",x); return false; } }
Example #11
Source File: ClusterJmxHelper.java From tomcatsrc with Apache License 2.0 | 5 votes |
private static ObjectName getDefaultClusterName(SimpleTcpCluster cluster) throws Exception { String domain = getMBeanServer().getDefaultDomain(); String type = ":type="; String clusterType= type+"Cluster"; if (cluster.getContainer() instanceof StandardHost) { domain = ((StandardHost) cluster.getContainer()).getDomain(); clusterType += ",host=" + cluster.getContainer().getName(); } else { if (cluster.getContainer() instanceof StandardEngine) { domain = ((StandardEngine) cluster.getContainer()).getDomain(); } } ObjectName clusterName = new ObjectName(domain + clusterType); return clusterName; }
Example #12
Source File: CatalinaClusterSF.java From Tomcat8-Source-Read with MIT License | 4 votes |
/** * Store the specified Cluster children. * * @param aWriter * PrintWriter to which we are storing * @param indent * Number of spaces to indent this element * @param aCluster * Cluster whose properties are being stored * * @exception Exception * if an exception occurs while storing */ @Override public void storeChildren(PrintWriter aWriter, int indent, Object aCluster, StoreDescription parentDesc) throws Exception { if (aCluster instanceof CatalinaCluster) { CatalinaCluster cluster = (CatalinaCluster) aCluster; if (cluster instanceof SimpleTcpCluster) { SimpleTcpCluster tcpCluster = (SimpleTcpCluster) cluster; // Store nested <Manager> element ClusterManager manager = tcpCluster.getManagerTemplate(); if (manager != null) { storeElement(aWriter, indent, manager); } } // Store nested <Channel> element Channel channel = cluster.getChannel(); if (channel != null) { storeElement(aWriter, indent, channel); } // Store nested <Deployer> element ClusterDeployer deployer = cluster.getClusterDeployer(); if (deployer != null) { storeElement(aWriter, indent, deployer); } // Store nested <Valve> element // ClusterValve are not store at Hosts element, see Valve valves[] = cluster.getValves(); storeElementArray(aWriter, indent, valves); if (aCluster instanceof SimpleTcpCluster) { // Store nested <Listener> elements LifecycleListener listeners[] = ((SimpleTcpCluster)cluster).findLifecycleListeners(); storeElementArray(aWriter, indent, listeners); // Store nested <ClusterListener> elements ClusterListener mlisteners[] = ((SimpleTcpCluster)cluster).findClusterListeners(); List<ClusterListener> clusterListeners = new ArrayList<>(); for (ClusterListener clusterListener : mlisteners) { if (clusterListener != deployer) { clusterListeners.add(clusterListener); } } storeElementArray(aWriter, indent, clusterListeners.toArray()); } } }
Example #13
Source File: ClusterJmxHelper.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
protected static void initDefaultCluster() { initMetaData(SimpleTcpCluster.class); initMetaData(FarmWarDeployer.class); //not functional yet }
Example #14
Source File: ClusterJmxHelper.java From tomcatsrc with Apache License 2.0 | 4 votes |
protected static void initDefaultCluster() { initMetaData(SimpleTcpCluster.class); initMetaData(FarmWarDeployer.class); //not functional yet }