use of org.apache.asterix.app.replication.message.ReplayPartitionLogsRequestMessage in project asterixdb by apache.
the class MetadataNodeFaultToleranceStrategy method notifyNodeFailure.
@Override
public synchronized void notifyNodeFailure(String nodeId) throws HyracksDataException {
failedNodes.add(nodeId);
hotStandbyMetadataReplica.remove(nodeId);
clusterManager.updateNodePartitions(nodeId, false);
if (nodeId.equals(metadataNodeId)) {
clusterManager.updateMetadataNode(metadataNodeId, false);
}
clusterManager.refreshState();
if (replicationStrategy.isParticipant(nodeId)) {
// Notify impacted replica
FaultToleranceUtil.notifyImpactedReplicas(nodeId, ClusterEventType.NODE_FAILURE, clusterManager, messageBroker, replicationStrategy);
}
// If the failed node is the metadata node, ask its replicas to replay any committed jobs
if (nodeId.equals(metadataNodeId)) {
ICcApplicationContext appCtx = (ICcApplicationContext) serviceCtx.getApplicationContext();
int metadataPartitionId = appCtx.getMetadataProperties().getMetadataPartition().getPartitionId();
Set<Integer> metadataPartition = new HashSet<>(Arrays.asList(metadataPartitionId));
Set<Replica> activeRemoteReplicas = replicationStrategy.getRemoteReplicas(metadataNodeId).stream().filter(replica -> !failedNodes.contains(replica.getId())).collect(Collectors.toSet());
//TODO Do election to identity the node with latest state
for (Replica replica : activeRemoteReplicas) {
ReplayPartitionLogsRequestMessage msg = new ReplayPartitionLogsRequestMessage(metadataPartition);
try {
messageBroker.sendApplicationMessageToNC(msg, replica.getId());
} catch (Exception e) {
LOGGER.log(Level.WARNING, "Failed sending an application message to an NC", e);
continue;
}
}
}
}
Aggregations