Search in sources :

Example 1 with INCLifecycleTask

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

the class MetadataNodeFaultToleranceStrategy method buildParticipantStartupSequence.

private List<INCLifecycleTask> buildParticipantStartupSequence(String nodeId, SystemState state) {
    final List<INCLifecycleTask> tasks = new ArrayList<>();
    switch(state) {
        case PERMANENT_DATA_LOSS:
            // If the metadata node (or replica) failed and lost its data
            // => Metadata Remote Recovery from standby replica
            tasks.add(getMetadataPartitionRecoveryPlan());
            // Checkpoint after remote recovery to move node to HEALTHY state
            tasks.add(new CheckpointTask());
            break;
        case CORRUPTED:
            // If the metadata node (or replica) failed and started again without losing data => Local Recovery
            LocalRecoveryTask rt = new LocalRecoveryTask(Arrays.asList(clusterManager.getNodePartitions(nodeId)).stream().map(ClusterPartition::getPartitionId).collect(Collectors.toSet()));
            tasks.add(rt);
            break;
        case BOOTSTRAPPING:
        case HEALTHY:
        case RECOVERING:
            break;
        default:
            break;
    }
    tasks.add(new StartReplicationServiceTask());
    final boolean isMetadataNode = nodeId.equals(metadataNodeId);
    if (isMetadataNode) {
        tasks.add(new MetadataBootstrapTask());
    }
    tasks.add(new ExternalLibrarySetupTask(isMetadataNode));
    tasks.add(new ReportMaxResourceIdTask());
    tasks.add(new CheckpointTask());
    tasks.add(new StartLifecycleComponentsTask());
    if (isMetadataNode) {
        tasks.add(new BindMetadataNodeTask(true));
    }
    return tasks;
}
Also used : LocalRecoveryTask(org.apache.asterix.app.nc.task.LocalRecoveryTask) ExternalLibrarySetupTask(org.apache.asterix.app.nc.task.ExternalLibrarySetupTask) ArrayList(java.util.ArrayList) MetadataBootstrapTask(org.apache.asterix.app.nc.task.MetadataBootstrapTask) CheckpointTask(org.apache.asterix.app.nc.task.CheckpointTask) ReportMaxResourceIdTask(org.apache.asterix.app.nc.task.ReportMaxResourceIdTask) StartLifecycleComponentsTask(org.apache.asterix.app.nc.task.StartLifecycleComponentsTask) BindMetadataNodeTask(org.apache.asterix.app.nc.task.BindMetadataNodeTask) StartReplicationServiceTask(org.apache.asterix.app.nc.task.StartReplicationServiceTask) INCLifecycleTask(org.apache.asterix.common.api.INCLifecycleTask) ClusterPartition(org.apache.asterix.common.cluster.ClusterPartition)

Example 2 with INCLifecycleTask

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

the class MetadataNodeFaultToleranceStrategy method process.

private synchronized void process(StartupTaskRequestMessage msg) throws HyracksDataException {
    final String nodeId = msg.getNodeId();
    final SystemState state = msg.getState();
    final boolean isParticipant = replicationStrategy.isParticipant(nodeId);
    List<INCLifecycleTask> tasks;
    if (!isParticipant) {
        tasks = buildNonParticipantStartupSequence(nodeId, state);
    } else {
        tasks = buildParticipantStartupSequence(nodeId, state);
    }
    StartupTaskResponseMessage response = new StartupTaskResponseMessage(nodeId, tasks);
    try {
        messageBroker.sendApplicationMessageToNC(response, msg.getNodeId());
    } catch (Exception e) {
        throw HyracksDataException.create(e);
    }
}
Also used : SystemState(org.apache.asterix.common.transactions.IRecoveryManager.SystemState) StartupTaskResponseMessage(org.apache.asterix.app.replication.message.StartupTaskResponseMessage) INCLifecycleTask(org.apache.asterix.common.api.INCLifecycleTask) RuntimeDataException(org.apache.asterix.common.exceptions.RuntimeDataException) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Example 3 with INCLifecycleTask

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

the class MetadataNodeFaultToleranceStrategy method buildNonParticipantStartupSequence.

private List<INCLifecycleTask> buildNonParticipantStartupSequence(String nodeId, SystemState state) {
    final List<INCLifecycleTask> tasks = new ArrayList<>();
    if (state == SystemState.CORRUPTED) {
        //need to perform local recovery for node partitions
        LocalRecoveryTask rt = new LocalRecoveryTask(Arrays.asList(clusterManager.getNodePartitions(nodeId)).stream().map(ClusterPartition::getPartitionId).collect(Collectors.toSet()));
        tasks.add(rt);
    }
    tasks.add(new ExternalLibrarySetupTask(false));
    tasks.add(new ReportMaxResourceIdTask());
    tasks.add(new CheckpointTask());
    tasks.add(new StartLifecycleComponentsTask());
    return tasks;
}
Also used : LocalRecoveryTask(org.apache.asterix.app.nc.task.LocalRecoveryTask) ReportMaxResourceIdTask(org.apache.asterix.app.nc.task.ReportMaxResourceIdTask) StartLifecycleComponentsTask(org.apache.asterix.app.nc.task.StartLifecycleComponentsTask) ExternalLibrarySetupTask(org.apache.asterix.app.nc.task.ExternalLibrarySetupTask) ArrayList(java.util.ArrayList) INCLifecycleTask(org.apache.asterix.common.api.INCLifecycleTask) CheckpointTask(org.apache.asterix.app.nc.task.CheckpointTask) ClusterPartition(org.apache.asterix.common.cluster.ClusterPartition)

