1 5 package com.tctest.runner; 6 7 import com.tc.object.config.DSOClientConfigHelper; 8 import com.tc.objectserver.control.ServerControl; 9 import com.tc.simulator.app.ApplicationConfig; 10 import com.tc.simulator.app.ApplicationConfigBuilder; 11 import com.tc.simulator.app.GlobalIdGenerator; 12 13 import java.util.HashMap ; 14 import java.util.Map ; 15 16 public class TransparentAppConfig implements ApplicationConfig, ApplicationConfigBuilder { 17 18 private final String applicationClassname; 19 private final GlobalIdGenerator idGenerator; 20 private final Map extraConfigAttributes = new HashMap (); 21 private final ServerControl serverControl; 22 private int intensity; 24 private int clientCount; 25 private int applicationInstancePerClientCount = 1; 26 27 public TransparentAppConfig(String applicationClassname, GlobalIdGenerator idGenerator, int clientCount, int intensity, ServerControl serverControl) { 28 this.applicationClassname = applicationClassname; 29 this.idGenerator = idGenerator; 30 if (clientCount < 1) throw new AssertionError ("Client count must be greater than 0"); 31 this.clientCount = clientCount; 32 this.intensity = intensity; 33 this.serverControl = serverControl; 34 } 35 36 public void setAttribute(String key, String value) { 37 extraConfigAttributes.put(key, value); 38 } 39 40 public String getAttribute(String key) { 41 return (String ) extraConfigAttributes.get(key); 42 } 43 44 public int nextGlobalId() { 45 return (int) idGenerator.nextId(); 46 } 47 48 public int getGlobalParticipantCount() { 49 return this.clientCount * this.applicationInstancePerClientCount; 50 } 51 52 public TransparentAppConfig setApplicationInstancePerClientCount(int applicationInstanceCount) { 53 this.applicationInstancePerClientCount = applicationInstanceCount; 54 return this; 55 } 56 57 public int getApplicationInstancePerClientCount() { 58 return this.applicationInstancePerClientCount; 59 } 60 61 public int getClientCount() { 62 return this.clientCount; 63 } 64 65 public TransparentAppConfig setClientCount(int i) { 66 this.clientCount = i; 67 return this; 68 } 69 70 public int getIntensity() { 71 return this.intensity; 72 } 73 74 public TransparentAppConfig setIntensity(int i) { 75 this.intensity = i; 76 return this; 77 } 78 79 public String getApplicationClassname() { 80 return this.applicationClassname; 81 } 82 83 85 public void visitClassLoaderConfig(DSOClientConfigHelper config) { 86 return; 87 } 88 89 public ApplicationConfig newApplicationConfig() { 90 return this; 91 } 92 93 public ApplicationConfig copy() { 94 throw new AssertionError (); 95 } 96 97 public ServerControl getServerControl() { 98 return serverControl; 99 } 100 101 } 102 | Popular Tags |