Search in sources :

Example 6 with MetadataProperties

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

the class StartLifecycleComponentsTask method perform.

@Override
public void perform(IControllerService cs) throws HyracksDataException {
    INcApplicationContext applicationContext = (INcApplicationContext) cs.getApplicationContext();
    NCServiceContext serviceCtx = (NCServiceContext) cs.getContext();
    MetadataProperties metadataProperties = applicationContext.getMetadataProperties();
    if (LOGGER.isLoggable(Level.INFO)) {
        LOGGER.info("Starting lifecycle components");
    }
    Map<String, String> lifecycleMgmtConfiguration = new HashMap<>();
    String dumpPathKey = LifeCycleComponentManager.Config.DUMP_PATH_KEY;
    String dumpPath = metadataProperties.getCoredumpPath(serviceCtx.getNodeId());
    lifecycleMgmtConfiguration.put(dumpPathKey, dumpPath);
    if (LOGGER.isLoggable(Level.INFO)) {
        LOGGER.info("Coredump directory for NC is: " + dumpPath);
    }
    ILifeCycleComponentManager lccm = serviceCtx.getLifeCycleComponentManager();
    lccm.configure(lifecycleMgmtConfiguration);
    if (LOGGER.isLoggable(Level.INFO)) {
        LOGGER.info("Configured:" + lccm);
    }
    serviceCtx.setStateDumpHandler(new AsterixStateDumpHandler(serviceCtx.getNodeId(), lccm.getDumpPath(), lccm));
    lccm.startAll();
}
Also used : INcApplicationContext(org.apache.asterix.common.api.INcApplicationContext) NCServiceContext(org.apache.hyracks.control.nc.application.NCServiceContext) HashMap(java.util.HashMap) ILifeCycleComponentManager(org.apache.hyracks.api.lifecycle.ILifeCycleComponentManager) AsterixStateDumpHandler(org.apache.asterix.hyracks.bootstrap.AsterixStateDumpHandler) MetadataProperties(org.apache.asterix.common.config.MetadataProperties)

Example 7 with MetadataProperties

use of org.apache.asterix.common.config.MetadataProperties 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)7 AsterixThreadFactory (org.apache.asterix.common.api.AsterixThreadFactory)2 PersistentLocalResourceRepository (org.apache.asterix.transaction.management.resource.PersistentLocalResourceRepository)2 NodeControllerService (org.apache.hyracks.control.nc.NodeControllerService)2 WebManager (org.apache.hyracks.http.server.WebManager)2 RemoteException (java.rmi.RemoteException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 ActiveLifecycleListener (org.apache.asterix.active.ActiveLifecycleListener)1 StatementExecutorContext (org.apache.asterix.api.http.ctx.StatementExecutorContext)1 CCExtensionManager (org.apache.asterix.app.cc.CCExtensionManager)1 ResourceIdManager (org.apache.asterix.app.cc.ResourceIdManager)1 NCAppRuntimeContext (org.apache.asterix.app.nc.NCAppRuntimeContext)1 IApplicationContext (org.apache.asterix.common.api.IApplicationContext)1 INcApplicationContext (org.apache.asterix.common.api.INcApplicationContext)1 ClusterPartition (org.apache.asterix.common.cluster.ClusterPartition)1 MessagingProperties (org.apache.asterix.common.config.MessagingProperties)1 TransactionProperties (org.apache.asterix.common.config.TransactionProperties)1 IStorageComponentProvider (org.apache.asterix.common.context.IStorageComponentProvider)1 ACIDException (org.apache.asterix.common.exceptions.ACIDException)1