use of org.corfudb.runtime.view.Layout in project CorfuDB by CorfuDB.
the class LayoutMsg method fromBuffer.
/**
* Parse the rest of the message from the buffer. Classes that extend CorfuMsg
* should parse their fields in this method.
*
* @param buffer
*/
@Override
public void fromBuffer(ByteBuf buffer) {
super.fromBuffer(buffer);
int length = buffer.readInt();
byte[] byteArray = new byte[length];
buffer.readBytes(byteArray, 0, length);
String str = new String(byteArray, StandardCharsets.UTF_8);
layout = parser.fromJson(str, Layout.class);
}
use of org.corfudb.runtime.view.Layout in project CorfuDB by CorfuDB.
the class ManagementServer method getCorfuRuntime.
/**
* Returns a connected instance of the CorfuRuntime.
*
* @return A connected instance of runtime.
*/
public synchronized CorfuRuntime getCorfuRuntime() {
if (corfuRuntime == null) {
corfuRuntime = new CorfuRuntime();
if ((Boolean) opts.get("--enable-tls")) {
corfuRuntime.enableTls((String) opts.get("--keystore"), (String) opts.get("--keystore-password-file"), (String) opts.get("--truststore"), (String) opts.get("--truststore-password-file"));
if ((Boolean) opts.get("--enable-sasl-plain-text-auth")) {
corfuRuntime.enableSaslPlainText((String) opts.get("--sasl-plain-text-username-file"), (String) opts.get("--sasl-plain-text-password-file"));
}
}
// Runtime can be set up either using the layout or the bootstrapEndpoint address.
if (latestLayout != null)
latestLayout.getLayoutServers().forEach(ls -> corfuRuntime.addLayoutServer(ls));
else
corfuRuntime.addLayoutServer(bootstrapEndpoint);
corfuRuntime.connect();
log.info("Corfu Runtime connected successfully");
}
return corfuRuntime;
}
use of org.corfudb.runtime.view.Layout in project CorfuDB by CorfuDB.
the class PurgeFailurePolicy method generateLayout.
/**
* Modifies the layout by removing/purging the set failed nodes.
*
* @param originalLayout Original Layout which needs to be modified.
* @param corfuRuntime Connected runtime to attach to the new layout.
* @param failedNodes Set of all failed/defected servers.
* @return The new and modified layout.
* @throws LayoutModificationException Thrown if attempt to create an invalid layout.
* @throws CloneNotSupportedException Clone not supported for layout.
*/
@Override
public Layout generateLayout(Layout originalLayout, CorfuRuntime corfuRuntime, Set<String> failedNodes) throws LayoutModificationException, CloneNotSupportedException {
LayoutWorkflowManager layoutManager = new LayoutWorkflowManager(originalLayout);
Layout newLayout = layoutManager.removeLayoutServers(failedNodes).removeSequencerServers(failedNodes).removeLogunitServers(failedNodes).build();
newLayout.setRuntime(corfuRuntime);
newLayout.setEpoch(newLayout.getEpoch() + 1);
return newLayout;
}
use of org.corfudb.runtime.view.Layout in project CorfuDB by CorfuDB.
the class ConservativeFailureHandlerPolicy method generateLayout.
/**
* Modifies the layout by marking the failed nodes as unresponsive but still keeping them in
* the layout.
*
* @param originalLayout Original Layout which needs to be modified.
* @param corfuRuntime Connected runtime to attach to the new layout.
* @param failedNodes Set of all failed/defected servers.
* @return The new and modified layout.
* @throws LayoutModificationException Thrown if attempt to create an invalid layout.
* @throws CloneNotSupportedException Clone not supported for layout.
*/
@Override
public Layout generateLayout(Layout originalLayout, CorfuRuntime corfuRuntime, Set<String> failedNodes) throws LayoutModificationException, CloneNotSupportedException {
LayoutWorkflowManager layoutManager = new LayoutWorkflowManager(originalLayout);
Layout newLayout = layoutManager.moveResponsiveSequencerToTop(failedNodes).addUnresponsiveServers(failedNodes).build();
newLayout.setRuntime(corfuRuntime);
newLayout.setEpoch(newLayout.getEpoch() + 1);
return newLayout;
}
use of org.corfudb.runtime.view.Layout in project CorfuDB by CorfuDB.
the class LayoutServer method handleMessageLayoutCommit.
/**
* Accepts any committed layouts for the current epoch or newer epochs.
* As part of the accept, the server changes it's current layout and epoch.
* @param msg
* @param ctx
* @param r
*/
// TODO If a server does not get SET_EPOCH layout commit message cannot reach it
// TODO as this message is not set to ignore EPOCH.
// TODO How do we handle holes in history if let in layout commit message. Maybe we have a hole filling process
// TODO how do reject the older epoch commits, should it be an explicit NACK.
@ServerHandler(type = CorfuMsgType.LAYOUT_COMMITTED, opTimer = metricsPrefix + "committed")
public synchronized void handleMessageLayoutCommit(CorfuPayloadMsg<LayoutCommittedRequest> msg, ChannelHandlerContext ctx, IServerRouter r, boolean isMetricsEnabled) {
Layout commitLayout = msg.getPayload().getLayout();
if (!checkBootstrap(msg, ctx, r)) {
return;
}
long serverEpoch = getServerEpoch();
if (msg.getPayload().getEpoch() < serverEpoch) {
r.sendResponse(ctx, msg, new CorfuPayloadMsg<>(CorfuMsgType.WRONG_EPOCH, serverEpoch));
return;
}
setCurrentLayout(commitLayout);
setServerEpoch(msg.getPayload().getEpoch());
r.sendResponse(ctx, msg, new CorfuMsg(CorfuMsgType.ACK));
}
Aggregations