Restart an aurora job
515397
@Override
  public boolean restart(Integer containerId) {
    List<String> auroraCmd = new ArrayList<>(Arrays.asList("aurora", "job", "restart"));
    if (containerId != null) {
      auroraCmd.add(String.format("%s/%d", jobSpec, containerId));
    } else {
      auroraCmd.add(jobSpec);
    }

    appendAuroraCommandOptions(auroraCmd, isVerbose);

    return runProcess(auroraCmd);
  }
822899
def restart_tools(self,
                      repo=None,
                      name=None,
                      groups=None,
                      branch='master',
                      version='HEAD',
                      main_cfg=False,
                      old_val='',
                      new_val=''):
        
        status = (True, None)
        if not main_cfg:
            try:
                t_identifier = {'name': name,
                                'branch': branch,
                                'version': version}
                result = Template(System().manifest).constrain_opts(t_identifier,
                                                                    ['running',
                                                                     'link_name'])
                tools = result[0]
                tool = list(tools.keys())[0]
                if ('running' in tools[tool] and
                        tools[tool]['running'] == 'yes'):
                    start_tools = [t_identifier]
                    dependent_tools = [tools[tool]['link_name']]
                    start_tools += Dependencies(dependent_tools)
                    # TODO
                    start_d = {}
                    for tool_identifier in start_tools:
                        self.clean(**tool_identifier)
                        start_d.update(self.prep_start(**tool_identifier)[1])
                    if start_d:
                        Tools().start(start_d, '', is_tool_d=True)
            except Exception as e:  # pragma: no cover
                self.logger.error('Trouble restarting tool ' + name +
                                  ' because: ' + str(e))
                status = (False, str(e))
        else:
            try:
                # string manipulation to get tools into arrays
                ext_start = old_val.find('[external-services]')
                if ext_start >= 0:
                    ot_str = old_val[old_val.find('[external-services]') + 20:]
                else:
                    ot_str = ''
                old_tools = []
                for old_tool in ot_str.split('\n'):
                    if old_tool != '':
                        old_tools.append(old_tool.split('=')[0].strip())
                ext_start = new_val.find('[external-services]')
                if ext_start >= 0:
                    nt_str = new_val[new_val.find('[external-services]') + 20:]
                else:
                    nt_str = ''
                new_tools = []
                for new_tool in nt_str.split('\n'):
                    if new_tool != '':
                        new_tools.append(new_tool.split('=')[0].strip())
                # find tools changed
                tool_changes = []
                for old_tool in old_tools:
                    if old_tool not in new_tools:
                        tool_changes.append(old_tool)
                for new_tool in new_tools:
                    if new_tool not in old_tools:
                        tool_changes.append(new_tool)
                    else:
                        # tool name will be the same
                        oconf = old_val[old_val.find(new_tool):].split('\n')[0]
                        nconf = new_val[new_val.find(new_tool):].split('\n')[0]
                        if oconf != nconf:
                            tool_changes.append(new_tool)
                # put link names in a dictionary for finding dependencies
                dependent_tools = []
                for i, entry in enumerate(tool_changes):
                    dependent_tools.append(entry)
                    # change names to lowercase for use in clean, prep_start
                    tool_changes[i] = {'name': entry.lower().replace('-', '_')}
                dependencies = Dependencies(dependent_tools)
                # restart tools
                restart = tool_changes + dependencies
                tool_d = {}
                for tool in restart:
                    self.clean(**tool)
                    tool_d.update(self.prep_start(**tool)[1])
                if tool_d:
                    # TODO fix the arguments
                    Tools().start(tool_d)
            except Exception as e:  # pragma: no cover
                self.logger.error('Problem restarting tools: ' + str(e))
                status = (False, str(e))
        return status
56211
def reset
      @adapter         = DEFAULT_ADAPTER
      @http_verb       = DEFAULT_HTTP_VERB
      @faraday_options = {}
      @max_retries     = DEFAULT_MAX_RETRIES
      @logger          = ::Logger.new(STDOUT)
      @log_requests    = DEFAULT_LOGGER_OPTIONS[:requests]
      @log_errors      = DEFAULT_LOGGER_OPTIONS[:errors]
      @log_responses   = DEFAULT_LOGGER_OPTIONS[:responses]
      @api_version     = nil
    end
1018511
def start(job_label, runas=None):
    '''
    
    '''
    service = _service_by_name(job_label)
    if service:
        cmd = 'launchctl load -w {0}'.format(service['file_path'], runas=runas)
        return not __salt__['cmd.retcode'](cmd, runas=runas, python_shell=False)

    return False
