*/
public class CartridgeAgentServiceComponent {
private static final Log log = LogFactory.getLog(CartridgeAgentServiceComponent.class);
protected void activate(ComponentContext ctx) {
RegistrantHealthChecker healthChecker;
ConfigurationContext configurationContext = DataHolder.getServerConfigContext();
FileInputStream confFileIPStream = null;
try {
long start = System.currentTimeMillis();
log.info("Starting WSO2 Cartridge Agent...");
Properties conf = new Properties();
confFileIPStream = new FileInputStream(CarbonUtils.getCarbonConfigDirPath() +
File.separator + "agent.properties");
conf.load(confFileIPStream);
for (String name : conf.stringPropertyNames()) {
String value = conf.getProperty(name);
System.setProperty(name, value);
}
RegistrantDatabase registrantDatabase = new RegistrantDatabase();
// AxisServer axisServer = new AxisServer();
// ConfigurationContext configurationContext = axisServer.getConfigurationContext();
ClusteringClient clusteringClient = new ClusteringClient(registrantDatabase);
configurationContext.setProperty(CartridgeAgentConstants.CLUSTERING_CLIENT, clusteringClient);
String healthCheckInterval = conf.getProperty("registrant.heathCheckInterval");
String threadPoolSize = conf.getProperty("registrant.healthCheckThreadPoolSize");
int healthCheckIntervalInt =
(healthCheckInterval == null) ? 2000 : Integer.parseInt(healthCheckInterval);
int threadPoolSizeInt =
(threadPoolSize == null) ? 10 : Integer.parseInt(healthCheckInterval);
log.info("Registrant health check interval: " + healthCheckIntervalInt + "s");
healthChecker = new RegistrantHealthChecker(registrantDatabase,
clusteringClient,
configurationContext,
healthCheckIntervalInt,
threadPoolSizeInt
);
clusteringClient.init(conf,
configurationContext,
new ELBMembershipListener(clusteringClient,
configurationContext,
registrantDatabase,
healthChecker));
healthChecker.startAll();
DataHolder.setHealthChecker(healthChecker);
Runtime.getRuntime().addShutdownHook(new Thread(){
@Override