use of org.apache.asterix.event.model.AsterixInstance in project asterixdb by apache.
the class BackupConfig method execCommand.
@Override
protected void execCommand() throws Exception {
InstallerDriver.initConfig(true);
String asterixInstanceName = ((BackupConfig) config).name;
AsterixInstance instance = AsterixEventServiceUtil.validateAsterixInstanceExists(asterixInstanceName, State.INACTIVE);
List<BackupInfo> backupInfo = instance.getBackupInfo();
Backup backupConf = AsterixEventService.getConfiguration().getBackup();
Patterns patterns = PatternCreator.INSTANCE.getBackUpAsterixPattern(instance, backupConf);
AsterixEventService.getAsterixEventServiceClient(instance.getCluster()).submit(patterns);
int backupId = backupInfo.size();
BackupInfo binfo = new BackupInfo(backupId, new Date(), backupConf);
backupInfo.add(binfo);
LOGGER.info(asterixInstanceName + " backed up " + binfo);
ServiceProvider.INSTANCE.getLookupService().updateAsterixInstance(instance);
}
use of org.apache.asterix.event.model.AsterixInstance 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));
}
use of org.apache.asterix.event.model.AsterixInstance in project asterixdb by apache.
the class DeleteConfig method execCommand.
@Override
protected void execCommand() throws Exception {
InstallerDriver.initConfig(true);
String asterixInstanceName = ((DeleteConfig) config).name;
AsterixInstance instance = AsterixEventServiceUtil.validateAsterixInstanceExists(asterixInstanceName, State.INACTIVE);
Patterns patterns = PatternCreator.INSTANCE.createDeleteInstancePattern(instance);
AsterixEventService.getAsterixEventServiceClient(instance.getCluster()).submit(patterns);
patterns = PatternCreator.INSTANCE.createRemoveAsterixWorkingDirPattern(instance);
AsterixEventService.getAsterixEventServiceClient(instance.getCluster()).submit(patterns);
ServiceProvider.INSTANCE.getLookupService().removeAsterixInstance(asterixInstanceName);
LOGGER.info("Deleted Asterix instance: " + asterixInstanceName);
}
use of org.apache.asterix.event.model.AsterixInstance in project asterixdb by apache.
the class InstallConfig method execCommand.
@Override
protected void execCommand() throws Exception {
InstallerDriver.initConfig(true);
InstallConfig installConfig = ((InstallConfig) config);
String instanceName = installConfig.name;
AsterixInstance instance = AsterixEventServiceUtil.validateAsterixInstanceExists(instanceName, State.INACTIVE);
PatternCreator pc = PatternCreator.INSTANCE;
Patterns patterns = pc.getLibraryInstallPattern(instance, installConfig.dataverseName, installConfig.libraryName, installConfig.libraryPath);
AsterixEventService.getAsterixEventServiceClient(instance.getCluster()).submit(patterns);
LOGGER.info("Installed library " + installConfig.libraryName);
}
use of org.apache.asterix.event.model.AsterixInstance in project asterixdb by apache.
the class AsterixLifecycleIT method test_3_DeleteActiveInstance.
@Test
public void test_3_DeleteActiveInstance() throws Exception {
try {
LOGGER.info("Starting test: test_3_DeleteActiveInstance");
AsterixInstallerIntegrationUtil.transformIntoRequiredState(State.INACTIVE);
String command = "delete -n " + AsterixInstallerIntegrationUtil.ASTERIX_INSTANCE_NAME;
cmdHandler.processCommand(command.split(" "));
AsterixInstance instance = ServiceProvider.INSTANCE.getLookupService().getAsterixInstance(AsterixInstallerIntegrationUtil.ASTERIX_INSTANCE_NAME);
assert (instance == null);
LOGGER.info("PASSED: test_3_DeleteActiveInstance");
} catch (Exception e) {
throw new Exception("Test delete active instance " + "\" FAILED!", e);
} finally {
// recreate instance
AsterixInstallerIntegrationUtil.createInstance();
}
}
Aggregations