1 7 package org.jboss.remoting.performance; 8 9 import org.apache.log4j.Level; 10 import org.jboss.remoting.ServerInvocationHandler; 11 import org.jboss.remoting.ShutdownListener; 12 import org.jboss.remoting.transport.socket.InvokerServerTest; 13 14 18 public class PerformanceInvokerServer extends InvokerServerTest implements ShutdownListener 19 { 20 public boolean timeToShutdown = false; 21 22 private final Object waitObj = new Object (); 23 24 25 public PerformanceInvokerServer(int instances) 26 { 27 super(instances); 28 } 29 30 public PerformanceInvokerServer(String name) 31 { 32 super(name); 33 } 34 35 41 public void shutdown() throws Exception 42 { 43 synchronized(waitObj) 44 { 45 try 46 { 47 waitObj.wait(10 * 1000); } 49 catch(InterruptedException e) 50 { 51 System.out.println("Got interrupted exception."); 52 } 53 } 54 super.shutdown(); 55 } 56 57 public PerformanceInvokerServer(String transport, int port) 58 { 59 super(transport, port); 60 } 61 62 public PerformanceInvokerServer(String transport, int port, int instances) 63 { 64 super(transport, port, instances); 65 } 66 67 protected ServerInvocationHandler getServerInvocationHandler() 68 { 69 return new TestServerInvocationHandler(this); 70 } 71 72 protected String getSubsystem() 73 { 74 return "test"; 75 } 76 77 public static void main(String [] args) 78 { 79 org.apache.log4j.BasicConfigurator.configure(); 80 org.apache.log4j.Category.getRoot().setLevel(Level.INFO); 81 org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.INFO); 82 org.apache.log4j.Category.getInstance("org.jboss.remoting.performance").setLevel(Level.DEBUG); 84 org.apache.log4j.Category.getInstance("test").setLevel(Level.DEBUG); 85 86 PerformanceInvokerServer server = null; 87 if(args.length == 1) 88 { 89 int instances = Integer.parseInt(args[0]); 90 server = new PerformanceInvokerServer(instances); 91 } 92 else if(args.length == 2) 93 { 94 String transport = args[0]; 95 int port = Integer.parseInt(args[1]); 96 server = new PerformanceInvokerServer(transport, port); 97 } 98 else if(args.length == 3) 99 { 100 String transport = args[0]; 101 int port = Integer.parseInt(args[1]); 102 int instances = Integer.parseInt(args[2]); 103 server = new PerformanceInvokerServer(transport, port, instances); 104 } 105 else 106 { 107 server = new PerformanceInvokerServer(InvokerServerTest.class.getName()); 108 System.out.println("Using default transport (" + server.getTransport() + 109 ") and default port (" + server.getPort() + ") and " + 110 "default number of instances (" + server.getNumberOfInstances() + ")" + 111 "\nCan enter transport, port, and instances via command line."); 112 } 113 114 try 115 { 116 server.serverTest(); 117 } 118 catch(Exception e) 119 { 120 e.printStackTrace(); 121 System.exit(1); 122 } 123 System.exit(0); 124 } 125 126 public void shutdownTest() 127 throws Exception 128 { 129 synchronized(waitObj) 130 { 131 waitObj.notify(); 132 } 133 } 134 135 136 } 137 | Popular Tags |