Search in sources :

Example 6 with INCLifecycleTask

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

the class AutoFaultToleranceStrategy method process.

private synchronized void process(StartupTaskRequestMessage msg) throws HyracksDataException {
    final String nodeId = msg.getNodeId();
    final SystemState state = msg.getState();
    List<INCLifecycleTask> tasks;
    if (state == SystemState.BOOTSTRAPPING || state == SystemState.HEALTHY) {
        tasks = buildStartupSequence(nodeId);
    } else {
        // failed node returned. Need to start failback process
        tasks = buildFailbackStartupSequence();
    }
    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 7 with INCLifecycleTask

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

the class AutoFaultToleranceStrategy method buildStartupSequence.

private List<INCLifecycleTask> buildStartupSequence(String nodeId) {
    final List<INCLifecycleTask> tasks = new ArrayList<>();
    tasks.add(new StartReplicationServiceTask());
    final boolean isMetadataNode = nodeId.equals(currentMetadataNode);
    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 : 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) StartReplicationServiceTask(org.apache.asterix.app.nc.task.StartReplicationServiceTask) 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)

Example 8 with INCLifecycleTask

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

the class AutoFaultToleranceStrategy method buildFailbackStartupSequence.

private List<INCLifecycleTask> buildFailbackStartupSequence() {
    final List<INCLifecycleTask> tasks = new ArrayList<>();
    tasks.add(new StartFailbackTask());
    tasks.add(new ReportMaxResourceIdTask());
    tasks.add(new StartLifecycleComponentsTask());
    return tasks;
}
Also used : ReportMaxResourceIdTask(org.apache.asterix.app.nc.task.ReportMaxResourceIdTask) StartLifecycleComponentsTask(org.apache.asterix.app.nc.task.StartLifecycleComponentsTask) ArrayList(java.util.ArrayList) StartFailbackTask(org.apache.asterix.app.nc.task.StartFailbackTask) INCLifecycleTask(org.apache.asterix.common.api.INCLifecycleTask)

Example 9 with INCLifecycleTask

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

the class StartupTaskResponseMessage method handle.

@Override
public void handle(INcApplicationContext appCtx) throws HyracksDataException, InterruptedException {
    INCMessageBroker broker = (INCMessageBroker) appCtx.getServiceContext().getMessageBroker();
    IControllerService cs = appCtx.getServiceContext().getControllerService();
    boolean success = true;
    HyracksDataException exception = null;
    try {
        for (INCLifecycleTask task : tasks) {
            task.perform(cs);
        }
    } catch (HyracksDataException e) {
        success = false;
        exception = e;
    }
    NCLifecycleTaskReportMessage result = new NCLifecycleTaskReportMessage(nodeId, success);
    result.setException(exception);
    try {
        broker.sendMessageToCC(result);
    } catch (Exception e) {
        LOGGER.log(Level.SEVERE, "Failed sending message to cc", e);
        throw HyracksDataException.create(e);
    }
}
Also used : INCLifecycleTask(org.apache.asterix.common.api.INCLifecycleTask) INCMessageBroker(org.apache.asterix.common.messaging.api.INCMessageBroker) IControllerService(org.apache.hyracks.api.service.IControllerService) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) 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