Post download retry event.

@param request download request
556607
void postRetry(final DownloadRequest request) {
    downloadPoster.execute(new Runnable() {
      @Override public void run() {
        request.downloadCallback().onRetry(request.downloadId());
      }
    });
  }
660181
function attemptToDownload() {
        if (checkIfOnline()) {
            postMessageToNode(MessageIds.PERFORM_CLEANUP, ['.json'], true);
        } else {
            enableCheckForUpdateEntry(true);
            UpdateStatus.cleanUpdateStatus();
            HealthLogger.sendAnalyticsData(
                autoUpdateEventNames.AUTOUPDATE_DOWNLOAD_FAILED,
                "autoUpdate",
                "download",
                "fail",
                "No Internet connection available."
            );
            UpdateInfoBar.showUpdateBar({
                type: "warning",
                title: Strings.DOWNLOAD_FAILED,
                description: Strings.INTERNET_UNAVAILABLE
            });

            setUpdateStateInJSON("autoUpdateInProgress", false);
        }
    }
1195232
@SuppressWarnings("unchecked")
  private void handlePublish(PublishRequest request) {
    state.getLogger().trace("{} - Received {}", state.getSessionId(), request);

    // If the request is for another session ID, this may be a session that was previously opened
    // for this client.
    if (request.session() != state.getSessionId()) {
      state.getLogger().trace("{} - Inconsistent session ID: {}", state.getSessionId(), request.session());
      return;
    }

    // If the request event index has already been processed, return.
    if (request.eventIndex() <= state.getEventIndex()) {
      return;
    }

    // If the request's previous event index doesn't equal the previous received event index,
    // respond with an undefined error and the last index received. This will cause the cluster
    // to resend events starting at eventIndex + 1.
    if (request.previousIndex() != state.getEventIndex()) {
      state.getLogger().trace("{} - Inconsistent event index: {}", state.getSessionId(), request.previousIndex());
      connection.send(ResetRequest.builder()
        .withSession(state.getSessionId())
        .withIndex(state.getEventIndex())
        .build());
      return;
    }

    // Store the event index. This will be used to verify that events are received in sequential order.
    state.setEventIndex(request.eventIndex());

    sequencer.sequenceEvent(request, () -> {
      for (Event<?> event : request.events()) {
        Set<Consumer> listeners = eventListeners.get(event.name());
        if (listeners != null) {
          for (Consumer listener : listeners) {
            listener.accept(event.message());
          }
        }
      }
    });
  }
812082
void postSuccess(final DownloadRequest request) {
    downloadPoster.execute(new Runnable() {
      @Override public void run() {
        request.downloadCallback().onSuccess(request.downloadId(), request.destinationFilePath());
      }
    });
  }
869603
protected void onRequestError(final RequestErrorEvent event) {
        LOGGER.log(Level.INFO, "onRequestError: {0}", event.getCrawlCandidate().getRequestUrl());
    }
903484
private void updateFailure(DownloadRequest request, int statusCode, String errMsg) {
    updateState(request, DownloadState.FAILURE);

    /* if the status code is 0, may be cause by the net error */
    int leftRetryTime = request.retryTime();
    if (leftRetryTime >= 0) {
      try {
        /* sleep a while before retrying */
        sleep(request.retryInterval());
      } catch (InterruptedException e) {
        /* we may have been interrupted because it was time to quit */
        if (quit) {
          request.finish();
          return;
        }
      }

      /* retry downloading */
      if (!request.isCanceled()) {
        logger.log("Retry DownloadRequest: "
            + request.downloadId()
            + " left retry time: "
            + leftRetryTime);
        updateRetry(request);
        executeDownload(request);
      }

      return;
    }

    /* notify the request that downloading has finished */
    request.finish();

    /* deliver failure message */
    delivery.postFailure(request, statusCode, errMsg);
  }
862951
private void handleShuffleState(final Request request) {

		String json = request.getParameter(SHUFFLE_REQUEST_KEY);
		if (Util.empty(json)) {
			return;
		}

		// New
		TreeItemIdNode newTree;
		try {
			newTree = TreeItemUtil.convertJsonToTree(json);
		} catch (Exception e) {
			LOG.warn("Could not parse JSON for shuffle tree items. " + e.getMessage());
			return;
		}

		// Current
		TreeItemIdNode currentTree = getCustomTree();

		boolean changed = !TreeItemUtil.isTreeSame(newTree, currentTree);

		if (changed) {
			setCustomTree(newTree);
			// Run the shuffle action (if set)
			final Action action = getShuffleAction();
			if (action != null) {
				final ActionEvent event = new ActionEvent(this, "shuffle");
				Runnable later = new Runnable() {
					@Override
					public void run() {
						action.execute(event);
					}
				};
				invokeLater(later);
			}
		}
	}
