use of org.apache.asterix.event.model.AsterixInstance in project asterixdb by apache.
the class AsterixInstallerIntegrationUtil method transformIntoRequiredState.
public static void transformIntoRequiredState(AsterixInstance.State state) throws Exception {
AsterixInstance instance = ServiceProvider.INSTANCE.getLookupService().getAsterixInstance(ASTERIX_INSTANCE_NAME);
assert (instance != null);
if (instance.getState().equals(state)) {
return;
}
if (state.equals(AsterixInstance.State.UNUSABLE)) {
throw new IllegalArgumentException("Invalid desired state");
}
String command = null;
switch(instance.getState()) {
case ACTIVE:
command = "stop -n " + ASTERIX_INSTANCE_NAME;
break;
case INACTIVE:
command = "start -n " + ASTERIX_INSTANCE_NAME;
break;
case UNUSABLE:
command = "delete -n " + ASTERIX_INSTANCE_NAME;
cmdHandler.processCommand(command.split(" "));
throw new Exception("Cluster state was Unusable");
}
cmdHandler.processCommand(command.split(" "));
}
use of org.apache.asterix.event.model.AsterixInstance in project asterixdb by apache.
the class RestoreConfig method execCommand.
@Override
protected void execCommand() throws Exception {
InstallerDriver.initConfig(true);
String asterixInstanceName = ((RestoreConfig) config).name;
AsterixInstance instance = AsterixEventServiceUtil.validateAsterixInstanceExists(asterixInstanceName, State.INACTIVE);
int backupId = ((RestoreConfig) config).backupId;
List<BackupInfo> backupInfoList = instance.getBackupInfo();
if (backupInfoList.size() <= backupId || backupId < 0) {
throw new IllegalStateException("Invalid backup id");
}
BackupInfo backupInfo = backupInfoList.get(backupId);
Patterns patterns = PatternCreator.INSTANCE.getRestoreAsterixPattern(instance, backupInfo);
AsterixEventService.getAsterixEventServiceClient(instance.getCluster()).submit(patterns);
LOGGER.info("Asterix instance: " + asterixInstanceName + " has been restored from backup");
}
use of org.apache.asterix.event.model.AsterixInstance 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.AsterixInstance 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.AsterixInstance 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);
}
}
Aggregations