Search in sources :

Example 1 with AsterixRuntimeState

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);
}
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 2 with AsterixRuntimeState

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

Example 3 with AsterixRuntimeState

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

Example 4 with AsterixRuntimeState

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);
}
Also used : Node(org.apache.asterix.event.schema.cluster.Node) ArrayList(java.util.ArrayList) Cluster(org.apache.asterix.event.schema.cluster.Cluster) ProcessInfo(org.apache.asterix.event.model.ProcessInfo) AsterixRuntimeState(org.apache.asterix.event.model.AsterixRuntimeState)

Example 5 with AsterixRuntimeState

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));
}
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)

Aggregations

AsterixRuntimeState (org.apache.asterix.event.model.AsterixRuntimeState)9 AsterixInstance (org.apache.asterix.event.model.AsterixInstance)8 AsterixEventServiceClient (org.apache.asterix.event.management.AsterixEventServiceClient)4 Patterns (org.apache.asterix.event.schema.pattern.Patterns)4 ArrayList (java.util.ArrayList)3 ProcessInfo (org.apache.asterix.event.model.ProcessInfo)3 Node (org.apache.asterix.event.schema.cluster.Node)3 InstallerException (org.apache.asterix.installer.error.InstallerException)3 ClusterState (org.apache.asterix.common.api.IClusterManagementWork.ClusterState)2 Cluster (org.apache.asterix.event.schema.cluster.Cluster)2 Pattern (org.apache.asterix.event.schema.pattern.Pattern)2 ClusterStateWatcher (org.apache.asterix.event.service.ClusterStateWatcher)2 Test (org.junit.Test)2 Date (java.util.Date)1