1351925
public GetFailedReasonResponse getFailedReason(SesRequest request) {
        InternalRequest internalRequest = this.createRequest("failedReason", request, HttpMethodName.GET);
        return this.invokeHttpClient(internalRequest, GetFailedReasonResponse.class);
    }
1027194
public static void bind(HttpServletRequest request) {
        if (request != null && threadLocal.get() != null) {
            throw new IllegalStateException("HttpServletRequestHolder.bind() called for a "
                    + "thread that already has a request associated with it. It's likely that the request "
                    + "was not correctly removed from the thread before it is put back into the thread pool.");
        }
        threadLocal.set(request);
    }
1037817
public void handleEvent(HttpServletRequest request) throws GitLabApiException {

        String eventName = request.getHeader("X-Gitlab-Event");
        if (eventName == null || eventName.trim().isEmpty()) {
            String message = "X-Gitlab-Event header is missing!";
            LOGGER.warning(message);
            return;
        }

        if (!isValidSecretToken(request)) {
            String message = "X-Gitlab-Token mismatch!";
            LOGGER.warning(message);
            throw new GitLabApiException(message);
        }

        LOGGER.info("handleEvent: X-Gitlab-Event=" + eventName);
        if (!SYSTEM_HOOK_EVENT.equals(eventName)) {
            String message = "Unsupported X-Gitlab-Event, event Name=" + eventName;
            LOGGER.warning(message);
            throw new GitLabApiException(message);
        }

        // Get the JSON as a JsonNode tree.  We do not directly unmarshal the input as special handling must
        // be done for "merge_request" events.
        JsonNode tree;
        try {

            if (LOGGER.isLoggable(Level.FINE)) {
                LOGGER.fine(HttpRequestUtils.getShortRequestDump("System Hook", true, request));
                String postData = HttpRequestUtils.getPostDataAsString(request);
                LOGGER.fine("Raw POST data:\n" + postData);
                tree = jacksonJson.readTree(postData);
            } else {
                InputStreamReader reader = new InputStreamReader(request.getInputStream());
                tree = jacksonJson.readTree(reader);
            }

        } catch (Exception e) {
            LOGGER.warning("Error reading JSON data, exception=" +
                    e.getClass().getSimpleName() + ", error=" + e.getMessage());
            throw new GitLabApiException(e);
        }

        // NOTE: This is a hack based on the GitLab documentation and actual content of the "merge_request" event
        // showing that the "event_name" property is missing from the merge_request system hook event.  The hack is
        // to inject the "event_name" node so that the polymorphic deserialization of a SystemHookEvent works correctly
        // when the system hook event is a "merge_request" event.
        if (!tree.has("event_name") && tree.has("object_kind")) {

            String objectKind = tree.get("object_kind").asText();
            if (MergeRequestSystemHookEvent.MERGE_REQUEST_EVENT.equals(objectKind)) {
                ObjectNode node = (ObjectNode)tree;
                node.put("event_name", MergeRequestSystemHookEvent.MERGE_REQUEST_EVENT);
            } else {
                String message = "Unsupported object_kind for system hook event, object_kind=" + objectKind;
                LOGGER.warning(message);
                throw new GitLabApiException(message);
            }
        }

        // Unmarshal the tree to a concrete instance of a SystemHookEvent and fire the event to any listeners
        try {

            SystemHookEvent event = jacksonJson.unmarshal(SystemHookEvent.class, tree);
            if (LOGGER.isLoggable(Level.FINE)) {
                LOGGER.fine(event.getEventName() + "\n" + jacksonJson.marshal(event) + "\n");
            }

            StringBuffer requestUrl = request.getRequestURL();
            event.setRequestUrl(requestUrl != null ? requestUrl.toString() : null);
            event.setRequestQueryString(request.getQueryString());
            fireEvent(event);

        } catch (Exception e) {
            LOGGER.warning("Error processing JSON data, exception=" +
                    e.getClass().getSimpleName() + ", error=" + e.getMessage());
            throw new GitLabApiException(e);
        }
    }
779685
public void attempt(Request request) {
    this.attempt(request, new APICallback() {
      @Override
      public void error(Exception ex) {
      }

      public void response(Response r) {
      }
    });
  }
398921
private void updateStart(DownloadRequest request, long totalBytes) {
    /* if the request has failed before, donnot deliver callback */
    if (request.downloadState() == DownloadState.FAILURE) {
      updateState(request, DownloadState.RUNNING);
      return;
    }

    /* set the download state of this request as running */
    updateState(request, DownloadState.RUNNING);
    delivery.postStart(request, totalBytes);
  }
