Search in sources :

Example 6 with INCMessageBroker

use of org.apache.asterix.common.messaging.api.INCMessageBroker in project asterixdb by apache.

the class StartupTaskResponseMessage method handle.

@Override
public void handle(INcApplicationContext appCtx) throws HyracksDataException, InterruptedException {
    INCMessageBroker broker = (INCMessageBroker) appCtx.getServiceContext().getMessageBroker();
    IControllerService cs = appCtx.getServiceContext().getControllerService();
    boolean success = true;
    HyracksDataException exception = null;
    try {
        for (INCLifecycleTask task : tasks) {
            task.perform(cs);
        }
    } catch (HyracksDataException e) {
        success = false;
        exception = e;
    }
    NCLifecycleTaskReportMessage result = new NCLifecycleTaskReportMessage(nodeId, success);
    result.setException(exception);
    try {
        broker.sendMessageToCC(result);
    } catch (Exception e) {
        LOGGER.log(Level.SEVERE, "Failed sending message to cc", e);
        throw HyracksDataException.create(e);
    }
}
Also used : INCLifecycleTask(org.apache.asterix.common.api.INCLifecycleTask) INCMessageBroker(org.apache.asterix.common.messaging.api.INCMessageBroker) IControllerService(org.apache.hyracks.api.service.IControllerService) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Example 7 with INCMessageBroker

use of org.apache.asterix.common.messaging.api.INCMessageBroker in project asterixdb by apache.

the class TakeoverMetadataNodeRequestMessage method handle.

@Override
public void handle(INcApplicationContext appContext) throws HyracksDataException, InterruptedException {
    INCMessageBroker broker = (INCMessageBroker) appContext.getServiceContext().getMessageBroker();
    HyracksDataException hde = null;
    try {
        appContext.initializeMetadata(false);
        appContext.exportMetadataNodeStub();
    } catch (Exception e) {
        LOGGER.log(Level.SEVERE, "Failed taking over metadata", e);
        hde = HyracksDataException.create(e);
    } finally {
        TakeoverMetadataNodeResponseMessage reponse = new TakeoverMetadataNodeResponseMessage(appContext.getTransactionSubsystem().getId());
        try {
            broker.sendMessageToCC(reponse);
        } catch (Exception e) {
            LOGGER.log(Level.SEVERE, "Failed taking over metadata", e);
            hde = HyracksDataException.suppress(hde, e);
        }
    }
    if (hde != null) {
        throw hde;
    }
}
Also used : INCMessageBroker(org.apache.asterix.common.messaging.api.INCMessageBroker) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Example 8 with INCMessageBroker

use of org.apache.asterix.common.messaging.api.INCMessageBroker in project asterixdb by apache.

the class TakeoverPartitionsRequestMessage method handle.

@Override
public void handle(INcApplicationContext appContext) throws HyracksDataException, InterruptedException {
    INCMessageBroker broker = (INCMessageBroker) appContext.getServiceContext().getMessageBroker();
    //if the NC is shutting down, it should ignore takeover partitions request
    if (!appContext.isShuttingdown()) {
        HyracksDataException hde = null;
        try {
            IRemoteRecoveryManager remoteRecoeryManager = appContext.getRemoteRecoveryManager();
            remoteRecoeryManager.takeoverPartitons(partitions);
        } catch (IOException | ACIDException e) {
            LOGGER.log(Level.SEVERE, "Failure taking over partitions", e);
            hde = HyracksDataException.suppress(hde, e);
        } finally {
            //send response after takeover is completed
            TakeoverPartitionsResponseMessage reponse = new TakeoverPartitionsResponseMessage(requestId, appContext.getTransactionSubsystem().getId(), partitions);
            try {
                broker.sendMessageToCC(reponse);
            } catch (Exception e) {
                LOGGER.log(Level.SEVERE, "Failure taking over partitions", e);
                hde = HyracksDataException.suppress(hde, e);
            }
        }
        if (hde != null) {
            throw hde;
        }
    }
}
Also used : IOException(java.io.IOException) INCMessageBroker(org.apache.asterix.common.messaging.api.INCMessageBroker) IRemoteRecoveryManager(org.apache.asterix.common.replication.IRemoteRecoveryManager) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) ACIDException(org.apache.asterix.common.exceptions.ACIDException) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) IOException(java.io.IOException) ACIDException(org.apache.asterix.common.exceptions.ACIDException)

Example 9 with INCMessageBroker

use of org.apache.asterix.common.messaging.api.INCMessageBroker in project asterixdb by apache.

the class ReportMaxResourceIdMessage method send.

public static void send(NodeControllerService cs) throws HyracksDataException {
    NodeControllerService ncs = cs;
    INcApplicationContext appContext = (INcApplicationContext) ncs.getApplicationContext();
    long maxResourceId = Math.max(appContext.getLocalResourceRepository().maxId(), MetadataIndexImmutableProperties.FIRST_AVAILABLE_USER_DATASET_ID);
    ReportMaxResourceIdMessage maxResourceIdMsg = new ReportMaxResourceIdMessage(ncs.getId(), maxResourceId);
    try {
        ((INCMessageBroker) ncs.getContext().getMessageBroker()).sendMessageToCC(maxResourceIdMsg);
    } catch (Exception e) {
        LOGGER.log(Level.SEVERE, "Unable to report max local resource id", e);
        throw HyracksDataException.create(e);
    }
}
Also used : NodeControllerService(org.apache.hyracks.control.nc.NodeControllerService) INcApplicationContext(org.apache.asterix.common.api.INcApplicationContext) INCMessageBroker(org.apache.asterix.common.messaging.api.INCMessageBroker) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Aggregations

INCMessageBroker (org.apache.asterix.common.messaging.api.INCMessageBroker)9 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)8 IOException (java.io.IOException)2 IRemoteRecoveryManager (org.apache.asterix.common.replication.IRemoteRecoveryManager)2 NodeControllerService (org.apache.hyracks.control.nc.NodeControllerService)2 RemoteException (java.rmi.RemoteException)1 ExecuteStatementRequestMessage (org.apache.asterix.app.message.ExecuteStatementRequestMessage)1 ExecuteStatementResponseMessage (org.apache.asterix.app.message.ExecuteStatementResponseMessage)1 ResultReader (org.apache.asterix.app.result.ResultReader)1 INCLifecycleTask (org.apache.asterix.common.api.INCLifecycleTask)1 INcApplicationContext (org.apache.asterix.common.api.INcApplicationContext)1 ACIDException (org.apache.asterix.common.exceptions.ACIDException)1 MessageFuture (org.apache.asterix.common.messaging.api.MessageFuture)1 ARecordType (org.apache.asterix.om.types.ARecordType)1 ResourceIdRequestMessage (org.apache.asterix.runtime.message.ResourceIdRequestMessage)1 ResourceIdRequestResponseMessage (org.apache.asterix.runtime.message.ResourceIdRequestResponseMessage)1 PersistentLocalResourceRepository (org.apache.asterix.transaction.management.resource.PersistentLocalResourceRepository)1 IStatementExecutor (org.apache.asterix.translator.IStatementExecutor)1 INCServiceContext (org.apache.hyracks.api.application.INCServiceContext)1 ResultSetId (org.apache.hyracks.api.dataset.ResultSetId)1