public static List<FakeInstance> addFakeDataInstancesToAutoJoinHelixCluster( String helixClusterName, String zkServer, int numInstances, int base) throws Exception { List<FakeInstance> ret = new ArrayList<FakeInstance>(); for (int i = base; i < numInstances + base; ++i) { final String instanceId = "Server_localhost_" + i; FakeInstance fakeInstance = new FakeInstance(helixClusterName, instanceId, zkServer); fakeInstance.start(); ret.add(fakeInstance); } return ret; }
public static void main(String[] args) throws Exception { // You can also specify your own instanceId // String instanceId = "testHelixMirrorMaker01"; String instanceId = "testHelixMirrorMaker-" + System.currentTimeMillis(); startDefault(instanceId); while (true) { Thread.sleep(10000); } } }
@Override public void run() { LOGGER.info("Running shutdown hook"); if (_fakeInstance != null) { try { _fakeInstance.stop(); } catch (Exception e) { LOGGER.error("Failed to Shutdown FakeInstance !!"); } } LOGGER.info("Shutdown completed !!"); } }
if (i % 2 == 0) { for (int k = 0; k < 10; ++k) { LOGGER.info("Trying to bring down: " + fakeInstances.get(i / 2).getInstanceId()); fakeInstances.get(i / 2).stop(); } else { for (int k = 0; k < 10; ++k) { LOGGER.info("Trying to bring up: " + fakeInstances.get(i / 2).getInstanceId()); fakeInstances.get(i / 2).start();
if (i % 2 == 0) { for (int k = 0; k < 10; ++k) { LOGGER.info("Trying to bring down: " + fakeInstances.get(i / 2).getInstanceId()); fakeInstances.get(i / 2).stop(); } else { for (int k = 0; k < 10; ++k) { LOGGER.info("Trying to bring up: " + fakeInstances.get(i / 2).getInstanceId()); fakeInstances.get(i / 2).start();
for (int i = 0; i < totalInstancesSize * 2; ++i) { if (i % 2 == 0) { LOGGER.info("Trying to bring down: " + fakeInstances.get(i / 2).getInstanceId()); fakeInstances.get(i / 2).stop(); totalInstancesSize--; } else { LOGGER.info("Trying to bring up: " + fakeInstances.get(i / 2).getInstanceId()); fakeInstances.get(i / 2).start(); totalInstancesSize++; LOGGER.info("Trying to bring down: " + fakeInstances.get(i).getInstanceId()); fakeInstances.get(i).stop(); totalInstancesSize--; Thread.sleep(5000); LOGGER.info("Trying to bring up: " + fakeInstances.get(i).getInstanceId()); fakeInstances.get(i).start(); totalInstancesSize++; Thread.sleep(5000);
public static FakeInstance startDefault(String instanceId) throws Exception { String zkPath = "localhost:2181"; String helixClusterName = "testMirrorMaker"; FakeInstance fakeInstance = new FakeInstance(helixClusterName, instanceId, zkPath); fakeInstance.start(); final ShutdownHook shutdownHook = new ShutdownHook(fakeInstance); Runtime.getRuntime().addShutdownHook(shutdownHook); return fakeInstance; }
@AfterTest public void shutdown() { LOGGER.info("Trying to shutdown"); for (FakeInstance fakeInstance : FAKE_INSTANCES) { try { LOGGER.info("Trying to shutdown: " + fakeInstance); fakeInstance.stop(); } catch (Exception e) { } } LOGGER.info("Trying to stop controller"); CONTROLLER_STARTER.stop(); LOGGER.info("Trying to stop zk"); kafkaBrokerTopicObserver.stop(); KafkaStarterUtils.stopServer(kafkaStarter); ZK_CLIENT.deleteRecursive("/" + HELIX_CLUSTER_NAME); ZK_CLIENT.close(); ZkStarter.stopLocalZkServer(); }
public static void main(String[] args) throws Exception { // You can also specify your own instanceId // String instanceId = "testHelixMirrorMaker01"; String instanceId = "testHelixMirrorMaker-" + System.currentTimeMillis(); startDefault(instanceId); while (true) { Thread.sleep(10000); } } }
for (int i = 0; i < totalInstancesSize * 2; ++i) { if (i % 2 == 0) { LOGGER.info("Trying to bring down: " + fakeInstances.get(i / 2).getInstanceId()); fakeInstances.get(i / 2).stop(); totalInstancesSize--; } else { LOGGER.info("Trying to bring up: " + fakeInstances.get(i / 2).getInstanceId()); fakeInstances.get(i / 2).start(); totalInstancesSize++; LOGGER.info("Trying to bring down: " + fakeInstances.get(i).getInstanceId()); fakeInstances.get(i).stop(); totalInstancesSize--; Thread.sleep(5000); LOGGER.info("Trying to bring up: " + fakeInstances.get(i).getInstanceId()); fakeInstances.get(i).start(); totalInstancesSize++; Thread.sleep(5000);
public static List<FakeInstance> addFakeDataInstancesToAutoJoinHelixCluster( String helixClusterName, String zkServer, int numInstances, int base) throws Exception { List<FakeInstance> ret = new ArrayList<FakeInstance>(); for (int i = base; i < numInstances + base; ++i) { final String instanceId = "Server_localhost_" + i; FakeInstance fakeInstance = new FakeInstance(helixClusterName, instanceId, zkServer); fakeInstance.start(); ret.add(fakeInstance); } return ret; }
@Override public void run() { LOGGER.info("Running shutdown hook"); if (_fakeInstance != null) { try { _fakeInstance.stop(); } catch (Exception e) { LOGGER.error("Failed to Shutdown FakeInstance !!"); } } LOGGER.info("Shutdown completed !!"); } }
for (int i = 0; i < totalInstancesSize * 2; ++i) { if (i % 2 == 0) { LOGGER.info("Trying to bring down: " + fakeInstances.get(i / 2).getInstanceId()); fakeInstances.get(i / 2).stop(); totalInstancesSize--; } else { LOGGER.info("Trying to bring up: " + fakeInstances.get(i / 2).getInstanceId()); fakeInstances.get(i / 2).start(); totalInstancesSize++; LOGGER.info("Trying to bring down: " + fakeInstances.get(i).getInstanceId()); fakeInstances.get(i).stop(); totalInstancesSize--; Thread.sleep(3000); LOGGER.info("Trying to bring up: " + fakeInstances.get(i).getInstanceId()); fakeInstances.get(i).start(); totalInstancesSize++; Thread.sleep(3000);
public static FakeInstance startDefault(String instanceId) throws Exception { String zkPath = "localhost:2181"; String helixClusterName = "testMirrorMaker"; FakeInstance fakeInstance = new FakeInstance(helixClusterName, instanceId, zkPath); fakeInstance.start(); final ShutdownHook shutdownHook = new ShutdownHook(fakeInstance); Runtime.getRuntime().addShutdownHook(shutdownHook); return fakeInstance; }
@AfterTest public void shutdown() { LOGGER.info("Trying to shutdown"); for (FakeInstance fakeInstance : FAKE_INSTANCES) { try { LOGGER.info("Trying to shutdown: " + fakeInstance); fakeInstance.stop(); } catch (Exception e) { } } LOGGER.info("Trying to stop controller"); CONTROLLER_STARTER.stop(); LOGGER.info("Trying to stop zk"); kafkaBrokerTopicObserver.stop(); KafkaStarterUtils.stopServer(kafkaStarter); ZK_CLIENT.deleteRecursive("/" + HELIX_CLUSTER_NAME); ZK_CLIENT.close(); ZkStarter.stopLocalZkServer(); }
for (int i = 0; i < totalInstancesSize * 2; ++i) { if (i % 2 == 0) { LOGGER.info("Trying to bring down: " + fakeInstances.get(i / 2).getInstanceId()); fakeInstances.get(i / 2).stop(); totalInstancesSize--; } else { LOGGER.info("Trying to bring up: " + fakeInstances.get(i / 2).getInstanceId()); fakeInstances.get(i / 2).start(); totalInstancesSize++; LOGGER.info("Trying to bring down: " + fakeInstances.get(i).getInstanceId()); fakeInstances.get(i).stop(); totalInstancesSize--; Thread.sleep(2000); LOGGER.info("Trying to bring up: " + fakeInstances.get(i).getInstanceId()); fakeInstances.get(i).start(); totalInstancesSize++; Thread.sleep(2000);
for (int i = 0; i < totalInstancesSize * 2; ++i) { if (i % 2 == 0) { LOGGER.info("Trying to bring down: " + fakeInstances.get(i / 2).getInstanceId()); fakeInstances.get(i / 2).stop(); totalInstancesSize--; } else { LOGGER.info("Trying to bring up: " + fakeInstances.get(i / 2).getInstanceId()); fakeInstances.get(i / 2).start(); totalInstancesSize++; LOGGER.info("Trying to bring down: " + fakeInstances.get(i).getInstanceId()); fakeInstances.get(i).stop(); totalInstancesSize--; Thread.sleep(6000); LOGGER.info("Trying to bring up: " + fakeInstances.get(i).getInstanceId()); fakeInstances.get(i).start(); totalInstancesSize++; Thread.sleep(6000);
if (i % 2 == 0) { for (int k = 0; k < 10; ++k) { LOGGER.info("Trying to bring down: " + fakeInstances.get(i / 2).getInstanceId()); fakeInstances.get(i / 2).stop(); } else { for (int k = 0; k < 10; ++k) { LOGGER.info("Trying to bring up: " + fakeInstances.get(i / 2).getInstanceId()); fakeInstances.get(i / 2).start();
for (int i = 0; i < totalInstancesSize * 2; ++i) { if (i % 2 == 0) { LOGGER.info("Trying to bring down: " + fakeInstances.get(i / 2).getInstanceId()); fakeInstances.get(i / 2).stop(); totalInstancesSize--; } else { LOGGER.info("Trying to bring up: " + fakeInstances.get(i / 2).getInstanceId()); fakeInstances.get(i / 2).start(); totalInstancesSize++; LOGGER.info("Trying to bring down: " + fakeInstances.get(i).getInstanceId()); fakeInstances.get(i).stop(); totalInstancesSize--; Thread.sleep(6000); LOGGER.info("Trying to bring up: " + fakeInstances.get(i).getInstanceId()); fakeInstances.get(i).start(); totalInstancesSize++; Thread.sleep(6000);