511158
public void setRequest(ServletRequest request) {
        if (request != null) {
            if (logger.isDebugEnabled()) {
                logger.debug(String.format("set request: %s", request));
            }
            this.threadLocalRequests.set((HttpServletRequest) request);
        } else {
            //if null, remove from threadLocalRequests
            // @see WindowTask#run 's finally
            if (logger.isDebugEnabled()) {
                HttpServletRequest tmpRequest = this.threadLocalRequests.get();
                logger.debug(String.format("remove request: %s", tmpRequest));
            }
            this.threadLocalRequests.remove();
        }
    }
446994
private void fireRequestSent(final AbstractBody request) {
        assertUnlocked();

        BOSHMessageEvent event = null;
        for (BOSHClientRequestListener listener : requestListeners) {
            if (event == null) {
                event = BOSHMessageEvent.createRequestSentEvent(this, request);
            }
            try {
                listener.requestSent(event);
            } catch (Exception ex) {
                LOG.log(Level.WARNING, UNHANDLED, ex);
            }
        }
    }
384193
private static void attemptRetryOnException(String logPrefix, Request<?> request,
                                                JusError exception) throws JusError {
        RetryPolicy retryPolicy = request.getRetryPolicy();

        if (retryPolicy == null) {
            throw exception;
        }

        try {
            retryPolicy.retry(exception);
        } catch (JusError e) {
            request.addMarker(Request.EVENT_NETWORK_RETRY_FAILED,
                    String.format("%s-timeout-giveup [conn-timeout=%s] [read-timeout=%s]",
                            logPrefix, retryPolicy.getCurrentConnectTimeout(),
                            retryPolicy.getCurrentReadTimeout()));
            throw e;
        }
        request.addMarker(Request.EVENT_NETWORK_RETRY,
                String.format("%s-retry [conn-timeout=%s] [read-timeout=%s]",
                        logPrefix, retryPolicy.getCurrentConnectTimeout(),
                        retryPolicy.getCurrentReadTimeout()));
    }
888733
function onRequest(request, response) {
  var filename = path.join(__dirname, request.url);

  // Serving server.js from cache. Useful for microbenchmarks.
  if (request.url === cachedUrl) {
    if (response.push) {
      // Also push down the client js, since it's possible if the requester wants
      // one, they want both.
      var push = response.push('/client.js');
      push.writeHead(200);
      fs.createReadStream(path.join(__dirname, '/client.js')).pipe(push);
    }
    response.end(cachedFile);
  }

  // Reading file from disk if it exists and is safe.
  else if ((filename.indexOf(__dirname) === 0) && fs.existsSync(filename) && fs.statSync(filename).isFile()) {
    response.writeHead(200);
    var fileStream = fs.createReadStream(filename);
    fileStream.pipe(response);
    fileStream.on('finish',response.end);
  }

  // Example for testing large (boundary-sized) frames.
  else if (request.url === "/largeframe") {
    response.writeHead(200);
    var body = 'a';
    for (var i = 0; i < 14; i++) {
      body += body;
    }
    body = body + 'a';
    response.end(body);
  }

  // Otherwise responding with 404.
  else {
    response.writeHead(404);
    response.end();
  }
}
288833
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        List<FileItem> items;
        // Parse the request
        try {
            items = upload.parseRequest(request);
        } catch (FileUploadException e) {
            throw new ServletException(e);
        }

        String repository = getParameter(items, REPOSITORY_NAME_PARAMETER);
        String incBinaries = getParameter(items, INCLUDE_BINARY_PARAMETER);
        String reindexOnFinish = getParameter(items, REINDEX_ON_FINISH_PARAMETER);

        RestoreParams params = new RestoreParams();
        params.setIncludeBinaries(Boolean.valueOf(incBinaries));
        params.setReindexOnFinish(Boolean.valueOf(reindexOnFinish));
        
        InputStream in = getStream(items);

        File dir = new File(tempDir.getAbsolutePath() + File.pathSeparator + 
                Long.toString(System.currentTimeMillis()));
        
        FileUtil.unzip(in, dir.getAbsolutePath());
        Connector connector = (Connector) request.getSession().getAttribute(REPOSITORY_CONNECTOR);

        try {
            connector.find(repository).restore(dir.getAbsolutePath(), params);
        } catch (Exception e) {
            throw new ServletException(e);
        }

        String uri = request.getContextPath()
                + String.format(DESTINATION_URL, repository);
        response.sendRedirect(uri);
    }