Search in sources :

Example 1 with WorkingDir

use of org.apache.asterix.event.schema.cluster.WorkingDir in project asterixdb by apache.

the class ConfigureConfig method configureCluster.

private void configureCluster(String dir, String file) throws JAXBException, PropertyException, FileNotFoundException {
    String clusterDir = InstallerDriver.getManagixHome() + File.separator + "clusters" + File.separator + dir;
    String localClusterPath = clusterDir + File.separator + file;
    if (!Files.exists(Paths.get(localClusterPath))) {
        return;
    }
    Cluster cluster = EventUtil.getCluster(localClusterPath);
    String workingDir = clusterDir + File.separator + "working_dir";
    cluster.setWorkingDir(new WorkingDir(workingDir, true));
    cluster.setIodevices(configureIoDevices(cluster.getIodevices(), workingDir));
    cluster.setLogDir(configureDirectory(cluster.getLogDir(), workingDir));
    cluster.setTxnLogDir(configureDirectory(cluster.getTxnLogDir(), workingDir));
    String javaHome = System.getProperty("java.home");
    if (javaHome.endsWith(File.separator + "jre")) {
        javaHome = javaHome.substring(0, javaHome.indexOf(File.separator + "jre"));
    }
    cluster.setJavaHome(javaHome);
    for (Node node : cluster.getNode()) {
        node.setIodevices(configureIoDevices(node.getIodevices(), workingDir));
        node.setLogDir(configureDirectory(node.getLogDir(), workingDir));
        node.setTxnLogDir(configureDirectory(node.getTxnLogDir(), workingDir));
    }
    JAXBContext ctx = JAXBContext.newInstance(Cluster.class);
    Marshaller marshaller = ctx.createMarshaller();
    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
    marshaller.marshal(cluster, new FileOutputStream(localClusterPath));
}
Also used : WorkingDir(org.apache.asterix.event.schema.cluster.WorkingDir) Marshaller(javax.xml.bind.Marshaller) Node(org.apache.asterix.event.schema.cluster.Node) FileOutputStream(java.io.FileOutputStream) Cluster(org.apache.asterix.event.schema.cluster.Cluster) JAXBContext(javax.xml.bind.JAXBContext)

Aggregations

FileOutputStream (java.io.FileOutputStream)1 JAXBContext (javax.xml.bind.JAXBContext)1 Marshaller (javax.xml.bind.Marshaller)1 Cluster (org.apache.asterix.event.schema.cluster.Cluster)1 Node (org.apache.asterix.event.schema.cluster.Node)1 WorkingDir (org.apache.asterix.event.schema.cluster.WorkingDir)1