use of org.apache.asterix.event.schema.cluster.Node 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();
}
use of org.apache.asterix.event.schema.cluster.Node in project asterixdb by apache.
the class Replica method create.
public static Replica create(DataInput input) throws IOException {
Node node = new Node();
Replica replica = new Replica(node);
replica.readFields(input);
return replica;
}
use of org.apache.asterix.event.schema.cluster.Node 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);
}
Aggregations