use of org.apache.asterix.event.schema.cluster.Cluster in project asterixdb by apache.
the class PatternCreator method createRemoveAsterixWorkingDirPattern.
public Patterns createRemoveAsterixWorkingDirPattern(AsterixInstance instance) throws Exception {
List<Pattern> patternList = new ArrayList<>();
Cluster cluster = instance.getCluster();
String workingDir = cluster.getWorkingDir().getDir();
String pargs = workingDir;
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));
if (!cluster.getWorkingDir().isNFS()) {
for (Node node : cluster.getNode()) {
nodeid = new Nodeid(new Value(null, node.getId()));
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.cluster.Cluster in project asterixdb by apache.
the class PatternCreator method getLocalBackUpAsterixPattern.
private Patterns getLocalBackUpAsterixPattern(AsterixInstance instance, Backup backupConf) throws Exception {
Cluster cluster = instance.getCluster();
String backupDir = backupConf.getBackupDir();
String workingDir = cluster.getWorkingDir().getDir();
String backupId = Integer.toString(instance.getBackupInfo().size());
String iodevices;
String txnLogDir;
String store;
String pargs;
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();
txnLogDir = node.getTxnLogDir() == null ? instance.getCluster().getTxnLogDir() : node.getTxnLogDir();
pargs = workingDir + " " + instance.getName() + " " + iodevices + " " + store + " " + StorageConstants.METADATA_ROOT + " " + txnLogDir + " " + backupId + " " + backupDir + " " + "local" + " " + node.getId();
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.Cluster in project asterixdb by apache.
the class PatternCreator method createRemoveLocalBackupPattern.
private Patterns createRemoveLocalBackupPattern(AsterixInstance instance, String localBackupDir) throws Exception {
List<Pattern> patternList = new ArrayList<>();
Cluster cluster = instance.getCluster();
String pathToDelete = localBackupDir + File.separator + instance.getName();
String pargs = pathToDelete;
List<String> removedBackupDirs = new ArrayList<>();
for (Node node : cluster.getNode()) {
if (removedBackupDirs.contains(node.getClusterIp())) {
continue;
}
Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
Event event = new Event("file_delete", nodeid, pargs);
patternList.add(new Pattern(null, 1, null, event));
removedBackupDirs.add(node.getClusterIp());
}
return new Patterns(patternList);
}
use of org.apache.asterix.event.schema.cluster.Cluster in project asterixdb by apache.
the class AsterixEventServiceUtil method writeAsterixClusterConfigurationFile.
private static void writeAsterixClusterConfigurationFile(AsterixInstance asterixInstance) throws IOException, EventException, JAXBException {
String asterixInstanceName = asterixInstance.getName();
Cluster cluster = asterixInstance.getCluster();
JAXBContext ctx = JAXBContext.newInstance(Cluster.class);
Marshaller marshaller = ctx.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(cluster, new FileOutputStream(AsterixEventService.getAsterixDir() + File.separator + asterixInstanceName + File.separator + "cluster.xml"));
}
use of org.apache.asterix.event.schema.cluster.Cluster in project asterixdb by apache.
the class AsterixEventServiceUtil method writeAsterixConfigurationFile.
private static void writeAsterixConfigurationFile(AsterixInstance asterixInstance) throws IOException, JAXBException {
String asterixInstanceName = asterixInstance.getName();
Cluster cluster = asterixInstance.getCluster();
String metadataNodeId = asterixInstance.getMetadataNodeId();
AsterixConfiguration configuration = asterixInstance.getAsterixConfiguration();
configuration.setInstanceName(asterixInstanceName);
configuration.setMetadataNode(asterixInstanceName + "_" + metadataNodeId);
List<Store> stores = new ArrayList<Store>();
String storeDir = cluster.getStore().trim();
for (Node node : cluster.getNode()) {
String iodevices = node.getIodevices() == null ? cluster.getIodevices() : node.getIodevices();
String[] nodeIdDevice = iodevices.split(",");
StringBuilder nodeStores = new StringBuilder();
for (int i = 0; i < nodeIdDevice.length; i++) {
nodeStores.append(nodeIdDevice[i] + File.separator + storeDir + ",");
}
//remove last comma
nodeStores.deleteCharAt(nodeStores.length() - 1);
stores.add(new Store(asterixInstanceName + "_" + node.getId(), nodeStores.toString()));
}
configuration.setStore(stores);
List<Coredump> coredump = new ArrayList<Coredump>();
List<TransactionLogDir> txnLogDirs = new ArrayList<TransactionLogDir>();
for (Node node : cluster.getNode()) {
String coredumpdir = node.getLogDir() == null ? cluster.getLogDir() : node.getLogDir();
coredump.add(new Coredump(asterixInstanceName + "_" + node.getId(), coredumpdir + File.separator + asterixInstanceName + "_" + node.getId()));
String txnLogDir = node.getTxnLogDir() == null ? cluster.getTxnLogDir() : node.getTxnLogDir();
txnLogDirs.add(new TransactionLogDir(asterixInstanceName + "_" + node.getId(), txnLogDir));
}
configuration.setCoredump(coredump);
configuration.setTransactionLogDir(txnLogDirs);
File asterixConfDir = new File(AsterixEventService.getAsterixDir() + File.separator + asterixInstanceName);
asterixConfDir.mkdirs();
JAXBContext ctx = JAXBContext.newInstance(AsterixConfiguration.class);
Marshaller marshaller = ctx.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
FileOutputStream os = new FileOutputStream(asterixConfDir + File.separator + ASTERIX_CONFIGURATION_FILE);
marshaller.marshal(configuration, os);
os.close();
}
Aggregations