314457
function restartProcessing (q) {
  logger('restartProcessing')
  setTimeout(function randomRestart () {
    queueProcess.restart(q)
  }, Math.floor(Math.random() * 1000))
}
489816
private void restart(long globalModVersionOfFailover) {
		try {
			if (transitionState(JobStatus.CREATED, JobStatus.RUNNING)) {
				// if we have checkpointed state, reload it into the executions
				if (executionGraph.getCheckpointCoordinator() != null) {
					// we restart the checkpoint scheduler for
					// i) enable new checkpoint could be triggered without waiting for last checkpoint expired.
					// ii) ensure the EXACTLY_ONCE semantics if needed.
					executionGraph.getCheckpointCoordinator().abortPendingCheckpoints(
						new CheckpointException(CheckpointFailureReason.JOB_FAILOVER_REGION));

					executionGraph.getCheckpointCoordinator().restoreLatestCheckpointedState(
						tasks, false, true);
				}

				HashSet<AllocationID> previousAllocationsInRegion = new HashSet<>(connectedExecutionVertexes.size());
				for (ExecutionVertex connectedExecutionVertex : connectedExecutionVertexes) {
					AllocationID latestPriorAllocation = connectedExecutionVertex.getLatestPriorAllocation();
					if (latestPriorAllocation != null) {
						previousAllocationsInRegion.add(latestPriorAllocation);
					}
				}

				//TODO, use restart strategy to schedule them.
				//restart all connected ExecutionVertexes
				for (ExecutionVertex ev : connectedExecutionVertexes) {
					try {
						ev.scheduleForExecution(
							executionGraph.getSlotProvider(),
							executionGraph.isQueuedSchedulingAllowed(),
							LocationPreferenceConstraint.ANY,
							previousAllocationsInRegion); // some inputs not belonging to the failover region might have failed concurrently
					}
					catch (Throwable e) {
						failover(globalModVersionOfFailover);
					}
				}
			}
			else {
				LOG.info("FailoverRegion {} switched from CREATED to RUNNING fail, will fail this region again.", id);
				failover(globalModVersionOfFailover);
			}
		} catch (Exception e) {
			LOG.info("FailoverRegion {} restart failed, failover again.", id, e);
			failover(globalModVersionOfFailover);
		}
	}
987624
@Command(name = "RestartServer")
    public void restartServer() throws DevFailed {
        xlogger.entry();
        tangoExporter.unexportAll();
        tangoExporter.exportAll();
        xlogger.exit();
    }
274551
def restart(ctx, **kwargs):
    
    update_context(ctx, kwargs)

    daemon = mk_daemon(ctx)
    daemon.stop()
    daemon.start()
1109740
def restart(self, timeout=300, config_callback=None):
        
        self.stop()
        if config_callback:
            self.cfg = config_callback(self.cfg.copy())
        self.config_path = process.write_config(self.cfg)
        return self.start(timeout)
1230973
def restart(self, all=False):
        """"""

        if all:
            data = {'type': self.type}

        else:
            data = {'ps': self.process}

        r = self._h._http_resource(
            method='POST',
            resource=('apps', self.app.name, 'ps', 'restart'),
            data=data
        )

        r.raise_for_status()
609933
def restart
      invoke :stop, :all => input[:all], :apps => input[:apps]

      line unless quiet?

      input[:apps].each do |app|
        unless input[:command].nil?
          app.command = input[:command]
        end
        app.update!
      end

      invoke :start, :all => input[:all], :apps => input[:apps],
        :debug_mode => input[:debug_mode]
    end
1222915
def restart(self, timeout=None, task=None, block_callbacks=False, role=None):
        
        self.set_state('restarting')
        if not block_callbacks:
            self.__cb_pending = ACTION_ON_RESTART
        ret = self.stop(block_callbacks=True) and self.start(timeout, task, True, role)
        if not ret and not self.is_starting():
            self.set_state('restart failed ({0})'.format(self.state))
        return ret
1203551
public void restartDyno(String appName, String dynoId) {
        connection.execute(new DynoRestart(appName, dynoId), apiKey);
    }
1264143
function restartNode() {
        try {
            _nodeConnection.domains.base.restartNode();
        } catch (e) {
            window.alert("Failed trying to restart Node: " + e.message);
        }
    }
287369
def restart(self):
        
        command = const.CMD_RESTART
        cmd_response = self.__send_command(command)
        if cmd_response.get('status'):
            self.is_connect = False
            self.next_uid = 1
            return True
        else:
            raise ZKErrorResponse("can't restart device")
617522
protected function restart()
    {
        if ($this->process->isStarted()) {
            event(new WorkerProcessRestarting($this));
        }

        $this->start($this->output);
    }
1135302
@Override
  public boolean restart(Integer containerId) {
    // there is no backpressure for container 0, delegate to aurora client
    if (containerId == null || containerId == 0) {
      return cliController.restart(containerId);
    }

    if (stateMgrAdaptor == null) {
      LOG.warning("SchedulerStateManagerAdaptor not initialized");
      return false;
    }

    StMgr sm = searchContainer(containerId);
    if (sm == null) {
      LOG.warning("container not found in pplan " + containerId);
      return false;
    }

    String url = "http://" + sm.getHostName() + ":" + sm.getShellPort() + "/killexecutor";
    String payload = "secret=" + stateMgrAdaptor.getExecutionState(topologyName).getTopologyId();
    LOG.info("sending `kill container` to " + url + "; payload: " + payload);

    HttpURLConnection con = NetworkUtils.getHttpConnection(url);
    try {
      if (NetworkUtils.sendHttpPostRequest(con, "X", payload.getBytes())) {
        return NetworkUtils.checkHttpResponseCode(con, 200);
      } else { // if heron-shell command fails, delegate to aurora client
        LOG.info("heron-shell killexecutor failed; try aurora client ..");
        return cliController.restart(containerId);
      }
    } finally {
      con.disconnect();
    }
  }