1 /*
2 * Copyright 2010-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License").
5 * You may not use this file except in compliance with the License.
6 * A copy of the License is located at
7 *
8 * http://aws.amazon.com/apache2.0
9 *
10 * or in the "license" file accompanying this file. This file is distributed
11 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12 * express or implied. See the License for the specific language governing
13 * permissions and limitations under the License.
14 */
15 package com.amazonaws.event;
16
17 /**
18 * An enumeration that denotes various types of progress event.
19 */
20 public enum ProgressEventType {
21 //////////////////////////////////////////////////////////////////////////
22 // Request Cycle Event:
23 // related to the execution of a single http request-response to AWS
24 //////////////////////////////////////////////////////////////////////////
25 /**
26 * A general byte transfer event that happens during sending a request or
27 * reading a response.
28 */
29 @Deprecated
30 BYTE_TRANSFER_EVENT,
31 /**
32 * Event of the content length to be sent in a request.
33 */
34 REQUEST_CONTENT_LENGTH_EVENT,
35 /**
36 * Event of the content length received in a response.
37 */
38 RESPONSE_CONTENT_LENGTH_EVENT,
39
40 /**
41 * Used to indicate the number of bytes to be sent to AWS.
42 */
43 REQUEST_BYTE_TRANSFER_EVENT,
44 /**
45 * Used to indicate the number of bytes received from AWS.
46 */
47 RESPONSE_BYTE_TRANSFER_EVENT,
48 /**
49 * Used to indicate the number of bytes discarded after being received from AWS.
50 */
51 RESPONSE_BYTE_DISCARD_EVENT,
52
53 /* Generic request progress events */
54
55 /**
56 * Event indicating that the client has started sending the AWS API request.
57 * This type of event is guaranteed to be only fired once during a
58 * request-response cycle, even when the request is retried.
59 */
60 CLIENT_REQUEST_STARTED_EVENT,
61
62 /**
63 * Event indicating that the client has started sending the HTTP request.
64 * The request progress listener will be notified of multiple instances of
65 * this type of event if the request gets retried.
66 */
67 HTTP_REQUEST_STARTED_EVENT,
68
69 /**
70 * Event indicating that the client has finished sending the HTTP request.
71 * The request progress listener will be notified of multiple instances of
72 * this type of event if the request gets retried.
73 */
74 HTTP_REQUEST_COMPLETED_EVENT,
75
76 /**
77 * Event indicating that the HTTP request content is reset, which may or may not
78 * be caused by the retry of the request.
79 */
80 HTTP_REQUEST_CONTENT_RESET_EVENT,
81
82 /**
83 * Event indicating that a failed request is detected as retryable and is
84 * ready for the next retry.
85 */
86 CLIENT_REQUEST_RETRY_EVENT,
87
88 /**
89 * Event indicating that the client has started reading the HTTP response.
90 * The request progress listener will be notified of this event only if the
91 * client receives a successful service response (i.e. 2XX status code).
92 */
93 HTTP_RESPONSE_STARTED_EVENT,
94
95 /**
96 * Event indicating that the client has finished reading the HTTP response.
97 * The request progress listener will be notified of this event only if the
98 * client receives a successful service response (i.e. 2XX status code).
99 */
100 HTTP_RESPONSE_COMPLETED_EVENT,
101
102 /**
103 * Event indicating that the HTTP response content is reset.
104 */
105 HTTP_RESPONSE_CONTENT_RESET_EVENT,
106
107 /**
108 * Event indicating that the client has received a successful service
109 * response and has finished parsing the response data.
110 */
111 CLIENT_REQUEST_SUCCESS_EVENT,
112
113 /**
114 * Event indicating that a client request has failed (after retries have
115 * been conducted).
116 */
117 CLIENT_REQUEST_FAILED_EVENT,
118
119 //////////////////////////////////////////////////////////////////////////
120 // Transfer Event:
121 // Progress events that are used by S3 and Glacier client */
122 //////////////////////////////////////////////////////////////////////////
123 TRANSFER_PREPARING_EVENT,
124 TRANSFER_STARTED_EVENT,
125 TRANSFER_COMPLETED_EVENT,
126 TRANSFER_FAILED_EVENT,
127 TRANSFER_CANCELED_EVENT,
128 TRANSFER_PART_STARTED_EVENT,
129 TRANSFER_PART_COMPLETED_EVENT,
130 TRANSFER_PART_FAILED_EVENT;
131
132 /**
133 * Returns true if this event type is a transfer event, which may involve
134 * multiple request cycle events.
135 *
136 * @see #isRequestCycleEvent()
137 */
138 public boolean isTransferEvent() {
139 switch (this) {
140 case TRANSFER_CANCELED_EVENT:
141 case TRANSFER_COMPLETED_EVENT:
142 case TRANSFER_FAILED_EVENT:
143 case TRANSFER_PART_COMPLETED_EVENT:
144 case TRANSFER_PART_FAILED_EVENT:
145 case TRANSFER_PART_STARTED_EVENT:
146 case TRANSFER_PREPARING_EVENT:
147 case TRANSFER_STARTED_EVENT:
148 return true;
149 default:
150 return false;
151 }
152 }
153
154 /**
155 * Returns true if this event type is related to the execution of a
156 * single http request-response to AWS; false otherwise.
157 */
158 public boolean isRequestCycleEvent() {
159 return !isTransferEvent();
160 }
161
162 /**
163 * Returns true if this even type is associated with some number of bytes;
164 * false otherwise.
165 */
166 public boolean isByteCountEvent() {
167 switch (this) {
168 case BYTE_TRANSFER_EVENT:
169 case HTTP_REQUEST_CONTENT_RESET_EVENT:
170 case HTTP_RESPONSE_CONTENT_RESET_EVENT:
171
172 case REQUEST_BYTE_TRANSFER_EVENT:
173 case RESPONSE_BYTE_TRANSFER_EVENT:
174
175 case RESPONSE_BYTE_DISCARD_EVENT:
176
177 case REQUEST_CONTENT_LENGTH_EVENT:
178 case RESPONSE_CONTENT_LENGTH_EVENT:
179 return true;
180 default:
181 return false;
182 }
183 }
184 }
185