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);
}
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);
}
use of org.apache.asterix.event.schema.pattern.Pattern in project asterixdb by apache.
the class ClusterManager method addNode.
@Override
public void addNode(ICcApplicationContext appCtx, Node node) throws AsterixException {
try {
Cluster cluster = ClusterProperties.INSTANCE.getCluster();
List<Pattern> pattern = new ArrayList<>();
String asterixInstanceName = appCtx.getMetadataProperties().getInstanceName();
Patterns prepareNode = PatternCreator.INSTANCE.createPrepareNodePattern(asterixInstanceName, ClusterProperties.INSTANCE.getCluster(), node);
cluster.getNode().add(node);
client.submit(prepareNode);
ExternalProperties externalProps = appCtx.getExternalProperties();
AsterixEventServiceUtil.poulateClusterEnvironmentProperties(cluster, externalProps.getCCJavaParams(), externalProps.getNCJavaParams());
pattern.clear();
String ccHost = cluster.getMasterNode().getClusterIp();
String hostId = node.getId();
String nodeControllerId = asterixInstanceName + "_" + node.getId();
String iodevices = node.getIodevices() == null ? cluster.getIodevices() : node.getIodevices();
Pattern startNC = PatternCreator.INSTANCE.createNCStartPattern(ccHost, hostId, nodeControllerId, iodevices, false);
pattern.add(startNC);
Patterns startNCPattern = new Patterns(pattern);
client.submit(startNCPattern);
removeNode(cluster.getSubstituteNodes().getNode(), node);
AsterixInstance instance = lookupService.getAsterixInstance(cluster.getInstanceName());
instance.getCluster().getNode().add(node);
removeNode(instance.getCluster().getSubstituteNodes().getNode(), node);
lookupService.updateAsterixInstance(instance);
} catch (Exception e) {
throw new AsterixException(e);
}
}
use of org.apache.asterix.event.schema.pattern.Pattern 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.Pattern 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);
}
Aggregations