Search in sources :

Example 1 with CorfuMsg

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));
}
Also used : CorfuMsg(org.corfudb.protocols.wireprotocol.CorfuMsg)

Example 2 with CorfuMsg

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));
    }
}
Also used : CorfuMsg(org.corfudb.protocols.wireprotocol.CorfuMsg)

Example 3 with CorfuMsg

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);
        }
    });
}
Also used : CorfuMsg(org.corfudb.protocols.wireprotocol.CorfuMsg) ByteBuf(io.netty.buffer.ByteBuf)

Example 4 with CorfuMsg

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);
}
Also used : CorfuMsg(org.corfudb.protocols.wireprotocol.CorfuMsg)

Example 5 with CorfuMsg

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());
}
Also used : CorfuMsg(org.corfudb.protocols.wireprotocol.CorfuMsg) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

CorfuMsg (org.corfudb.protocols.wireprotocol.CorfuMsg)15 ByteBuf (io.netty.buffer.ByteBuf)4 Test (org.junit.Test)2 Timer (com.codahale.metrics.Timer)1 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)1 java.lang.invoke (java.lang.invoke)1 Modifier (java.lang.reflect.Modifier)1 Arrays (java.util.Arrays)1 Map (java.util.Map)1 Set (java.util.Set)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 CorfuMsgType (org.corfudb.protocols.wireprotocol.CorfuMsgType)1 WrongEpochException (org.corfudb.runtime.exceptions.WrongEpochException)1 MetricsUtils (org.corfudb.util.MetricsUtils)1