Search in sources :

Example 11 with Pattern

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

Example 12 with Pattern

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

the class PatternCreator method createRemoveAsterixTxnLogs.

private Patterns createRemoveAsterixTxnLogs(AsterixInstance instance) throws Exception {
    List<Pattern> patternList = new ArrayList<>();
    Cluster cluster = instance.getCluster();
    Nodeid nodeid;
    Event event;
    for (Node node : cluster.getNode()) {
        String txnLogDir = node.getTxnLogDir() == null ? cluster.getTxnLogDir() : node.getTxnLogDir();
        nodeid = new Nodeid(new Value(null, node.getId()));
        event = new Event("file_delete", nodeid, txnLogDir);
        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 13 with Pattern

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

the class PatternCreator method getLibraryInstallPattern.

public Patterns getLibraryInstallPattern(AsterixInstance instance, String dataverse, String libraryName, String libraryPath) throws Exception {
    List<Pattern> patternList = new ArrayList<>();
    Cluster cluster = instance.getCluster();
    Nodeid nodeid = new Nodeid(new Value(null, EventDriver.CLIENT_NODE.getId()));
    String username = cluster.getUsername() != null ? cluster.getUsername() : System.getProperty("user.name");
    String workingDir = cluster.getWorkingDir().getDir();
    String destDir = workingDir + File.separator + "library" + File.separator + dataverse + File.separator + libraryName;
    String fileToTransfer = new File(libraryPath).getAbsolutePath();
    Iterator<Node> installTargets = cluster.getNode().iterator();
    Node installNode = installTargets.next();
    String destinationIp = installNode.getClusterIp();
    String pargs = username + " " + fileToTransfer + " " + destinationIp + " " + destDir + " " + "unpack";
    Event event = new Event("file_transfer", nodeid, pargs);
    Pattern p = new Pattern(null, 1, null, event);
    patternList.add(p);
    if (!cluster.getWorkingDir().isNFS()) {
        while (installTargets.hasNext()) {
            Node node = installTargets.next();
            pargs = username + " " + fileToTransfer + " " + node.getClusterIp() + " " + destDir + " " + "unpack";
            event = new Event("file_transfer", nodeid, pargs);
            p = new Pattern(null, 1, null, event);
            patternList.add(p);
        }
        pargs = username + " " + fileToTransfer + " " + cluster.getMasterNode().getClusterIp() + " " + destDir + " " + "unpack";
        event = new Event("file_transfer", 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) 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) File(java.io.File) Patterns(org.apache.asterix.event.schema.pattern.Patterns)

Example 14 with Pattern

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

the class PatternCreator method createCCStartPattern.

private Pattern createCCStartPattern(String hostId) {
    Nodeid nodeid = new Nodeid(new Value(null, hostId));
    Event event = new Event("cc_start", nodeid, "");
    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 15 with Pattern

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

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