@VisibleForTesting List<String> processMessage(String message) { // Split leaves a trailing empty line if there's a terminating newline. ArrayList<String> split = Lists.newArrayList(message.split("\r?\n", -1)); Preconditions.checkArgument(split.size() > 0); synchronized (this) { buffer.append(split.get(0)); if (split.size() == 1) // no newlines. return ImmutableList.of(); split.set(0, buffer.toString()); buffer = new StringBuilder().append(split.remove(split.size() - 1)); } return split; }
private synchronized void restartServer(String znodePath) throws Exception { String child = znodePath.replace( parentZnode + Constants.DEFAULT_ZOOKEEPER_ZNODE_SERVERS_RUNNING + "/", ""); Scanner scn = new Scanner(child); scn.useDelimiter(":"); String hostName = scn.next(); String instance = scn.next(); int infoPort = Integer.parseInt(scn.next()); long serverStartTimestamp = Long.parseLong(scn.next()); scn.close(); LOG.error("WmsServer [" + hostName + ":" + instance + "] failed."); if (runningServers.contains(child)) { LOG.debug("Found [" + child + "], deleting from running servers list"); runningServers.remove(child); metrics.setTotalRunning(runningServers.size()); } RestartHandler handler = new RestartHandler(child); restartQueue.add(handler); }