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);
}
}
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;
}
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;
}
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);
}
}
Aggregations