1 5 package com.tc.test.server.dsoserver; 6 7 import com.tc.config.Directories; 8 import com.tc.objectserver.control.ExtraProcessServerControl; 9 import com.tc.test.server.ServerParameters; 10 import com.tc.test.server.ServerResult; 11 12 import java.util.ArrayList ; 13 import java.util.List ; 14 15 18 public final class StandardDsoServer implements DsoServer { 19 20 private ExtraProcessServerControl dsoServer; 21 private static final String domain = "127.0.0.1"; 22 private static final List jvmArgs = new ArrayList (); 23 24 public ServerResult start(ServerParameters rawParams) throws Exception { 25 DsoServerParameters params = (DsoServerParameters) rawParams; 26 jvmArgs.add("-Xmx128m"); 27 jvmArgs.add("-verbose:gc"); 28 30 dsoServer = new ExtraProcessServerControl(new ExtraProcessServerControl.DebugParams(), domain, params.dsoPort(), 31 params.jmxPort(), params.configFile().toString(), params.workingDir(), 32 Directories.getInstallationRoot(), false, jvmArgs, ""); 33 dsoServer.writeOutputTo(params.outputFile()); 34 dsoServer.start(2 * 60 * 1000); 35 36 return new DsoServerResult(params.dsoPort(), this); 37 } 38 39 public void stop() throws Exception { 40 if (dsoServer != null) { 41 dsoServer.shutdown(); 42 dsoServer.waitFor(); 43 } else { 44 System.err.println("**** DSO server was not started so ignoring request to stop the server. ****"); 45 } 46 } 47 48 public void addJvmArgs(final List args) { 49 if (dsoServer != null && dsoServer.isRunning()) { throw new AssertionError ( 50 "Attempting to add jvm args after DSO server has been started."); } 51 if (args != null && !args.isEmpty()) { 52 jvmArgs.addAll(args); 53 } 54 } 55 56 public boolean isRunning() { 57 if (dsoServer == null || !dsoServer.isRunning()) { return false; } 58 return true; 59 } 60 } 61 | Popular Tags |