Search in sources :

Example 6 with Patterns

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

the class PatternCreator method getLocalRestoreAsterixPattern.

public Patterns getLocalRestoreAsterixPattern(AsterixInstance instance, BackupInfo backupInfo) throws Exception {
    Cluster cluster = instance.getCluster();
    String clusterStore = instance.getCluster().getStore();
    String backupDir = backupInfo.getBackupConf().getBackupDir();
    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 + " " + backupDir + " " + "local" + " " + node.getId();
        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)

Example 7 with Patterns

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

the class PatternCreator method getStartAsterixPattern.

public Patterns getStartAsterixPattern(String asterixInstanceName, Cluster cluster, boolean createCommand) throws Exception {
    String ccLocationId = cluster.getMasterNode().getId();
    List<Pattern> ps = new ArrayList<>();
    Pattern createCC = createCCStartPattern(ccLocationId);
    addInitialDelay(createCC, 3, "sec");
    ps.add(createCC);
    for (Node node : cluster.getNode()) {
        String iodevices = node.getIodevices() == null ? cluster.getIodevices() : node.getIodevices();
        Pattern createNC = createNCStartPattern(cluster.getMasterNode().getClusterIp(), node.getId(), asterixInstanceName + "_" + node.getId(), iodevices, createCommand);
        addInitialDelay(createNC, 5, "sec");
        ps.add(createNC);
    }
    return new Patterns(ps);
}
Also used : Pattern(org.apache.asterix.event.schema.pattern.Pattern) Node(org.apache.asterix.event.schema.cluster.Node) ArrayList(java.util.ArrayList) Patterns(org.apache.asterix.event.schema.pattern.Patterns)

Example 8 with Patterns

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

the class PatternCreator method getBackUpAsterixPattern.

public Patterns getBackUpAsterixPattern(AsterixInstance instance, Backup backupConf) throws Exception {
    BackupType backupType = BackupInfo.getBackupType(backupConf);
    Patterns patterns = null;
    switch(backupType) {
        case HDFS:
            patterns = getHDFSBackUpAsterixPattern(instance, backupConf);
            break;
        case LOCAL:
            patterns = getLocalBackUpAsterixPattern(instance, backupConf);
            break;
    }
    return patterns;
}
Also used : BackupType(org.apache.asterix.event.model.BackupInfo.BackupType) Patterns(org.apache.asterix.event.schema.pattern.Patterns)

Example 9 with Patterns

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

the class PatternCreator method createPrepareNodePattern.

public Patterns createPrepareNodePattern(String instanceName, Cluster cluster, Node nodeToBeAdded) {
    List<Pattern> ps = new ArrayList<>();
    boolean workingDirOnNFS = cluster.getWorkingDir().isNFS();
    if (!workingDirOnNFS) {
        String ccLocationIp = cluster.getMasterNode().getClusterIp();
        String destDir = cluster.getWorkingDir().getDir() + File.separator + "asterix";
        Pattern copyHyracks = createCopyHyracksPattern(instanceName, cluster, ccLocationIp, destDir);
        ps.add(copyHyracks);
        String workingDir = cluster.getWorkingDir().getDir();
        String hadoopVersion = AsterixEventService.getConfiguration().getBackup().getHdfs().getVersion();
        File hadoopDir = new File(AsterixEventService.getEventHome() + File.separator + "hadoop-" + hadoopVersion);
        if (!hadoopDir.exists()) {
            throw new IllegalStateException("Hadoop version :" + hadoopVersion + " not supported");
        }
        Nodeid nodeid = new Nodeid(new Value(null, EventDriver.CLIENT_NODE.getId()));
        String username = cluster.getUsername() != null ? cluster.getUsername() : System.getProperty("user.name");
        String pargs = username + " " + hadoopDir.getAbsolutePath() + " " + cluster.getMasterNode().getClusterIp() + " " + workingDir;
        Event event = new Event("directory_transfer", nodeid, pargs);
        Pattern p = new Pattern(null, 1, null, event);
        addInitialDelay(p, 2, "sec");
        ps.add(p);
        nodeid = new Nodeid(new Value(null, nodeToBeAdded.getId()));
        pargs = cluster.getUsername() + " " + hadoopDir.getAbsolutePath() + " " + nodeToBeAdded.getClusterIp() + " " + workingDir;
        event = new Event("directory_transfer", nodeid, pargs);
        p = new Pattern(null, 1, null, event);
        addInitialDelay(p, 2, "sec");
        ps.add(p);
    }
    return new Patterns(ps);
}
Also used : Pattern(org.apache.asterix.event.schema.pattern.Pattern) ArrayList(java.util.ArrayList) Nodeid(org.apache.asterix.event.schema.pattern.Nodeid) Value(org.apache.asterix.event.schema.pattern.Value) Event(org.apache.asterix.event.schema.pattern.Event) File(java.io.File) Patterns(org.apache.asterix.event.schema.pattern.Patterns)

Example 10 with Patterns

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

the class PatternCreator method getAsterixBinaryTransferPattern.

public Patterns getAsterixBinaryTransferPattern(String asterixInstanceName, Cluster cluster) throws Exception {
    String ccLocationIp = cluster.getMasterNode().getClusterIp();
    String destDir = cluster.getWorkingDir().getDir() + File.separator + "asterix";
    List<Pattern> ps = new ArrayList<>();
    Pattern copyHyracks = createCopyHyracksPattern(asterixInstanceName, cluster, ccLocationIp, destDir);
    ps.add(copyHyracks);
    boolean copyHyracksToNC = !cluster.getWorkingDir().isNFS();
    for (Node node : cluster.getNode()) {
        if (copyHyracksToNC) {
            Pattern copyHyracksForNC = createCopyHyracksPattern(asterixInstanceName, cluster, node.getClusterIp(), destDir);
            ps.add(copyHyracksForNC);
        }
    }
    ps.addAll(createHadoopLibraryTransferPattern(cluster).getPattern());
    return new Patterns(ps);
}
Also used : Pattern(org.apache.asterix.event.schema.pattern.Pattern) Node(org.apache.asterix.event.schema.cluster.Node) ArrayList(java.util.ArrayList) 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