Author: fhanik Date: Tue Feb 28 08:15:14 2006 New Revision: 381688 URL: http://svn.apache.org/viewcvs?rev=381688&view=rev Log: Channel creator Added: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/demos/ChannelCreator.java Added: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/demos/ChannelCreator.java URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/demos/ChannelCreator.java?rev=381688&view=auto ============================================================================== --- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/demos/ChannelCreator.java (added) +++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/demos/ChannelCreator.java Tue Feb 28 08:15:14 2006 @@ -0,0 +1,144 @@ +/* + * Copyright 1999,2004-2006 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.catalina.tribes.demos; + +import org.apache.catalina.tribes.Channel; +import org.apache.catalina.tribes.tcp.ReplicationListener; +import org.apache.catalina.tribes.tcp.ReplicationTransmitter; +import org.apache.catalina.tribes.ManagedChannel; +import org.apache.catalina.tribes.group.GroupChannel; +import org.apache.catalina.tribes.mcast.McastService; +import org.apache.catalina.tribes.group.interceptors.GzipInterceptor; + +/** + *
Title:
+ * + *Description:
+ * + * + *Company:
+ * + * @author fhanik + * @version 1.0 + */ +public class ChannelCreator { + + public static StringBuffer usage() { + StringBuffer buf = new StringBuffer(); + buf.append("\n\t\t[-sender pooled|fastasyncqueue]") + .append("\n\t\t[-bind tcpbindaddress]") + .append("\n\t\t[-tcpselto tcpselectortimeout]") + .append("\n\t\t[-tcpthreads tcpthreadcount]") + .append("\n\t\t[-port tcplistenport]") + .append("\n\t\t[-ack true|false]") + .append("\n\t\t[-ackto acktimeout]") + .append("\n\t\t[-autoconnect true|false]") + .append("\n\t\t[-sync true|false]") + .append("\n\t\t[-maddr multicastaddr]") + .append("\n\t\t[-mport multicastport]") + .append("\n\t\t[-mbind multicastbindaddr]") + .append("\n\t\t[-mfreq multicastfrequency]") + .append("\n\t\t[-mdrop multicastdroptime]") + .append("\n\t\t[-gzip]") + ; + return buf; + + } + + public static Channel createChannel(String[] args) { + String bind = "auto"; + int port = 4001; + String mbind = null; + boolean ack = true; + boolean sync = true; + boolean gzip = false; + String sender = "pooled"; + int tcpseltimeout = 100; + int tcpthreadcount = 4; + int acktimeout = 15000; + boolean autoconnect = true; + String mcastaddr = "228.0.0.5"; + int mcastport = 45565; + long mcastfreq = 500; + long mcastdrop = 2000; + + for (int i = 0; i < args.length; i++) { + if ("-bind".equals(args[i])) { + bind = args[++i]; + } else if ("-sender".equals(args[i])) { + sender = args[++i]; + } else if ("-port".equals(args[i])) { + port = Integer.parseInt(args[++i]); + } else if ("-tcpselto".equals(args[i])) { + tcpseltimeout = Integer.parseInt(args[++i]); + } else if ("-tcpthreads".equals(args[i])) { + tcpthreadcount = Integer.parseInt(args[++i]); + } else if ("-gzip".equals(args[i])) { + gzip = true; + } else if ("-ack".equals(args[i])) { + ack = Boolean.parseBoolean(args[++i]); + } else if ("-ackto".equals(args[i])) { + acktimeout = Integer.parseInt(args[++i]); + } else if ("-sync".equals(args[i])) { + sync = Boolean.parseBoolean(args[++i]); + } else if ("-autoconnect".equals(args[i])) { + autoconnect = Boolean.parseBoolean(args[++i]); + } else if ("-maddr".equals(args[i])) { + mcastaddr = args[++i]; + } else if ("-mport".equals(args[i])) { + mcastport = Integer.parseInt(args[++i]); + } else if ("-mfreq".equals(args[i])) { + mcastfreq = Long.parseLong(args[++i]); + } else if ("-mdrop".equals(args[i])) { + mcastdrop = Long.parseLong(args[++i]); + } else if ("-mbind".equals(args[i])) { + mbind = args[++i]; + } + } + + ReplicationListener rl = new ReplicationListener(); + rl.setTcpListenAddress(bind); + rl.setTcpListenPort(port); + rl.setTcpSelectorTimeout(tcpseltimeout); + rl.setTcpThreadCount(tcpthreadcount); + rl.getBind(); + rl.setSendAck(ack); + rl.setSynchronized(sync); + + ReplicationTransmitter ps = new ReplicationTransmitter(); + ps.setReplicationMode(sender); + ps.setAckTimeout(acktimeout); + ps.setAutoConnect(autoconnect); + ps.setWaitForAck(ack); + + McastService service = new McastService(); + service.setMcastAddr(mcastaddr); + if (mbind != null) service.setMcastBindAddress(mbind); + service.setMcastFrequency(mcastfreq); + service.setMcastDropTime(mcastdrop); + service.setMcastPort(mcastport); + + ManagedChannel channel = new GroupChannel(); + channel.setChannelReceiver(rl); + channel.setChannelSender(ps); + channel.setMembershipService(service); + + if (gzip) channel.addInterceptor(new GzipInterceptor()); + return channel; + + } + +} \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org