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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations