Search in sources :

Example 11 with Nodeid

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

the class PatternCreator method getGenerateLogPattern.

public Patterns getGenerateLogPattern(Cluster cluster, String outputDir) {
    List<Pattern> patternList = new ArrayList<>();
    Map<String, String> nodeLogs = new HashMap<>();
    String username = cluster.getUsername() == null ? System.getProperty("user.name") : cluster.getUsername();
    String srcHost = cluster.getMasterNode().getClientIp();
    Nodeid nodeid = new Nodeid(new Value(null, EventDriver.CLIENT_NODE.getId()));
    String srcDir = cluster.getMasterNode().getLogDir() == null ? cluster.getLogDir() : cluster.getMasterNode().getLogDir();
    String destDir = outputDir + File.separator + "cc";
    String pargs = username + " " + srcHost + " " + srcDir + " " + destDir;
    Event event = new Event("directory_copy", nodeid, pargs);
    Pattern p = new Pattern(null, 1, null, event);
    patternList.add(p);
    nodeLogs.put(cluster.getMasterNode().getClusterIp(), srcDir);
    for (Node node : cluster.getNode()) {
        srcHost = node.getClusterIp();
        srcDir = node.getLogDir() == null ? cluster.getLogDir() : node.getLogDir();
        if (nodeLogs.get(node.getClusterIp()) != null && nodeLogs.get(node.getClusterIp()).equals(srcDir)) {
            continue;
        }
        destDir = outputDir + File.separator + node.getId();
        pargs = username + " " + srcHost + " " + srcDir + " " + destDir;
        event = new Event("directory_copy", nodeid, pargs);
        p = new Pattern(null, 1, null, event);
        patternList.add(p);
    }
    return new Patterns(patternList);
}
Also used : Pattern(org.apache.asterix.event.schema.pattern.Pattern) HashMap(java.util.HashMap) 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) Patterns(org.apache.asterix.event.schema.pattern.Patterns)

Example 12 with Nodeid

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

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

Example 14 with Nodeid

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

the class PatternCreator method createRemoveAsterixLogDirPattern.

private Patterns createRemoveAsterixLogDirPattern(AsterixInstance instance) throws Exception {
    List<Pattern> patternList = new ArrayList<>();
    Cluster cluster = instance.getCluster();
    String pargs = instance.getCluster().getLogDir();
    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));
    for (Node node : cluster.getNode()) {
        nodeid = new Nodeid(new Value(null, node.getId()));
        if (node.getLogDir() != null) {
            pargs = node.getLogDir();
        }
        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 15 with Nodeid

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

the class PatternCreator method createNCStartPattern.

public Pattern createNCStartPattern(String ccHost, String hostId, String nodeControllerId, String iodevices, boolean isInitialRun) {
    Nodeid nodeid = new Nodeid(new Value(null, hostId));
    String pargs = ccHost + " " + nodeControllerId + " " + iodevices;
    if (isInitialRun) {
        pargs += " " + "-initial-run";
    }
    Event event = new Event("node_join", nodeid, pargs);
    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

Nodeid (org.apache.asterix.event.schema.pattern.Nodeid)22 Pattern (org.apache.asterix.event.schema.pattern.Pattern)22 Value (org.apache.asterix.event.schema.pattern.Value)22 Event (org.apache.asterix.event.schema.pattern.Event)21 ArrayList (java.util.ArrayList)17 Patterns (org.apache.asterix.event.schema.pattern.Patterns)17 Node (org.apache.asterix.event.schema.cluster.Node)16 Cluster (org.apache.asterix.event.schema.cluster.Cluster)13 File (java.io.File)5 FileOutputStream (java.io.FileOutputStream)1 HashMap (java.util.HashMap)1 JAXBContext (javax.xml.bind.JAXBContext)1 Marshaller (javax.xml.bind.Marshaller)1