Search in sources :

Example 31 with Pattern

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

the class AsterixEventServiceClient method getDirectoryTransferPattern.

private Pattern getDirectoryTransferPattern(String username, String src, Nodeid srcNode, String destNodeIp, String destDir) {
    String pargs = username + " " + src + " " + destNodeIp + " " + destDir;
    Event event = new Event("directory_transfer", srcNode, pargs);
    return new Pattern(null, 1, null, event);
}
Also used : Pattern(org.apache.asterix.event.schema.pattern.Pattern) Event(org.apache.asterix.event.schema.pattern.Event)

Example 32 with Pattern

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

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