Search in sources :

Example 1 with TakeoverMetadataNodeRequestMessage

use of org.apache.asterix.app.replication.message.TakeoverMetadataNodeRequestMessage in project asterixdb by apache.

the class AutoFaultToleranceStrategy method requestMetadataNodeTakeover.

private synchronized void requestMetadataNodeTakeover() {
    //need a new node to takeover metadata node
    ICcApplicationContext appCtx = (ICcApplicationContext) serviceCtx.getApplicationContext();
    ClusterPartition metadataPartiton = appCtx.getMetadataProperties().getMetadataPartition();
    //request the metadataPartition node to register itself as the metadata node
    TakeoverMetadataNodeRequestMessage takeoverRequest = new TakeoverMetadataNodeRequestMessage();
    try {
        messageBroker.sendApplicationMessageToNC(takeoverRequest, metadataPartiton.getActiveNodeId());
        // Since the metadata node will be changed, we need to rebind the proxy object
        MetadataManager.INSTANCE.rebindMetadataNode();
    } catch (Exception e) {
        /*
             * if we fail to send the request, it means the NC we tried to send the request to
             * has failed. When the failure notification arrives, a new NC will be assigned to
             * the metadata partition and a new metadata node takeover request will be sent to it.
             */
        LOGGER.log(Level.WARNING, "Failed to send metadata node takeover request to: " + metadataPartiton.getActiveNodeId(), e);
    }
}
Also used : ICcApplicationContext(org.apache.asterix.common.dataflow.ICcApplicationContext) TakeoverMetadataNodeRequestMessage(org.apache.asterix.app.replication.message.TakeoverMetadataNodeRequestMessage) RuntimeDataException(org.apache.asterix.common.exceptions.RuntimeDataException) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) ClusterPartition(org.apache.asterix.common.cluster.ClusterPartition)

Aggregations

TakeoverMetadataNodeRequestMessage (org.apache.asterix.app.replication.message.TakeoverMetadataNodeRequestMessage)1 ClusterPartition (org.apache.asterix.common.cluster.ClusterPartition)1 ICcApplicationContext (org.apache.asterix.common.dataflow.ICcApplicationContext)1 RuntimeDataException (org.apache.asterix.common.exceptions.RuntimeDataException)1 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)1