Search in sources :

Example 6 with Pattern

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

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

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

the class PatternCreator method createCCStopPattern.

public Pattern createCCStopPattern(String hostId) {
    Nodeid nodeid = new Nodeid(new Value(null, hostId));
    Event event = new Event("cc_failure", nodeid, null);
    return new Pattern(null, 1, null, event);
}
Also used : Pattern(org.apache.asterix.event.schema.pattern.Pattern) Nodeid(org.apache.asterix.event.schema.pattern.Nodeid) Value(org.apache.asterix.event.schema.pattern.Value) Event(org.apache.asterix.event.schema.pattern.Event)

Example 9 with Pattern

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

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

the class PatternCreator method createNCStopPattern.

public Pattern createNCStopPattern(String hostId, String nodeControllerId) {
    Nodeid nodeid = new Nodeid(new Value(null, hostId));
    Event event = new Event("node_failure", nodeid, nodeControllerId);
    return new Pattern(null, 1, null, event);
}
Also used : Pattern(org.apache.asterix.event.schema.pattern.Pattern) Nodeid(org.apache.asterix.event.schema.pattern.Nodeid) Value(org.apache.asterix.event.schema.pattern.Value) Event(org.apache.asterix.event.schema.pattern.Event)

Aggregations

Pattern (org.apache.asterix.event.schema.pattern.Pattern)32 ArrayList (java.util.ArrayList)24 Patterns (org.apache.asterix.event.schema.pattern.Patterns)24 Event (org.apache.asterix.event.schema.pattern.Event)23 Nodeid (org.apache.asterix.event.schema.pattern.Nodeid)22 Value (org.apache.asterix.event.schema.pattern.Value)22 Node (org.apache.asterix.event.schema.cluster.Node)21 Cluster (org.apache.asterix.event.schema.cluster.Cluster)15 File (java.io.File)5 AsterixInstance (org.apache.asterix.event.model.AsterixInstance)4 AsterixEventServiceClient (org.apache.asterix.event.management.AsterixEventServiceClient)3 Date (java.util.Date)2 AsterixRuntimeState (org.apache.asterix.event.model.AsterixRuntimeState)2 ProcessInfo (org.apache.asterix.event.model.ProcessInfo)2 InstallerException (org.apache.asterix.installer.error.InstallerException)2 FileOutputStream (java.io.FileOutputStream)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 JAXBContext (javax.xml.bind.JAXBContext)1 Marshaller (javax.xml.bind.Marshaller)1