public static void start(String cfgPath) { if (!started.compareAndSet(false, true)) { return; } try { MonitorCfg cfg = MonitorCfgLoader.load(cfgPath); agent.setRegistryAddress(cfg.getRegistryAddress()); agent.setClusterName(cfg.getClusterName()); if (StringUtils.isNotEmpty(cfg.getBindIp())) { agent.setBindIp(cfg.getBindIp()); } if (StringUtils.isNotEmpty(cfg.getIdentity())) { agent.setIdentity(cfg.getIdentity()); } for (Map.Entry<String, String> config : cfg.getConfigs().entrySet()) { agent.addConfig(config.getKey(), config.getValue()); } agent.start(); Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { @Override public void run() { agent.stop(); } })); } catch (CfgException e) { System.err.println("Monitor Startup Error: " + e.getMessage()); e.printStackTrace(); } }
public static void start(String cfgPath) { if (!started.compareAndSet(false, true)) { return; } try { MonitorCfg cfg = MonitorCfgLoader.load(cfgPath); agent.setRegistryAddress(cfg.getRegistryAddress()); agent.setClusterName(cfg.getClusterName()); if (StringUtils.isNotEmpty(cfg.getBindIp())) { agent.setBindIp(cfg.getBindIp()); } if (StringUtils.isNotEmpty(cfg.getIdentity())) { agent.setIdentity(cfg.getIdentity()); } for (Map.Entry<String, String> config : cfg.getConfigs().entrySet()) { agent.addConfig(config.getKey(), config.getValue()); } agent.start(); Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { @Override public void run() { agent.stop(); } })); } catch (CfgException e) { System.err.println("Monitor Startup Error: " + e.getMessage()); e.printStackTrace(); } }
@Override public void afterPropertiesSet() throws Exception { properties.checkProperties(); agent = new MonitorAgent(); agent.setRegistryAddress(properties.getRegistryAddress()); if (StringUtils.isNotEmpty(properties.getClusterName())) { agent.setClusterName(properties.getClusterName()); } if (StringUtils.isNotEmpty(properties.getIdentity())) { agent.setIdentity(properties.getIdentity()); } if (StringUtils.isNotEmpty(properties.getBindIp())) { agent.setBindIp(properties.getBindIp()); } if (CollectionUtils.isNotEmpty(properties.getConfigs())) { for (Map.Entry<String, String> entry : properties.getConfigs().entrySet()) { agent.addConfig(entry.getKey(), entry.getValue()); } } agent.start(); }
@Override public void afterPropertiesSet() throws Exception { properties.checkProperties(); agent = new MonitorAgent(); agent.setRegistryAddress(properties.getRegistryAddress()); if (StringUtils.isNotEmpty(properties.getClusterName())) { agent.setClusterName(properties.getClusterName()); } if (StringUtils.isNotEmpty(properties.getIdentity())) { agent.setIdentity(properties.getIdentity()); } if (StringUtils.isNotEmpty(properties.getBindIp())) { agent.setBindIp(properties.getBindIp()); } if (CollectionUtils.isNotEmpty(properties.getConfigs())) { for (Map.Entry<String, String> entry : properties.getConfigs().entrySet()) { agent.addConfig(entry.getKey(), entry.getValue()); } } agent.start(); }
public static void start(String cfgPath) { if (!started.compareAndSet(false, true)) { return; } try { MonitorCfg cfg = MonitorCfgLoader.load(cfgPath); agent.setRegistryAddress(cfg.getRegistryAddress()); agent.setClusterName(cfg.getClusterName()); if (StringUtils.isNotEmpty(cfg.getBindIp())) { agent.setBindIp(cfg.getBindIp()); } if (StringUtils.isNotEmpty(cfg.getIdentity())) { agent.setIdentity(cfg.getIdentity()); } for (Map.Entry<String, String> config : cfg.getConfigs().entrySet()) { agent.addConfig(config.getKey(), config.getValue()); } agent.start(); Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { @Override public void run() { agent.stop(); } })); } catch (CfgException e) { System.err.println("Monitor Startup Error: " + e.getMessage()); e.printStackTrace(); } }
@Override public void afterPropertiesSet() throws Exception { properties.checkProperties(); agent = new MonitorAgent(); agent.setRegistryAddress(properties.getRegistryAddress()); if (StringUtils.isNotEmpty(properties.getClusterName())) { agent.setClusterName(properties.getClusterName()); } if (StringUtils.isNotEmpty(properties.getIdentity())) { agent.setIdentity(properties.getIdentity()); } if (StringUtils.isNotEmpty(properties.getBindIp())) { agent.setBindIp(properties.getBindIp()); } if (CollectionUtils.isNotEmpty(properties.getConfigs())) { for (Map.Entry<String, String> entry : properties.getConfigs().entrySet()) { agent.addConfig(entry.getKey(), entry.getValue()); } } agent.start(); }