
org.jsimpledb.kv.raft.cmd.RaftFallbackForceStandaloneCommand Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jsimpledb-kv-raft Show documentation
Show all versions of jsimpledb-kv-raft Show documentation
JSimpleDB distributed, linearizable ACID compliant key/value store implementation based on the Raft consensus algorithm.
The newest version!
/*
* Copyright (C) 2015 Archie L. Cobbs. All rights reserved.
*/
package org.jsimpledb.kv.raft.cmd;
import java.util.EnumSet;
import java.util.Map;
import org.jsimpledb.SessionMode;
import org.jsimpledb.cli.CliSession;
import org.jsimpledb.cli.cmd.AbstractCommand;
import org.jsimpledb.kv.raft.fallback.FallbackKVDatabase;
import org.jsimpledb.util.ParseContext;
public class RaftFallbackForceStandaloneCommand extends AbstractCommand {
public RaftFallbackForceStandaloneCommand() {
super("raft-fallback-force-standalone on:boolean");
}
@Override
public String getHelpSummary() {
return "Forces the Raft fallback database into standalone mode";
}
@Override
public EnumSet getSessionModes() {
return EnumSet.allOf(SessionMode.class);
}
@Override
public CliSession.Action getAction(CliSession session0, ParseContext ctx, boolean complete, Map params) {
final boolean on = (Boolean)params.get("on");
return session -> {
if (!(session.getKVDatabase() instanceof FallbackKVDatabase))
throw new Exception("key/value store is not Raft fallback");
final FallbackKVDatabase fallbackKV = (FallbackKVDatabase)session.getKVDatabase();
fallbackKV.setMaximumTargetIndex(on ? -1 : Integer.MAX_VALUE);
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy