You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by kk...@apache.org on 2011/11/06 22:15:08 UTC
svn commit: r1198560 - in
/tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes: demos/ group/
group/interceptors/ membership/
Author: kkolinko
Date: Sun Nov 6 21:15:08 2011
New Revision: 1198560
URL: http://svn.apache.org/viewvc?rev=1198560&view=rev
Log:
Porting r1187806 - whitespace cleanup in /test
Modified:
tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/ChannelCreator.java
tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/CoordinationDemo.java
tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/EchoRpcTest.java
tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/IntrospectionUtils.java
tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/LoadTest.java
tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/MapDemo.java
tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/MembersWithProperties.java
tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelOptionFlag.java
tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelSenderConnections.java
tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelStartStop.java
tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/group/interceptors/TestOrderInterceptor.java
tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/group/interceptors/TestTcpFailureDetector.java
tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/membership/TestMemberImplSerialization.java
Modified: tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/ChannelCreator.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/ChannelCreator.java?rev=1198560&r1=1198559&r2=1198560&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/ChannelCreator.java (original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/ChannelCreator.java Sun Nov 6 21:15:08 2011
@@ -51,16 +51,16 @@ import org.apache.catalina.tribes.transp
* @version 1.0
*/
public class ChannelCreator {
-
-
+
+
public static StringBuilder usage() {
StringBuilder buf = new StringBuilder();
buf.append("\n\t\t[-bind tcpbindaddress]")
- .append("\n\t\t[-tcpselto tcpselectortimeout]")
- .append("\n\t\t[-tcpthreads tcpthreadcount]")
+ .append("\n\t\t[-tcpselto tcpselectortimeout]")
+ .append("\n\t\t[-tcpthreads tcpthreadcount]")
.append("\n\t\t[-port tcplistenport]")
.append("\n\t\t[-autobind tcpbindtryrange]")
- .append("\n\t\t[-ackto acktimeout]")
+ .append("\n\t\t[-ackto acktimeout]")
.append("\n\t\t[-receiver org.apache.catalina.tribes.transport.nio.NioReceiver|org.apache.catalina.tribes.transport.bio.BioReceiver|]")
.append("\n\t\t[-transport org.apache.catalina.tribes.transport.nio.PooledParallelSender|org.apache.catalina.tribes.transport.bio.PooledMultiSender]")
.append("\n\t\t[-transport.xxx transport specific property]")
@@ -108,7 +108,7 @@ public class ChannelCreator {
int asyncsize = 1024*1024*50; //50MB
boolean throughput = false;
boolean failuredetect = false;
-
+
for (int i = 0; i < args.length; i++) {
if ("-bind".equals(args[i])) {
bind = args[++i];
@@ -169,7 +169,7 @@ public class ChannelCreator {
mbind = args[++i];
}
}
-
+
System.out.println("Creating receiver class="+receiver);
Class<?> cl = Class.forName(receiver, true,
ChannelCreator.class.getClassLoader());
@@ -184,7 +184,7 @@ public class ChannelCreator {
rx.setTxBufSize(25188);
rx.setAutoBind(autoBind);
-
+
ReplicationTransmitter ps = new ReplicationTransmitter();
System.out.println("Creating transport class="+transport);
MultiPointSender sender = (MultiPointSender)Class.forName(transport,true,ChannelCreator.class.getClassLoader()).newInstance();
@@ -211,7 +211,7 @@ public class ChannelCreator {
channel.setChannelReceiver(rx);
channel.setChannelSender(ps);
channel.setMembershipService(service);
-
+
if ( throughput ) channel.addInterceptor(new ThroughputInterceptor());
if (gzip) channel.addInterceptor(new GzipInterceptor());
if ( frag ) {
@@ -224,14 +224,14 @@ public class ChannelCreator {
oi.setMaxQueue(ordersize);
channel.addInterceptor(oi);
}
-
+
if ( async ) {
MessageDispatchInterceptor mi = new MessageDispatch15Interceptor();
mi.setMaxQueueSize(asyncsize);
channel.addInterceptor(mi);
System.out.println("Added MessageDispatchInterceptor");
}
-
+
if ( failuredetect ) {
TcpFailureDetector tcpfi = new TcpFailureDetector();
channel.addInterceptor(tcpfi);
Modified: tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/CoordinationDemo.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/CoordinationDemo.java?rev=1198560&r1=1198559&r2=1198560&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/CoordinationDemo.java (original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/CoordinationDemo.java Sun Nov 6 21:15:08 2011
@@ -47,13 +47,13 @@ public class CoordinationDemo {
public CoordinationDemo() {
// Default constructor
}
-
+
public void init() {
reader = new BufferedReader(new InputStreamReader(System.in));
status = new Status[CHANNEL_COUNT];
}
-
-
+
+
public void clearScreen() {
StringBuilder buf = new StringBuilder(700);
for (int i=0; i<CLEAR_SCREEN; i++ ) buf.append("\n");
@@ -68,7 +68,7 @@ public class CoordinationDemo {
System.out.println("\tquit");
System.out.print("Enter command:");
}
-
+
public synchronized void printScreen() {
clearScreen();
System.out.println(" ###."+getHeader());
@@ -79,9 +79,9 @@ public class CoordinationDemo {
System.out.println("\n\n");
System.out.println("Overall status:"+statusLine);
printMenuOptions();
-
+
}
-
+
public String getHeader() {
//member - 30
//running- 10
@@ -96,19 +96,19 @@ public class CoordinationDemo {
buf.append(leftfill("View-id(short)",24," "));
buf.append(leftfill("Count",8," "));
buf.append("\n");
-
+
buf.append(rightfill("==="+new java.sql.Timestamp(System.currentTimeMillis()).toString(),SCREEN_WIDTH,"="));
buf.append("\n");
return buf.toString();
}
-
+
public String[] tokenize(String line) {
StringTokenizer tz = new StringTokenizer(line," ");
String[] result = new String[tz.countTokens()];
for (int i=0; i<result.length; i++ ) result[i] = tz.nextToken();
return result;
}
-
+
public void waitForInput() throws IOException {
for ( int i=0; i<status.length; i++ ) status[i] = new Status(this);
printScreen();
@@ -150,7 +150,7 @@ public class CoordinationDemo {
}
for (int i = 0; i < status.length; i++) if (MULTI_THREAD ) t[i].start(); else t[i].run();
setSystemStatus("System stopped.");
- } else {
+ } else {
int index = -1;
try { index = Integer.parseInt(args[1])-1;}catch ( Exception x ) {setSystemStatus("Invalid index:"+args[1]);}
if ( index >= 0 ) {
@@ -176,7 +176,7 @@ public class CoordinationDemo {
}
for (int i = 0; i < status.length; i++) if (MULTI_THREAD ) t[i].start(); else t[i].run();
setSystemStatus("System started.");
- } else {
+ } else {
int index = -1;
try { index = Integer.parseInt(args[1])-1;}catch ( Exception x ) {setSystemStatus("Invalid index:"+args[1]);}
if ( index >= 0 ) {
@@ -201,7 +201,7 @@ public class CoordinationDemo {
VIEW_EVENTS[idx] = true;
}
}
-
+
public static void run(String[] args,CoordinationDemo demo) throws Exception {
usage();
java.util.Arrays.fill(VIEW_EVENTS,true);
@@ -221,7 +221,7 @@ public class CoordinationDemo {
}
demo.init();
demo.waitForInput();
- }
+ }
private static void usage() {
System.out.println("Usage:");
@@ -237,14 +237,14 @@ public class CoordinationDemo {
CoordinationDemo demo = new CoordinationDemo();
run(args,demo);
}
-
+
public static String leftfill(String value, int length, String ch) {
return fill(value,length,ch,true);
}
-
+
public static String rightfill(String value, int length, String ch) {
return fill(value,length,ch,false);
- }
+ }
public static String fill(String value, int length, String ch, boolean left) {
StringBuilder buf = new StringBuilder();
@@ -253,8 +253,8 @@ public class CoordinationDemo {
if ( left ) buf.append(value.trim());
return buf.toString();
}
-
-
+
+
public static class Status {
public CoordinationDemo parent;
public GroupChannel channel;
@@ -262,11 +262,11 @@ public class CoordinationDemo {
public String status;
public Exception error;
public String startstatus = "new";
-
+
public Status(CoordinationDemo parent) {
this.parent = parent;
}
-
+
public String getStatusLine() {
//member - 30
//running- 10
@@ -297,12 +297,12 @@ public class CoordinationDemo {
buf.append("\n");
return buf.toString();
}
-
+
public String getByteString(byte[] b) {
if ( b == null ) return "{}";
return Arrays.toString(b,0,Math.min(b.length,4));
}
-
+
public void start() {
try {
if ( channel == null ) {
@@ -329,7 +329,7 @@ public class CoordinationDemo {
interceptor = null;
}
}
-
+
public void stop() {
try {
if ( channel != null ) {
@@ -353,7 +353,7 @@ public class CoordinationDemo {
interceptor = null;
}
}
-
+
public GroupChannel createChannel() {
channel = new GroupChannel();
((ReceiverBase)channel.getChannelReceiver()).setAutoBind(100);
Modified: tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/EchoRpcTest.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/EchoRpcTest.java?rev=1198560&r1=1198559&r2=1198560&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/EchoRpcTest.java (original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/EchoRpcTest.java Sun Nov 6 21:15:08 2011
@@ -37,7 +37,7 @@ import org.apache.catalina.tribes.group.
* @version 1.0
*/
public class EchoRpcTest implements RpcCallback, Runnable {
-
+
Channel channel;
int count;
String message;
@@ -46,7 +46,7 @@ public class EchoRpcTest implements RpcC
int options;
long timeout;
String name;
-
+
public EchoRpcTest(Channel channel, String name, int count, String message, long pause, int options, long timeout) {
this.channel = channel;
this.count = count;
@@ -85,7 +85,7 @@ public class EchoRpcTest implements RpcC
System.out.println("Received a reply request message from ["+sender.getName()+"] with data ["+msg+"]");
return "Reply("+name+"):"+msg;
}
-
+
@Override
public void run() {
long counter = 0;
@@ -105,7 +105,7 @@ public class EchoRpcTest implements RpcC
}
}
}
-
+
public static void usage() {
System.out.println("Tribes RPC tester.");
System.out.println("Usage:\n\t"+
@@ -127,7 +127,7 @@ public class EchoRpcTest implements RpcC
"java EchoRpcTest -bind 192.168.0.45 -port 4005\n\t"+
"java EchoRpcTest -bind 192.168.0.45 -port 4005 -mbind 192.168.0.45 -count 100 -stats 10\n");
}
-
+
public static void main(String[] args) throws Exception {
long pause = 3000;
int count = 1000000;
@@ -170,24 +170,24 @@ public class EchoRpcTest implements RpcC
System.exit(1);
}
}
-
-
+
+
ManagedChannel channel = (ManagedChannel)ChannelCreator.createChannel(args);
EchoRpcTest test = new EchoRpcTest(channel,name,count,message,pause,options,timeout);
channel.start(Channel.DEFAULT);
Runtime.getRuntime().addShutdownHook(new Shutdown(channel));
test.run();
-
+
System.out.println("System test complete, sleeping to let threads finish.");
Thread.sleep(60*1000*60);
- }
-
+ }
+
public static class Shutdown extends Thread {
ManagedChannel channel = null;
public Shutdown(ManagedChannel channel) {
this.channel = channel;
}
-
+
@Override
public void run() {
System.out.println("Shutting down...");
@@ -196,7 +196,7 @@ public class EchoRpcTest implements RpcC
exit.start();
try {
channel.stop(Channel.DEFAULT);
-
+
}catch ( Exception x ) {
x.printStackTrace();
}
@@ -216,6 +216,6 @@ public class EchoRpcTest implements RpcC
x.printStackTrace();
}
System.exit(0);
-
+
}
}}
\ No newline at end of file
Modified: tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/IntrospectionUtils.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/IntrospectionUtils.java?rev=1198560&r1=1198559&r2=1198560&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/IntrospectionUtils.java (original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/IntrospectionUtils.java Sun Nov 6 21:15:08 2011
@@ -37,10 +37,10 @@ import java.util.Vector;
*/
public final class IntrospectionUtils {
-
+
private static final org.apache.juli.logging.Log log=
org.apache.juli.logging.LogFactory.getLog( IntrospectionUtils.class );
-
+
/**
* Call execute() - any ant-like task should work
*/
@@ -134,7 +134,7 @@ public final class IntrospectionUtils {
* Guess a product install/home by analyzing the class path. It works for
* product using the pattern: lib/executable.jar or if executable.jar is
* included in classpath by a shell script. ( java -jar also works )
- *
+ *
* Insures both "install" and "home" System properties are set. If either or
* both System properties are unset, "install" and "home" will be set to the
* same value. This value will be the other System property that is set, or
@@ -343,9 +343,9 @@ public final class IntrospectionUtils {
if (methods[i].getReturnType()==Boolean.TYPE){
setPropertyMethodBool = methods[i];
}else {
- setPropertyMethodVoid = methods[i];
+ setPropertyMethodVoid = methods[i];
}
-
+
}
}
@@ -440,7 +440,7 @@ public final class IntrospectionUtils {
return null;
}
- /**
+ /**
*/
public static void setProperty(Object o, String name) {
String setter = "set" + capitalize(name);
@@ -628,7 +628,7 @@ public final class IntrospectionUtils {
* Add elements from the classpath <i>cp </i> to a Vector <i>jars </i> as
* file URLs (We use Vector for JDK 1.1 compat).
* <p>
- *
+ *
* @param jars The jar list
* @param cp a String classpath of directory or jar file elements
* separated by path.separator delimiters.
@@ -700,7 +700,7 @@ public final class IntrospectionUtils {
public static void clear() {
objectMethods.clear();
}
-
+
static Hashtable<Class<?>,Method[]> objectMethods =
new Hashtable<Class<?>,Method[]>();
@@ -866,7 +866,7 @@ public final class IntrospectionUtils {
}
return result;
}
-
+
// -------------------- Get property --------------------
// This provides a layer of abstraction
Modified: tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/LoadTest.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/LoadTest.java?rev=1198560&r1=1198559&r2=1198560&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/LoadTest.java (original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/LoadTest.java Sun Nov 6 21:15:08 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You 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.
@@ -45,7 +45,7 @@ public class LoadTest implements Members
public static int size = 24000;
public static Object mutex = new Object();
public boolean doRun = true;
-
+
public long bytesReceived = 0;
public float mBytesReceived = 0;
public int messagesReceived = 0;
@@ -59,30 +59,30 @@ public class LoadTest implements Members
public boolean async = false;
public long receiveStart = 0;
public int channelOptions = Channel.SEND_OPTIONS_DEFAULT;
-
+
static int messageSize = 0;
-
+
public static long messagesSent = 0;
public static long messageStartSendTime = 0;
public static long messageEndSendTime = 0;
public static int threadCount = 0;
-
+
public static synchronized void startTest() {
threadCount++;
if ( messageStartSendTime == 0 ) messageStartSendTime = System.currentTimeMillis();
}
-
+
public static synchronized void endTest() {
threadCount--;
if ( messageEndSendTime == 0 && threadCount==0 ) messageEndSendTime = System.currentTimeMillis();
}
-
+
public static synchronized long addSendStats(long count) {
messagesSent+=count;
return 0l;
- }
-
+ }
+
private static void printSendStats(long counter, int messageSize) {
float cnt = counter;
float size = messageSize;
@@ -96,7 +96,7 @@ public class LoadTest implements Members
}
- public LoadTest(ManagedChannel channel,
+ public LoadTest(ManagedChannel channel,
boolean send,
int msgCount,
boolean debug,
@@ -115,11 +115,11 @@ public class LoadTest implements Members
@Override
public void run() {
-
+
long counter = 0;
long total = 0;
LoadMessage msg = new LoadMessage();
-
+
try {
startTest();
while (total < msgCount) {
@@ -158,7 +158,7 @@ public class LoadTest implements Members
//print from the global counter
//printSendStats(LoadTest.messagesSent, LoadTest.messageSize, LoadTest.messageSendTime);
printSendStats(LoadTest.messagesSent, LoadTest.messageSize);
-
+
}
}
@@ -197,29 +197,29 @@ public class LoadTest implements Members
public void memberDisappeared(Member member) {
log.info("Member disappeared:"+member);
}
-
+
@Override
- public boolean accept(Serializable msg, Member mbr){
+ public boolean accept(Serializable msg, Member mbr){
return (msg instanceof LoadMessage) || (msg instanceof ByteMessage);
}
-
+
@Override
- public void messageReceived(Serializable msg, Member mbr){
+ public void messageReceived(Serializable msg, Member mbr){
if ( receiveStart == 0 ) receiveStart = System.currentTimeMillis();
if ( debug ) {
if ( msg instanceof LoadMessage ) {
printArray(((LoadMessage)msg).getMessage());
}
}
-
+
if ( msg instanceof ByteMessage && !(msg instanceof LoadMessage)) {
LoadMessage tmp = new LoadMessage();
tmp.setMessage(((ByteMessage)msg).getMessage());
msg = tmp;
tmp = null;
}
-
-
+
+
bytesReceived+=((LoadMessage)msg).getMessage().length;
mBytesReceived+=(((LoadMessage)msg).getMessage().length)/1024f/1024f;
messagesReceived++;
@@ -237,8 +237,8 @@ public class LoadTest implements Members
}
}
-
-
+
+
public static void printArray(byte[] data) {
System.out.print("{");
for (int i=0; i<data.length; i++ ) {
@@ -250,7 +250,7 @@ public class LoadTest implements Members
public static class LoadMessage extends ByteMessage {
-
+
public static byte[] outdata = new byte[size];
public static Random r = new Random();
public static int getMessageSize (LoadMessage msg) {
@@ -259,13 +259,13 @@ public class LoadTest implements Members
static {
r.nextBytes(outdata);
}
-
+
protected byte[] message = getMessage();
-
+
public LoadMessage() {
// Default constructor
}
-
+
@Override
public byte[] getMessage() {
if ( message == null ) {
@@ -273,13 +273,13 @@ public class LoadTest implements Members
}
return message;
}
-
+
@Override
public void setMessage(byte[] data) {
this.message = data;
}
}
-
+
public static void usage() {
System.out.println("Tribes Load tester.");
System.out.println("The load tester can be used in sender or received mode or both");
@@ -304,7 +304,7 @@ public class LoadTest implements Members
"java LoadTest -bind 192.168.0.45 -port 4005\n\t"+
"java LoadTest -bind 192.168.0.45 -port 4005 -mbind 192.168.0.45 -count 100 -stats 10\n");
}
-
+
public static void main(String[] args) throws Exception {
boolean send = true;
boolean debug = false;
@@ -347,19 +347,19 @@ public class LoadTest implements Members
if ( "receive".equals(args[++i]) ) send = false;
} else if ("-debug".equals(args[i])) {
debug = true;
- } else if ("-help".equals(args[i]))
+ } 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);
@@ -377,14 +377,14 @@ public class LoadTest implements Members
if ( shutdown && send ) channel.stop(Channel.DEFAULT);
System.out.println("System test complete, sleeping to let threads finish.");
Thread.sleep(60*1000*60);
- }
-
+ }
+
public static class Shutdown extends Thread {
ManagedChannel channel = null;
public Shutdown(ManagedChannel channel) {
this.channel = channel;
}
-
+
@Override
public void run() {
System.out.println("Shutting down...");
@@ -393,7 +393,7 @@ public class LoadTest implements Members
exit.start();
try {
channel.stop(Channel.DEFAULT);
-
+
}catch ( Exception x ) {
x.printStackTrace();
}
@@ -416,5 +416,5 @@ public class LoadTest implements Members
}
}
-
+
}
\ No newline at end of file
Modified: tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/MapDemo.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/MapDemo.java?rev=1198560&r1=1198559&r2=1198560&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/MapDemo.java (original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/MapDemo.java Sun Nov 6 21:15:08 2011
@@ -46,23 +46,23 @@ import org.apache.catalina.tribes.Member
import org.apache.catalina.tribes.tipis.LazyReplicatedMap;
/**
- * Example of how the lazy replicated map works, also shows how the BackupManager
+ * Example of how the lazy replicated map works, also shows how the BackupManager
* works in a Tomcat cluster
* @author fhanik
* @version 1.1
*/
public class MapDemo implements ChannelListener, MembershipListener{
-
+
/**
* The Map containing the replicated data
*/
protected LazyReplicatedMap map;
-
+
/**
* Table to be displayed in Swing
*/
protected SimpleTableDemo table;
-
+
/**
* Constructs a map demo object.
* @param channel - the Tribes channel object to be used for communication
@@ -80,10 +80,10 @@ public class MapDemo implements ChannelL
//initialize the map by receiving a fake message
this.messageReceived(null,null);
}
-
+
/**
* Decides if the messageReceived should be invoked
- * will always return false since we rely on the
+ * will always return false since we rely on the
* lazy map to do all the messaging for us
*/
@Override
@@ -92,7 +92,7 @@ public class MapDemo implements ChannelL
table.dataModel.getValueAt(-1,-1);
return false;
}
-
+
/**
* Invoked if accept returns true.
* No op for now
@@ -103,7 +103,7 @@ public class MapDemo implements ChannelL
public void messageReceived(Serializable msg, Member source) {
// NOOP
}
-
+
/**
* Invoked when a member is added to the group
*/
@@ -111,7 +111,7 @@ public class MapDemo implements ChannelL
public void memberAdded(Member member) {
// NOOP
}
-
+
/**
* Invoked when a member leaves the group
*/
@@ -120,13 +120,13 @@ public class MapDemo implements ChannelL
//just refresh the table model
table.dataModel.getValueAt(-1,-1);
}
-
+
/**
* Prints usage
*/
public static void usage() {
System.out.println("Tribes MapDemo.");
- System.out.println("Usage:\n\t" +
+ System.out.println("Usage:\n\t" +
"java MapDemo [channel options] mapName\n\t" +
"\tChannel options:" +
ChannelCreator.usage());
@@ -153,7 +153,7 @@ public class MapDemo implements ChannelL
Runtime.getRuntime().addShutdownHook(new Shutdown(channel));
//create a map demo object
new MapDemo(channel,mapName);
-
+
//put the main thread to sleep until we are done
System.out.println("System test complete, time to start="+(System.currentTimeMillis()-start)+" ms. Sleeping to let threads finish.");
Thread.sleep(60 * 1000 * 60);
@@ -165,12 +165,12 @@ public class MapDemo implements ChannelL
public static class Shutdown extends Thread {
//the channel running in this demo
ManagedChannel channel = null;
-
+
public Shutdown(ManagedChannel channel) {
this.channel = channel;
}
-
+
@Override
public void run() {
System.out.println("Shutting down...");
@@ -211,12 +211,12 @@ public class MapDemo implements ChannelL
private static final long serialVersionUID = 1L;
private static int WIDTH = 550;
-
+
private LazyReplicatedMap map;
private boolean DEBUG = false;
AbstractTableModel dataModel = new AbstractTableModel() {
-
-
+
+
private static final long serialVersionUID = 1L;
String[] columnNames = {
"Rownum",
@@ -230,10 +230,10 @@ public class MapDemo implements ChannelL
@Override
public int getColumnCount() { return columnNames.length; }
-
+
@Override
public int getRowCount() {return map.sizeFull() +1; }
-
+
public StringBuilder getMemberNames(Member[] members){
StringBuilder buf = new StringBuilder();
if ( members!=null ) {
@@ -244,7 +244,7 @@ public class MapDemo implements ChannelL
}
return buf;
}
-
+
@Override
public Object getValueAt(int row, int col) {
if ( row==-1 ) {
@@ -266,25 +266,25 @@ public class MapDemo implements ChannelL
case 7: return Boolean.valueOf(entry.isBackup());
default: return "";
}
-
+
}
-
+
public void update() {
fireTableDataChanged();
}
};
-
+
JTextField txtAddKey = new JTextField(20);
JTextField txtAddValue = new JTextField(20);
JTextField txtRemoveKey = new JTextField(20);
JTextField txtChangeKey = new JTextField(20);
JTextField txtChangeValue = new JTextField(20);
-
+
JTable table = null;
public SimpleTableDemo(LazyReplicatedMap map) {
super();
this.map = map;
-
+
this.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
//final JTable table = new JTable(data, columnNames);
@@ -305,7 +305,7 @@ public class MapDemo implements ChannelL
}
});
}
-
+
//setLayout(new GridLayout(5, 0));
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
@@ -314,7 +314,7 @@ public class MapDemo implements ChannelL
//Add the scroll pane to this panel.
add(scrollPane);
-
+
//create a add value button
JPanel addpanel = new JPanel();
addpanel.setPreferredSize(new Dimension(WIDTH,30));
@@ -323,7 +323,7 @@ public class MapDemo implements ChannelL
addpanel.add(txtAddValue);
addpanel.setMaximumSize(new Dimension(WIDTH,30));
add(addpanel);
-
+
//create a remove value button
JPanel removepanel = new JPanel( );
removepanel.setPreferredSize(new Dimension(WIDTH,30));
@@ -353,14 +353,14 @@ public class MapDemo implements ChannelL
}
-
+
public JButton createButton(String text, String command) {
JButton button = new JButton(text);
button.setActionCommand(command);
button.addActionListener(this);
return button;
}
-
+
@Override
public void actionPerformed(ActionEvent e) {
System.out.println(e.getActionCommand());
@@ -408,7 +408,7 @@ public class MapDemo implements ChannelL
};
t.start();
}
-
+
if ( "replicate".equals(e.getActionCommand()) ) {
System.out.println("Replicating out to the other nodes.");
map.replicate(true);
@@ -432,10 +432,10 @@ public class MapDemo implements ChannelL
end = Integer.MAX_VALUE;
}
}
-
+
char[] buffer = new char[count];
int gap = end - start;
-
+
while (count-- != 0) {
char ch;
if (chars == null) {
@@ -445,7 +445,7 @@ public class MapDemo implements ChannelL
}
if ((letters && Character.isLetter(ch))
|| (numbers && Character.isDigit(ch))
- || (!letters && !numbers))
+ || (!letters && !numbers))
{
if(ch >= 56320 && ch <= 57343) {
if(count == 0) {
@@ -520,9 +520,9 @@ public class MapDemo implements ChannelL
return newContentPane;
}
}
-
+
static class ColorRenderer extends DefaultTableCellRenderer {
-
+
private static final long serialVersionUID = 1L;
public ColorRenderer() {
@@ -548,8 +548,8 @@ public class MapDemo implements ChannelL
}
return cell;
}
-
-
+
+
}
Modified: tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/MembersWithProperties.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/MembersWithProperties.java?rev=1198560&r1=1198559&r2=1198560&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/MembersWithProperties.java (original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/MembersWithProperties.java Sun Nov 6 21:15:08 2011
@@ -36,13 +36,13 @@ public class MembersWithProperties imple
ManagedChannel mchannel = (ManagedChannel)channel;
mchannel.getMembershipService().setPayload(getPayload(props));
}
-
+
byte[] getPayload(Properties props) throws IOException {
ByteArrayOutputStream bout = new ByteArrayOutputStream();
props.store(bout,"");
return bout.toByteArray();
}
-
+
Properties getProperties(byte[] payload) throws IOException {
ByteArrayInputStream bin = new ByteArrayInputStream(payload);
Properties props = new Properties();
@@ -60,7 +60,7 @@ public class MembersWithProperties imple
x.printStackTrace();
}
}
-
+
@Override
public void memberDisappeared(Member member) {
try {
Modified: tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelOptionFlag.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelOptionFlag.java?rev=1198560&r1=1198559&r2=1198560&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelOptionFlag.java (original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelOptionFlag.java Sun Nov 6 21:15:08 2011
@@ -28,12 +28,12 @@ import org.apache.catalina.tribes.Channe
import org.apache.catalina.tribes.ChannelInterceptor;
/**
- * <p>Title: </p>
- *
- * <p>Description: </p>
- *
+ * <p>Title: </p>
+ *
+ * <p>Description: </p>
+ *
* <p>Company: </p>
- *
+ *
* @author not attributable
* @version 1.0
*/
@@ -89,7 +89,7 @@ public class TestGroupChannelOptionFlag
}
assertFalse(error);
}
-
+
public static class TestInterceptor extends ChannelInterceptorBase {
// Just use base class
}
Modified: tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelSenderConnections.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelSenderConnections.java?rev=1198560&r1=1198559&r2=1198560&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelSenderConnections.java (original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelSenderConnections.java Sun Nov 6 21:15:08 2011
@@ -98,7 +98,7 @@ public class TestGroupChannelSenderConne
}
}
-
+
public static class TestMsg implements Serializable {
private static final long serialVersionUID = 1L;
static Random r = new Random();
@@ -119,13 +119,13 @@ public class TestGroupChannelSenderConne
public TestMsgListener(String name) {
this.name = name;
}
-
+
@Override
public void messageReceived(Serializable msg, Member sender) {
System.out.println("["+name+"] Received message:"+msg+" from " + sender.getName());
}
-
+
@Override
public boolean accept(Serializable msg, Member sender) {
return true;
Modified: tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelStartStop.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelStartStop.java?rev=1198560&r1=1198559&r2=1198560&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelStartStop.java (original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelStartStop.java Sun Nov 6 21:15:08 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You 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.
Modified: tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/group/interceptors/TestOrderInterceptor.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/group/interceptors/TestOrderInterceptor.java?rev=1198560&r1=1198559&r2=1198560&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/group/interceptors/TestOrderInterceptor.java (original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/group/interceptors/TestOrderInterceptor.java Sun Nov 6 21:15:08 2011
@@ -56,7 +56,7 @@ public class TestOrderInterceptor {
threads = new Thread[channelCount];
for ( int i=0; i<channelCount; i++ ) {
channels[i] = new GroupChannel();
-
+
orderitcs[i] = new OrderInterceptor();
mangleitcs[i] = new MangleOrderInterceptor();
orderitcs[i].setExpire(Long.MAX_VALUE);
@@ -125,7 +125,7 @@ public class TestOrderInterceptor {
threads[i].join();
}
if (!exceptionQueue.isEmpty()) {
- fail("Exception while sending in threads: "
+ fail("Exception while sending in threads: "
+ exceptionQueue.remove().toString());
}
Thread.sleep(5000);
@@ -145,7 +145,7 @@ public class TestOrderInterceptor {
public static void main(String[] args) {
org.junit.runner.JUnitCore.main(TestOrderInterceptor.class.getName());
}
-
+
public static class TestListener implements ChannelListener {
int id = -1;
public TestListener(int id) {
@@ -169,7 +169,7 @@ public class TestOrderInterceptor {
return (msg instanceof Integer);
}
}
-
+
public static class MangleOrderInterceptor extends ChannelInterceptorBase {
ChannelMessage hold = null;
Member[] dest = null;
Modified: tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/group/interceptors/TestTcpFailureDetector.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/group/interceptors/TestTcpFailureDetector.java?rev=1198560&r1=1198559&r2=1198560&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/group/interceptors/TestTcpFailureDetector.java (original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/group/interceptors/TestTcpFailureDetector.java Sun Nov 6 21:15:08 2011
@@ -34,12 +34,12 @@ import org.apache.catalina.tribes.Member
import org.apache.catalina.tribes.group.GroupChannel;
/**
- * <p>Title: </p>
- *
- * <p>Description: </p>
- *
+ * <p>Title: </p>
+ *
+ * <p>Description: </p>
+ *
* <p>Company: </p>
- *
+ *
* @author not attributable
* @version 1.0
*/
@@ -66,7 +66,7 @@ public class TestTcpFailureDetector {
channel1.addMembershipListener(mbrlist1);
channel2.addMembershipListener(mbrlist2);
}
-
+
public void clear() {
mbrlist1.members.clear();
mbrlist2.members.clear();
@@ -139,7 +139,7 @@ public class TestTcpFailureDetector {
try { channel2.stop(Channel.DEFAULT);}catch (Exception ignore){ /* Ignore */ }
channel2 = null;
}
-
+
public static class TestMbrListener implements MembershipListener {
public String name = null;
public TestMbrListener(String name) {
@@ -157,7 +157,7 @@ public class TestTcpFailureDetector {
}
}
}
-
+
@Override
public void memberDisappeared(Member member) {
if ( members.contains(member) ) {
@@ -169,7 +169,7 @@ public class TestTcpFailureDetector {
}
}
}
-
+
}
}
Modified: tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/membership/TestMemberImplSerialization.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/membership/TestMemberImplSerialization.java?rev=1198560&r1=1198559&r2=1198560&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/membership/TestMemberImplSerialization.java (original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/membership/TestMemberImplSerialization.java Sun Nov 6 21:15:08 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You 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.
@@ -75,7 +75,7 @@ public class TestMemberImplSerialization
MemberImpl a1 = MemberImpl.getMember(md1);
MemberImpl a2 = MemberImpl.getMember(md2);
-
+
assertTrue(a1.getUdpPort()==a2.getUdpPort());
assertTrue(a1.getUdpPort()==udpPort);
}
@@ -94,7 +94,7 @@ public class TestMemberImplSerialization
assertFalse(Arrays.equals(md1,mda1));
ma1 = MemberImpl.getMember(mda1);
assertTrue(compareMembers(p1,ma1));
-
+
md1 = m.getData(true,true);
Thread.sleep(50);
mda1 = m.getData(true,true);
@@ -102,10 +102,10 @@ public class TestMemberImplSerialization
MemberImpl a2 = MemberImpl.getMember(mda1);
assertTrue(a1.equals(a2));
assertFalse(Arrays.equals(md1,mda1));
-
-
+
+
}
-
+
public boolean compareMembers(MemberImpl impl1, MemberImpl impl2) {
boolean result = true;
result = result && Arrays.equals(impl1.getHost(),impl2.getHost());
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org