Search in sources :

Example 16 with AsterixInstance

use of org.apache.asterix.event.model.AsterixInstance in project asterixdb by apache.

the class AsterixInstallerIntegrationUtil method deleteInstance.

private static void deleteInstance() throws Exception {
    String command = null;
    AsterixInstance instance = ServiceProvider.INSTANCE.getLookupService().getAsterixInstance(ASTERIX_INSTANCE_NAME);
    if (instance == null) {
        return;
    } else {
        transformIntoRequiredState(State.INACTIVE);
        command = "delete -n " + ASTERIX_INSTANCE_NAME;
        cmdHandler.processCommand(command.split(" "));
    }
    instance = ServiceProvider.INSTANCE.getLookupService().getAsterixInstance(ASTERIX_INSTANCE_NAME);
    assert (instance == null);
}
Also used : AsterixInstance(org.apache.asterix.event.model.AsterixInstance)

Example 17 with AsterixInstance

use of org.apache.asterix.event.model.AsterixInstance in project asterixdb by apache.

the class AsterixInstallerIntegrationUtil method createInstance.

public static void createInstance() throws Exception {
    String command = null;
    AsterixInstance instance = ServiceProvider.INSTANCE.getLookupService().getAsterixInstance(ASTERIX_INSTANCE_NAME);
    if (instance != null) {
        transformIntoRequiredState(State.INACTIVE);
        command = "delete -n " + ASTERIX_INSTANCE_NAME;
        cmdHandler.processCommand(command.split(" "));
    }
    command = "create -n " + ASTERIX_INSTANCE_NAME + " " + "-c" + " " + clusterConfigurationPath;
    cmdHandler.processCommand(command.split(" "));
    instance = ServiceProvider.INSTANCE.getLookupService().getAsterixInstance(ASTERIX_INSTANCE_NAME);
    AsterixRuntimeState state = VerificationUtil.getAsterixRuntimeState(instance);
    assert (state.getFailedNCs().isEmpty() && state.isCcRunning());
}
Also used : AsterixInstance(org.apache.asterix.event.model.AsterixInstance) AsterixRuntimeState(org.apache.asterix.event.model.AsterixRuntimeState)

Example 18 with AsterixInstance

use of org.apache.asterix.event.model.AsterixInstance in project asterixdb by apache.

the class ZookeeperUtil method readAsterixInstanceObject.

private AsterixInstance readAsterixInstanceObject(byte[] asterixInstanceBytes) throws IOException, ClassNotFoundException {
    ByteArrayInputStream b = new ByteArrayInputStream(asterixInstanceBytes);
    ObjectInputStream ois = new ObjectInputStream(b);
    return (AsterixInstance) ois.readObject();
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) AsterixInstance(org.apache.asterix.event.model.AsterixInstance) ObjectInputStream(java.io.ObjectInputStream)

Example 19 with AsterixInstance

use of org.apache.asterix.event.model.AsterixInstance in project asterixdb by apache.

the class ClusterManager method addNode.

@Override
public void addNode(ICcApplicationContext appCtx, Node node) throws AsterixException {
    try {
        Cluster cluster = ClusterProperties.INSTANCE.getCluster();
        List<Pattern> pattern = new ArrayList<>();
        String asterixInstanceName = appCtx.getMetadataProperties().getInstanceName();
        Patterns prepareNode = PatternCreator.INSTANCE.createPrepareNodePattern(asterixInstanceName, ClusterProperties.INSTANCE.getCluster(), node);
        cluster.getNode().add(node);
        client.submit(prepareNode);
        ExternalProperties externalProps = appCtx.getExternalProperties();
        AsterixEventServiceUtil.poulateClusterEnvironmentProperties(cluster, externalProps.getCCJavaParams(), externalProps.getNCJavaParams());
        pattern.clear();
        String ccHost = cluster.getMasterNode().getClusterIp();
        String hostId = node.getId();
        String nodeControllerId = asterixInstanceName + "_" + node.getId();
        String iodevices = node.getIodevices() == null ? cluster.getIodevices() : node.getIodevices();
        Pattern startNC = PatternCreator.INSTANCE.createNCStartPattern(ccHost, hostId, nodeControllerId, iodevices, false);
        pattern.add(startNC);
        Patterns startNCPattern = new Patterns(pattern);
        client.submit(startNCPattern);
        removeNode(cluster.getSubstituteNodes().getNode(), node);
        AsterixInstance instance = lookupService.getAsterixInstance(cluster.getInstanceName());
        instance.getCluster().getNode().add(node);
        removeNode(instance.getCluster().getSubstituteNodes().getNode(), node);
        lookupService.updateAsterixInstance(instance);
    } catch (Exception e) {
        throw new AsterixException(e);
    }
}
Also used : Pattern(org.apache.asterix.event.schema.pattern.Pattern) AsterixException(org.apache.asterix.common.exceptions.AsterixException) ArrayList(java.util.ArrayList) ExternalProperties(org.apache.asterix.common.config.ExternalProperties) Cluster(org.apache.asterix.event.schema.cluster.Cluster) AsterixInstance(org.apache.asterix.event.model.AsterixInstance) Patterns(org.apache.asterix.event.schema.pattern.Patterns) AsterixException(org.apache.asterix.common.exceptions.AsterixException)

Example 20 with AsterixInstance

use of org.apache.asterix.event.model.AsterixInstance in project asterixdb by apache.

the class UninstallConfig method execCommand.

@Override
protected void execCommand() throws Exception {
    InstallerDriver.initConfig(true);
    UninstallConfig uninstallConfig = ((UninstallConfig) config);
    String instanceName = uninstallConfig.name;
    AsterixEventServiceUtil.validateAsterixInstanceExists(instanceName, State.INACTIVE);
    ILookupService lookupService = ServiceProvider.INSTANCE.getLookupService();
    AsterixInstance instance = lookupService.getAsterixInstance(instanceName);
    PatternCreator pc = PatternCreator.INSTANCE;
    Patterns patterns = pc.getLibraryUninstallPattern(instance, uninstallConfig.dataverseName, uninstallConfig.libraryName);
    AsterixEventServiceClient client = AsterixEventService.getAsterixEventServiceClient(instance.getCluster());
    client.submit(patterns);
    LOGGER.info("Uninstalled library " + uninstallConfig.libraryName);
}
Also used : AsterixEventServiceClient(org.apache.asterix.event.management.AsterixEventServiceClient) PatternCreator(org.apache.asterix.event.util.PatternCreator) AsterixInstance(org.apache.asterix.event.model.AsterixInstance) Patterns(org.apache.asterix.event.schema.pattern.Patterns) ILookupService(org.apache.asterix.event.service.ILookupService)

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