Search in sources :

Example 1 with IResourceIdManager

use of org.apache.asterix.common.transactions.IResourceIdManager 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)

Example 2 with IResourceIdManager

use of org.apache.asterix.common.transactions.IResourceIdManager in project asterixdb by apache.

the class ReportMaxResourceIdMessage method handle.

@Override
public void handle(ICcApplicationContext appCtx) throws HyracksDataException, InterruptedException {
    IResourceIdManager resourceIdManager = appCtx.getResourceIdManager();
    resourceIdManager.report(src, maxResourceId);
}
Also used : IResourceIdManager(org.apache.asterix.common.transactions.IResourceIdManager)

Aggregations

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