Java Code Examples for org.apache.catalina.tribes.Channel#DEFAULT
The following examples show how to use
org.apache.catalina.tribes.Channel#DEFAULT .
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: ChannelCoordinator.java From Tomcat8-Source-Read with MIT License | 5 votes |
/** * Shuts down the channel. This can be called multiple times for individual services to shutdown * The svc parameter can be the logical or value of any constants * @param svc int value of <BR> * DEFAULT - will shutdown all services <BR> * MBR_RX_SEQ - starts the membership receiver <BR> * MBR_TX_SEQ - starts the membership broadcaster <BR> * SND_TX_SEQ - starts the replication transmitter<BR> * SND_RX_SEQ - starts the replication receiver<BR> * @throws ChannelException if a startup error occurs or the service is already started. */ protected synchronized void internalStop(int svc) throws ChannelException { try { //make sure we don't pass down any flags that are unrelated to the bottom layer svc = svc & Channel.DEFAULT; if (startLevel == 0) return; //we have already stopped up all components if (svc == 0 ) return;//nothing to stop boolean valid = false; if ( Channel.SND_RX_SEQ==(svc & Channel.SND_RX_SEQ) ) { clusterReceiver.stop(); clusterReceiver.setMessageListener(null); valid = true; } if ( Channel.SND_TX_SEQ==(svc & Channel.SND_TX_SEQ) ) { clusterSender.stop(); valid = true; } if ( Channel.MBR_RX_SEQ==(svc & Channel.MBR_RX_SEQ) ) { membershipService.stop(MembershipService.MBR_RX); membershipService.setMembershipListener(null); valid = true; } if ( Channel.MBR_TX_SEQ==(svc & Channel.MBR_TX_SEQ) ) { valid = true; membershipService.stop(MembershipService.MBR_TX); } if ( !valid) { throw new IllegalArgumentException(sm.getString("channelCoordinator.invalid.startLevel")); } startLevel = (startLevel & (~svc)); setChannel(null); } catch (Exception x) { throw new ChannelException(x); } }
Example 2
Source File: ChannelCoordinator.java From Tomcat8-Source-Read with MIT License | 4 votes |
/** * Starts up the channel. This can be called multiple times for individual services to start * The svc parameter can be the logical or value of any constants * @param svc int value of <BR> * DEFAULT - will start all services <BR> * MBR_RX_SEQ - starts the membership receiver <BR> * MBR_TX_SEQ - starts the membership broadcaster <BR> * SND_TX_SEQ - starts the replication transmitter<BR> * SND_RX_SEQ - starts the replication receiver<BR> * @throws ChannelException if a startup error occurs or the service is already started. */ protected synchronized void internalStart(int svc) throws ChannelException { try { boolean valid = false; //make sure we don't pass down any flags that are unrelated to the bottom layer svc = svc & Channel.DEFAULT; if (startLevel == Channel.DEFAULT) return; //we have already started up all components if (svc == 0 ) return;//nothing to start if (svc == (svc & startLevel)) { throw new ChannelException(sm.getString("channelCoordinator.alreadyStarted", Integer.toString(svc))); } //must start the receiver first so that we can coordinate the port it //listens to with the local membership settings if ( Channel.SND_RX_SEQ==(svc & Channel.SND_RX_SEQ) ) { clusterReceiver.setMessageListener(this); clusterReceiver.setChannel(getChannel()); clusterReceiver.start(); //synchronize, big time FIXME Member localMember = getChannel().getLocalMember(false); if (localMember instanceof StaticMember) { // static member StaticMember staticMember = (StaticMember)localMember; staticMember.setHost(getClusterReceiver().getHost()); staticMember.setPort(getClusterReceiver().getPort()); staticMember.setSecurePort(getClusterReceiver().getSecurePort()); } else { // multicast member membershipService.setLocalMemberProperties(getClusterReceiver().getHost(), getClusterReceiver().getPort(), getClusterReceiver().getSecurePort(), getClusterReceiver().getUdpPort()); } valid = true; } if ( Channel.SND_TX_SEQ==(svc & Channel.SND_TX_SEQ) ) { clusterSender.setChannel(getChannel()); clusterSender.start(); valid = true; } if ( Channel.MBR_RX_SEQ==(svc & Channel.MBR_RX_SEQ) ) { membershipService.setMembershipListener(this); membershipService.setChannel(getChannel()); if (membershipService instanceof McastService) { ((McastService)membershipService).setMessageListener(this); } membershipService.start(MembershipService.MBR_RX); valid = true; } if ( Channel.MBR_TX_SEQ==(svc & Channel.MBR_TX_SEQ) ) { membershipService.setChannel(getChannel()); membershipService.start(MembershipService.MBR_TX); valid = true; } if (!valid) { throw new IllegalArgumentException(sm.getString("channelCoordinator.invalid.startLevel")); } startLevel = (startLevel | svc); }catch ( ChannelException cx ) { throw cx; }catch ( Exception x ) { throw new ChannelException(x); } }
Example 3
Source File: LoadTest.java From Tomcat8-Source-Read with MIT License | 4 votes |
public static void main(String[] args) throws Exception { boolean send = true; boolean debug = false; long pause = 0; int count = 1000000; int stats = 10000; boolean breakOnEx = false; int threads = 1; boolean shutdown = false; int startoptions = Channel.DEFAULT; int channelOptions = Channel.SEND_OPTIONS_DEFAULT; if ( args.length == 0 ) { args = new String[] {"-help"}; } for (int i = 0; i < args.length; i++) { if ("-threads".equals(args[i])) { threads = Integer.parseInt(args[++i]); } else if ("-count".equals(args[i])) { count = Integer.parseInt(args[++i]); System.out.println("Sending "+count+" messages."); } else if ("-pause".equals(args[i])) { pause = Long.parseLong(args[++i])*1000; } else if ("-break".equals(args[i])) { breakOnEx = true; } else if ("-shutdown".equals(args[i])) { shutdown = true; } else if ("-stats".equals(args[i])) { stats = Integer.parseInt(args[++i]); System.out.println("Stats every "+stats+" message"); } else if ("-sendoptions".equals(args[i])) { channelOptions = Integer.parseInt(args[++i]); System.out.println("Setting send options to "+channelOptions); } else if ("-startoptions".equals(args[i])) { startoptions = Integer.parseInt(args[++i]); System.out.println("Setting start options to "+startoptions); } else if ("-size".equals(args[i])) { size = Integer.parseInt(args[++i])-4; System.out.println("Message size will be:"+(size+4)+" bytes"); } else if ("-mode".equals(args[i])) { if ( "receive".equals(args[++i]) ) send = false; } else if ("-debug".equals(args[i])) { debug = true; } else if ("-help".equals(args[i])) { usage(); System.exit(1); } } ManagedChannel channel = (ManagedChannel)ChannelCreator.createChannel(args); LoadTest test = new LoadTest(channel,send,count,debug,pause,stats,breakOnEx); test.channelOptions = channelOptions; LoadMessage msg = new LoadMessage(); messageSize = LoadMessage.getMessageSize(msg); channel.addChannelListener(test); channel.addMembershipListener(test); channel.start(startoptions); Runtime.getRuntime().addShutdownHook(new Shutdown(channel)); while ( threads > 1 ) { Thread t = new Thread(test); t.setDaemon(true); t.start(); threads--; test = new LoadTest(channel,send,count,debug,pause,stats,breakOnEx); test.channelOptions = channelOptions; } test.run(); if ( shutdown && send ) channel.stop(Channel.DEFAULT); System.out.println("System test complete, sleeping to let threads finish."); Thread.sleep(60*1000*60); }
Example 4
Source File: ChannelCoordinator.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
/** * Starts up the channel. This can be called multiple times for individual services to start * The svc parameter can be the logical or value of any constants * @param svc int value of <BR> * DEFAULT - will start all services <BR> * MBR_RX_SEQ - starts the membership receiver <BR> * MBR_TX_SEQ - starts the membership broadcaster <BR> * SND_TX_SEQ - starts the replication transmitter<BR> * SND_RX_SEQ - starts the replication receiver<BR> * @throws ChannelException if a startup error occurs or the service is already started. */ protected synchronized void internalStart(int svc) throws ChannelException { try { boolean valid = false; //make sure we don't pass down any flags that are unrelated to the bottom layer svc = svc & Channel.DEFAULT; if (startLevel == Channel.DEFAULT) return; //we have already started up all components if (svc == 0 ) return;//nothing to start if (svc == (svc & startLevel)) throw new ChannelException("Channel already started for level:"+svc); //must start the receiver first so that we can coordinate the port it //listens to with the local membership settings if ( Channel.SND_RX_SEQ==(svc & Channel.SND_RX_SEQ) ) { clusterReceiver.setMessageListener(this); clusterReceiver.start(); //synchronize, big time FIXME membershipService.setLocalMemberProperties(getClusterReceiver().getHost(), getClusterReceiver().getPort(), getClusterReceiver().getSecurePort(), getClusterReceiver().getUdpPort()); valid = true; } if ( Channel.SND_TX_SEQ==(svc & Channel.SND_TX_SEQ) ) { clusterSender.start(); valid = true; } if ( Channel.MBR_RX_SEQ==(svc & Channel.MBR_RX_SEQ) ) { membershipService.setMembershipListener(this); if (membershipService instanceof McastService) { ((McastService)membershipService).setMessageListener(this); } membershipService.start(MembershipService.MBR_RX); valid = true; } if ( Channel.MBR_TX_SEQ==(svc & Channel.MBR_TX_SEQ) ) { membershipService.start(MembershipService.MBR_TX); valid = true; } if ( !valid) { throw new IllegalArgumentException("Invalid start level, valid levels are:SND_RX_SEQ,SND_TX_SEQ,MBR_TX_SEQ,MBR_RX_SEQ"); } startLevel = (startLevel | svc); }catch ( ChannelException cx ) { throw cx; }catch ( Exception x ) { throw new ChannelException(x); } }
Example 5
Source File: ChannelCoordinator.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
/** * Shuts down the channel. This can be called multiple times for individual services to shutdown * The svc parameter can be the logical or value of any constants * @param svc int value of <BR> * DEFAULT - will shutdown all services <BR> * MBR_RX_SEQ - starts the membership receiver <BR> * MBR_TX_SEQ - starts the membership broadcaster <BR> * SND_TX_SEQ - starts the replication transmitter<BR> * SND_RX_SEQ - starts the replication receiver<BR> * @throws ChannelException if a startup error occurs or the service is already started. */ protected synchronized void internalStop(int svc) throws ChannelException { try { //make sure we don't pass down any flags that are unrelated to the bottom layer svc = svc & Channel.DEFAULT; if (startLevel == 0) return; //we have already stopped up all components if (svc == 0 ) return;//nothing to stop boolean valid = false; if ( Channel.SND_RX_SEQ==(svc & Channel.SND_RX_SEQ) ) { clusterReceiver.stop(); clusterReceiver.setMessageListener(null); valid = true; } if ( Channel.SND_TX_SEQ==(svc & Channel.SND_TX_SEQ) ) { clusterSender.stop(); valid = true; } if ( Channel.MBR_RX_SEQ==(svc & Channel.MBR_RX_SEQ) ) { membershipService.stop(MembershipService.MBR_RX); membershipService.setMembershipListener(null); valid = true; } if ( Channel.MBR_TX_SEQ==(svc & Channel.MBR_TX_SEQ) ) { valid = true; membershipService.stop(MembershipService.MBR_TX); } if ( !valid) { throw new IllegalArgumentException("Invalid start level, valid levels are:SND_RX_SEQ,SND_TX_SEQ,MBR_TX_SEQ,MBR_RX_SEQ"); } startLevel = (startLevel & (~svc)); }catch ( Exception x ) { throw new ChannelException(x); } finally { } }
Example 6
Source File: LoadTest.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
public static void main(String[] args) throws Exception { boolean send = true; boolean debug = false; long pause = 0; int count = 1000000; int stats = 10000; boolean breakOnEx = false; int threads = 1; boolean shutdown = false; int startoptions = Channel.DEFAULT; int channelOptions = Channel.SEND_OPTIONS_DEFAULT; if ( args.length == 0 ) { args = new String[] {"-help"}; } for (int i = 0; i < args.length; i++) { if ("-threads".equals(args[i])) { threads = Integer.parseInt(args[++i]); } else if ("-count".equals(args[i])) { count = Integer.parseInt(args[++i]); System.out.println("Sending "+count+" messages."); } else if ("-pause".equals(args[i])) { pause = Long.parseLong(args[++i])*1000; } else if ("-break".equals(args[i])) { breakOnEx = true; } else if ("-shutdown".equals(args[i])) { shutdown = true; } else if ("-stats".equals(args[i])) { stats = Integer.parseInt(args[++i]); System.out.println("Stats every "+stats+" message"); } else if ("-sendoptions".equals(args[i])) { channelOptions = Integer.parseInt(args[++i]); System.out.println("Setting send options to "+channelOptions); } else if ("-startoptions".equals(args[i])) { startoptions = Integer.parseInt(args[++i]); System.out.println("Setting start options to "+startoptions); } else if ("-size".equals(args[i])) { size = Integer.parseInt(args[++i])-4; System.out.println("Message size will be:"+(size+4)+" bytes"); } else if ("-mode".equals(args[i])) { if ( "receive".equals(args[++i]) ) send = false; } else if ("-debug".equals(args[i])) { debug = true; } else if ("-help".equals(args[i])) { usage(); System.exit(1); } } ManagedChannel channel = (ManagedChannel)ChannelCreator.createChannel(args); LoadTest test = new LoadTest(channel,send,count,debug,pause,stats,breakOnEx); test.channelOptions = channelOptions; LoadMessage msg = new LoadMessage(); messageSize = LoadMessage.getMessageSize(msg); channel.addChannelListener(test); channel.addMembershipListener(test); channel.start(startoptions); Runtime.getRuntime().addShutdownHook(new Shutdown(channel)); while ( threads > 1 ) { Thread t = new Thread(test); t.setDaemon(true); t.start(); threads--; test = new LoadTest(channel,send,count,debug,pause,stats,breakOnEx); test.channelOptions = channelOptions; } test.run(); if ( shutdown && send ) channel.stop(Channel.DEFAULT); System.out.println("System test complete, sleeping to let threads finish."); Thread.sleep(60*1000*60); }
Example 7
Source File: ChannelCoordinator.java From tomcatsrc with Apache License 2.0 | 4 votes |
/** * Starts up the channel. This can be called multiple times for individual services to start * The svc parameter can be the logical or value of any constants * @param svc int value of <BR> * DEFAULT - will start all services <BR> * MBR_RX_SEQ - starts the membership receiver <BR> * MBR_TX_SEQ - starts the membership broadcaster <BR> * SND_TX_SEQ - starts the replication transmitter<BR> * SND_RX_SEQ - starts the replication receiver<BR> * @throws ChannelException if a startup error occurs or the service is already started. */ protected synchronized void internalStart(int svc) throws ChannelException { try { boolean valid = false; //make sure we don't pass down any flags that are unrelated to the bottom layer svc = svc & Channel.DEFAULT; if (startLevel == Channel.DEFAULT) return; //we have already started up all components if (svc == 0 ) return;//nothing to start if (svc == (svc & startLevel)) throw new ChannelException("Channel already started for level:"+svc); //must start the receiver first so that we can coordinate the port it //listens to with the local membership settings if ( Channel.SND_RX_SEQ==(svc & Channel.SND_RX_SEQ) ) { clusterReceiver.setMessageListener(this); if (clusterReceiver instanceof ReceiverBase) { ((ReceiverBase)clusterReceiver).setChannel(getChannel()); } clusterReceiver.start(); //synchronize, big time FIXME Member localMember = getChannel().getLocalMember(false); if (localMember instanceof StaticMember) { // static member StaticMember staticMember = (StaticMember)localMember; staticMember.setHost(getClusterReceiver().getHost()); staticMember.setPort(getClusterReceiver().getPort()); staticMember.setSecurePort(getClusterReceiver().getSecurePort()); } else { // multicast member membershipService.setLocalMemberProperties(getClusterReceiver().getHost(), getClusterReceiver().getPort(), getClusterReceiver().getSecurePort(), getClusterReceiver().getUdpPort()); } valid = true; } if ( Channel.SND_TX_SEQ==(svc & Channel.SND_TX_SEQ) ) { if (clusterSender instanceof ReplicationTransmitter) { ((ReplicationTransmitter)clusterSender).setChannel(getChannel()); } valid = true; clusterSender.start(); } if ( Channel.MBR_RX_SEQ==(svc & Channel.MBR_RX_SEQ) ) { membershipService.setMembershipListener(this); if (membershipService instanceof McastService) { ((McastService)membershipService).setMessageListener(this); ((McastService)membershipService).setChannel(getChannel()); } membershipService.start(MembershipService.MBR_RX); valid = true; } if ( Channel.MBR_TX_SEQ==(svc & Channel.MBR_TX_SEQ) ) { if (membershipService instanceof McastService) { ((McastService)membershipService).setChannel(getChannel()); } membershipService.start(MembershipService.MBR_TX); valid = true; } if ( !valid) { throw new IllegalArgumentException("Invalid start level, valid levels are:SND_RX_SEQ,SND_TX_SEQ,MBR_TX_SEQ,MBR_RX_SEQ"); } startLevel = (startLevel | svc); }catch ( ChannelException cx ) { throw cx; }catch ( Exception x ) { throw new ChannelException(x); } }
Example 8
Source File: ChannelCoordinator.java From tomcatsrc with Apache License 2.0 | 4 votes |
/** * Shuts down the channel. This can be called multiple times for individual services to shutdown * The svc parameter can be the logical or value of any constants * @param svc int value of <BR> * DEFAULT - will shutdown all services <BR> * MBR_RX_SEQ - starts the membership receiver <BR> * MBR_TX_SEQ - starts the membership broadcaster <BR> * SND_TX_SEQ - starts the replication transmitter<BR> * SND_RX_SEQ - starts the replication receiver<BR> * @throws ChannelException if a startup error occurs or the service is already started. */ protected synchronized void internalStop(int svc) throws ChannelException { try { //make sure we don't pass down any flags that are unrelated to the bottom layer svc = svc & Channel.DEFAULT; if (startLevel == 0) return; //we have already stopped up all components if (svc == 0 ) return;//nothing to stop boolean valid = false; if ( Channel.SND_RX_SEQ==(svc & Channel.SND_RX_SEQ) ) { clusterReceiver.stop(); clusterReceiver.setMessageListener(null); valid = true; } if ( Channel.SND_TX_SEQ==(svc & Channel.SND_TX_SEQ) ) { clusterSender.stop(); valid = true; } if ( Channel.MBR_RX_SEQ==(svc & Channel.MBR_RX_SEQ) ) { membershipService.stop(MembershipService.MBR_RX); membershipService.setMembershipListener(null); valid = true; } if ( Channel.MBR_TX_SEQ==(svc & Channel.MBR_TX_SEQ) ) { valid = true; membershipService.stop(MembershipService.MBR_TX); } if ( !valid) { throw new IllegalArgumentException("Invalid start level, valid levels are:SND_RX_SEQ,SND_TX_SEQ,MBR_TX_SEQ,MBR_RX_SEQ"); } startLevel = (startLevel & (~svc)); setChannel(null); }catch ( Exception x ) { throw new ChannelException(x); } finally { } }
Example 9
Source File: LoadTest.java From tomcatsrc with Apache License 2.0 | 4 votes |
public static void main(String[] args) throws Exception { boolean send = true; boolean debug = false; long pause = 0; int count = 1000000; int stats = 10000; boolean breakOnEx = false; int threads = 1; boolean shutdown = false; int startoptions = Channel.DEFAULT; int channelOptions = Channel.SEND_OPTIONS_DEFAULT; if ( args.length == 0 ) { args = new String[] {"-help"}; } for (int i = 0; i < args.length; i++) { if ("-threads".equals(args[i])) { threads = Integer.parseInt(args[++i]); } else if ("-count".equals(args[i])) { count = Integer.parseInt(args[++i]); System.out.println("Sending "+count+" messages."); } else if ("-pause".equals(args[i])) { pause = Long.parseLong(args[++i])*1000; } else if ("-break".equals(args[i])) { breakOnEx = true; } else if ("-shutdown".equals(args[i])) { shutdown = true; } else if ("-stats".equals(args[i])) { stats = Integer.parseInt(args[++i]); System.out.println("Stats every "+stats+" message"); } else if ("-sendoptions".equals(args[i])) { channelOptions = Integer.parseInt(args[++i]); System.out.println("Setting send options to "+channelOptions); } else if ("-startoptions".equals(args[i])) { startoptions = Integer.parseInt(args[++i]); System.out.println("Setting start options to "+startoptions); } else if ("-size".equals(args[i])) { size = Integer.parseInt(args[++i])-4; System.out.println("Message size will be:"+(size+4)+" bytes"); } else if ("-mode".equals(args[i])) { if ( "receive".equals(args[++i]) ) send = false; } else if ("-debug".equals(args[i])) { debug = true; } else if ("-help".equals(args[i])) { usage(); System.exit(1); } } ManagedChannel channel = (ManagedChannel)ChannelCreator.createChannel(args); LoadTest test = new LoadTest(channel,send,count,debug,pause,stats,breakOnEx); test.channelOptions = channelOptions; LoadMessage msg = new LoadMessage(); messageSize = LoadMessage.getMessageSize(msg); channel.addChannelListener(test); channel.addMembershipListener(test); channel.start(startoptions); Runtime.getRuntime().addShutdownHook(new Shutdown(channel)); while ( threads > 1 ) { Thread t = new Thread(test); t.setDaemon(true); t.start(); threads--; test = new LoadTest(channel,send,count,debug,pause,stats,breakOnEx); test.channelOptions = channelOptions; } test.run(); if ( shutdown && send ) channel.stop(Channel.DEFAULT); System.out.println("System test complete, sleeping to let threads finish."); Thread.sleep(60*1000*60); }