Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -614,18 +614,10 @@ public synchronized void start() throws IOException, InterruptedException {

control.start(ServerType.TABLET_SERVER);

int ret = 0;
for (int i = 0; i < 5; i++) {
ret = exec(Main.class, SetGoalState.class.getName(), ManagerGoalState.NORMAL.toString())
.getProcess().waitFor();
if (ret == 0) {
break;
}
sleepUninterruptibly(1, TimeUnit.SECONDS);
}
if (ret != 0) {
throw new IllegalStateException("Could not set manager goal state, process returned " + ret
+ ". Check the logs in " + config.getLogDir() + " for errors.");
try {
SetGoalState.setGoalState(getServerContext(), ManagerGoalState.NORMAL);
} catch (KeeperException e) {
throw new IllegalStateException("Could not set manager goal state", e);
}

control.start(ServerType.MANAGER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.accumulo.manager.upgrade.RenameMasterDirInZK;
import org.apache.accumulo.server.ServerContext;
import org.apache.accumulo.server.security.SecurityUtil;
import org.apache.zookeeper.KeeperException;

import com.google.common.base.Preconditions;

Expand All @@ -38,13 +39,15 @@ public class SetGoalState {
* Utility program that will change the goal state for the manager from the command line.
*/
public static void main(String[] args) throws Exception {
final ManagerGoalState targetGoalState;
try {
Preconditions.checkArgument(args.length == 1);
ManagerGoalState.valueOf(args[0]);
targetGoalState = ManagerGoalState.valueOf(args[0]);
} catch (IllegalArgumentException e) {
System.err.println(
"Usage: accumulo " + SetGoalState.class.getName() + " [NORMAL|SAFE_MODE|CLEAN_STOP]");
System.exit(-1);
return;
Comment thread
ddanielr marked this conversation as resolved.
}

try {
Expand All @@ -53,12 +56,20 @@ public static void main(String[] args) throws Exception {
var context = new ServerContext(siteConfig);
RenameMasterDirInZK.renameMasterDirInZK(context);
context.waitForZookeeperAndHdfs();
context.getZooReaderWriter().putPersistentData(
context.getZooKeeperRoot() + Constants.ZMANAGER_GOAL_STATE, args[0].getBytes(UTF_8),
NodeExistsPolicy.OVERWRITE);
setGoalState(context, targetGoalState);
} finally {
SingletonManager.setMode(Mode.CLOSED);
}
}

/**
* Writes the manager goal state to ZooKeeper, overwriting the current value.
*/
public static void setGoalState(ServerContext context, ManagerGoalState targetGoalState)
throws KeeperException, InterruptedException {
context.getZooReaderWriter().putPersistentData(
context.getZooKeeperRoot() + Constants.ZMANAGER_GOAL_STATE,
targetGoalState.name().getBytes(UTF_8), NodeExistsPolicy.OVERWRITE);
}

}
Loading