Search in sources :

Example 1 with RequestResult

use of com.microsoft.azure.storage.RequestResult in project hadoop by apache.

the class SelfThrottlingIntercept method responseReceived.

public void responseReceived(ResponseReceivedEvent event) {
    RequestResult result = event.getRequestResult();
    Date startDate = result.getStartDate();
    Date stopDate = result.getStopDate();
    long elapsed = stopDate.getTime() - startDate.getTime();
    synchronized (this) {
        this.lastE2Elatency = elapsed;
    }
    if (LOG.isDebugEnabled()) {
        int statusCode = result.getStatusCode();
        String etag = result.getEtag();
        HttpURLConnection urlConnection = (HttpURLConnection) event.getConnectionObject();
        int contentLength = urlConnection.getContentLength();
        String requestMethod = urlConnection.getRequestMethod();
        long threadId = Thread.currentThread().getId();
        LOG.debug(String.format("SelfThrottlingIntercept:: ResponseReceived: threadId=%d, Status=%d, Elapsed(ms)=%d, ETAG=%s, contentLength=%d, requestMethod=%s", threadId, statusCode, elapsed, etag, contentLength, requestMethod));
    }
}
Also used : RequestResult(com.microsoft.azure.storage.RequestResult) HttpURLConnection(java.net.HttpURLConnection) Date(java.util.Date)

Example 2 with RequestResult

use of com.microsoft.azure.storage.RequestResult in project hadoop by apache.

the class ErrorMetricUpdater method eventOccurred.

@Override
public void eventOccurred(ResponseReceivedEvent eventArg) {
    RequestResult currentResult = operationContext.getLastResult();
    int statusCode = currentResult.getStatusCode();
    // if it's not found).
    if (statusCode >= HTTP_BAD_REQUEST && statusCode < HTTP_INTERNAL_ERROR && statusCode != HTTP_NOT_FOUND) {
        instrumentation.clientErrorEncountered();
    } else if (statusCode >= HTTP_INTERNAL_ERROR) {
        // It's a server error: a 5xx status. Could be an Azure Storage
        // bug or (more likely) throttling.
        instrumentation.serverErrorEncountered();
    }
}
Also used : RequestResult(com.microsoft.azure.storage.RequestResult)

Example 3 with RequestResult

use of com.microsoft.azure.storage.RequestResult in project hadoop by apache.

the class ResponseReceivedMetricUpdater method eventOccurred.

/**
   * Handle the response-received event from Azure SDK.
   */
@Override
public void eventOccurred(ResponseReceivedEvent eventArg) {
    instrumentation.webResponse();
    if (!(eventArg.getConnectionObject() instanceof HttpURLConnection)) {
        // Typically this shouldn't happen, but just let it pass
        return;
    }
    HttpURLConnection connection = (HttpURLConnection) eventArg.getConnectionObject();
    RequestResult currentResult = eventArg.getRequestResult();
    if (currentResult == null) {
        // Again, typically shouldn't happen, but let it pass
        return;
    }
    long requestLatency = currentResult.getStopDate().getTime() - currentResult.getStartDate().getTime();
    if (currentResult.getStatusCode() == HttpURLConnection.HTTP_CREATED && connection.getRequestMethod().equalsIgnoreCase("PUT")) {
        // If it's a PUT with an HTTP_CREATED status then it's a successful
        // block upload.
        long length = getRequestContentLength(connection);
        if (length > 0) {
            blockUploadGaugeUpdater.blockUploaded(currentResult.getStartDate(), currentResult.getStopDate(), length);
            instrumentation.rawBytesUploaded(length);
            instrumentation.blockUploaded(requestLatency);
        }
    } else if (currentResult.getStatusCode() == HttpURLConnection.HTTP_PARTIAL && connection.getRequestMethod().equalsIgnoreCase("GET")) {
        // If it's a GET with an HTTP_PARTIAL status then it's a successful
        // block download.
        long length = getResponseContentLength(connection);
        if (length > 0) {
            blockUploadGaugeUpdater.blockDownloaded(currentResult.getStartDate(), currentResult.getStopDate(), length);
            instrumentation.rawBytesDownloaded(length);
            instrumentation.blockDownloaded(requestLatency);
        }
    }
}
Also used : RequestResult(com.microsoft.azure.storage.RequestResult) HttpURLConnection(java.net.HttpURLConnection)

Aggregations

RequestResult (com.microsoft.azure.storage.RequestResult)3 HttpURLConnection (java.net.HttpURLConnection)2 Date (java.util.Date)1