public class LayoutServer extends AbstractServer
For replication and high availability, the layout server implements a basic Paxos protocol. The layout server functions as a Paxos acceptor, and accepts proposals from clients consisting of a rank and desired layout. The protocol consists of three rounds:
1) Prepare(rank) - Clients first contact each server with a rank. If the server responds with ACK, the server promises not to accept any requests with a rank lower than the given rank. If the server responds with LAYOUT_PREPARE_REJECT, the server informs the client of the current high rank and the request is rejected.
2) Propose(rank,layout) - Clients then contact each server with the previously prepared rank and the desired layout. If no other client has sent a prepare with a higher rank, the layout is persisted, and the server begins serving that layout to other clients. If the server responds with LAYOUT_PROPOSE_REJECT, either another client has sent a prepare with a higher rank, or this was a propose of a previously accepted rank.
3) Committed(rank, layout) - Clients then send a hint to each layout server that a new rank has been accepted by a quorum of servers.
Created by mwei on 12/8/15.
AbstractServer.ServerState
Constructor and Description |
---|
LayoutServer(ServerContext serverContext)
Returns new LayoutServer for context.
|
Modifier and Type | Method and Description |
---|---|
Layout |
getCurrentLayout() |
ExecutorService |
getExecutor() |
Rank |
getPhase1Rank() |
org.corfudb.infrastructure.Phase2Data |
getPhase2Data() |
Rank |
getPhase2Rank()
Returns the phase 2 rank.
|
Layout |
getProposedLayout()
Returns the proposed layout received in phase 2 data.
|
void |
handleMessageLayoutBootstrap(CorfuPayloadMsg<LayoutBootstrapRequest> msg,
io.netty.channel.ChannelHandlerContext ctx,
IServerRouter r)
Sets the new layout if the server has not been bootstrapped with one already.
|
void |
handleMessageLayoutCommit(CorfuPayloadMsg<LayoutCommittedRequest> msg,
io.netty.channel.ChannelHandlerContext ctx,
IServerRouter r)
Accepts any committed layouts for the current epoch or newer epochs.
|
void |
handleMessageLayoutPrepare(CorfuPayloadMsg<LayoutPrepareRequest> msg,
io.netty.channel.ChannelHandlerContext ctx,
IServerRouter r)
Accepts a prepare message if the rank is higher than any accepted so far.
|
void |
handleMessageLayoutPropose(CorfuPayloadMsg<LayoutProposeRequest> msg,
io.netty.channel.ChannelHandlerContext ctx,
IServerRouter r)
Accepts a proposal for which it had accepted in the prepare phase.
|
void |
handleMessageLayoutRequest(CorfuPayloadMsg<Long> msg,
io.netty.channel.ChannelHandlerContext ctx,
IServerRouter r)
Handle a layout request message.
|
boolean |
isServerReadyToHandleMsg(CorfuMsg msg) |
void |
setCurrentLayout(Layout layout)
Sets the current layout in context DataStore.
|
void |
setLayoutInHistory(Layout layout) |
void |
setPhase1Rank(Rank rank) |
void |
setPhase2Data(org.corfudb.infrastructure.Phase2Data phase2Data) |
getHandler, getState, handleMessage, sealServerWithEpoch, setState, shutdown
public LayoutServer(@Nonnull ServerContext serverContext)
serverContext
- context object providing settings and objectspublic boolean isServerReadyToHandleMsg(CorfuMsg msg)
isServerReadyToHandleMsg
in class AbstractServer
public ExecutorService getExecutor()
getExecutor
in class AbstractServer
public void handleMessageLayoutRequest(CorfuPayloadMsg<Long> msg, io.netty.channel.ChannelHandlerContext ctx, IServerRouter r)
msg
- corfu message containing LAYOUT_REQUESTctx
- netty ChannelHandlerContextr
- server routerpublic void handleMessageLayoutBootstrap(@NonNull CorfuPayloadMsg<LayoutBootstrapRequest> msg, io.netty.channel.ChannelHandlerContext ctx, @NonNull IServerRouter r)
msg
- corfu message containing LAYOUT_BOOTSTRAPctx
- netty ChannelHandlerContextr
- server routerpublic void handleMessageLayoutPrepare(@NonNull CorfuPayloadMsg<LayoutPrepareRequest> msg, io.netty.channel.ChannelHandlerContext ctx, @NonNull IServerRouter r)
msg
- corfu message containing LAYOUT_PREPAREctx
- netty ChannelHandlerContextr
- server routerpublic void handleMessageLayoutPropose(@NonNull CorfuPayloadMsg<LayoutProposeRequest> msg, io.netty.channel.ChannelHandlerContext ctx, @NonNull IServerRouter r)
msg
- corfu message containing LAYOUT_PROPOSEctx
- netty ChannelHandlerContextr
- server routerpublic void handleMessageLayoutCommit(@NonNull CorfuPayloadMsg<LayoutCommittedRequest> msg, io.netty.channel.ChannelHandlerContext ctx, @NonNull IServerRouter r)
msg
- corfu message containing LAYOUT_COMMITTEDctx
- netty ChannelHandlerContextr
- server routerpublic Layout getCurrentLayout()
public void setCurrentLayout(Layout layout)
layout
- layout to setpublic Rank getPhase1Rank()
public void setPhase1Rank(Rank rank)
public org.corfudb.infrastructure.Phase2Data getPhase2Data()
public void setPhase2Data(org.corfudb.infrastructure.Phase2Data phase2Data)
public void setLayoutInHistory(Layout layout)
public Rank getPhase2Rank()
public Layout getProposedLayout()
Copyright © 2019 CorfuDB. All rights reserved.