Search in sources :

Example 1 with Patterns

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

the class RestoreConfig method execCommand.

@Override
protected void execCommand() throws Exception {
    InstallerDriver.initConfig(true);
    String asterixInstanceName = ((RestoreConfig) config).name;
    AsterixInstance instance = AsterixEventServiceUtil.validateAsterixInstanceExists(asterixInstanceName, State.INACTIVE);
    int backupId = ((RestoreConfig) config).backupId;
    List<BackupInfo> backupInfoList = instance.getBackupInfo();
    if (backupInfoList.size() <= backupId || backupId < 0) {
        throw new IllegalStateException("Invalid backup id");
    }
    BackupInfo backupInfo = backupInfoList.get(backupId);
    Patterns patterns = PatternCreator.INSTANCE.getRestoreAsterixPattern(instance, backupInfo);
    AsterixEventService.getAsterixEventServiceClient(instance.getCluster()).submit(patterns);
    LOGGER.info("Asterix instance: " + asterixInstanceName + " has been restored from backup");
}
Also used : BackupInfo(org.apache.asterix.event.model.BackupInfo) AsterixInstance(org.apache.asterix.event.model.AsterixInstance) Patterns(org.apache.asterix.event.schema.pattern.Patterns)

Example 2 with Patterns

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

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

the class AsterixEventServiceClient method initializeCluster.

private void initializeCluster(String eventsDir) throws Exception {
    Patterns patterns = initPattern(eventsDir);
    submit(patterns);
}
Also used : Patterns(org.apache.asterix.event.schema.pattern.Patterns)

Example 4 with Patterns

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

the class PatternCreator method getHDFSBackUpAsterixPattern.

private Patterns getHDFSBackUpAsterixPattern(AsterixInstance instance, Backup backupConf) throws Exception {
    Cluster cluster = instance.getCluster();
    String hdfsUrl = backupConf.getHdfs().getUrl();
    String hadoopVersion = backupConf.getHdfs().getVersion();
    String hdfsBackupDir = backupConf.getBackupDir();
    VerificationUtil.verifyBackupRestoreConfiguration(hdfsUrl, hadoopVersion, hdfsBackupDir);
    String workingDir = cluster.getWorkingDir().getDir();
    String backupId = Integer.toString(instance.getBackupInfo().size());
    String store;
    String pargs;
    String iodevices;
    store = cluster.getStore();
    List<Pattern> patternList = new ArrayList<>();
    for (Node node : cluster.getNode()) {
        Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
        iodevices = node.getIodevices() == null ? instance.getCluster().getIodevices() : node.getIodevices();
        pargs = workingDir + " " + instance.getName() + " " + iodevices + " " + store + " " + StorageConstants.METADATA_ROOT + " " + AsterixEventServiceUtil.TXN_LOG_DIR + " " + backupId + " " + hdfsBackupDir + " " + "hdfs" + " " + node.getId() + " " + hdfsUrl + " " + hadoopVersion;
        Event event = new Event("backup", 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)

Example 5 with Patterns

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

the class PatternCreator method getHDFSRestoreAsterixPattern.

public Patterns getHDFSRestoreAsterixPattern(AsterixInstance instance, BackupInfo backupInfo) throws Exception {
    Cluster cluster = instance.getCluster();
    String clusterStore = instance.getCluster().getStore();
    String hdfsUrl = backupInfo.getBackupConf().getHdfs().getUrl();
    String hadoopVersion = backupInfo.getBackupConf().getHdfs().getVersion();
    String hdfsBackupDir = backupInfo.getBackupConf().getBackupDir();
    VerificationUtil.verifyBackupRestoreConfiguration(hdfsUrl, hadoopVersion, hdfsBackupDir);
    String workingDir = cluster.getWorkingDir().getDir();
    int backupId = backupInfo.getId();
    String pargs;
    List<Pattern> patternList = new ArrayList<>();
    for (Node node : cluster.getNode()) {
        Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
        String iodevices = node.getIodevices() == null ? cluster.getIodevices() : node.getIodevices();
        pargs = workingDir + " " + instance.getName() + " " + iodevices + " " + clusterStore + " " + StorageConstants.METADATA_ROOT + " " + AsterixEventServiceUtil.TXN_LOG_DIR + " " + backupId + " " + " " + hdfsBackupDir + " " + "hdfs" + " " + node.getId() + " " + hdfsUrl + " " + hadoopVersion;
        Event event = new Event("restore", 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