Search in sources :

Example 1 with IRemoteRecoveryManager

use of org.apache.asterix.common.replication.IRemoteRecoveryManager in project asterixdb by apache.

the class CompleteFailbackRequestMessage method handle.

@Override
public void handle(INcApplicationContext appContext) throws HyracksDataException, InterruptedException {
    INCMessageBroker broker = (INCMessageBroker) appContext.getServiceContext().getMessageBroker();
    HyracksDataException hde = null;
    try {
        IRemoteRecoveryManager remoteRecoeryManager = appContext.getRemoteRecoveryManager();
        remoteRecoeryManager.completeFailbackProcess();
    } catch (IOException | InterruptedException e) {
        LOGGER.log(Level.SEVERE, "Failure during completion of failback process", e);
        hde = HyracksDataException.create(e);
    } finally {
        CompleteFailbackResponseMessage reponse = new CompleteFailbackResponseMessage(planId, requestId, partitions);
        try {
            broker.sendMessageToCC(reponse);
        } catch (Exception e) {
            LOGGER.log(Level.SEVERE, "Failure sending message to CC", 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) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) IOException(java.io.IOException)

Example 2 with IRemoteRecoveryManager

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

Aggregations

IOException (java.io.IOException)2 INCMessageBroker (org.apache.asterix.common.messaging.api.INCMessageBroker)2 IRemoteRecoveryManager (org.apache.asterix.common.replication.IRemoteRecoveryManager)2 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)2 ACIDException (org.apache.asterix.common.exceptions.ACIDException)1