|
35 | 35 |
|
36 | 36 | /** |
37 | 37 | * Manages the lifetime of binding on the operation contexts to intercept send |
38 | | - * request events to Azure storage. |
| 38 | + * request events to Azure storage and allow concurrent OOB I/Os. |
39 | 39 | */ |
40 | 40 | @InterfaceAudience.Private |
41 | 41 | public final class SendRequestIntercept extends StorageEvent<SendingRequestEvent> { |
42 | 42 |
|
43 | 43 | public static final Log LOG = LogFactory.getLog(SendRequestIntercept.class); |
44 | 44 |
|
45 | 45 | private static final String ALLOW_ALL_REQUEST_PRECONDITIONS = "*"; |
46 | | - private final StorageCredentials storageCreds; |
47 | | - private final boolean allowConcurrentOOBIo; |
48 | | - private final OperationContext opContext; |
49 | 46 |
|
50 | 47 | /** |
51 | | - * Getter returning the storage account credentials. |
52 | | - * |
53 | | - * @return storageCreds - account storage credentials. |
54 | | - */ |
55 | | - private StorageCredentials getCredentials() { |
56 | | - return storageCreds; |
57 | | - } |
58 | | - |
59 | | - /** |
60 | | - * Query if out-of-band I/Os are allowed. |
61 | | - * |
62 | | - * return allowConcurrentOOBIo - true if OOB I/O is allowed, and false |
63 | | - * otherwise. |
| 48 | + * Hidden default constructor for SendRequestIntercept. |
64 | 49 | */ |
65 | | - private boolean isOutOfBandIoAllowed() { |
66 | | - return allowConcurrentOOBIo; |
67 | | - } |
68 | | - |
69 | | - /** |
70 | | - * Getter returning the operation context. |
71 | | - * |
72 | | - * @return storageCreds - account storage credentials. |
73 | | - */ |
74 | | - private OperationContext getOperationContext() { |
75 | | - return opContext; |
76 | | - } |
77 | | - |
78 | | - /** |
79 | | - * Constructor for SendRequestThrottle. |
80 | | - * |
81 | | - * @param storageCreds |
82 | | - * - storage account credentials for signing packets. |
83 | | - * |
84 | | - */ |
85 | | - private SendRequestIntercept(StorageCredentials storageCreds, |
86 | | - boolean allowConcurrentOOBIo, OperationContext opContext) { |
87 | | - // Capture the send delay callback interface. |
88 | | - this.storageCreds = storageCreds; |
89 | | - this.allowConcurrentOOBIo = allowConcurrentOOBIo; |
90 | | - this.opContext = opContext; |
| 50 | + private SendRequestIntercept() { |
91 | 51 | } |
92 | 52 |
|
93 | 53 | /** |
94 | 54 | * Binds a new lister to the operation context so the WASB file system can |
95 | | - * appropriately intercept sends. By allowing concurrent OOB I/Os, we bypass |
96 | | - * the blob immutability check when reading streams. |
| 55 | + * appropriately intercept sends and allow concurrent OOB I/Os. This |
| 56 | + * by-passes the blob immutability check when reading streams. |
97 | 57 | * |
98 | | - * @param storageCreds The credential of blob storage. |
99 | | - * @param opContext |
100 | | - * The operation context to bind to listener. |
101 | | - * |
102 | | - * @param allowConcurrentOOBIo |
103 | | - * True if reads are allowed with concurrent OOB writes. |
| 58 | + * @param opContext the operation context assocated with this request. |
104 | 59 | */ |
105 | | - public static void bind(StorageCredentials storageCreds, |
106 | | - OperationContext opContext, boolean allowConcurrentOOBIo) { |
107 | | - SendRequestIntercept sendListener = new SendRequestIntercept(storageCreds, |
108 | | - allowConcurrentOOBIo, opContext); |
109 | | - opContext.getSendingRequestEventHandler().addListener(sendListener); |
| 60 | + public static void bind(OperationContext opContext) { |
| 61 | + opContext.getSendingRequestEventHandler().addListener(new SendRequestIntercept()); |
110 | 62 | } |
111 | 63 |
|
112 | 64 | /** |
@@ -134,36 +86,11 @@ public void eventOccurred(SendingRequestEvent sendEvent) { |
134 | 86 | // Determine whether this is a download request by checking that the request |
135 | 87 | // method |
136 | 88 | // is a "GET" operation. |
137 | | - if (urlConnection.getRequestMethod().equalsIgnoreCase("GET") |
138 | | - && isOutOfBandIoAllowed()) { |
| 89 | + if (urlConnection.getRequestMethod().equalsIgnoreCase("GET")) { |
139 | 90 | // If concurrent reads on OOB writes are allowed, reset the if-match |
140 | 91 | // condition on the conditional header. |
141 | 92 | urlConnection.setRequestProperty(HeaderConstants.IF_MATCH, |
142 | 93 | ALLOW_ALL_REQUEST_PRECONDITIONS); |
143 | | - |
144 | | - // In the Java AzureSDK the packet is signed before firing the |
145 | | - // SendRequest. Setting |
146 | | - // the conditional packet header property changes the contents of the |
147 | | - // packet, therefore the packet has to be re-signed. |
148 | | - try { |
149 | | - // Sign the request. GET's have no payload so the content length is |
150 | | - // zero. |
151 | | - StorageCredentialsHelper.signBlobQueueAndFileRequest(getCredentials(), |
152 | | - urlConnection, -1L, getOperationContext()); |
153 | | - } catch (InvalidKeyException e) { |
154 | | - // Log invalid key exception to track signing error before the send |
155 | | - // fails. |
156 | | - String errString = String.format( |
157 | | - "Received invalid key exception when attempting sign packet." |
158 | | - + " Cause: %s", e.getCause().toString()); |
159 | | - LOG.error(errString); |
160 | | - } catch (StorageException e) { |
161 | | - // Log storage exception to track signing error before the call fails. |
162 | | - String errString = String.format( |
163 | | - "Received storage exception when attempting to sign packet." |
164 | | - + " Cause: %s", e.getCause().toString()); |
165 | | - LOG.error(errString); |
166 | | - } |
167 | 94 | } |
168 | 95 | } |
169 | 96 | } |
0 commit comments