use of org.apache.asterix.common.messaging.api.INCMessageBroker 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);
}
}
use of org.apache.asterix.common.messaging.api.INCMessageBroker in project asterixdb by apache.
the class TakeoverMetadataNodeRequestMessage method handle.
@Override
public void handle(INcApplicationContext appContext) throws HyracksDataException, InterruptedException {
INCMessageBroker broker = (INCMessageBroker) appContext.getServiceContext().getMessageBroker();
HyracksDataException hde = null;
try {
appContext.initializeMetadata(false);
appContext.exportMetadataNodeStub();
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Failed taking over metadata", e);
hde = HyracksDataException.create(e);
} finally {
TakeoverMetadataNodeResponseMessage reponse = new TakeoverMetadataNodeResponseMessage(appContext.getTransactionSubsystem().getId());
try {
broker.sendMessageToCC(reponse);
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Failed taking over metadata", e);
hde = HyracksDataException.suppress(hde, e);
}
}
if (hde != null) {
throw hde;
}
}
use of org.apache.asterix.common.messaging.api.INCMessageBroker in project asterixdb by apache.
the class TakeoverPartitionsRequestMessage method handle.
@Override
public void handle(INcApplicationContext appContext) throws HyracksDataException, InterruptedException {
INCMessageBroker broker = (INCMessageBroker) appContext.getServiceContext().getMessageBroker();
//if the NC is shutting down, it should ignore takeover partitions request
if (!appContext.isShuttingdown()) {
HyracksDataException hde = null;
try {
IRemoteRecoveryManager remoteRecoeryManager = appContext.getRemoteRecoveryManager();
remoteRecoeryManager.takeoverPartitons(partitions);
} catch (IOException | ACIDException e) {
LOGGER.log(Level.SEVERE, "Failure taking over partitions", e);
hde = HyracksDataException.suppress(hde, e);
} finally {
//send response after takeover is completed
TakeoverPartitionsResponseMessage reponse = new TakeoverPartitionsResponseMessage(requestId, appContext.getTransactionSubsystem().getId(), partitions);
try {
broker.sendMessageToCC(reponse);
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Failure taking over partitions", e);
hde = HyracksDataException.suppress(hde, e);
}
}
if (hde != null) {
throw hde;
}
}
}
use of org.apache.asterix.common.messaging.api.INCMessageBroker in project asterixdb by apache.
the class ReportMaxResourceIdMessage method send.
public static void send(NodeControllerService cs) throws HyracksDataException {
NodeControllerService ncs = cs;
INcApplicationContext appContext = (INcApplicationContext) ncs.getApplicationContext();
long maxResourceId = Math.max(appContext.getLocalResourceRepository().maxId(), MetadataIndexImmutableProperties.FIRST_AVAILABLE_USER_DATASET_ID);
ReportMaxResourceIdMessage maxResourceIdMsg = new ReportMaxResourceIdMessage(ncs.getId(), maxResourceId);
try {
((INCMessageBroker) ncs.getContext().getMessageBroker()).sendMessageToCC(maxResourceIdMsg);
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Unable to report max local resource id", e);
throw HyracksDataException.create(e);
}
}
Aggregations