Search in sources :

Example 1 with ICCMessageBroker

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

the class FeedOperations method SendActiveMessage.

private static void SendActiveMessage(ICcApplicationContext appCtx, ActiveManagerMessage activeManagerMessage, String nodeId) throws Exception {
    ICCMessageBroker messageBroker = (ICCMessageBroker) appCtx.getServiceContext().getMessageBroker();
    messageBroker.sendApplicationMessageToNC(activeManagerMessage, nodeId);
}
Also used : ICCMessageBroker(org.apache.asterix.common.messaging.api.ICCMessageBroker)

Example 2 with ICCMessageBroker

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

the class ResourceIdRequestMessage method handle.

@Override
public void handle(ICcApplicationContext appCtx) throws HyracksDataException, InterruptedException {
    try {
        ICCMessageBroker broker = (ICCMessageBroker) appCtx.getServiceContext().getMessageBroker();
        ResourceIdRequestResponseMessage reponse = new ResourceIdRequestResponseMessage();
        if (!ClusterStateManager.INSTANCE.isClusterActive()) {
            reponse.setResourceId(-1);
            reponse.setException(new Exception("Cannot generate global resource id when cluster is not active."));
        } else {
            IResourceIdManager resourceIdManager = appCtx.getResourceIdManager();
            reponse.setResourceId(resourceIdManager.createResourceId());
            if (reponse.getResourceId() < 0) {
                reponse.setException(new Exception("One or more nodes has not reported max resource id."));
            }
            requestMaxResourceID(resourceIdManager, broker);
        }
        broker.sendApplicationMessageToNC(reponse, src);
    } catch (Exception e) {
        throw HyracksDataException.create(e);
    }
}
Also used : ICCMessageBroker(org.apache.asterix.common.messaging.api.ICCMessageBroker) IResourceIdManager(org.apache.asterix.common.transactions.IResourceIdManager) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Aggregations

ICCMessageBroker (org.apache.asterix.common.messaging.api.ICCMessageBroker)2 IResourceIdManager (org.apache.asterix.common.transactions.IResourceIdManager)1 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)1