Search in sources :

Example 1 with NCMessageBroker

use of org.apache.asterix.messaging.NCMessageBroker in project asterixdb by apache.

the class NCApplication method start.

@Override
public void start(IServiceContext serviceCtx, String[] args) throws Exception {
    if (args.length > 0) {
        throw new IllegalArgumentException("Unrecognized argument(s): " + Arrays.toString(args));
    }
    this.ncServiceCtx = (INCServiceContext) serviceCtx;
    ncServiceCtx.setThreadFactory(new AsterixThreadFactory(ncServiceCtx.getThreadFactory(), ncServiceCtx.getLifeCycleComponentManager()));
    nodeId = this.ncServiceCtx.getNodeId();
    if (LOGGER.isLoggable(Level.INFO)) {
        LOGGER.info("Starting Asterix node controller: " + nodeId);
    }
    configureLoggingLevel(ncServiceCtx.getAppConfig().getLoggingLevel(ExternalProperties.Option.LOG_LEVEL));
    final NodeControllerService controllerService = (NodeControllerService) ncServiceCtx.getControllerService();
    if (System.getProperty("java.rmi.server.hostname") == null) {
        System.setProperty("java.rmi.server.hostname", (controllerService).getConfiguration().getClusterPublicAddress());
    }
    runtimeContext = new NCAppRuntimeContext(this.ncServiceCtx, getExtensions());
    MetadataProperties metadataProperties = runtimeContext.getMetadataProperties();
    if (!metadataProperties.getNodeNames().contains(this.ncServiceCtx.getNodeId())) {
        if (LOGGER.isLoggable(Level.INFO)) {
            LOGGER.info("Substitute node joining : " + this.ncServiceCtx.getNodeId());
        }
        updateOnNodeJoin();
    }
    runtimeContext.initialize(runtimeContext.getNodeProperties().isInitialRun());
    MessagingProperties messagingProperties = runtimeContext.getMessagingProperties();
    IMessageBroker messageBroker = new NCMessageBroker(controllerService, messagingProperties);
    this.ncServiceCtx.setMessageBroker(messageBroker);
    MessagingChannelInterfaceFactory interfaceFactory = new MessagingChannelInterfaceFactory((NCMessageBroker) messageBroker, messagingProperties);
    this.ncServiceCtx.setMessagingChannelInterfaceFactory(interfaceFactory);
    IRecoveryManager recoveryMgr = runtimeContext.getTransactionSubsystem().getRecoveryManager();
    systemState = recoveryMgr.getSystemState();
    if (systemState == SystemState.PERMANENT_DATA_LOSS) {
        if (LOGGER.isLoggable(Level.INFO)) {
            LOGGER.info("System state: " + SystemState.PERMANENT_DATA_LOSS);
            LOGGER.info("Node ID: " + nodeId);
            LOGGER.info("Stores: " + PrintUtil.toString(metadataProperties.getStores()));
            LOGGER.info("Root Metadata Store: " + metadataProperties.getStores().get(nodeId)[0]);
        }
        PersistentLocalResourceRepository localResourceRepository = (PersistentLocalResourceRepository) runtimeContext.getLocalResourceRepository();
        localResourceRepository.initializeNewUniverse(ClusterProperties.INSTANCE.getStorageDirectoryName());
    }
    webManager = new WebManager();
    performLocalCleanUp();
}
Also used : NodeControllerService(org.apache.hyracks.control.nc.NodeControllerService) PersistentLocalResourceRepository(org.apache.asterix.transaction.management.resource.PersistentLocalResourceRepository) MessagingChannelInterfaceFactory(org.apache.asterix.messaging.MessagingChannelInterfaceFactory) WebManager(org.apache.hyracks.http.server.WebManager) NCAppRuntimeContext(org.apache.asterix.app.nc.NCAppRuntimeContext) IMessageBroker(org.apache.hyracks.api.messages.IMessageBroker) MetadataProperties(org.apache.asterix.common.config.MetadataProperties) NCMessageBroker(org.apache.asterix.messaging.NCMessageBroker) AsterixThreadFactory(org.apache.asterix.common.api.AsterixThreadFactory) MessagingProperties(org.apache.asterix.common.config.MessagingProperties) IRecoveryManager(org.apache.asterix.common.transactions.IRecoveryManager)

Example 2 with NCMessageBroker

use of org.apache.asterix.messaging.NCMessageBroker in project asterixdb by apache.

the class ExecuteStatementResponseMessage method handle.

@Override
public void handle(INcApplicationContext appCtx) throws HyracksDataException, InterruptedException {
    NCMessageBroker mb = (NCMessageBroker) appCtx.getServiceContext().getMessageBroker();
    MessageFuture future = mb.deregisterMessageFuture(requestMessageId);
    if (future != null) {
        future.complete(this);
    }
}
Also used : MessageFuture(org.apache.asterix.common.messaging.api.MessageFuture) NCMessageBroker(org.apache.asterix.messaging.NCMessageBroker)

Aggregations

NCMessageBroker (org.apache.asterix.messaging.NCMessageBroker)2 NCAppRuntimeContext (org.apache.asterix.app.nc.NCAppRuntimeContext)1 AsterixThreadFactory (org.apache.asterix.common.api.AsterixThreadFactory)1 MessagingProperties (org.apache.asterix.common.config.MessagingProperties)1 MetadataProperties (org.apache.asterix.common.config.MetadataProperties)1 MessageFuture (org.apache.asterix.common.messaging.api.MessageFuture)1 IRecoveryManager (org.apache.asterix.common.transactions.IRecoveryManager)1 MessagingChannelInterfaceFactory (org.apache.asterix.messaging.MessagingChannelInterfaceFactory)1 PersistentLocalResourceRepository (org.apache.asterix.transaction.management.resource.PersistentLocalResourceRepository)1 IMessageBroker (org.apache.hyracks.api.messages.IMessageBroker)1 NodeControllerService (org.apache.hyracks.control.nc.NodeControllerService)1 WebManager (org.apache.hyracks.http.server.WebManager)1