Search in sources :

Example 11 with AsterixInstance

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);
}
Also used : BackupInfo(org.apache.asterix.event.model.BackupInfo) Backup(org.apache.asterix.installer.schema.conf.Backup) AsterixInstance(org.apache.asterix.event.model.AsterixInstance) Patterns(org.apache.asterix.event.schema.pattern.Patterns) Date(java.util.Date)

Example 12 with AsterixInstance

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));
}
Also used : ClusterState(org.apache.asterix.common.api.IClusterManagementWork.ClusterState) AsterixEventServiceClient(org.apache.asterix.event.management.AsterixEventServiceClient) ClusterStateWatcher(org.apache.asterix.event.service.ClusterStateWatcher) AsterixInstance(org.apache.asterix.event.model.AsterixInstance) Patterns(org.apache.asterix.event.schema.pattern.Patterns) AsterixRuntimeState(org.apache.asterix.event.model.AsterixRuntimeState)

Example 13 with AsterixInstance

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);
}
Also used : AsterixInstance(org.apache.asterix.event.model.AsterixInstance) Patterns(org.apache.asterix.event.schema.pattern.Patterns)

Example 14 with AsterixInstance

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);
}
Also used : PatternCreator(org.apache.asterix.event.util.PatternCreator) AsterixInstance(org.apache.asterix.event.model.AsterixInstance) Patterns(org.apache.asterix.event.schema.pattern.Patterns)

Example 15 with AsterixInstance

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();
    }
}
Also used : AsterixInstance(org.apache.asterix.event.model.AsterixInstance) Test(org.junit.Test)

Aggregations

AsterixInstance (org.apache.asterix.event.model.AsterixInstance)25 Patterns (org.apache.asterix.event.schema.pattern.Patterns)12 AsterixRuntimeState (org.apache.asterix.event.model.AsterixRuntimeState)8 AsterixEventServiceClient (org.apache.asterix.event.management.AsterixEventServiceClient)7 ArrayList (java.util.ArrayList)6 Date (java.util.Date)5 Node (org.apache.asterix.event.schema.cluster.Node)5 Pattern (org.apache.asterix.event.schema.pattern.Pattern)4 InstallerException (org.apache.asterix.installer.error.InstallerException)4 PatternCreator (org.apache.asterix.event.util.PatternCreator)3 Test (org.junit.Test)3 IOException (java.io.IOException)2 JAXBException (javax.xml.bind.JAXBException)2 ClusterState (org.apache.asterix.common.api.IClusterManagementWork.ClusterState)2 EventException (org.apache.asterix.event.error.EventException)2 BackupInfo (org.apache.asterix.event.model.BackupInfo)2 ProcessInfo (org.apache.asterix.event.model.ProcessInfo)2 Cluster (org.apache.asterix.event.schema.cluster.Cluster)2 ClusterStateWatcher (org.apache.asterix.event.service.ClusterStateWatcher)2 ILookupService (org.apache.asterix.event.service.ILookupService)2