use of org.apache.asterix.event.schema.pattern.Patterns in project asterixdb by apache.
the class PatternCreator method getLocalRestoreAsterixPattern.
public Patterns getLocalRestoreAsterixPattern(AsterixInstance instance, BackupInfo backupInfo) throws Exception {
Cluster cluster = instance.getCluster();
String clusterStore = instance.getCluster().getStore();
String backupDir = backupInfo.getBackupConf().getBackupDir();
String workingDir = cluster.getWorkingDir().getDir();
int backupId = backupInfo.getId();
String pargs;
List<Pattern> patternList = new ArrayList<>();
for (Node node : cluster.getNode()) {
Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
String iodevices = node.getIodevices() == null ? cluster.getIodevices() : node.getIodevices();
pargs = workingDir + " " + instance.getName() + " " + iodevices + " " + clusterStore + " " + StorageConstants.METADATA_ROOT + " " + AsterixEventServiceUtil.TXN_LOG_DIR + " " + backupId + " " + backupDir + " " + "local" + " " + node.getId();
Event event = new Event("restore", nodeid, pargs);
patternList.add(new Pattern(null, 1, null, event));
}
return new Patterns(patternList);
}
use of org.apache.asterix.event.schema.pattern.Patterns in project asterixdb by apache.
the class PatternCreator method getStartAsterixPattern.
public Patterns getStartAsterixPattern(String asterixInstanceName, Cluster cluster, boolean createCommand) throws Exception {
String ccLocationId = cluster.getMasterNode().getId();
List<Pattern> ps = new ArrayList<>();
Pattern createCC = createCCStartPattern(ccLocationId);
addInitialDelay(createCC, 3, "sec");
ps.add(createCC);
for (Node node : cluster.getNode()) {
String iodevices = node.getIodevices() == null ? cluster.getIodevices() : node.getIodevices();
Pattern createNC = createNCStartPattern(cluster.getMasterNode().getClusterIp(), node.getId(), asterixInstanceName + "_" + node.getId(), iodevices, createCommand);
addInitialDelay(createNC, 5, "sec");
ps.add(createNC);
}
return new Patterns(ps);
}
use of org.apache.asterix.event.schema.pattern.Patterns in project asterixdb by apache.
the class PatternCreator method getBackUpAsterixPattern.
public Patterns getBackUpAsterixPattern(AsterixInstance instance, Backup backupConf) throws Exception {
BackupType backupType = BackupInfo.getBackupType(backupConf);
Patterns patterns = null;
switch(backupType) {
case HDFS:
patterns = getHDFSBackUpAsterixPattern(instance, backupConf);
break;
case LOCAL:
patterns = getLocalBackUpAsterixPattern(instance, backupConf);
break;
}
return patterns;
}
use of org.apache.asterix.event.schema.pattern.Patterns 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.Patterns 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);
}
Aggregations