use of org.apache.asterix.event.schema.cluster.Node in project asterixdb by apache.
the class EventDriver method cleanup.
private static void cleanup(Cluster cluster) throws IOException, InterruptedException {
List<String> args = new ArrayList<String>();
args.add(scriptDirSuffix);
Node clientNode = new Node();
clientNode.setId("client");
clientNode.setClusterIp(CLUSTER_IP);
for (Node node : cluster.getNode()) {
args.add(node.getClusterIp());
}
EventUtil.executeLocalScript(clientNode, eventsDir + "/" + "events" + "/" + "cleanup.sh", args);
}
use of org.apache.asterix.event.schema.cluster.Node in project asterixdb by apache.
the class PatternCreator method getHDFSBackUpAsterixPattern.
private Patterns getHDFSBackUpAsterixPattern(AsterixInstance instance, Backup backupConf) throws Exception {
Cluster cluster = instance.getCluster();
String hdfsUrl = backupConf.getHdfs().getUrl();
String hadoopVersion = backupConf.getHdfs().getVersion();
String hdfsBackupDir = backupConf.getBackupDir();
VerificationUtil.verifyBackupRestoreConfiguration(hdfsUrl, hadoopVersion, hdfsBackupDir);
String workingDir = cluster.getWorkingDir().getDir();
String backupId = Integer.toString(instance.getBackupInfo().size());
String store;
String pargs;
String iodevices;
store = cluster.getStore();
List<Pattern> patternList = new ArrayList<>();
for (Node node : cluster.getNode()) {
Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
iodevices = node.getIodevices() == null ? instance.getCluster().getIodevices() : node.getIodevices();
pargs = workingDir + " " + instance.getName() + " " + iodevices + " " + store + " " + StorageConstants.METADATA_ROOT + " " + AsterixEventServiceUtil.TXN_LOG_DIR + " " + backupId + " " + hdfsBackupDir + " " + "hdfs" + " " + node.getId() + " " + hdfsUrl + " " + hadoopVersion;
Event event = new Event("backup", nodeid, pargs);
patternList.add(new Pattern(null, 1, null, event));
}
return new Patterns(patternList);
}
use of org.apache.asterix.event.schema.cluster.Node in project asterixdb by apache.
the class PatternCreator method getHDFSRestoreAsterixPattern.
public Patterns getHDFSRestoreAsterixPattern(AsterixInstance instance, BackupInfo backupInfo) throws Exception {
Cluster cluster = instance.getCluster();
String clusterStore = instance.getCluster().getStore();
String hdfsUrl = backupInfo.getBackupConf().getHdfs().getUrl();
String hadoopVersion = backupInfo.getBackupConf().getHdfs().getVersion();
String hdfsBackupDir = backupInfo.getBackupConf().getBackupDir();
VerificationUtil.verifyBackupRestoreConfiguration(hdfsUrl, hadoopVersion, hdfsBackupDir);
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 + " " + " " + hdfsBackupDir + " " + "hdfs" + " " + node.getId() + " " + hdfsUrl + " " + hadoopVersion;
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.cluster.Node 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.cluster.Node in project asterixdb by apache.
the class AsterixEventServiceUtil method evaluateConflictWithOtherInstances.
public static void evaluateConflictWithOtherInstances(AsterixInstance instance) throws Exception {
List<AsterixInstance> existingInstances = ServiceProvider.INSTANCE.getLookupService().getAsterixInstances();
List<String> usedIps = new ArrayList<String>();
String masterIp = instance.getCluster().getMasterNode().getClusterIp();
for (Node node : instance.getCluster().getNode()) {
usedIps.add(node.getClusterIp());
}
usedIps.add(instance.getCluster().getMasterNode().getClusterIp());
boolean conflictFound = false;
AsterixInstance conflictingInstance = null;
for (AsterixInstance existing : existingInstances) {
if (existing.getState().equals(State.INACTIVE)) {
continue;
}
InetAddress extantAddress = InetAddress.getByName(existing.getCluster().getMasterNode().getClusterIp());
InetAddress masterAddress = InetAddress.getByName(masterIp);
if (extantAddress.equals(masterAddress)) {
conflictingInstance = existing;
break;
}
for (Node n : existing.getCluster().getNode()) {
if (usedIps.contains(n.getClusterIp())) {
conflictFound = true;
conflictingInstance = existing;
break;
}
}
}
if (conflictFound) {
throw new Exception("Cluster definition conflicts with an existing instance of Asterix: " + conflictingInstance.getName());
}
}
Aggregations