Example 4 with INCLifecycleTask

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

the class NoFaultToleranceStrategy method buildNCStartupSequence.

private List<INCLifecycleTask> buildNCStartupSequence(String nodeId, SystemState state) {
    final List<INCLifecycleTask> tasks = new ArrayList<>();
    if (state == SystemState.CORRUPTED) {
        //need to perform local recovery for node partitions
        LocalRecoveryTask rt = new LocalRecoveryTask(Arrays.asList(clusterManager.getNodePartitions(nodeId)).stream().map(ClusterPartition::getPartitionId).collect(Collectors.toSet()));
        tasks.add(rt);
    }
    final boolean isMetadataNode = nodeId.equals(metadataNodeId);
    if (isMetadataNode) {
        tasks.add(new MetadataBootstrapTask());
    }
    tasks.add(new ExternalLibrarySetupTask(isMetadataNode));
    tasks.add(new ReportMaxResourceIdTask());
    tasks.add(new CheckpointTask());
    tasks.add(new StartLifecycleComponentsTask());
    if (isMetadataNode) {
        tasks.add(new BindMetadataNodeTask(true));
    }
    return tasks;
}
Also used : LocalRecoveryTask(org.apache.asterix.app.nc.task.LocalRecoveryTask) ReportMaxResourceIdTask(org.apache.asterix.app.nc.task.ReportMaxResourceIdTask) StartLifecycleComponentsTask(org.apache.asterix.app.nc.task.StartLifecycleComponentsTask) ExternalLibrarySetupTask(org.apache.asterix.app.nc.task.ExternalLibrarySetupTask) BindMetadataNodeTask(org.apache.asterix.app.nc.task.BindMetadataNodeTask) ArrayList(java.util.ArrayList) INCLifecycleTask(org.apache.asterix.common.api.INCLifecycleTask) MetadataBootstrapTask(org.apache.asterix.app.nc.task.MetadataBootstrapTask) CheckpointTask(org.apache.asterix.app.nc.task.CheckpointTask) ClusterPartition(org.apache.asterix.common.cluster.ClusterPartition)

Example 5 with INCLifecycleTask

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

the class NoFaultToleranceStrategy method process.

private void process(StartupTaskRequestMessage msg) throws HyracksDataException {
    final String nodeId = msg.getNodeId();
    List<INCLifecycleTask> tasks = buildNCStartupSequence(msg.getNodeId(), msg.getState());
    StartupTaskResponseMessage response = new StartupTaskResponseMessage(nodeId, tasks);
    try {
        messageBroker.sendApplicationMessageToNC(response, msg.getNodeId());
    } catch (Exception e) {
        throw HyracksDataException.create(e);
    }
}
Also used : StartupTaskResponseMessage(org.apache.asterix.app.replication.message.StartupTaskResponseMessage) INCLifecycleTask(org.apache.asterix.common.api.INCLifecycleTask) RuntimeDataException(org.apache.asterix.common.exceptions.RuntimeDataException) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Aggregations

INCLifecycleTask (org.apache.asterix.common.api.INCLifecycleTask)9 ArrayList (java.util.ArrayList)5 ReportMaxResourceIdTask (org.apache.asterix.app.nc.task.ReportMaxResourceIdTask)5 StartLifecycleComponentsTask (org.apache.asterix.app.nc.task.StartLifecycleComponentsTask)5 CheckpointTask (org.apache.asterix.app.nc.task.CheckpointTask)4 ExternalLibrarySetupTask (org.apache.asterix.app.nc.task.ExternalLibrarySetupTask)4 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)4 BindMetadataNodeTask (org.apache.asterix.app.nc.task.BindMetadataNodeTask)3 LocalRecoveryTask (org.apache.asterix.app.nc.task.LocalRecoveryTask)3 MetadataBootstrapTask (org.apache.asterix.app.nc.task.MetadataBootstrapTask)3 StartupTaskResponseMessage (org.apache.asterix.app.replication.message.StartupTaskResponseMessage)3 ClusterPartition (org.apache.asterix.common.cluster.ClusterPartition)3 RuntimeDataException (org.apache.asterix.common.exceptions.RuntimeDataException)3 StartReplicationServiceTask (org.apache.asterix.app.nc.task.StartReplicationServiceTask)2 SystemState (org.apache.asterix.common.transactions.IRecoveryManager.SystemState)2 StartFailbackTask (org.apache.asterix.app.nc.task.StartFailbackTask)1 INCMessageBroker (org.apache.asterix.common.messaging.api.INCMessageBroker)1 IControllerService (org.apache.hyracks.api.service.IControllerService)1