Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
   *
   * Licensed under the Apache License, Version 2.0 (the "License").
   * You may not use this file except in compliance with the License.
   * A copy of the License is located at
   *
   *  http://aws.amazon.com/apache2.0
   *
  * or in the "license" file accompanying this file. This file is distributed
  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  * express or implied. See the License for the specific language governing
  * permissions and limitations under the License.
  */
 package com.amazonaws.event.request;
 
An actual implementation to represent the progress of a request/response.
 
 public class ProgressSupport extends Progress {
     /* Request transfer progress */
     private volatile long requestContentLength = -1;
     private volatile long requestBytesTransferred;
 
     /* Response transfer progress */
     private volatile long responseContentLength = -1;
     private volatile long responseBytesTransferred;
 
     private static final Object lock = new Object();

    
Returns the number of bytes to be expected in the request, or -1 if the number is unknown (e.g. when the request is still not serialized yet, or when the request contains raw InputStream as the payload in which case the SDK cannot infer the content-length in advance).
 
     @Override
     public long getRequestContentLength() {
         return ;
     }

    
Adds the number of bytes to be expected in the request.
 
     @Override
     public void addRequestContentLength(long contentLength) {
         if (contentLength < 0)
             throw new IllegalArgumentException();
         synchronized() {
             if (this. == -1)
                 this. = contentLength;
             else
                 this. += contentLength;
         }
     }

    
Returns the number of bytes that have been transferred in the request.
 
     @Override
     public long getRequestBytesTransferred() {
         return ;
     }

    
Returns the number of bytes to be expected in the response, or -1 if the number is unknown (e.g. when the client hasn't received the response yet).
 
     @Override
     public long getResponseContentLength() {
         return ;
     }

    
Adds the number of bytes to be expected in the response.
 
     @Override
     public void addResponseContentLength(long contentLength) {
         if (contentLength < 0)
             throw new IllegalArgumentException();
         synchronized() {
             if (this. == -1)
                 this. = contentLength;
             else
                 this. += contentLength;
         }
     }

    
Returns the number of bytes that have been transferred in the response.
 
     @Override
     public long getResponseBytesTransferred() {
         return ;
     }
    @Override
    public void addRequestBytesTransferred(long bytes) {
        synchronized () {
             += bytes;
        }
    }
    @Override
    public void addResponseBytesTransferred(long bytes) {
        synchronized() {
             += bytes;
        }
    }
    @Override
    public String toString() {
        return String.format("Request: %d/%d, Response: %d/%d",
                ,
                );
    }
    @Override
    public final boolean isEnabled() { return true; }
New to GrepCode? Check out our FAQ X