Search in sources :

Example 41 with Node

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();
}
Also used : Marshaller(javax.xml.bind.Marshaller) AsterixConfiguration(org.apache.asterix.common.configuration.AsterixConfiguration) TransactionLogDir(org.apache.asterix.common.configuration.TransactionLogDir) Node(org.apache.asterix.event.schema.cluster.Node) ArrayList(java.util.ArrayList) Cluster(org.apache.asterix.event.schema.cluster.Cluster) Store(org.apache.asterix.common.configuration.Store) JAXBContext(javax.xml.bind.JAXBContext) FileOutputStream(java.io.FileOutputStream) Coredump(org.apache.asterix.common.configuration.Coredump) JarFile(java.util.jar.JarFile) File(java.io.File)

Example 42 with Node

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;
}
Also used : Node(org.apache.asterix.event.schema.cluster.Node)

Example 43 with Node

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);
}
Also used : Pattern(org.apache.asterix.event.schema.pattern.Pattern) Marshaller(javax.xml.bind.Marshaller) FileOutputStream(java.io.FileOutputStream) Node(org.apache.asterix.event.schema.cluster.Node) Nodeid(org.apache.asterix.event.schema.pattern.Nodeid) Value(org.apache.asterix.event.schema.pattern.Value) ArrayList(java.util.ArrayList) JAXBContext(javax.xml.bind.JAXBContext) File(java.io.File) Patterns(org.apache.asterix.event.schema.pattern.Patterns)

Aggregations

Node (org.apache.asterix.event.schema.cluster.Node)43 ArrayList (java.util.ArrayList)29 Pattern (org.apache.asterix.event.schema.pattern.Pattern)21 Patterns (org.apache.asterix.event.schema.pattern.Patterns)21 Cluster (org.apache.asterix.event.schema.cluster.Cluster)20 Nodeid (org.apache.asterix.event.schema.pattern.Nodeid)16 Value (org.apache.asterix.event.schema.pattern.Value)16 Event (org.apache.asterix.event.schema.pattern.Event)15 File (java.io.File)5 HashSet (java.util.HashSet)5 AsterixInstance (org.apache.asterix.event.model.AsterixInstance)5 FileOutputStream (java.io.FileOutputStream)3 JAXBContext (javax.xml.bind.JAXBContext)3 Marshaller (javax.xml.bind.Marshaller)3 AsterixEventServiceClient (org.apache.asterix.event.management.AsterixEventServiceClient)3 AsterixRuntimeState (org.apache.asterix.event.model.AsterixRuntimeState)3 ProcessInfo (org.apache.asterix.event.model.ProcessInfo)3 Date (java.util.Date)2 IClusterManagementWork (org.apache.asterix.common.api.IClusterManagementWork)2 AsterixException (org.apache.asterix.common.exceptions.AsterixException)2