Search in sources :

Example 16 with Patterns

use of org.apache.asterix.event.schema.pattern.Patterns 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 17 with Patterns

use of org.apache.asterix.event.schema.pattern.Patterns 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 18 with Patterns

use of org.apache.asterix.event.schema.pattern.Patterns in project asterixdb by apache.

the class AsterixEventServiceClient method initPattern.

private Patterns initPattern(String eventsDir) throws Exception {
    Nodeid nodeid = new Nodeid(new Value(null, EventDriver.CLIENT_NODE.getId()));
    List<Pattern> patternList = new ArrayList<Pattern>();
    String workingDir = cluster.getWorkingDir().getDir();
    String username = cluster.getUsername() == null ? System.getProperty("user.name") : cluster.getUsername();
    patternList.add(getDirectoryTransferPattern(username, eventsDir, nodeid, cluster.getMasterNode().getClusterIp(), workingDir));
    JAXBContext ctx = JAXBContext.newInstance(Configuration.class);
    Marshaller marshaller = ctx.createMarshaller();
    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
    String outputPathDir = System.getProperty("java.io.tmpdir") + File.separator + "conf-" + System.getProperty("user.name");
    new File(outputPathDir).mkdirs();
    String outputPath = outputPathDir + File.separator + "configuration.xml";
    marshaller.marshal(configuration, new FileOutputStream(outputPath));
    patternList.add(getFileTransferPattern(username, outputPath, nodeid, cluster.getMasterNode().getClusterIp(), workingDir));
    if (!cluster.getWorkingDir().isNFS()) {
        for (Node node : cluster.getNode()) {
            patternList.add(getDirectoryTransferPattern(username, eventsDir, nodeid, node.getClusterIp(), workingDir));
        }
    }
    return new Patterns(patternList);
}
Also used : Pattern(org.apache.asterix.event.schema.pattern.Pattern) Marshaller(javax.xml.bind.Marshaller) FileOutputStream(java.io.FileOutputStream) Node(org.apache.asterix.event.schema.cluster.Node) Nodeid(org.apache.asterix.event.schema.pattern.Nodeid) Value(org.apache.asterix.event.schema.pattern.Value) ArrayList(java.util.ArrayList) JAXBContext(javax.xml.bind.JAXBContext) File(java.io.File) Patterns(org.apache.asterix.event.schema.pattern.Patterns)

Example 19 with Patterns

use of org.apache.asterix.event.schema.pattern.Patterns 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 Patterns

use of org.apache.asterix.event.schema.pattern.Patterns in project asterixdb by apache.

the class PatternCreator method createRemoveAsterixStoragePattern.

private Patterns createRemoveAsterixStoragePattern(AsterixInstance instance) throws Exception {
    List<Pattern> patternList = new ArrayList<>();
    Cluster cluster = instance.getCluster();
    String pargs;
    for (Node node : cluster.getNode()) {
        Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
        String[] nodeIODevices;
        String iodevices = node.getIodevices() == null ? cluster.getIodevices() : node.getIodevices();
        nodeIODevices = iodevices.trim().split(",");
        String nodeStore = cluster.getStore().trim();
        for (String nodeIODevice : nodeIODevices) {
            pargs = nodeIODevice.trim() + File.separator + nodeStore;
            Event event = new Event("file_delete", nodeid, pargs);
            patternList.add(new Pattern(null, 1, null, event));
        }
    }
    return new Patterns(patternList);
}
Also used : Pattern(org.apache.asterix.event.schema.pattern.Pattern) Node(org.apache.asterix.event.schema.cluster.Node) ArrayList(java.util.ArrayList) Nodeid(org.apache.asterix.event.schema.pattern.Nodeid) Value(org.apache.asterix.event.schema.pattern.Value) Cluster(org.apache.asterix.event.schema.cluster.Cluster) Event(org.apache.asterix.event.schema.pattern.Event) Patterns(org.apache.asterix.event.schema.pattern.Patterns)

Aggregations

Patterns (org.apache.asterix.event.schema.pattern.Patterns)35 ArrayList (java.util.ArrayList)24 Pattern (org.apache.asterix.event.schema.pattern.Pattern)24 Node (org.apache.asterix.event.schema.cluster.Node)21 Nodeid (org.apache.asterix.event.schema.pattern.Nodeid)17 Value (org.apache.asterix.event.schema.pattern.Value)17 Event (org.apache.asterix.event.schema.pattern.Event)16 Cluster (org.apache.asterix.event.schema.cluster.Cluster)15 AsterixInstance (org.apache.asterix.event.model.AsterixInstance)12 AsterixEventServiceClient (org.apache.asterix.event.management.AsterixEventServiceClient)7 File (java.io.File)5 Date (java.util.Date)4 AsterixRuntimeState (org.apache.asterix.event.model.AsterixRuntimeState)4 BackupInfo (org.apache.asterix.event.model.BackupInfo)3 PatternCreator (org.apache.asterix.event.util.PatternCreator)3 InstallerException (org.apache.asterix.installer.error.InstallerException)3 ClusterState (org.apache.asterix.common.api.IClusterManagementWork.ClusterState)2 BackupType (org.apache.asterix.event.model.BackupInfo.BackupType)2 ProcessInfo (org.apache.asterix.event.model.ProcessInfo)2 ClusterStateWatcher (org.apache.asterix.event.service.ClusterStateWatcher)2