private synchronized HostCommand nextCommandSynchronized() throws IOException { // In case of failure to move on to next command, stop the partition server and rethrow the exception. try { return host.nextCommand(); } catch (IOException e) { stop(); throw e; } }
private void processServeData(HostState state) throws IOException { switch (state) { case IDLE: serveData(); host.setState(HostState.SERVING); // In case of exception, server will stop and state will be coherent. host.nextCommand(); // In case of exception, server will stop and state will be coherent. break; default: LOG.info(ignoreIncompatibleCommandMessage(HostCommand.SERVE_DATA, state)); host.nextCommand(); // In case of exception, server will stop and state will be coherent. } }
private void processGoToIdle(HostState state) throws IOException { switch (state) { case SERVING: // Set IDLE state proactively. If the shutting down hangs, it will be safe since clients will be already aware. host.setState(HostState.IDLE); // In case of exception, server will stop and state will be coherent. stopServingData(); host.nextCommand(); // In case of exception, server will stop and state will be coherent. break; default: LOG.info(ignoreIncompatibleCommandMessage(HostCommand.GO_TO_IDLE, state)); host.nextCommand(); // In case of exception, server will stop and state will be coherent. } }
public void processCommandOnStartup() { try { HostCommand command = host.getCurrentCommand(); LOG.info("Current command is: " + command); if (command != null) { commandQueue.put(command); } else { host.nextCommand(); } } catch (Exception e) { LOG.error("Failed to process current command on startup.", e); stop(); } hasProcessedCommandOnStartup = true; }
@Override public synchronized void onCommandQueueChange(Host host) { LOG.info("Command queue changed."); // Do not process anything when we have not yet tried to process a command when starting up. if (!hasProcessedCommandOnStartup) { LOG.info("Ignoring command queue change as commands have not yet been executed on startup."); return; } try { HostCommand command = host.getCurrentCommand(); if (command == null) { // When command queue changes, and current command is empty, move on to next command host.nextCommand(); } else { // A current command was already in place, we are still executing it. Do nothing. LOG.info("Ignoring command queue change as a command is currently being executed."); } } catch (IOException e) { LOG.error("Failed to move on to next command.", e); stop(); } }
private void processExecuteUpdate(HostState state) throws IOException { switch (state) { case IDLE: host.setState(HostState.UPDATING); // In case of exception, server will stop and state will be coherent. executeUpdate(); // Next command is set by the updater thread break; default: LOG.info(ignoreIncompatibleCommandMessage(HostCommand.EXECUTE_UPDATE, state)); host.nextCommand(); // In case of exception, server will stop and state will be coherent. } }
protected void doDiscardCurrentCommand(HttpServletRequest req, HttpServletResponse resp) throws IOException { RingGroup rg = coordinator.getRingGroup(req.getParameter("g")); Ring r = rg.getRing(Integer.parseInt(req.getParameter("n"))); Host h = r.getHostByAddress(PartitionServerAddress.parse(URLEnc.decode(req.getParameter("h")))); h.nextCommand(); redirectBack(resp, rg, r, h); }
host.nextCommand(); throw new IOException("Failed to load Readers. Encountered " + exceptions.size() + " exceptions.");