use of org.corfudb.protocols.wireprotocol.CorfuMsg in project CorfuDB by CorfuDB.
the class ManagementServer method initiateFailureHandler.
/**
* Trigger to start the failure handler.
*
* @param msg
* @param ctx
* @param r
*/
@ServerHandler(type = CorfuMsgType.MANAGEMENT_START_FAILURE_HANDLER, opTimer = metricsPrefix + "start-failure-handler")
public synchronized void initiateFailureHandler(CorfuMsg msg, ChannelHandlerContext ctx, IServerRouter r, boolean isMetricsEnabled) {
if (isShutdown()) {
log.warn("Management Server received {} but is shutdown.", msg.getMsgType().toString());
r.sendResponse(ctx, msg, new CorfuMsg(CorfuMsgType.NACK));
return;
}
// This server has not been bootstrapped yet, ignore all requests.
if (!checkBootstrap(msg, ctx, r)) {
return;
}
if (!startFailureHandler) {
startFailureHandler = true;
log.info("Initiated Failure Handler.");
} else {
log.info("Failure Handler already initiated.");
}
r.sendResponse(ctx, msg, new CorfuMsg(CorfuMsgType.ACK));
}
use of org.corfudb.protocols.wireprotocol.CorfuMsg in project CorfuDB by CorfuDB.
the class ManagementServer method handleFailureDetectedMsg.
/**
* Triggers the failure handler.
* The msg contains the failed/defected nodes.
*
* @param msg
* @param ctx
* @param r
*/
@ServerHandler(type = CorfuMsgType.MANAGEMENT_FAILURE_DETECTED, opTimer = metricsPrefix + "failure-detected")
public synchronized void handleFailureDetectedMsg(CorfuPayloadMsg<FailureDetectorMsg> msg, ChannelHandlerContext ctx, IServerRouter r, boolean isMetricsEnabled) {
if (isShutdown()) {
log.warn("Management Server received {} but is shutdown.", msg.getMsgType().toString());
r.sendResponse(ctx, msg, new CorfuMsg(CorfuMsgType.NACK));
return;
}
// This server has not been bootstrapped yet, ignore all requests.
if (!checkBootstrap(msg, ctx, r)) {
return;
}
log.info("Received Failures : {}", msg.getPayload().getNodes());
try {
failureHandlerDispatcher.dispatchHandler(failureHandlerPolicy, (Layout) latestLayout.clone(), getCorfuRuntime(), msg.getPayload().getNodes());
r.sendResponse(ctx, msg, new CorfuMsg(CorfuMsgType.ACK));
} catch (CloneNotSupportedException e) {
log.error("Failure Handler could not clone layout: {}", e);
r.sendResponse(ctx, msg, new CorfuMsg(CorfuMsgType.NACK));
}
}
use of org.corfudb.protocols.wireprotocol.CorfuMsg in project CorfuDB by CorfuDB.
the class TestChannelContext method sendMessageAsync.
void sendMessageAsync(Object o, Object orig) {
CompletableFuture.runAsync(() -> {
try {
//for debugging
Object origCapture = orig;
if (o instanceof ByteBuf) {
CorfuMsg m = CorfuMsg.deserialize((ByteBuf) o);
hmf.handleMessage(m);
((ByteBuf) o).release();
}
} catch (Exception e) {
log.warn("Error during deserialization", e);
}
});
}
use of org.corfudb.protocols.wireprotocol.CorfuMsg in project CorfuDB by CorfuDB.
the class TestClientRouter method routeMessage.
private void routeMessage(CorfuMsg message) {
CorfuMsg m = simulateSerialization(message);
serverRouter.sendServerMessage(m, channelContext);
}
use of org.corfudb.protocols.wireprotocol.CorfuMsg in project CorfuDB by CorfuDB.
the class TestChannelContext method simulateSerialization.
public ByteBuf simulateSerialization(Object message) {
if (message instanceof CorfuMsg) {
/* simulate serialization/deserialization */
ByteBuf oBuf = Unpooled.buffer();
((CorfuMsg) message).serialize(oBuf);
oBuf.resetReaderIndex();
return oBuf;
}
throw new UnsupportedOperationException("Test framework does not support serialization of object type " + message.getClass());
}
Aggregations