Search in sources :

Example 26 with Patterns

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

the class PatternCreator method createRemoveAsterixWorkingDirPattern.

public Patterns createRemoveAsterixWorkingDirPattern(AsterixInstance instance) throws Exception {
    List<Pattern> patternList = new ArrayList<>();
    Cluster cluster = instance.getCluster();
    String workingDir = cluster.getWorkingDir().getDir();
    String pargs = workingDir;
    Nodeid nodeid = new Nodeid(new Value(null, cluster.getMasterNode().getId()));
    Event event = new Event("file_delete", nodeid, pargs);
    patternList.add(new Pattern(null, 1, null, event));
    if (!cluster.getWorkingDir().isNFS()) {
        for (Node node : cluster.getNode()) {
            nodeid = new Nodeid(new Value(null, node.getId()));
            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)

Example 27 with Patterns

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

the class PatternCreator method getLocalBackUpAsterixPattern.

private Patterns getLocalBackUpAsterixPattern(AsterixInstance instance, Backup backupConf) throws Exception {
    Cluster cluster = instance.getCluster();
    String backupDir = backupConf.getBackupDir();
    String workingDir = cluster.getWorkingDir().getDir();
    String backupId = Integer.toString(instance.getBackupInfo().size());
    String iodevices;
    String txnLogDir;
    String store;
    String pargs;
    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();
        txnLogDir = node.getTxnLogDir() == null ? instance.getCluster().getTxnLogDir() : node.getTxnLogDir();
        pargs = workingDir + " " + instance.getName() + " " + iodevices + " " + store + " " + StorageConstants.METADATA_ROOT + " " + txnLogDir + " " + backupId + " " + backupDir + " " + "local" + " " + node.getId();
        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 28 with Patterns

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

the class PatternCreator method createHadoopLibraryTransferPattern.

public Patterns createHadoopLibraryTransferPattern(Cluster cluster) throws Exception {
    List<Pattern> patternList = new ArrayList<>();
    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");
    patternList.add(p);
    boolean copyToNC = !cluster.getWorkingDir().isNFS();
    if (copyToNC) {
        for (Node node : cluster.getNode()) {
            nodeid = new Nodeid(new Value(null, node.getId()));
            pargs = cluster.getUsername() + " " + hadoopDir.getAbsolutePath() + " " + node.getClusterIp() + " " + workingDir;
            event = new Event("directory_transfer", nodeid, pargs);
            p = new Pattern(null, 1, null, event);
            addInitialDelay(p, 2, "sec");
            patternList.add(p);
        }
    }
    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) Event(org.apache.asterix.event.schema.pattern.Event) File(java.io.File) Patterns(org.apache.asterix.event.schema.pattern.Patterns)

Example 29 with Patterns

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

the class PatternCreator method getRestoreAsterixPattern.

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

Example 30 with Patterns

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

the class PatternCreator method createRemoveLocalBackupPattern.

private Patterns createRemoveLocalBackupPattern(AsterixInstance instance, String localBackupDir) throws Exception {
    List<Pattern> patternList = new ArrayList<>();
    Cluster cluster = instance.getCluster();
    String pathToDelete = localBackupDir + File.separator + instance.getName();
    String pargs = pathToDelete;
    List<String> removedBackupDirs = new ArrayList<>();
    for (Node node : cluster.getNode()) {
        if (removedBackupDirs.contains(node.getClusterIp())) {
            continue;
        }
        Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
        Event event = new Event("file_delete", nodeid, pargs);
        patternList.add(new Pattern(null, 1, null, event));
        removedBackupDirs.add(node.getClusterIp());
    }
    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