use of org.apache.asterix.event.model.AsterixRuntimeState in project asterixdb by apache.
the class StartConfig method execCommand.
@Override
protected void execCommand() throws Exception {
InstallerDriver.initConfig(true);
String asterixInstanceName = ((StartConfig) config).name;
AsterixInstance instance = AsterixEventServiceUtil.validateAsterixInstanceExists(asterixInstanceName, State.INACTIVE);
AsterixEventServiceUtil.createAsterixZip(instance);
AsterixEventServiceClient client = AsterixEventService.getAsterixEventServiceClient(instance.getCluster());
Patterns asterixBinaryTransferPattern = PatternCreator.INSTANCE.getAsterixBinaryTransferPattern(asterixInstanceName, instance.getCluster());
client.submit(asterixBinaryTransferPattern);
// Start the watcher
ClusterStateWatcher stateWatcher = ServiceProvider.INSTANCE.getLookupService().startWatchingClusterState(asterixInstanceName);
AsterixEventServiceUtil.createClusterProperties(instance.getCluster(), instance.getAsterixConfiguration());
Patterns patterns = PatternCreator.INSTANCE.getStartAsterixPattern(asterixInstanceName, instance.getCluster(), false);
client.submit(patterns);
// Check the cluster state
ClusterState clusterState = stateWatcher.waitForClusterStart();
if (clusterState != ClusterState.ACTIVE) {
throw new Exception("CC failed to start");
}
AsterixEventServiceUtil.deleteDirectory(InstallerDriver.getManagixHome() + File.separator + InstallerDriver.ASTERIX_DIR + File.separator + asterixInstanceName);
AsterixRuntimeState runtimeState = VerificationUtil.getAsterixRuntimeState(instance);
VerificationUtil.updateInstanceWithRuntimeDescription(instance, runtimeState, true);
LOGGER.info(instance.getDescription(false));
ServiceProvider.INSTANCE.getLookupService().updateAsterixInstance(instance);
}
use of org.apache.asterix.event.model.AsterixRuntimeState in project asterixdb by apache.
the class AsterixLifecycleIT method test_2_StartActiveInstance.
@Test
public void test_2_StartActiveInstance() throws Exception {
try {
LOGGER.info("Starting test: test_2_StartActiveInstance");
AsterixInstallerIntegrationUtil.transformIntoRequiredState(State.INACTIVE);
String command = "start -n " + AsterixInstallerIntegrationUtil.ASTERIX_INSTANCE_NAME;
cmdHandler.processCommand(command.split(" "));
AsterixInstance instance = ServiceProvider.INSTANCE.getLookupService().getAsterixInstance(AsterixInstallerIntegrationUtil.ASTERIX_INSTANCE_NAME);
AsterixRuntimeState state = VerificationUtil.getAsterixRuntimeState(instance);
assert (state.getFailedNCs().size() == 0 && state.isCcRunning());
LOGGER.info("PASSED: test_2_StartActiveInstance");
} catch (Exception e) {
throw new Exception("Test configure installer " + "\" FAILED!", e);
}
}
use of org.apache.asterix.event.model.AsterixRuntimeState in project asterixdb by apache.
the class AsterixLifecycleIT method test_1_StopActiveInstance.
@Test
public void test_1_StopActiveInstance() throws Exception {
try {
LOGGER.info("Starting test: test_1_StopActiveInstance");
AsterixInstallerIntegrationUtil.transformIntoRequiredState(State.ACTIVE);
String command = "stop -n " + AsterixInstallerIntegrationUtil.ASTERIX_INSTANCE_NAME;
cmdHandler.processCommand(command.split(" "));
Thread.sleep(4000);
AsterixInstance instance = ServiceProvider.INSTANCE.getLookupService().getAsterixInstance(AsterixInstallerIntegrationUtil.ASTERIX_INSTANCE_NAME);
AsterixRuntimeState state = VerificationUtil.getAsterixRuntimeState(instance);
assert (state.getFailedNCs().size() == NUM_NC && !state.isCcRunning());
LOGGER.info("PASSED: test_1_StopActiveInstance");
} catch (Exception e) {
throw new Exception("Test configure installer " + "\" FAILED!", e);
}
}
use of org.apache.asterix.event.model.AsterixRuntimeState in project asterixdb by apache.
the class VerificationUtil method getAsterixRuntimeState.
public static AsterixRuntimeState getAsterixRuntimeState(AsterixInstance instance) throws Exception {
Cluster cluster = instance.getCluster();
List<String> args = new ArrayList<String>();
args.add(instance.getName());
args.add(instance.getCluster().getMasterNode().getClusterIp());
for (Node node : cluster.getNode()) {
args.add(node.getClusterIp());
args.add(instance.getName() + "_" + node.getId());
}
Thread.sleep(2000);
String output = AsterixEventServiceUtil.executeLocalScript(VERIFY_SCRIPT_PATH, args);
boolean ccRunning = true;
List<String> failedNCs = new ArrayList<String>();
String[] infoFields;
List<ProcessInfo> processes = new ArrayList<ProcessInfo>();
for (String line : output.split("\n")) {
String nodeid = null;
infoFields = line.split(":");
try {
int pid = Integer.parseInt(infoFields[3]);
if (infoFields[0].equals("NC")) {
nodeid = infoFields[2].split("_")[1];
} else {
nodeid = instance.getCluster().getMasterNode().getId();
}
processes.add(new ProcessInfo(infoFields[0], infoFields[1], nodeid, pid));
} catch (Exception e) {
if (infoFields[0].equalsIgnoreCase("CC")) {
ccRunning = false;
} else {
failedNCs.add(infoFields[1]);
}
}
}
return new AsterixRuntimeState(processes, failedNCs, ccRunning);
}
use of org.apache.asterix.event.model.AsterixRuntimeState in project asterixdb by apache.
the class CreateConfig method execCommand.
@Override
protected void execCommand() throws Exception {
InstallerDriver.initConfig(true);
ValidateCommand validateCommand = new ValidateCommand();
boolean valid = validateCommand.validateCluster(((CreateConfig) config).clusterPath);
if (!valid) {
throw new Exception("Cannot create an Asterix instance.");
}
asterixInstanceName = ((CreateConfig) config).name;
AsterixEventServiceUtil.validateAsterixInstanceNotExists(asterixInstanceName);
CreateConfig createConfig = (CreateConfig) config;
cluster = EventUtil.getCluster(createConfig.clusterPath);
cluster.setInstanceName(asterixInstanceName);
asterixConfiguration = InstallerUtil.getAsterixConfiguration(createConfig.asterixConfPath);
AsterixInstance asterixInstance = AsterixEventServiceUtil.createAsterixInstance(asterixInstanceName, cluster, asterixConfiguration);
AsterixEventServiceUtil.evaluateConflictWithOtherInstances(asterixInstance);
AsterixEventServiceUtil.createAsterixZip(asterixInstance);
AsterixEventServiceUtil.createClusterProperties(cluster, asterixConfiguration);
AsterixEventServiceClient eventrixClient = AsterixEventService.getAsterixEventServiceClient(cluster, true, false);
// Store the cluster initially in Zookeeper and start watching
ServiceProvider.INSTANCE.getLookupService().writeAsterixInstance(asterixInstance);
ClusterStateWatcher stateWatcher = ServiceProvider.INSTANCE.getLookupService().startWatchingClusterState(asterixInstanceName);
Patterns asterixBinarytrasnferPattern = PatternCreator.INSTANCE.getAsterixBinaryTransferPattern(asterixInstanceName, cluster);
eventrixClient.submit(asterixBinarytrasnferPattern);
Patterns patterns = PatternCreator.INSTANCE.getStartAsterixPattern(asterixInstanceName, cluster, true);
eventrixClient.submit(patterns);
// Check the cluster state
ClusterState clusterState = stateWatcher.waitForClusterStart();
if (clusterState != ClusterState.ACTIVE) {
throw new Exception("CC failed to start");
}
AsterixRuntimeState runtimeState = VerificationUtil.getAsterixRuntimeState(asterixInstance);
VerificationUtil.updateInstanceWithRuntimeDescription(asterixInstance, runtimeState, true);
ServiceProvider.INSTANCE.getLookupService().updateAsterixInstance(asterixInstance);
AsterixEventServiceUtil.deleteDirectory(InstallerDriver.getManagixHome() + File.separator + InstallerDriver.ASTERIX_DIR + File.separator + asterixInstanceName);
LOGGER.info(asterixInstance.getDescription(false));
}
Aggregations