use of org.apache.asterix.event.schema.pattern.Value in project asterixdb by apache.
the class PatternCreator method createPrepareNodePattern.
public Patterns createPrepareNodePattern(String instanceName, Cluster cluster, Node nodeToBeAdded) {
List<Pattern> ps = new ArrayList<>();
boolean workingDirOnNFS = cluster.getWorkingDir().isNFS();
if (!workingDirOnNFS) {
String ccLocationIp = cluster.getMasterNode().getClusterIp();
String destDir = cluster.getWorkingDir().getDir() + File.separator + "asterix";
Pattern copyHyracks = createCopyHyracksPattern(instanceName, cluster, ccLocationIp, destDir);
ps.add(copyHyracks);
String workingDir = cluster.getWorkingDir().getDir();
String hadoopVersion = AsterixEventService.getConfiguration().getBackup().getHdfs().getVersion();
File hadoopDir = new File(AsterixEventService.getEventHome() + File.separator + "hadoop-" + hadoopVersion);
if (!hadoopDir.exists()) {
throw new IllegalStateException("Hadoop version :" + hadoopVersion + " not supported");
}
Nodeid nodeid = new Nodeid(new Value(null, EventDriver.CLIENT_NODE.getId()));
String username = cluster.getUsername() != null ? cluster.getUsername() : System.getProperty("user.name");
String pargs = username + " " + hadoopDir.getAbsolutePath() + " " + cluster.getMasterNode().getClusterIp() + " " + workingDir;
Event event = new Event("directory_transfer", nodeid, pargs);
Pattern p = new Pattern(null, 1, null, event);
addInitialDelay(p, 2, "sec");
ps.add(p);
nodeid = new Nodeid(new Value(null, nodeToBeAdded.getId()));
pargs = cluster.getUsername() + " " + hadoopDir.getAbsolutePath() + " " + nodeToBeAdded.getClusterIp() + " " + workingDir;
event = new Event("directory_transfer", nodeid, pargs);
p = new Pattern(null, 1, null, event);
addInitialDelay(p, 2, "sec");
ps.add(p);
}
return new Patterns(ps);
}
use of org.apache.asterix.event.schema.pattern.Value in project asterixdb by apache.
the class PatternCreator method addInitialDelay.
private void addInitialDelay(Pattern p, int delay, String unit) {
Delay d = new Delay(new Value(null, Integer.toString(delay)), unit);
p.setDelay(d);
}
use of org.apache.asterix.event.schema.pattern.Value in project asterixdb by apache.
the class PatternCreator method createNCStopPattern.
public Pattern createNCStopPattern(String hostId, String nodeControllerId) {
Nodeid nodeid = new Nodeid(new Value(null, hostId));
Event event = new Event("node_failure", nodeid, nodeControllerId);
return new Pattern(null, 1, null, event);
}
use of org.apache.asterix.event.schema.pattern.Value 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);
}
use of org.apache.asterix.event.schema.pattern.Value 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);
}
Aggregations