Search in sources :

Example 1 with TransactionProperties

use of org.apache.asterix.common.config.TransactionProperties in project asterixdb by apache.

the class NCApplication method updateOnNodeJoin.

private void updateOnNodeJoin() {
    MetadataProperties metadataProperties = runtimeContext.getMetadataProperties();
    if (!metadataProperties.getNodeNames().contains(nodeId)) {
        Cluster cluster = ClusterProperties.INSTANCE.getCluster();
        if (cluster == null) {
            throw new IllegalStateException("No cluster configuration found for this instance");
        }
        NCConfig ncConfig = ((NodeControllerService) ncServiceCtx.getControllerService()).getConfiguration();
        ncConfig.getConfigManager().registerVirtualNode(nodeId);
        String asterixInstanceName = metadataProperties.getInstanceName();
        TransactionProperties txnProperties = runtimeContext.getTransactionProperties();
        Node self = null;
        List<Node> nodes;
        if (cluster.getSubstituteNodes() != null) {
            nodes = cluster.getSubstituteNodes().getNode();
        } else {
            throw new IllegalStateException("Unknown node joining the cluster");
        }
        for (Node node : nodes) {
            String ncId = asterixInstanceName + "_" + node.getId();
            if (ncId.equalsIgnoreCase(nodeId)) {
                String storeDir = ClusterProperties.INSTANCE.getStorageDirectoryName();
                String nodeIoDevices = node.getIodevices() == null ? cluster.getIodevices() : node.getIodevices();
                String[] ioDevicePaths = nodeIoDevices.trim().split(",");
                for (int i = 0; i < ioDevicePaths.length; i++) {
                    // construct full store path
                    ioDevicePaths[i] += File.separator + storeDir;
                }
                metadataProperties.getStores().put(nodeId, ioDevicePaths);
                String coredumpPath = node.getLogDir() == null ? cluster.getLogDir() : node.getLogDir();
                metadataProperties.getCoredumpPaths().put(nodeId, coredumpPath);
                String txnLogDir = node.getTxnLogDir() == null ? cluster.getTxnLogDir() : node.getTxnLogDir();
                txnProperties.getLogDirectories().put(nodeId, txnLogDir);
                if (LOGGER.isLoggable(Level.INFO)) {
                    LOGGER.info("Store set to : " + storeDir);
                    LOGGER.info("Coredump dir set to : " + coredumpPath);
                    LOGGER.info("Transaction log dir set to :" + txnLogDir);
                }
                self = node;
                break;
            }
        }
        if (self != null) {
            cluster.getSubstituteNodes().getNode().remove(self);
            cluster.getNode().add(self);
        } else {
            throw new IllegalStateException("Unknown node joining the cluster");
        }
    }
}
Also used : NodeControllerService(org.apache.hyracks.control.nc.NodeControllerService) NCConfig(org.apache.hyracks.control.common.controllers.NCConfig) TransactionProperties(org.apache.asterix.common.config.TransactionProperties) Node(org.apache.asterix.event.schema.cluster.Node) Cluster(org.apache.asterix.event.schema.cluster.Cluster) MetadataProperties(org.apache.asterix.common.config.MetadataProperties)

Aggregations

MetadataProperties (org.apache.asterix.common.config.MetadataProperties)1 TransactionProperties (org.apache.asterix.common.config.TransactionProperties)1 Cluster (org.apache.asterix.event.schema.cluster.Cluster)1 Node (org.apache.asterix.event.schema.cluster.Node)1 NCConfig (org.apache.hyracks.control.common.controllers.NCConfig)1 NodeControllerService (org.apache.hyracks.control.nc.NodeControllerService)1