From 8a143d867d8d1ebbbd37b748c8991a15d4d86910 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 14 Jan 2013 14:47:26 -0800 Subject: [PATCH 01/43] update the unit tests so that the job integration tests have the right prefixes. --- .../windowsazure/services/media/EncryptionIntegrationTest.java | 2 +- .../windowsazure/services/media/IntegrationTestBase.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java index 7713b82f1cb9e..012468b3f9fe2 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java @@ -93,7 +93,7 @@ public void uploadAesProtectedAssetAndDownloadSuccess() throws Exception { uploadEncryptedAssetFile(assetInfo, blobWriter, "MPEG4-H264.mp4", encryptedContent, contentKeyId, iv); // submit and execute the decoding job. - JobInfo jobInfo = decodeAsset("uploadAesProtectedAssetSuccess", assetInfo.getId()); + JobInfo jobInfo = decodeAsset(testJobPrefix + "uploadAesProtectedAssetSuccess", assetInfo.getId()); // assert LinkInfo taskLinkInfo = jobInfo.getTasksLink(); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java index e2e893b86b1f2..6535237b97d05 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java @@ -99,8 +99,8 @@ protected static void cleanupEnvironment() { removeAllTestLocators(); removeAllTestAssets(); removeAllTestAccessPolicies(); - removeAllTestContentKeys(); removeAllTestJobs(); + removeAllTestContentKeys(); } private static void removeAllTestContentKeys() { From 624cfa209a4969c746b2c360eb60e23bf84adaa9 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 14 Jan 2013 15:33:25 -0800 Subject: [PATCH 02/43] add TaskHistoricalEvent to the queue. --- .../media/models/TaskHistoricalEvent.java | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskHistoricalEvent.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskHistoricalEvent.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskHistoricalEvent.java new file mode 100644 index 0000000000000..14d44fc85142e --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskHistoricalEvent.java @@ -0,0 +1,76 @@ +/* + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License 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.microsoft.windowsazure.services.media.models; + +import java.util.Date; + +/** + * The Class TaskHistoricalEvent. + */ +public class TaskHistoricalEvent { + + /** The code. */ + private final String code; + + /** The message. */ + private final String message; + + /** The time stamp. */ + private final Date timeStamp; + + /** + * Instantiates a new error detail. + * + * @param code + * the code + * @param message + * the message + * @param timeStamp + * the time stamp + */ + public TaskHistoricalEvent(String code, String message, Date timeStamp) { + this.code = code; + this.message = message; + this.timeStamp = timeStamp; + } + + /** + * Gets the code. + * + * @return the code + */ + public String getCode() { + return this.code; + } + + /** + * Gets the message. + * + * @return the message + */ + public String getMessage() { + return this.message; + } + + /** + * Gets the time stamp. + * + * @return the time stamp + */ + public Date getTimeStamp() { + return this.timeStamp; + } +} From 84c6bd5d8495d52302de49da9158c4dc684c6170 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 14 Jan 2013 16:56:51 -0800 Subject: [PATCH 03/43] partial checkin for task historical event --- .../services/media/models/TaskInfo.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java index 8e8c3cd110877..6155b441531e5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java @@ -86,6 +86,22 @@ public List getErrorDetails() { return null; } + public List getTaskHistoricalEvents() { + List result = new ArrayList(); + List taskHistoricalEventTypes = getContent().getTaskHistoricalEventTypes(); + + if (taskHistoricalEventTypes != null) { + for (TaskHistoricalEventType taskHistoricalEventType : taskHistoricalEventTypes) { + TaskHistoricalEvent taskHistoricalEvent = new TaskHistoricalEvent(taskHistoricalEventType.getCode(), taskHistoricalEventType.getMessage(), taskHistoricalEventType.get) + result.add(taskHistoricalEvent); + } + } + + + + return null; + } + /** * Gets the media processor id. * From 76d9ecc7c05a786a4bdb59d88937fc573b19f9db Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 15 Jan 2013 14:03:45 -0800 Subject: [PATCH 04/43] initial check in to add task historical event type. --- .../content/TaskHistoricalEventType.java | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskHistoricalEventType.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskHistoricalEventType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskHistoricalEventType.java new file mode 100644 index 0000000000000..3a5ffdef35f33 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskHistoricalEventType.java @@ -0,0 +1,80 @@ +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License 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.microsoft.windowsazure.services.media.implementation.content; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; + +/** + * This type maps the XML returned in the odata ATOM serialization + * for ErrorDetail entities. + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +public class ErrorDetailType implements MediaServiceDTO { + + /** The code. */ + @XmlElement(name = "Code", namespace = Constants.ODATA_DATA_NS) + protected String code; + + /** The message. */ + @XmlElement(name = "Message", namespace = Constants.ODATA_DATA_NS) + protected String message; + + /** + * Gets the code. + * + * @return the code + */ + public String getCode() { + return code; + } + + /** + * Sets the code. + * + * @param code + * the id to set + * @return the error detail type + */ + public ErrorDetailType setCode(String code) { + this.code = code; + return this; + } + + /** + * Gets the message. + * + * @return the message + */ + public String getMessage() { + return message; + } + + /** + * Sets the message. + * + * @param message + * the message to set + * @return the error detail type + */ + public ErrorDetailType setMessage(String message) { + this.message = message; + return this; + } + +} From 7d5b4b63074cee3efae9b85eb0185e80fd27852e Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 15 Jan 2013 17:39:54 -0800 Subject: [PATCH 05/43] second checkin to support task historical events. --- .../content/TaskHistoricalEventType.java | 36 +++++++++++++++++-- .../implementation/content/TaskType.java | 13 +++++++ .../services/media/models/TaskInfo.java | 10 +++--- 3 files changed, 51 insertions(+), 8 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskHistoricalEventType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskHistoricalEventType.java index 3a5ffdef35f33..d5398864e2268 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskHistoricalEventType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskHistoricalEventType.java @@ -15,6 +15,8 @@ package com.microsoft.windowsazure.services.media.implementation.content; +import java.util.Date; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; @@ -25,7 +27,7 @@ * */ @XmlAccessorType(XmlAccessType.FIELD) -public class ErrorDetailType implements MediaServiceDTO { +public class TaskHistoricalEventType implements MediaServiceDTO { /** The code. */ @XmlElement(name = "Code", namespace = Constants.ODATA_DATA_NS) @@ -35,7 +37,14 @@ public class ErrorDetailType implements MediaServiceDTO { @XmlElement(name = "Message", namespace = Constants.ODATA_DATA_NS) protected String message; + /** The time stamp. */ + @XmlElement(name = "TimeStamp", namespace = Constants.ODATA_DATA_NS) + protected Date timeStamp; + /** + * The + * + * /** * Gets the code. * * @return the code @@ -51,7 +60,7 @@ public String getCode() { * the id to set * @return the error detail type */ - public ErrorDetailType setCode(String code) { + public TaskHistoricalEventType setCode(String code) { this.code = code; return this; } @@ -72,9 +81,30 @@ public String getMessage() { * the message to set * @return the error detail type */ - public ErrorDetailType setMessage(String message) { + public TaskHistoricalEventType setMessage(String message) { this.message = message; return this; } + /** + * Gets the time stamp. + * + * @return the time stamp + */ + public Date getTimeStamp() { + return timeStamp; + } + + /** + * Sets the time stamp. + * + * @param timeStamp + * the time stamp + * @return the task historical event type + */ + public TaskHistoricalEventType setTimeStamp(Date timeStamp) { + this.timeStamp = timeStamp; + return this; + } + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java index 9436ca9ab0255..a2ca4a59889b2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java @@ -44,6 +44,10 @@ public class TaskType implements MediaServiceDTO { @XmlElement(name = "element", namespace = Constants.ODATA_DATA_NS) protected List errorDetails; + @XmlElementWrapper(name = "TaskHistoricalEventDetails", namespace = Constants.ODATA_DATA_NS) + @XmlElement(name = "element", namespace = Constants.ODATA_DATA_NS) + protected List taskHistoricalEventTypes; + @XmlElement(name = "MediaProcessorId", namespace = Constants.ODATA_DATA_NS) protected String mediaProcessorId; @@ -269,4 +273,13 @@ public TaskType setInputMediaAssets(List inputMediaAssets) { this.inputMediaAssets = inputMediaAssets; return this; } + + public List getTaskHistoricalEventTypes() { + return taskHistoricalEventTypes; + } + + public TaskType setTaskHistoricalEventTypes(List taskHistoricalEventTypes) { + this.taskHistoricalEventTypes = taskHistoricalEventTypes; + return this; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java index 6155b441531e5..99b983acfb1bd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java @@ -22,6 +22,7 @@ import com.microsoft.windowsazure.services.media.implementation.ODataEntity; import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; import com.microsoft.windowsazure.services.media.implementation.content.ErrorDetailType; +import com.microsoft.windowsazure.services.media.implementation.content.TaskHistoricalEventType; import com.microsoft.windowsazure.services.media.implementation.content.TaskType; /** @@ -89,16 +90,15 @@ public List getErrorDetails() { public List getTaskHistoricalEvents() { List result = new ArrayList(); List taskHistoricalEventTypes = getContent().getTaskHistoricalEventTypes(); - + if (taskHistoricalEventTypes != null) { for (TaskHistoricalEventType taskHistoricalEventType : taskHistoricalEventTypes) { - TaskHistoricalEvent taskHistoricalEvent = new TaskHistoricalEvent(taskHistoricalEventType.getCode(), taskHistoricalEventType.getMessage(), taskHistoricalEventType.get) + TaskHistoricalEvent taskHistoricalEvent = new TaskHistoricalEvent(taskHistoricalEventType.getCode(), + taskHistoricalEventType.getMessage(), taskHistoricalEventType.getTimeStamp()); result.add(taskHistoricalEvent); } } - - - + return null; } From 466c43b9657535f8d6634e196394a3f8a11968c7 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 22 Jan 2013 17:10:18 -0800 Subject: [PATCH 06/43] add job integration test for taskhistorical event --- .../implementation/content/TaskType.java | 2 +- .../services/media/models/TaskInfo.java | 2 +- .../services/media/JobIntegrationTest.java | 26 +++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java index a2ca4a59889b2..2626a0489a7ac 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java @@ -44,7 +44,7 @@ public class TaskType implements MediaServiceDTO { @XmlElement(name = "element", namespace = Constants.ODATA_DATA_NS) protected List errorDetails; - @XmlElementWrapper(name = "TaskHistoricalEventDetails", namespace = Constants.ODATA_DATA_NS) + @XmlElementWrapper(name = "HistoricalEvents", namespace = Constants.ODATA_DATA_NS) @XmlElement(name = "element", namespace = Constants.ODATA_DATA_NS) protected List taskHistoricalEventTypes; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java index 99b983acfb1bd..e63c8ff4ff9c8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java @@ -99,7 +99,7 @@ public List getTaskHistoricalEvents() { } } - return null; + return result; } /** diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index d93041f2c5330..8ce2bd3578916 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -35,6 +35,7 @@ import com.microsoft.windowsazure.services.media.models.ListResult; import com.microsoft.windowsazure.services.media.models.Task; import com.microsoft.windowsazure.services.media.models.Task.CreateBatchOperation; +import com.microsoft.windowsazure.services.media.models.TaskHistoricalEvent; import com.microsoft.windowsazure.services.media.models.TaskInfo; public class JobIntegrationTest extends IntegrationTestBase { @@ -344,4 +345,29 @@ public void canGetInputOutputAssetsFromTask() throws Exception { assertTrue(outputs.get(0).getName().contains(name)); } + @Test + public void canGetTaskHistoricalEventsFromTask() throws Exception { + // Arrange + String jobName = testJobPrefix + "canGetTaskHistoricalEventsFromTask"; + int priority = 3; + int retryCounter = 0; + + // Act + JobInfo actualJobInfo = service.create(Job.create().setName(jobName).setPriority(priority) + .addInputMediaAsset(assetInfo.getId()).addTaskCreator(getTaskCreator(0))); + + while (actualJobInfo.getState().getCode() < 3 && retryCounter < 30) { + Thread.sleep(10000); + actualJobInfo = service.get(Job.get(actualJobInfo.getId())); + retryCounter++; + } + ListResult tasks = service.list(Task.list(actualJobInfo.getTasksLink())); + TaskInfo taskInfo = tasks.get(0); + List taskHistoricalEvents = taskInfo.getTaskHistoricalEvents(); + + // Assert + assertEquals(5, taskHistoricalEvents.size()); + + } + } From f7dce4bd3ed875217afa0b30c5063e09704dfada Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 24 Jan 2013 16:22:18 -0800 Subject: [PATCH 07/43] code review feedback. --- .../content/TaskHistoricalEventType.java | 3 --- .../implementation/content/TaskType.java | 10 ++++---- .../services/media/models/TaskInfo.java | 23 +++++++++++++------ .../services/media/JobIntegrationTest.java | 9 +++++--- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskHistoricalEventType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskHistoricalEventType.java index d5398864e2268..973b9b53c3e2c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskHistoricalEventType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskHistoricalEventType.java @@ -42,9 +42,6 @@ public class TaskHistoricalEventType implements MediaServiceDTO { protected Date timeStamp; /** - * The - * - * /** * Gets the code. * * @return the code diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java index 2626a0489a7ac..e6486eb697d0b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java @@ -46,7 +46,7 @@ public class TaskType implements MediaServiceDTO { @XmlElementWrapper(name = "HistoricalEvents", namespace = Constants.ODATA_DATA_NS) @XmlElement(name = "element", namespace = Constants.ODATA_DATA_NS) - protected List taskHistoricalEventTypes; + protected List historicalEventTypes; @XmlElement(name = "MediaProcessorId", namespace = Constants.ODATA_DATA_NS) protected String mediaProcessorId; @@ -274,12 +274,12 @@ public TaskType setInputMediaAssets(List inputMediaAssets) { return this; } - public List getTaskHistoricalEventTypes() { - return taskHistoricalEventTypes; + public List getHistoricalEventTypes() { + return historicalEventTypes; } - public TaskType setTaskHistoricalEventTypes(List taskHistoricalEventTypes) { - this.taskHistoricalEventTypes = taskHistoricalEventTypes; + public TaskType setHistoricalEventTypes(List historicalEventTypes) { + this.historicalEventTypes = historicalEventTypes; return this; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java index e63c8ff4ff9c8..6f22c00bb7697 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java @@ -87,14 +87,23 @@ public List getErrorDetails() { return null; } - public List getTaskHistoricalEvents() { + /** + * Gets the task historical events. + * + * @return the task historical events + */ + public List getHistoricalEvents() { List result = new ArrayList(); - List taskHistoricalEventTypes = getContent().getTaskHistoricalEventTypes(); + List historicalEventTypes = getContent().getHistoricalEventTypes(); - if (taskHistoricalEventTypes != null) { - for (TaskHistoricalEventType taskHistoricalEventType : taskHistoricalEventTypes) { + if (historicalEventTypes != null) { + for (TaskHistoricalEventType taskHistoricalEventType : historicalEventTypes) { + String message = taskHistoricalEventType.getMessage(); + if ((message != null) && (message.isEmpty())) { + message = null; + } TaskHistoricalEvent taskHistoricalEvent = new TaskHistoricalEvent(taskHistoricalEventType.getCode(), - taskHistoricalEventType.getMessage(), taskHistoricalEventType.getTimeStamp()); + message, taskHistoricalEventType.getTimeStamp()); result.add(taskHistoricalEvent); } } @@ -229,7 +238,7 @@ public String getInitializationVector() { } /** - * Gets link to the task's input assets + * Gets link to the task's input assets. * * @return the link */ @@ -238,7 +247,7 @@ public LinkInfo getInputAssetsLink() { } /** - * Gets link to the task's output assets + * Gets link to the task's output assets. * * @return the link */ diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index 8ce2bd3578916..def737d69d566 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -363,11 +363,14 @@ public void canGetTaskHistoricalEventsFromTask() throws Exception { } ListResult tasks = service.list(Task.list(actualJobInfo.getTasksLink())); TaskInfo taskInfo = tasks.get(0); - List taskHistoricalEvents = taskInfo.getTaskHistoricalEvents(); + List historicalEvents = taskInfo.getHistoricalEvents(); + TaskHistoricalEvent historicalEvent = historicalEvents.get(0); // Assert - assertEquals(5, taskHistoricalEvents.size()); - + assertEquals(5, historicalEvents.size()); + assertNotNull(historicalEvent.getCode()); + assertNotNull(historicalEvent.getTimeStamp()); + assertNull(historicalEvent.getMessage()); } } From 6db3cad63749441f220db23ea6fe0078578a2a5c Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 24 Jan 2013 16:44:50 -0800 Subject: [PATCH 08/43] a missed unit test. --- .../windowsazure/services/media/JobIntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index def737d69d566..ebfa367250e17 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -367,7 +367,7 @@ public void canGetTaskHistoricalEventsFromTask() throws Exception { TaskHistoricalEvent historicalEvent = historicalEvents.get(0); // Assert - assertEquals(5, historicalEvents.size()); + assertTrue(historicalEvents.size() >= 5); assertNotNull(historicalEvent.getCode()); assertNotNull(historicalEvent.getTimeStamp()); assertNull(historicalEvent.getMessage()); From 78067fcb4d816044818f4b0daa5024ace55888ec Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" Date: Mon, 28 Jan 2013 14:12:30 -0800 Subject: [PATCH 09/43] Minor changes to address the compile-time warnings --- .../core/utils/ServiceExceptionFactory.java | 2 +- .../implementation/BrokerProperties.java | 20 ++++++------ .../services/table/client/TableQuery.java | 4 +++ .../table/implementation/TableRestProxy.java | 4 +++ .../queue/client/CloudQueueClientTests.java | 32 ++++++++++++++----- .../queue/client/CloudQueueTests.java | 8 +++-- .../serviceBus/ServiceBusIntegrationTest.java | 2 +- 7 files changed, 50 insertions(+), 22 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/ServiceExceptionFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/ServiceExceptionFactory.java index 2efac14c00b04..2d7a029c30c71 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/ServiceExceptionFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/ServiceExceptionFactory.java @@ -28,7 +28,7 @@ public static ServiceException process(String serviceName, ServiceException exce Throwable cause = exception.getCause(); for (Throwable scan = cause; scan != null; scan = scan.getCause()) { - Class scanClass = scan.getClass(); + Class scanClass = scan.getClass(); if (ServiceException.class.isAssignableFrom(scanClass)) { return populate(exception, serviceName, (ServiceException) scan); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerProperties.java index 2db84273def96..e677178530558 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerProperties.java @@ -2,15 +2,15 @@ * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License 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. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License 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.microsoft.windowsazure.services.serviceBus.implementation; @@ -19,7 +19,7 @@ import org.codehaus.jackson.annotate.JsonIgnore; import org.codehaus.jackson.annotate.JsonIgnoreProperties; import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.annotate.JsonWriteNullProperties; +import org.codehaus.jackson.map.annotate.JsonSerialize; // // members of this class defined per specification at @@ -27,7 +27,7 @@ // @JsonIgnoreProperties(ignoreUnknown = true) -@JsonWriteNullProperties(false) +@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) public class BrokerProperties { @JsonProperty("CorrelationId") diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableQuery.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableQuery.java index 6b5e126951015..924ab0fead225 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableQuery.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableQuery.java @@ -202,6 +202,8 @@ public static String generateFilterCondition(String propertyName, String operati for (byte b : value) { formatter.format("%02x", b); } + formatter.flush(); + formatter.close(); return generateFilterCondition(propertyName, operation, sb.toString(), EdmType.BINARY); } @@ -232,6 +234,8 @@ public static String generateFilterCondition(String propertyName, String operati for (byte b : value) { formatter.format("%02x", b); } + formatter.flush(); + formatter.close(); return generateFilterCondition(propertyName, operation, sb.toString(), EdmType.BINARY); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/TableRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/TableRestProxy.java index 72379bb2582bd..193f2305b1996 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/TableRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/TableRestProxy.java @@ -257,6 +257,8 @@ else if (value.getClass() == byte[].class) { for (byte b : byteArray) { formatter.format("%02x", b); } + formatter.flush(); + formatter.close(); sb.append("'"); } else if (value.getClass() == Byte[].class) { @@ -266,6 +268,8 @@ else if (value.getClass() == Byte[].class) { for (Byte b : byteArray) { formatter.format("%02x", b); } + formatter.flush(); + formatter.close(); sb.append("'"); } else { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClientTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClientTests.java index b3c266fac5aed..0d560e3f9ef25 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClientTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClientTests.java @@ -67,7 +67,9 @@ public void testListQueuesSmallNumber() throws URISyntaxException, StorageExcept int initialCount = 0; for (CloudQueue queue : qClient.listQueues()) { - initialCount++; + if (queue != null) { + initialCount++; + } } HashMap metadata1 = new HashMap(); @@ -82,7 +84,9 @@ public void testListQueuesSmallNumber() throws URISyntaxException, StorageExcept int count = 0; for (CloudQueue queue : qClient.listQueues()) { - count++; + if (queue != null) { + count++; + } } Assert.assertEquals(count, initialCount + 25); @@ -99,7 +103,9 @@ public void testListQueuesSmallNumber() throws URISyntaxException, StorageExcept count = 0; for (CloudQueue queue : qClient.listQueues(perfix, QueueListingDetails.METADATA, null, null)) { - count++; + if (queue != null) { + count++; + } Assert.assertTrue(queue.getMetadata().size() == 1 && queue.getMetadata().get("tags").equals(queue.getName())); } @@ -111,7 +117,9 @@ public void testListQueuesSmallNumber() throws URISyntaxException, StorageExcept public void testListQueuesAndListQueuesSegmentedLargeNumber() throws URISyntaxException, StorageException { int count = 0; for (CloudQueue queue : qClient.listQueues()) { - count++; + if (queue != null) { + count++; + } } int totalLimit = 5005; @@ -130,7 +138,9 @@ public void testListQueuesAndListQueuesSegmentedLargeNumber() throws URISyntaxEx count = 0; for (CloudQueue queue : qClient.listQueues()) { - count++; + if (queue != null) { + count++; + } } } @@ -181,17 +191,23 @@ public void testListQueuesSegmented() throws URISyntaxException, StorageExceptio public void testListQueuesEqual() throws URISyntaxException, StorageException { int count1 = 0; for (CloudQueue queue : qClient.listQueues()) { - count1++; + if (queue != null) { + count1++; + } } int count2 = 0; for (CloudQueue queue : qClient.listQueues("")) { - count2++; + if (queue != null) { + count2++; + } } int count3 = 0; for (CloudQueue queue : qClient.listQueues(null)) { - count3++; + if (queue != null) { + count3++; + } } Assert.assertEquals(count1, count2); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java index d97bb4bdc7b45..bf9b428d9fa8f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java @@ -487,7 +487,9 @@ public void testClearMessages() throws URISyntaxException, StorageException, Uns int count = 0; for (CloudQueueMessage m : queue.peekMessages(32)) { - count++; + if (m != null) { + count++; + } } Assert.assertTrue(count == 2); @@ -498,7 +500,9 @@ public void testClearMessages() throws URISyntaxException, StorageException, Uns count = 0; for (CloudQueueMessage m : queue.peekMessages(32)) { - count++; + if (m != null) { + count++; + } } Assert.assertTrue(count == 0); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index bd86d9b7abf9f..c09af13305b8b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -128,7 +128,7 @@ public void getNonExistQueueFail() throws Exception { String queuePath = "testGetNonExistQueueFail"; // Act - GetQueueResult getQueueResult = service.getQueue(queuePath); + service.getQueue(queuePath); // Assert } From 7a8812e48afa72b8fe227a64e8d2122f2e0fd8ee Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" Date: Tue, 29 Jan 2013 09:15:31 -0800 Subject: [PATCH 10/43] Remove trivial TODO comments from tests --- .../Protocol1RuntimeGoalStateClientTests.java | 24 +++++++++---------- .../queue/client/CloudQueueTests.java | 4 ---- .../table/client/TableQueryTests.java | 1 - 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClientTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClientTests.java index 42f4d4acab31f..00a669a080ffe 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClientTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClientTests.java @@ -2,25 +2,26 @@ * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License 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. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License 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.microsoft.windowsazure.serviceruntime; +import static org.hamcrest.Matchers.*; +import static org.junit.Assert.*; + import java.io.InputStream; import java.util.LinkedList; import java.util.List; import org.junit.Test; -import static org.junit.Assert.*; -import static org.hamcrest.Matchers.*; /** * @@ -88,7 +89,7 @@ public void goalStateClientRestartsThread() { Protocol1RuntimeCurrentStateClient currentStateClient = new Protocol1RuntimeCurrentStateClient(null, null); GoalStateDeserializer goalStateDeserializer = new GoalStateDeserializer() { - private ChunkedGoalStateDeserializer deserializer = new ChunkedGoalStateDeserializer(); + private final ChunkedGoalStateDeserializer deserializer = new ChunkedGoalStateDeserializer(); @Override public void initialize(InputStream inputStream) { @@ -148,7 +149,6 @@ public RoleEnvironmentData deserialize(InputStream stream) { client.getCurrentGoalState(); } catch (InterruptedException e) { - // TODO Auto-generated catch block e.printStackTrace(); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java index bf9b428d9fa8f..543b0b382cd32 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java @@ -691,7 +691,6 @@ public void testAddMessageWithVisibilityTimeout() throws URISyntaxException, Sto Thread.sleep(2000); } catch (InterruptedException e) { - // TODO Auto-generated catch block e.printStackTrace(); } @@ -841,7 +840,6 @@ public void testRetrieveMessage() throws URISyntaxException, StorageException, U Thread.sleep(2000); } catch (InterruptedException e) { - // TODO Auto-generated catch block e.printStackTrace(); } @@ -934,7 +932,6 @@ public void testDequeueCountIncreases() throws URISyntaxException, StorageExcept Thread.sleep(2000); } catch (InterruptedException e) { - // TODO Auto-generated catch block e.printStackTrace(); } @@ -1170,7 +1167,6 @@ public void testUpdateMessageFullPass() throws URISyntaxException, StorageExcept Thread.sleep(2000); } catch (InterruptedException e) { - // TODO Auto-generated catch block e.printStackTrace(); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableQueryTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableQueryTests.java index 7bec262714c07..8023517879ace 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableQueryTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableQueryTests.java @@ -364,7 +364,6 @@ public void testQueryOnSupportedTypes() throws StorageException { Thread.sleep(100); } catch (InterruptedException e) { - // TODO Auto-generated catch block e.printStackTrace(); } batch.insert(ent); From dda240d20da918b7529df2b014e5646c3ea079a6 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" Date: Tue, 29 Jan 2013 09:19:28 -0800 Subject: [PATCH 11/43] Removing trivial TODO Auto-generated comments --- .../serviceruntime/RoleEnvironment.java | 18 ++++++------ .../BrokerPropertiesMapper.java | 28 ++++++------------- .../implementation/MarshallerProvider.java | 23 ++++++--------- .../table/implementation/SharedKeyFilter.java | 2 -- 4 files changed, 26 insertions(+), 45 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironment.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironment.java index 5d8f04727b042..e5e3e865f67c2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironment.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironment.java @@ -2,15 +2,15 @@ * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License 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. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License 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.microsoft.windowsazure.serviceruntime; @@ -50,7 +50,6 @@ public final class RoleEnvironment { JAXBContext.newInstance(RoleEnvironment.class.getPackage().getName()); } catch (JAXBException e) { - // TODO Auto-generated catch block e.printStackTrace(); } clientId = UUID.randomUUID().toString(); @@ -93,6 +92,7 @@ private static synchronized void initialize() { lastState = new AtomicReference(); runtimeClient.addGoalStateChangedListener(new GoalStateChangedListener() { + @Override public void goalStateChanged(GoalState newGoalState) { switch (newGoalState.getExpectedState()) { case STARTED: diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java index 5a8dda45f9bae..a01aa2aed43b0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java @@ -2,15 +2,15 @@ * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License 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. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License 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.microsoft.windowsazure.services.serviceBus.implementation; @@ -31,18 +31,12 @@ public BrokerProperties fromString(String value) throws IllegalArgumentException return mapper.readValue(value.getBytes(), BrokerProperties.class); } catch (JsonParseException e) { - // TODO Auto-generated catch block - e.printStackTrace(); throw new IllegalArgumentException(e); } catch (JsonMappingException e) { - // TODO Auto-generated catch block - e.printStackTrace(); throw new IllegalArgumentException(e); } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); throw new IllegalArgumentException(e); } } @@ -54,18 +48,12 @@ public String toString(BrokerProperties value) { mapper.writeValue(writer, value); } catch (JsonGenerationException e) { - // TODO Auto-generated catch block - e.printStackTrace(); throw new RuntimeException(e); } catch (JsonMappingException e) { - // TODO Auto-generated catch block - e.printStackTrace(); throw new RuntimeException(e); } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); throw new RuntimeException(e); } return writer.toString(); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/MarshallerProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/MarshallerProvider.java index fbda9c3f7f5e1..3edfc51d87c26 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/MarshallerProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/MarshallerProvider.java @@ -2,15 +2,15 @@ * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License 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. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License 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.microsoft.windowsazure.services.serviceBus.implementation; @@ -30,19 +30,16 @@ public class MarshallerProvider implements ContextResolver { @Context private ContextResolver jaxbContextResolver; + @Override public Marshaller getContext(Class type) { Marshaller marshaller; try { marshaller = getJAXBContext(type).createMarshaller(); } catch (JAXBException e) { - // TODO Auto-generated catch block - e.printStackTrace(); return null; } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); return null; } com.sun.xml.bind.marshaller.NamespacePrefixMapper mapper = new NamespacePrefixMapperImpl(); @@ -50,8 +47,6 @@ public Marshaller getContext(Class type) { marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", mapper); } catch (PropertyException e) { - // TODO Auto-generated catch block - e.printStackTrace(); return null; } return marshaller; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/SharedKeyFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/SharedKeyFilter.java index d14843554216f..352115a45dbae 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/SharedKeyFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/SharedKeyFilter.java @@ -55,8 +55,6 @@ public void sign(ClientRequest cr) { if (log.isDebugEnabled()) { log.debug(String.format("String to sign: \"%s\"", stringToSign)); } - //TODO: Remove or comment the following line - //System.out.println(String.format("String to sign: \"%s\"", stringToSign)); String signature = this.getSigner().sign(stringToSign); cr.getHeaders().putSingle("Authorization", "SharedKey " + this.getAccountName() + ":" + signature); From 40bd3e5a0eb9bbd70f918fd188c11c2ff0666ad1 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" Date: Tue, 29 Jan 2013 10:32:33 -0800 Subject: [PATCH 12/43] Replace trivial *if* statement with more useful Assert --- .../queue/client/CloudQueueClientTests.java | 39 +++++++------------ .../queue/client/CloudQueueTests.java | 10 ++--- 2 files changed, 19 insertions(+), 30 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClientTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClientTests.java index 0d560e3f9ef25..fd3a57a7f1f1b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClientTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClientTests.java @@ -67,9 +67,8 @@ public void testListQueuesSmallNumber() throws URISyntaxException, StorageExcept int initialCount = 0; for (CloudQueue queue : qClient.listQueues()) { - if (queue != null) { - initialCount++; - } + Assert.assertNotNull(queue); + initialCount++; } HashMap metadata1 = new HashMap(); @@ -84,9 +83,8 @@ public void testListQueuesSmallNumber() throws URISyntaxException, StorageExcept int count = 0; for (CloudQueue queue : qClient.listQueues()) { - if (queue != null) { - count++; - } + Assert.assertNotNull(queue); + count++; } Assert.assertEquals(count, initialCount + 25); @@ -103,9 +101,7 @@ public void testListQueuesSmallNumber() throws URISyntaxException, StorageExcept count = 0; for (CloudQueue queue : qClient.listQueues(perfix, QueueListingDetails.METADATA, null, null)) { - if (queue != null) { - count++; - } + count++; Assert.assertTrue(queue.getMetadata().size() == 1 && queue.getMetadata().get("tags").equals(queue.getName())); } @@ -117,9 +113,8 @@ public void testListQueuesSmallNumber() throws URISyntaxException, StorageExcept public void testListQueuesAndListQueuesSegmentedLargeNumber() throws URISyntaxException, StorageException { int count = 0; for (CloudQueue queue : qClient.listQueues()) { - if (queue != null) { - count++; - } + Assert.assertNotNull(queue); + count++; } int totalLimit = 5005; @@ -138,9 +133,8 @@ public void testListQueuesAndListQueuesSegmentedLargeNumber() throws URISyntaxEx count = 0; for (CloudQueue queue : qClient.listQueues()) { - if (queue != null) { - count++; - } + Assert.assertNotNull(queue); + count++; } } @@ -191,23 +185,20 @@ public void testListQueuesSegmented() throws URISyntaxException, StorageExceptio public void testListQueuesEqual() throws URISyntaxException, StorageException { int count1 = 0; for (CloudQueue queue : qClient.listQueues()) { - if (queue != null) { - count1++; - } + Assert.assertNotNull(queue); + count1++; } int count2 = 0; for (CloudQueue queue : qClient.listQueues("")) { - if (queue != null) { - count2++; - } + Assert.assertNotNull(queue); + count2++; } int count3 = 0; for (CloudQueue queue : qClient.listQueues(null)) { - if (queue != null) { - count3++; - } + Assert.assertNotNull(queue); + count3++; } Assert.assertEquals(count1, count2); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java index 543b0b382cd32..699bbd128b10e 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java @@ -487,9 +487,8 @@ public void testClearMessages() throws URISyntaxException, StorageException, Uns int count = 0; for (CloudQueueMessage m : queue.peekMessages(32)) { - if (m != null) { - count++; - } + Assert.assertNotNull(m); + count++; } Assert.assertTrue(count == 2); @@ -500,9 +499,8 @@ public void testClearMessages() throws URISyntaxException, StorageException, Uns count = 0; for (CloudQueueMessage m : queue.peekMessages(32)) { - if (m != null) { - count++; - } + Assert.assertNotNull(m); + count++; } Assert.assertTrue(count == 0); From 269db3f312b47e10969aec4a3f84787a47a5721e Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" Date: Tue, 29 Jan 2013 11:11:16 -0800 Subject: [PATCH 13/43] Remove "catch (InterruptedException e)" that could obscure unexpected test failres. --- .../queue/client/CloudQueueTests.java | 40 +++++-------------- .../table/client/TableQueryTests.java | 11 ++--- 2 files changed, 14 insertions(+), 37 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java index 699bbd128b10e..9258e5931787f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java @@ -676,7 +676,7 @@ public void testAddMessageLargeMessageInput() throws URISyntaxException, Storage @Test public void testAddMessageWithVisibilityTimeout() throws URISyntaxException, StorageException, - UnsupportedEncodingException { + UnsupportedEncodingException, InterruptedException { final String queueName = UUID.randomUUID().toString().toLowerCase(); final CloudQueue queue = qClient.getQueueReference(queueName); queue.create(); @@ -685,12 +685,7 @@ public void testAddMessageWithVisibilityTimeout() throws URISyntaxException, Sto Date d1 = m1.getExpirationTime(); queue.deleteMessage(m1); - try { - Thread.sleep(2000); - } - catch (InterruptedException e) { - e.printStackTrace(); - } + Thread.sleep(2000); queue.addMessage(new CloudQueueMessage("message"), 20, 0, null, null); CloudQueueMessage m2 = queue.retrieveMessage(); @@ -819,7 +814,8 @@ public void testDeleteMessageNullMessage() throws URISyntaxException, StorageExc } @Test - public void testRetrieveMessage() throws URISyntaxException, StorageException, UnsupportedEncodingException { + public void testRetrieveMessage() throws URISyntaxException, StorageException, UnsupportedEncodingException, + InterruptedException { String queueName = UUID.randomUUID().toString().toLowerCase(); CloudQueue newQueue = qClient.getQueueReference(queueName); newQueue.create(); @@ -834,12 +830,7 @@ public void testRetrieveMessage() throws URISyntaxException, StorageException, U newQueue.deleteMessage(message1); - try { - Thread.sleep(2000); - } - catch (InterruptedException e) { - e.printStackTrace(); - } + Thread.sleep(2000); newQueue.addMessage(new CloudQueueMessage("message"), 20, 0, null, null); CloudQueueMessage message2 = newQueue.retrieveMessage(); @@ -917,7 +908,8 @@ public void testRetrieveMessagesNonFound() throws URISyntaxException, StorageExc } @Test - public void testDequeueCountIncreases() throws URISyntaxException, StorageException, UnsupportedEncodingException { + public void testDequeueCountIncreases() throws URISyntaxException, StorageException, UnsupportedEncodingException, + InterruptedException { String queueName = UUID.randomUUID().toString().toLowerCase(); CloudQueue newQueue = qClient.getQueueReference(queueName); newQueue.create(); @@ -926,13 +918,7 @@ public void testDequeueCountIncreases() throws URISyntaxException, StorageExcept Assert.assertTrue(message1.getDequeueCount() == 1); for (int i = 2; i < 5; i++) { - try { - Thread.sleep(2000); - } - catch (InterruptedException e) { - e.printStackTrace(); - } - + Thread.sleep(2000); CloudQueueMessage message2 = newQueue.retrieveMessage(1, null, null); Assert.assertTrue(message2.getDequeueCount() == i); } @@ -1146,7 +1132,8 @@ public void testUpdateMessage() throws URISyntaxException, StorageException, Uns } @Test - public void testUpdateMessageFullPass() throws URISyntaxException, StorageException, UnsupportedEncodingException { + public void testUpdateMessageFullPass() throws URISyntaxException, StorageException, UnsupportedEncodingException, + InterruptedException { String queueName = UUID.randomUUID().toString().toLowerCase(); CloudQueue newQueue = qClient.getQueueReference(queueName); newQueue.create(); @@ -1161,12 +1148,7 @@ public void testUpdateMessageFullPass() throws URISyntaxException, StorageExcept Assert.assertTrue(popreceipt2 != popreceipt1); Assert.assertTrue(NextVisibleTim1.before(NextVisibleTim2)); - try { - Thread.sleep(2000); - } - catch (InterruptedException e) { - e.printStackTrace(); - } + Thread.sleep(2000); String newMesage = message.getMessageContentAsString() + "updated"; message.setMessageContent(newMesage); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableQueryTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableQueryTests.java index 8023517879ace..d8818dddc09c2 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableQueryTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableQueryTests.java @@ -334,7 +334,7 @@ public void tableInvalidQuery() throws StorageException, IOException, URISyntaxE } @Test - public void testQueryOnSupportedTypes() throws StorageException { + public void testQueryOnSupportedTypes() throws StorageException, InterruptedException { // Setup TableBatchOperation batch = new TableBatchOperation(); String pk = UUID.randomUUID().toString(); @@ -359,13 +359,8 @@ public void testQueryOnSupportedTypes() throws StorageException { ent.setGuid(UUID.randomUUID()); ent.setString(String.format("%04d", j)); - try { - // Add delay to make times unique - Thread.sleep(100); - } - catch (InterruptedException e) { - e.printStackTrace(); - } + // Add delay to make times unique + Thread.sleep(100); batch.insert(ent); if (j == 50) { middleRef = ent; From 4bf887e76141a99e2f8d1ff00641315607a90d0e Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" Date: Tue, 29 Jan 2013 12:09:00 -0800 Subject: [PATCH 14/43] Remove hard-coded Fiddler code in tests --- .../windowsazure/services/blob/client/BlobTestBase.java | 7 ------- .../windowsazure/services/queue/client/QueueTestBase.java | 7 ------- .../windowsazure/services/table/client/TableTestBase.java | 6 ------ 3 files changed, 20 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/BlobTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/BlobTestBase.java index 81ac9334d8dc3..cba0245c4270c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/BlobTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/BlobTestBase.java @@ -40,13 +40,6 @@ public class BlobTestBase { @BeforeClass public static void setup() throws URISyntaxException, StorageException, InvalidKeyException { - - // UNCOMMENT TO USE FIDDLER - System.setProperty("http.proxyHost", "localhost"); - System.setProperty("http.proxyPort", "8888"); - System.setProperty("https.proxyHost", "localhost"); - System.setProperty("https.proxyPort", "8888"); - if (USE_DEV_FABRIC) { httpAcc = CloudStorageAccount.getDevelopmentStorageAccount(); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/QueueTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/QueueTestBase.java index ead279ce3dbdb..e44acb2a21000 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/QueueTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/QueueTestBase.java @@ -41,13 +41,6 @@ public class QueueTestBase { @BeforeClass public static void setup() throws URISyntaxException, StorageException, InvalidKeyException { - - // UNCOMMENT TO USE FIDDLER - System.setProperty("http.proxyHost", "localhost"); - System.setProperty("http.proxyPort", "8888"); - System.setProperty("https.proxyHost", "localhost"); - System.setProperty("https.proxyPort", "8888"); - if (USE_DEV_FABRIC) { httpAcc = CloudStorageAccount.getDevelopmentStorageAccount(); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableTestBase.java index b5c68c6df8765..91d4398f760d8 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableTestBase.java @@ -567,12 +567,6 @@ public static class1 generateRandomEnitity(String pk) { @BeforeClass public static void setup() throws URISyntaxException, StorageException, InvalidKeyException { - - //UNCOMMENT TO USE FIDDLER - System.setProperty("http.proxyHost", "localhost"); - System.setProperty("http.proxyPort", "8888"); - System.setProperty("https.proxyHost", "localhost"); - System.setProperty("https.proxyPort", "8888"); if (USE_DEV_FABRIC) { httpAcc = CloudStorageAccount.getDevelopmentStorageAccount(); } From 277921fa2444ce5a44a30f2ca5fb15ee308d87b3 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" Date: Tue, 29 Jan 2013 12:17:22 -0800 Subject: [PATCH 15/43] Adding deltas to assertEquals for Date and Double, which are likely to experience slight rounding error and cause transient failures. --- .../services/table/client/TableTestBase.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableTestBase.java index 91d4398f760d8..80c7ce30738af 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableTestBase.java @@ -176,12 +176,13 @@ public void assertEquality(ComplexEntity other) { Assert.assertEquals(this.getPartitionKey(), other.getPartitionKey()); Assert.assertEquals(this.getRowKey(), other.getRowKey()); - Assert.assertEquals(this.getDateTime(), other.getDateTime()); + assertDateApproxEquals(this.getDateTime(), other.getDateTime(), 100); + Assert.assertEquals(this.getGuid(), other.getGuid()); Assert.assertEquals(this.getString(), other.getString()); - Assert.assertEquals(this.getDouble(), other.getDouble()); - Assert.assertEquals(this.getDoublePrimitive(), other.getDoublePrimitive()); + Assert.assertEquals(this.getDouble(), other.getDouble(), 1.0e-10); + Assert.assertEquals(this.getDoublePrimitive(), other.getDoublePrimitive(), 1.0e-10); Assert.assertEquals(this.getInt32(), other.getInt32()); Assert.assertEquals(this.getIntegerPrimitive(), other.getIntegerPrimitive()); Assert.assertEquals(this.getBool(), other.getBool()); @@ -192,6 +193,18 @@ public void assertEquality(ComplexEntity other) { Assert.assertTrue(Arrays.equals(this.getBinaryPrimitive(), other.getBinaryPrimitive())); } + protected void assertDateApproxEquals(Date expected, Date actual, int deltaInMs) { + if (expected == null || actual == null) { + Assert.assertEquals(expected, actual); + } + else { + long diffInMilliseconds = Math.abs(expected.getTime() - actual.getTime()); + if (diffInMilliseconds > deltaInMs) { + Assert.assertEquals(expected, actual); + } + } + } + /** * @return the binary */ From 38b3a52fb0615690cb76babbaf387c247df34fe3 Mon Sep 17 00:00:00 2001 From: Joe Giardino Date: Wed, 20 Feb 2013 13:45:18 -0800 Subject: [PATCH 16/43] [JXSCL] : Make OperationContext RequestResults thread safe, --- .../core/storage/OperationContext.java | 14 ++++++++++-- .../core/storage/ResponseReceivedEvent.java | 22 ++++++++++++++++--- .../core/storage/SendingRequestEvent.java | 18 ++++++++++++++- .../utils/implementation/ExecutionEngine.java | 21 ++++++++++++------ .../blob/client/CloudBlobContainerTests.java | 1 + 5 files changed, 63 insertions(+), 13 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java index 7e6e3a3320dae..d19a8eba6b649 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java @@ -51,7 +51,7 @@ public final class OperationContext { * Represents request results, in the form of an ArrayList object that contains the * {@link RequestResult} objects, for each physical request that is made. */ - private ArrayList requestResults; + private final ArrayList requestResults; /** * Represents an event that is triggered before sending a request. @@ -135,7 +135,7 @@ public MessageDigest getIntermediateMD5() { * * @return A {@link RequestResult} object that represents the last request result. */ - public RequestResult getLastResult() { + public synchronized RequestResult getLastResult() { if (this.requestResults == null || this.requestResults.size() == 0) { return null; } @@ -165,6 +165,16 @@ public ArrayList getRequestResults() { return this.requestResults; } + /** + * Reserved for internal use. appends a {@link RequestResult} object to the internal collection in a synchronized + * manner. + * + * @param requestResult + */ + public synchronized void appendRequestResult(RequestResult requestResult) { + this.requestResults.add(requestResult); + } + /** * @return the SendingRequestEvent */ diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResponseReceivedEvent.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResponseReceivedEvent.java index f0b8419d1ab5b..a172d1dbf6cdf 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResponseReceivedEvent.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResponseReceivedEvent.java @@ -23,13 +23,18 @@ public final class ResponseReceivedEvent { * Represents a connection object. Currently only java.net.HttpURLConnection is supported as a * connection object. */ - private Object connectionObject; + private final Object connectionObject; /** * Represents a context for the current operation. This object is used to track requests to the storage service, and * to provide additional runtime information about the operation. */ - private OperationContext opContext; + private final OperationContext opContext; + + /** + * A {@link RequestResult} object that represents the last request result. + */ + private final RequestResult requestResult; /** * Creates an instance of the ResponseReceivedEvent class. @@ -41,10 +46,14 @@ public final class ResponseReceivedEvent { * @param connectionObject * Represents a connection object. Currently only java.net.HttpURLConnection is supported as * a connection object. + * @param requestResult + * A {@link RequestResult} object that represents the current request result. */ - public ResponseReceivedEvent(final OperationContext opContext, final Object connectionObject) { + public ResponseReceivedEvent(final OperationContext opContext, final Object connectionObject, + final RequestResult requestResult) { this.opContext = opContext; this.connectionObject = connectionObject; + this.requestResult = requestResult; } /** @@ -60,4 +69,11 @@ public Object getConnectionObject() { public OperationContext getOpContext() { return this.opContext; } + + /** + * @return A {@link RequestResult} object that represents the current request result. + */ + public RequestResult getRequestResult() { + return requestResult; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/SendingRequestEvent.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/SendingRequestEvent.java index 8b61f7e092ff9..521f8b5737911 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/SendingRequestEvent.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/SendingRequestEvent.java @@ -31,6 +31,11 @@ public final class SendingRequestEvent { */ private final OperationContext opContext; + /** + * A {@link RequestResult} object that represents the last request result. + */ + private final RequestResult requestResult; + /** * Creates an instance of the SendingRequestEvent class. * @@ -41,10 +46,14 @@ public final class SendingRequestEvent { * @param connectionObject * Represents a connection object. Currently only java.net.HttpURLConnection is supported as * a connection object. + * @param requestResult + * A {@link RequestResult} object that represents the current request result. */ - public SendingRequestEvent(final OperationContext opContext, final Object connectionObject) { + public SendingRequestEvent(final OperationContext opContext, final Object connectionObject, + final RequestResult requestResult) { this.opContext = opContext; this.connectionObject = connectionObject; + this.requestResult = requestResult; } /** @@ -60,4 +69,11 @@ public Object getConnectionObject() { public OperationContext getOpContext() { return this.opContext; } + + /** + * @return A {@link RequestResult} object that represents the current request result. + */ + public RequestResult getRequestResult() { + return requestResult; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java index ba188fb376928..8a591896b265c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java @@ -223,10 +223,11 @@ public static InputStream getInputStream(final HttpURLConnection request, final final RequestResult currResult = new RequestResult(); opContext.setCurrentRequestObject(request); currResult.setStartDate(new Date()); - opContext.getRequestResults().add(currResult); + opContext.appendRequestResult(currResult); if (opContext.getSendingRequestEventHandler().hasListeners()) { - opContext.getSendingRequestEventHandler().fireEvent(new SendingRequestEvent(opContext, request)); + opContext.getSendingRequestEventHandler() + .fireEvent(new SendingRequestEvent(opContext, request, currResult)); } try { @@ -278,7 +279,8 @@ public static void getResponseCode(final RequestResult currResult, final HttpURL currResult.setContentMD5(BaseResponse.getContentMD5(request)); if (opContext.getResponseReceivedEventHandler().hasListeners()) { - opContext.getResponseReceivedEventHandler().fireEvent(new ResponseReceivedEvent(opContext, request)); + opContext.getResponseReceivedEventHandler().fireEvent( + new ResponseReceivedEvent(opContext, request, currResult)); } } @@ -296,13 +298,16 @@ public static void getResponseCode(final RequestResult currResult, final HttpURL */ public static RequestResult processRequest(final HttpURLConnection request, final OperationContext opContext) throws IOException { + final RequestResult currResult = new RequestResult(); currResult.setStartDate(new Date()); - opContext.getRequestResults().add(currResult); + opContext.appendRequestResult(currResult); + opContext.setCurrentRequestObject(request); if (opContext.getSendingRequestEventHandler().hasListeners()) { - opContext.getSendingRequestEventHandler().fireEvent(new SendingRequestEvent(opContext, request)); + opContext.getSendingRequestEventHandler() + .fireEvent(new SendingRequestEvent(opContext, request, currResult)); } // Send the request @@ -316,7 +321,8 @@ public static RequestResult processRequest(final HttpURLConnection request, fina currResult.setContentMD5(BaseResponse.getContentMD5(request)); if (opContext.getResponseReceivedEventHandler().hasListeners()) { - opContext.getResponseReceivedEventHandler().fireEvent(new ResponseReceivedEvent(opContext, request)); + opContext.getResponseReceivedEventHandler().fireEvent( + new ResponseReceivedEvent(opContext, request, currResult)); } return currResult; @@ -332,8 +338,9 @@ public static RequestResult processRequest(final HttpURLConnection request, fina */ private static void setLastException(final OperationContext opContext, final Exception exceptionToSet) { if (opContext.getLastResult() == null) { - opContext.getRequestResults().add(new RequestResult()); + opContext.appendRequestResult(new RequestResult()); } + opContext.getLastResult().setException(exceptionToSet); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainerTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainerTests.java index f16cfe5a2db6d..f922f3954baed 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainerTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainerTests.java @@ -688,6 +688,7 @@ public void testSendingRequestEventBlob() throws StorageException, URISyntaxExce @Override public void eventOccurred(SendingRequestEvent eventArg) { + Assert.assertEquals(eventArg.getRequestResult(), eventArg.getOpContext().getLastResult()); callList.add(true); } }); From f5e7c15ef03c43ff39a031dce7f44d6b1b52304a Mon Sep 17 00:00:00 2001 From: Joe Giardino Date: Thu, 21 Feb 2013 10:12:29 -0800 Subject: [PATCH 17/43] CR Feedback - Update tasks to provide result affinity. Now the RequestResult is set directly on the task, Internally no one access OperationContext getLastResult --- .../services/blob/client/CloudBlob.java | 60 ++++++++-------- .../services/blob/client/CloudBlobClient.java | 2 +- .../blob/client/CloudBlobContainer.java | 70 ++++++++++--------- .../services/blob/client/CloudBlockBlob.java | 6 +- .../services/blob/client/CloudPageBlob.java | 6 +- .../core/storage/ResponseReceivedEvent.java | 2 +- .../core/storage/SendingRequestEvent.java | 2 +- .../services/core/storage/ServiceClient.java | 4 +- .../utils/implementation/ExecutionEngine.java | 58 ++++++--------- .../services/queue/client/CloudQueue.java | 36 +++++----- .../queue/client/CloudQueueClient.java | 2 +- .../services/table/client/CloudTable.java | 4 +- .../table/client/CloudTableClient.java | 2 +- .../table/client/QueryTableOperation.java | 2 +- .../table/client/TableBatchOperation.java | 3 +- .../services/table/client/TableOperation.java | 8 +-- 16 files changed, 126 insertions(+), 141 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java index 585c5cb8da14d..b84fd9836ef18 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java @@ -221,7 +221,7 @@ protected CloudBlob(final CloudBlob otherBlob) { * * @param leaseTimeInSeconds * Specifies the span of time for which to acquire the lease, in seconds. - * If null, an infinite lease will be acquired. If not null, the value must be greater than + * If null, an infinite lease will be acquired. If not null, the value must be greater than * zero. * * @param proposedLeaseId @@ -245,7 +245,7 @@ public final String acquireLease(final Integer leaseTimeInSeconds, final String * * @param leaseTimeInSeconds * Specifies the span of time for which to acquire the lease, in seconds. - * If null, an infinite lease will be acquired. If not null, the value must be greater than + * If null, an infinite lease will be acquired. If not null, the value must be greater than * zero. * * @param proposedLeaseId @@ -254,12 +254,12 @@ public final String acquireLease(final Integer leaseTimeInSeconds, final String * * @param accessCondition * An {@link AccessCondition} object that represents the access conditions for the blob. - * + * * @param options * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client + * null will use the default request options from the associated service client * ({@link CloudBlobClient}). - * + * * @param opContext * An {@link OperationContext} object that represents the context for the current operation. The context * is used to track requests to the storage service, and to provide additional runtime information about @@ -298,7 +298,7 @@ public String execute(final CloudBlobClient client, final CloudBlob blob, final client.getCredentials().signRequest(request, 0L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { this.setNonExceptionedRetryableFailure(true); @@ -342,7 +342,7 @@ protected final void assertCorrectBlobType() throws StorageException { } /** - * Breaks the lease and ensures that another client cannot acquire a new lease until the current lease period + * Breaks the lease and ensures that another client cannot acquire a new lease until the current lease period * has expired. * * @param breakPeriodInSeconds @@ -360,7 +360,7 @@ public final long breakLease(final Integer breakPeriodInSeconds) throws StorageE } /** - * Breaks the existing lease, using the specified request options and operation context, and ensures that another + * Breaks the existing lease, using the specified request options and operation context, and ensures that another * client cannot acquire a new lease until the current lease period has expired. * * @param breakPeriodInSeconds @@ -371,7 +371,7 @@ public final long breakLease(final Integer breakPeriodInSeconds) throws StorageE * An {@link AccessCondition} object that represents the access conditions for the blob. * @param options * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client + * null will use the default request options from the associated service client * ({@link CloudBlobClient}). * @param opContext * An {@link OperationContext} object that represents the context for the current operation. The context @@ -410,7 +410,7 @@ public Long execute(final CloudBlobClient client, final CloudBlob blob, final Op client.getCredentials().signRequest(request, 0L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { this.setNonExceptionedRetryableFailure(true); @@ -544,7 +544,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op BlobRequest.addMetadata(request, blob.metadata, opContext); client.getCredentials().signRequest(request, 0); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { this.setNonExceptionedRetryableFailure(true); @@ -623,7 +623,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op client.getCredentials().signRequest(request, 0); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { this.setNonExceptionedRetryableFailure(true); @@ -698,7 +698,7 @@ public CloudBlob execute(final CloudBlobClient client, final CloudBlob blob, client.getCredentials().signRequest(request, 0L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { this.setNonExceptionedRetryableFailure(true); @@ -787,7 +787,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { this.setNonExceptionedRetryableFailure(true); @@ -878,7 +878,7 @@ public Boolean execute(final CloudBlobClient client, final CloudBlob blob, final client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_ACCEPTED) { return true; @@ -961,8 +961,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op blobOptions.getTimeoutIntervalInMs(), blob.snapshotID, accessCondition, blobOptions, opContext); client.getCredentials().signRequest(request, -1L); - final InputStream streamRef = ExecutionEngine.getInputStream(request, opContext); - this.setResult(opContext.getLastResult()); + final InputStream streamRef = ExecutionEngine.getInputStream(request, opContext, this); final String contentMD5 = request.getHeaderField(Constants.HeaderConstants.CONTENT_MD5); final Boolean validateMD5 = !blobOptions.getDisableContentMD5Validation() @@ -1015,8 +1014,8 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op if ((ex.getHttpStatusCode() == Constants.HeaderConstants.HTTP_UNUSED_306 && !ex.getErrorCode().equals( StorageErrorCodeStrings.OUT_OF_RANGE_INPUT)) || ex.getHttpStatusCode() == HttpURLConnection.HTTP_PRECON_FAILED - || !dummyPolicy.shouldRetry(0, opContext.getLastResult().getStatusCode(), - (Exception) ex.getCause(), opContext).isShouldRetry()) { + || !dummyPolicy.shouldRetry(0, impl.getResult().getStatusCode(), (Exception) ex.getCause(), + opContext).isShouldRetry()) { opContext.setIntermediateMD5(null); throw ex; } @@ -1141,7 +1140,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); @@ -1298,8 +1297,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op client.getCredentials().signRequest(request, -1L); - final InputStream sourceStream = ExecutionEngine.getInputStream(request, opContext); - this.setResult(opContext.getLastResult()); + final InputStream sourceStream = ExecutionEngine.getInputStream(request, opContext, this); int totalRead = 0; int nextRead = buffer.length - bufferOffset; @@ -1433,7 +1431,7 @@ public Boolean execute(final CloudBlobClient client, final CloudBlob blob, final client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_OK) { final BlobAttributes retrievedAttributes = BlobResponse.getAttributes(request, blob.getUri(), @@ -1920,7 +1918,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op client.getCredentials().signRequest(request, 0L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); @@ -2000,7 +1998,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op client.getCredentials().signRequest(request, 0L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); @@ -2049,7 +2047,7 @@ public final void changeLease(final String proposedLeaseId, final AccessConditio * required to be set with an access condition. * @param options * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client + * null will use the default request options from the associated service client * ({@link CloudBlobClient}). * @param opContext * An {@link OperationContext} object that represents the context for the current operation. The context @@ -2089,7 +2087,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op client.getCredentials().signRequest(request, 0L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); @@ -2216,7 +2214,7 @@ public Long execute(final CloudBlobClient client, final CloudBlob blob, final Op client.getCredentials().signRequest(request, 0L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CONFLICT) { final StorageException potentialConflictException = StorageException.translateException(request, @@ -2366,7 +2364,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op HttpURLConnection.HTTP_FORBIDDEN, null, null); } - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { this.setNonExceptionedRetryableFailure(true); @@ -2440,7 +2438,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op BlobRequest.addMetadata(request, blob.metadata, opContext); client.getCredentials().signRequest(request, 0L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); @@ -2514,7 +2512,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op BlobRequest.addMetadata(request, blob.metadata, opContext); client.getCredentials().signRequest(request, 0L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java index 181549a8d5750..d9130ed5f9546 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java @@ -388,7 +388,7 @@ ResultSegment listContainersCore(final String prefix, this.getCredentials().signRequest(listContainerRequest, -1L); - taskReference.setResult(ExecutionEngine.processRequest(listContainerRequest, opContext)); + ExecutionEngine.processRequest(listContainerRequest, opContext, taskReference); if (taskReference.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { taskReference.setNonExceptionedRetryableFailure(true); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java index ff67b888bfe33..1cf83f19e7cb6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java @@ -224,7 +224,7 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta ContainerRequest.addMetadata(request, container.metadata, opContext); client.getCredentials().signRequest(request, 0L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { this.setNonExceptionedRetryableFailure(true); @@ -298,7 +298,7 @@ public Boolean execute(final CloudBlobClient client, final CloudBlobContainer co ContainerRequest.addMetadata(request, container.metadata, opContext); client.getCredentials().signRequest(request, 0L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); // Validate response code here if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CREATED) { @@ -390,7 +390,7 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { this.setNonExceptionedRetryableFailure(true); @@ -460,7 +460,7 @@ public Boolean execute(final CloudBlobClient client, final CloudBlobContainer co client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_ACCEPTED) { container.updatePropertiesFromResponse(request); @@ -533,7 +533,7 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); @@ -610,7 +610,7 @@ public BlobContainerPermissions execute(final CloudBlobClient client, final Clou client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); @@ -689,7 +689,7 @@ public Boolean execute(final CloudBlobClient client, final CloudBlobContainer co client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_OK) { container.updatePropertiesFromResponse(request); @@ -1108,7 +1108,7 @@ ResultSegment listBlobsCore(final String prefix, final boolean use this.blobServiceClient.getCredentials().signRequest(listBlobsRequest, -1L); - taskReference.setResult(ExecutionEngine.processRequest(listBlobsRequest, opContext)); + ExecutionEngine.processRequest(listBlobsRequest, opContext, taskReference); if (taskReference.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { taskReference.setNonExceptionedRetryableFailure(true); @@ -1533,7 +1533,7 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta ContainerRequest.addMetadata(request, container.metadata, opContext); client.getCredentials().signRequest(request, 0L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); @@ -1613,7 +1613,7 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta final OutputStream outStreamRef = request.getOutputStream(); outStreamRef.write(aclBytes); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); @@ -1633,7 +1633,7 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta * * @param leaseTimeInSeconds * Specifies the span of time for which to acquire the lease, in seconds. - * If null, an infinite lease will be acquired. If not null, the value must be greater than + * If null, an infinite lease will be acquired. If not null, the value must be greater than * zero. * * @param proposedLeaseId @@ -1657,7 +1657,7 @@ public final String acquireLease(final Integer leaseTimeInSeconds, final String * * @param leaseTimeInSeconds * Specifies the span of time for which to acquire the lease, in seconds. - * If null, an infinite lease will be acquired. If not null, the value must be greater than + * If null, an infinite lease will be acquired. If not null, the value must be greater than * zero. * * @param proposedLeaseId @@ -1666,12 +1666,12 @@ public final String acquireLease(final Integer leaseTimeInSeconds, final String * * @param accessCondition * An {@link AccessCondition} object that represents the access conditions for the container. - * + * * @param options * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client + * null will use the default request options from the associated service client * ({@link CloudBlobClient}). - * + * * @param opContext * An {@link OperationContext} object that represents the context for the current operation. The context * is used to track requests to the storage service, and to provide additional runtime information about @@ -1710,7 +1710,7 @@ public String execute(final CloudBlobClient client, final CloudBlobContainer con client.getCredentials().signRequest(request, 0L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { this.setNonExceptionedRetryableFailure(true); @@ -1731,7 +1731,8 @@ public String execute(final CloudBlobClient client, final CloudBlobContainer con * Renews an existing lease with the specified access conditions. * * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the container. The lease ID is + * An {@link AccessCondition} object that represents the access conditions for the container. The lease + * ID is * required to be set with an access condition. * * @throws StorageException @@ -1748,12 +1749,12 @@ public final void renewLease(final AccessCondition accessCondition) throws Stora * @param accessCondition * An {@link AccessCondition} object that represents the access conditions for the blob. The lease ID is * required to be set with an access condition. - * + * * @param options * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client + * null will use the default request options from the associated service client * ({@link CloudBlobClient}). - * + * * @param opContext * An {@link OperationContext} object that represents the context for the current operation. The context * is used to track requests to the storage service, and to provide additional runtime information about @@ -1792,7 +1793,7 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta client.getCredentials().signRequest(request, 0L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); @@ -1824,17 +1825,18 @@ public final void releaseLease(final AccessCondition accessCondition) throws Sto } /** - * Releases the lease on the container using the specified access conditions, request options, and operation context. + * Releases the lease on the container using the specified access conditions, request options, and operation + * context. * * @param accessCondition * An {@link AccessCondition} object that represents the access conditions for the blob. The lease ID is * required to be set with an access condition. - * + * * @param options * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client + * null will use the default request options from the associated service client * ({@link CloudBlobClient}). - * + * * @param opContext * An {@link OperationContext} object that represents the context for the current operation. The context * is used to track requests to the storage service, and to provide additional runtime information about @@ -1873,7 +1875,7 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta client.getCredentials().signRequest(request, 0L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); @@ -1890,7 +1892,7 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta } /** - * Breaks the lease and ensures that another client cannot acquire a new lease until the current lease + * Breaks the lease and ensures that another client cannot acquire a new lease until the current lease * period has expired. * * @param breakPeriodInSeconds @@ -1908,7 +1910,7 @@ public final long breakLease(final Integer breakPeriodInSeconds) throws StorageE } /** - * Breaks the existing lease, using the specified request options and operation context, and ensures that + * Breaks the existing lease, using the specified request options and operation context, and ensures that * another client cannot acquire a new lease until the current lease period has expired. * * @param breakPeriodInSeconds @@ -1919,7 +1921,7 @@ public final long breakLease(final Integer breakPeriodInSeconds) throws StorageE * An {@link AccessCondition} object that represents the access conditions for the blob. * @param options * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client + * null will use the default request options from the associated service client * ({@link CloudBlobClient}). * @param opContext * An {@link OperationContext} object that represents the context for the current operation. The context @@ -1958,7 +1960,7 @@ public Long execute(final CloudBlobClient client, final CloudBlobContainer conta client.getCredentials().signRequest(request, 0L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { this.setNonExceptionedRetryableFailure(true); @@ -2006,12 +2008,12 @@ public final void changeLease(final String proposedLeaseId, final AccessConditio * @param accessCondition * An {@link AccessCondition} object that represents the access conditions for the blob. The lease ID is * required to be set with an access condition. - * + * * @param options * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client + * null will use the default request options from the associated service client * ({@link CloudBlobClient}). - * + * * @param opContext * An {@link OperationContext} object that represents the context for the current operation. The context * is used to track requests to the storage service, and to provide additional runtime information about @@ -2050,7 +2052,7 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta client.getCredentials().signRequest(request, 0L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java index b28a54a6affd6..03408a6aa4644 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java @@ -204,7 +204,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op Utility.writeToOutputStream(blockListInputStream, request.getOutputStream(), descriptor.getLength(), false, false, null, opContext); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { this.setNonExceptionedRetryableFailure(true); @@ -293,7 +293,7 @@ public ArrayList execute(final CloudBlobClient client, final CloudBl client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); @@ -624,7 +624,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op Utility.writeToOutputStream(sourceStream, request.getOutputStream(), length, true /* rewindSourceStream */, false /* calculateMD5 */, null, opContext); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { this.setNonExceptionedRetryableFailure(true); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java index e31eb5aff1961..b68248998d016 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java @@ -272,7 +272,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op client.getCredentials().signRequest(request, 0L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { this.setNonExceptionedRetryableFailure(true); @@ -352,7 +352,7 @@ public ArrayList execute(final CloudBlobClient client, final CloudBlo client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); @@ -482,7 +482,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op client.getCredentials().signRequest(request, 0L); } - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { this.setNonExceptionedRetryableFailure(true); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResponseReceivedEvent.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResponseReceivedEvent.java index a172d1dbf6cdf..bf1506495a5db 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResponseReceivedEvent.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResponseReceivedEvent.java @@ -74,6 +74,6 @@ public OperationContext getOpContext() { * @return A {@link RequestResult} object that represents the current request result. */ public RequestResult getRequestResult() { - return requestResult; + return this.requestResult; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/SendingRequestEvent.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/SendingRequestEvent.java index 521f8b5737911..8d0e6da594d66 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/SendingRequestEvent.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/SendingRequestEvent.java @@ -74,6 +74,6 @@ public OperationContext getOpContext() { * @return A {@link RequestResult} object that represents the current request result. */ public RequestResult getRequestResult() { - return requestResult; + return this.requestResult; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java index 02f0322b2808d..9e86e9de1dd34 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java @@ -144,7 +144,7 @@ public ServiceProperties execute(final ServiceClient client, final Void v, final .getRequestOptions().getTimeoutIntervalInMs(), null, opContext); client.getCredentials().signRequest(request, -1); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); @@ -330,7 +330,7 @@ public Void execute(final ServiceClient client, final Void v, final OperationCon Utility.writeToOutputStream(dataInputStream, request.getOutputStream(), descriptor.getLength(), false /* rewindSourceStream */, false /* calculateMD5 */, null, opContext); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { this.setNonExceptionedRetryableFailure(true); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java index 8a591896b265c..6addf94b43bcf 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java @@ -119,7 +119,7 @@ public static RESULT_TYPE executeWithRet else { // The task may have already parsed an exception. translatedException = task.materializeException(getLastRequestObject(opContext), opContext); - setLastException(opContext, translatedException); + task.getResult().setException(translatedException); // throw on non retryable status codes: 501, 505, blob type // mismatch @@ -134,45 +134,45 @@ public static RESULT_TYPE executeWithRet // Retryable translatedException = StorageException .translateException(getLastRequestObject(opContext), e, opContext); - setLastException(opContext, translatedException); + task.getResult().setException(translatedException); } catch (final SocketTimeoutException e) { // Retryable translatedException = new StorageException(StorageErrorCodeStrings.OPERATION_TIMED_OUT, "The operation did not complete in the specified time.", -1, null, e); - setLastException(opContext, translatedException); + task.getResult().setException(translatedException); } catch (final IOException e) { // Retryable translatedException = StorageException .translateException(getLastRequestObject(opContext), e, opContext); - setLastException(opContext, translatedException); + task.getResult().setException(translatedException); } catch (final XMLStreamException e) { // Non Retryable, just throw translatedException = StorageException .translateException(getLastRequestObject(opContext), e, opContext); - setLastException(opContext, translatedException); + task.getResult().setException(translatedException); throw translatedException; } catch (final InvalidKeyException e) { // Non Retryable, just throw translatedException = StorageException .translateException(getLastRequestObject(opContext), e, opContext); - setLastException(opContext, translatedException); + task.getResult().setException(translatedException); throw translatedException; } catch (final URISyntaxException e) { // Non Retryable, just throw translatedException = StorageException .translateException(getLastRequestObject(opContext), e, opContext); - setLastException(opContext, translatedException); + task.getResult().setException(translatedException); throw translatedException; } catch (final TableServiceException e) { task.getResult().setStatusCode(e.getHttpStatusCode()); task.getResult().setStatusMessage(e.getMessage()); - setLastException(opContext, e); + task.getResult().setException(e); if (!e.isRetryable()) { throw e; } @@ -183,20 +183,20 @@ public static RESULT_TYPE executeWithRet catch (final StorageException e) { // Non Retryable, just throw // do not translate StorageException - setLastException(opContext, e); + task.getResult().setException(e); throw e; } catch (final Exception e) { // Non Retryable, just throw translatedException = StorageException .translateException(getLastRequestObject(opContext), e, opContext); - setLastException(opContext, translatedException); + task.getResult().setException(translatedException); throw translatedException; } // Evaluate Retry Policy - retryRes = policy.shouldRetry(currentRetryCount, task.getResult().getStatusCode(), opContext - .getLastResult().getException(), opContext); + retryRes = policy.shouldRetry(currentRetryCount, task.getResult().getStatusCode(), task.getResult() + .getException(), opContext); if (!retryRes.isShouldRetry()) { throw translatedException; } @@ -214,16 +214,19 @@ public static RESULT_TYPE executeWithRet * the request to process * @param opContext * an object used to track the execution of the operation + * @param operation + * the operation in which to set the current RequestResult object * @return the input stream from the request * @throws IOException * if there is an error making the connection */ - public static InputStream getInputStream(final HttpURLConnection request, final OperationContext opContext) - throws IOException { + public static InputStream getInputStream(final HttpURLConnection request, final OperationContext opContext, + final StorageOperation operation) throws IOException { final RequestResult currResult = new RequestResult(); opContext.setCurrentRequestObject(request); currResult.setStartDate(new Date()); opContext.appendRequestResult(currResult); + operation.setResult(currResult); if (opContext.getSendingRequestEventHandler().hasListeners()) { opContext.getSendingRequestEventHandler() @@ -292,18 +295,19 @@ public static void getResponseCode(final RequestResult currResult, final HttpURL * the request to process * @param opContext * an object used to track the execution of the operation - * @return a RequestResult object representing the status code/ message of the current request + * @param operation + * the operation in which to set the current RequestResult object * @throws IOException * if there is an error making the connection */ - public static RequestResult processRequest(final HttpURLConnection request, final OperationContext opContext) - throws IOException { + public static void processRequest(final HttpURLConnection request, final OperationContext opContext, + final StorageOperation operation) throws IOException { final RequestResult currResult = new RequestResult(); currResult.setStartDate(new Date()); opContext.appendRequestResult(currResult); - opContext.setCurrentRequestObject(request); + operation.setResult(currResult); if (opContext.getSendingRequestEventHandler().hasListeners()) { opContext.getSendingRequestEventHandler() @@ -324,24 +328,6 @@ public static RequestResult processRequest(final HttpURLConnection request, fina opContext.getResponseReceivedEventHandler().fireEvent( new ResponseReceivedEvent(opContext, request, currResult)); } - - return currResult; - } - - /** - * Sets the exception on the last request result in a safe way, if there is no last result one is added. - * - * @param opContext - * an object used to track the execution of the operation - * @param exceptionToSet - * the exception to set on the result. - */ - private static void setLastException(final OperationContext opContext, final Exception exceptionToSet) { - if (opContext.getLastResult() == null) { - opContext.appendRequestResult(new RequestResult()); - } - - opContext.getLastResult().setException(exceptionToSet); } /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java index 93771ce03de9e..b0dfe652f9565 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java @@ -220,7 +220,7 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final final OutputStream outStreamRef = request.getOutputStream(); outStreamRef.write(messageBytes); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { this.setNonExceptionedRetryableFailure(true); @@ -286,7 +286,7 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { this.setNonExceptionedRetryableFailure(true); @@ -351,7 +351,7 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final QueueRequest.addMetadata(request, queue.metadata, opContext); client.getCredentials().signRequest(request, 0L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED && this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { @@ -424,7 +424,7 @@ public Boolean execute(final CloudQueueClient client, final CloudQueue queue, QueueRequest.addMetadata(request, queue.metadata, opContext); client.getCredentials().signRequest(request, 0L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CREATED) { return true; @@ -509,7 +509,7 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { this.setNonExceptionedRetryableFailure(true); @@ -580,7 +580,7 @@ public Boolean execute(final CloudQueueClient client, final CloudQueue queue, client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NO_CONTENT) { return true; @@ -667,7 +667,7 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { this.setNonExceptionedRetryableFailure(true); @@ -733,7 +733,7 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); @@ -806,7 +806,7 @@ public Boolean execute(final CloudQueueClient client, final CloudQueue queue, client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_OK) { return Boolean.valueOf(true); @@ -1021,7 +1021,7 @@ public ArrayList execute(final CloudQueueClient client, final client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); @@ -1155,7 +1155,7 @@ public ArrayList execute(final CloudQueueClient client, final client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); @@ -1293,7 +1293,7 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final client.getCredentials().signRequest(request, 0L); } - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { this.setNonExceptionedRetryableFailure(true); @@ -1366,7 +1366,7 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final QueueRequest.addMetadata(request, queue.metadata, opContext); client.getCredentials().signRequest(request, 0L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { this.setNonExceptionedRetryableFailure(true); @@ -1445,7 +1445,7 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final final OutputStream outStreamRef = request.getOutputStream(); outStreamRef.write(aclBytes); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { this.setNonExceptionedRetryableFailure(true); @@ -1515,7 +1515,7 @@ public QueuePermissions execute(final CloudQueueClient client, final CloudQueue client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); @@ -1545,11 +1545,11 @@ public QueuePermissions execute(final CloudQueueClient client, final CloudQueue * A queue-level access policy. * @return A shared access signature for the queue. * @throws InvalidKeyException - * If an invalid key was passed. + * If an invalid key was passed. * @throws StorageException - * If a storage service error occurred. + * If a storage service error occurred. * @throws IllegalArgumentException - * If an unexpected value is passed. + * If an unexpected value is passed. */ public String generateSharedAccessSignature(final SharedAccessQueuePolicy policy, final String groupPolicyIdentifier) throws InvalidKeyException, StorageException { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java index 0ca46aaf25bc3..5d161d81ccb27 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java @@ -227,7 +227,7 @@ ResultSegment listQueuesCore(final String prefix, final QueueListing this.getCredentials().signRequest(listQueueRequest, -1L); - taskReference.setResult(ExecutionEngine.processRequest(listQueueRequest, opContext)); + ExecutionEngine.processRequest(listQueueRequest, opContext, taskReference); if (taskReference.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { taskReference.setNonExceptionedRetryableFailure(true); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTable.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTable.java index 536b3adfb5821..4481d252421d1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTable.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTable.java @@ -493,7 +493,7 @@ public Void execute(final CloudTableClient client, final CloudTable table, final final OutputStream outStreamRef = request.getOutputStream(); outStreamRef.write(aclBytes); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { this.setNonExceptionedRetryableFailure(true); @@ -564,7 +564,7 @@ public TablePermissions execute(final CloudTableClient client, final CloudTable client.getCredentials().signRequestLite(request, -1L, opContext); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTableClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTableClient.java index e49f6e3fdfca6..c4b103f321618 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTableClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTableClient.java @@ -800,7 +800,7 @@ protected ResultSegment executeQuerySegmentedCore( this.getCredentials().signRequestLite(queryRequest, -1L, opContext); - taskReference.setResult(ExecutionEngine.processRequest(queryRequest, opContext)); + ExecutionEngine.processRequest(queryRequest, opContext, taskReference); if (taskReference.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { throw TableServiceException.generateTableServiceException(true, taskReference.getResult(), null, diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/QueryTableOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/QueryTableOperation.java index bc5c112c31876..dd74e256fc1d0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/QueryTableOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/QueryTableOperation.java @@ -189,7 +189,7 @@ tableName, generateRequestIdentity(isTableEntry, operation.getPartitionKey(), fa client.getCredentials().signRequestLite(request, -1L, opContext); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_OK) { // Parse response for updates diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableBatchOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableBatchOperation.java index 4f81296856b6f..544e0201d42de 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableBatchOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableBatchOperation.java @@ -399,10 +399,9 @@ public ArrayList execute(final CloudTableClient client, final Table MimeHelper.writeBatchToStream(request.getOutputStream(), tableName, batch, batchID, changeSet, opContext); - final InputStream streamRef = ExecutionEngine.getInputStream(request, opContext); + final InputStream streamRef = ExecutionEngine.getInputStream(request, opContext, this); ArrayList responseParts = null; try { - this.setResult(opContext.getLastResult()); final String contentType = request.getHeaderField(Constants.HeaderConstants.CONTENT_TYPE); final String[] headerVals = contentType.split("multipart/mixed; boundary="); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableOperation.java index 130d59fe9914d..c4ce82e4df378 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableOperation.java @@ -262,7 +262,7 @@ public TableResult execute(final CloudTableClient client, final TableOperation o client.getCredentials().signRequestLite(request, -1L, opContext); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND || this.getResult().getStatusCode() == HttpURLConnection.HTTP_CONFLICT) { @@ -333,7 +333,7 @@ public TableResult execute(final CloudTableClient client, final TableOperation o AtomPubParser.writeSingleEntityToStream(operation.getEntity(), isTableEntry, request.getOutputStream(), opContext); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (operation.opType == TableOperationType.INSERT) { if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CONFLICT) { throw TableServiceException.generateTableServiceException(false, this.getResult(), operation, @@ -419,7 +419,7 @@ public TableResult execute(final CloudTableClient client, final TableOperation o AtomPubParser.writeSingleEntityToStream(operation.getEntity(), false, request.getOutputStream(), opContext); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND || this.getResult().getStatusCode() == HttpURLConnection.HTTP_CONFLICT) { @@ -485,7 +485,7 @@ public TableResult execute(final CloudTableClient client, final TableOperation o AtomPubParser.writeSingleEntityToStream(operation.getEntity(), false, request.getOutputStream(), opContext); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + ExecutionEngine.processRequest(request, opContext, this); if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND || this.getResult().getStatusCode() == HttpURLConnection.HTTP_CONFLICT) { From 118bac16dcf2cd8117331f3320d384768c10bd0e Mon Sep 17 00:00:00 2001 From: Joe Giardino Date: Thu, 21 Feb 2013 10:31:35 -0800 Subject: [PATCH 18/43] Make BlobOutputStream use latest instead of uncommitted. --- .../windowsazure/services/blob/client/BlobOutputStream.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobOutputStream.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobOutputStream.java index dae6409998617..93d870b15e1bf 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobOutputStream.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobOutputStream.java @@ -356,7 +356,7 @@ private synchronized void dispatchWrite(final int writeLength) throws IOExceptio if (this.streamType == BlobType.BLOCK_BLOB) { final CloudBlockBlob blobRef = (CloudBlockBlob) this.parentBlobRef; final String blockID = Base64.encode(Utility.getBytesFromLong(this.blockIdSequenceNumber++)); - this.blockList.add(new BlockEntry(blockID, BlockSearchMode.UNCOMMITTED)); + this.blockList.add(new BlockEntry(blockID, BlockSearchMode.LATEST)); worker = new Callable() { @Override From 36ebeb4f55f2e3fb5a53451512a0fa5c6953a605 Mon Sep 17 00:00:00 2001 From: Serdar Ozler Date: Fri, 22 Feb 2013 14:26:08 -0800 Subject: [PATCH 19/43] BlobInputStream MD5 verification fix and a couple more fixes --- ChangeLog.txt | 6 +++ .../services/blob/client/BlobInputStream.java | 26 ++++++++--- .../services/blob/client/CloudBlob.java | 26 ++++++----- .../services/blob/client/CloudPageBlob.java | 3 +- .../services/core/storage/Constants.java | 2 +- .../services/table/client/TableOperation.java | 21 ++++----- .../blob/client/CloudBlobContainerTests.java | 45 +++++++++++++++++-- .../queue/client/CloudQueueTests.java | 2 + .../table/client/TableOperationTests.java | 12 ++++- 9 files changed, 107 insertions(+), 36 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 78ac7b32bfa1d..149038f5a6b36 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,9 @@ +2013.01.28 Version 0.4.1 + * Fixed the return value of BlobInputStream.read + * Fixed CloudPageBlob.downloadPageRanges to retrieve the blob length + * Fixed MD5 validation in BlobInputStream + * Return ETag in TableResult not only for Insert but also for other operations + 2012.10.29 Version 0.3.3 * In the blob client, fixed a bug which allows users to call write APIs on a blob snapshot reference * Updated the URL parse method in storage client libraries, to allow users to pass a URL ending with "/" diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobInputStream.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobInputStream.java index 55a8ca520e873..8c2954d6b1c9e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobInputStream.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobInputStream.java @@ -82,6 +82,11 @@ public final class BlobInputStream extends InputStream { */ private boolean validateBlobMd5; + /** + * Holds the Blob MD5. + */ + private final String retrievedContentMD5Value; + /** * Holds the reference to the current buffered data. */ @@ -161,11 +166,11 @@ protected BlobInputStream(final CloudBlob parentBlob, final AccessCondition acce final HttpURLConnection attributesRequest = this.opContext.getCurrentRequestObject(); - final String retrievedContentMD5Value = attributesRequest.getHeaderField(Constants.HeaderConstants.CONTENT_MD5); + this.retrievedContentMD5Value = attributesRequest.getHeaderField(Constants.HeaderConstants.CONTENT_MD5); // Will validate it if it was returned this.validateBlobMd5 = !options.getDisableContentMD5Validation() - && !Utility.isNullOrEmpty(retrievedContentMD5Value); + && !Utility.isNullOrEmpty(this.retrievedContentMD5Value); // Validates the first option, and sets future requests to use if match // request option. @@ -395,8 +400,17 @@ public boolean markSupported() { @DoesServiceRequest public int read() throws IOException { final byte[] tBuff = new byte[1]; - this.read(tBuff, 0, 1); - return tBuff[0]; + final int numberOfBytesRead = this.read(tBuff, 0, 1); + + if (numberOfBytesRead > 0) { + return tBuff[0] & 0xFF; + } + else if (numberOfBytesRead == 0) { + throw new IOException("Unexpected error. Stream returned unexpected number of bytes."); + } + else { + return -1; + } } /** @@ -519,13 +533,13 @@ private synchronized int readInternal(final byte[] b, final int off, int len) th if (this.currentAbsoluteReadPosition == this.streamLength) { // Reached end of stream, validate md5. final String calculatedMd5 = Base64.encode(this.md5Digest.digest()); - if (!calculatedMd5.equals(this.parentBlobRef.getProperties().getContentMD5())) { + if (!calculatedMd5.equals(this.retrievedContentMD5Value)) { this.lastError = Utility .initIOException(new StorageException( StorageErrorCodeStrings.INVALID_MD5, String.format( "Blob data corrupted (integrity check failed), Expected value is %s, retrieved %s", - this.parentBlobRef.getProperties().getContentMD5(), calculatedMd5), + this.retrievedContentMD5Value, calculatedMd5), Constants.HeaderConstants.HTTP_UNUSED_306, null, null)); this.streamFaulted = true; throw this.lastError; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java index 6fc3821409256..353b9a5ad23e4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java @@ -221,7 +221,7 @@ protected CloudBlob(final CloudBlob otherBlob) { * * @param leaseTimeInSeconds * Specifies the span of time for which to acquire the lease, in seconds. - * If null, an infinite lease will be acquired. If not null, the value must be greater than + * If null, an infinite lease will be acquired. If not null, the value must be greater than * zero. * * @param proposedLeaseId @@ -245,7 +245,7 @@ public final String acquireLease(final Integer leaseTimeInSeconds, final String * * @param leaseTimeInSeconds * Specifies the span of time for which to acquire the lease, in seconds. - * If null, an infinite lease will be acquired. If not null, the value must be greater than + * If null, an infinite lease will be acquired. If not null, the value must be greater than * zero. * * @param proposedLeaseId @@ -254,12 +254,12 @@ public final String acquireLease(final Integer leaseTimeInSeconds, final String * * @param accessCondition * An {@link AccessCondition} object that represents the access conditions for the blob. - * + * * @param options * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client + * null will use the default request options from the associated service client * ({@link CloudBlobClient}). - * + * * @param opContext * An {@link OperationContext} object that represents the context for the current operation. The context * is used to track requests to the storage service, and to provide additional runtime information about @@ -342,7 +342,7 @@ protected final void assertCorrectBlobType() throws StorageException { } /** - * Breaks the lease and ensures that another client cannot acquire a new lease until the current lease period + * Breaks the lease and ensures that another client cannot acquire a new lease until the current lease period * has expired. * * @param breakPeriodInSeconds @@ -360,7 +360,7 @@ public final long breakLease(final Integer breakPeriodInSeconds) throws StorageE } /** - * Breaks the existing lease, using the specified request options and operation context, and ensures that another + * Breaks the existing lease, using the specified request options and operation context, and ensures that another * client cannot acquire a new lease until the current lease period has expired. * * @param breakPeriodInSeconds @@ -371,7 +371,7 @@ public final long breakLease(final Integer breakPeriodInSeconds) throws StorageE * An {@link AccessCondition} object that represents the access conditions for the blob. * @param options * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client + * null will use the default request options from the associated service client * ({@link CloudBlobClient}). * @param opContext * An {@link OperationContext} object that represents the context for the current operation. The context @@ -1328,14 +1328,16 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op return null; } - // Do not update blob length in downloadRangeInternal API. - final long orignalBlobLength = blob.properties.getLength(); + // Do not update blob length and Content-MD5 in downloadRangeInternal API. + final long originalBlobLength = blob.properties.getLength(); + final String originalContentMD5 = blob.properties.getContentMD5(); final BlobAttributes retrievedAttributes = BlobResponse.getAttributes(request, blob.getUri(), blob.snapshotID, opContext); blob.properties = retrievedAttributes.getProperties(); blob.metadata = retrievedAttributes.getMetadata(); blob.copyState = retrievedAttributes.getCopyState(); - blob.properties.setLength(orignalBlobLength); + blob.properties.setContentMD5(originalContentMD5); + blob.properties.setLength(originalBlobLength); final String contentLength = request.getHeaderField(Constants.HeaderConstants.CONTENT_LENGTH); final long expectedLength = Long.parseLong(contentLength); @@ -2053,7 +2055,7 @@ public final void changeLease(final String proposedLeaseId, final AccessConditio * required to be set with an access condition. * @param options * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client + * null will use the default request options from the associated service client * ({@link CloudBlobClient}). * @param opContext * An {@link OperationContext} object that represents the context for the current operation. The context diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java index f5ce8f06f4c8b..ff7f79ba35a14 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java @@ -360,6 +360,8 @@ public ArrayList execute(final CloudBlobClient client, final CloudBlo } blob.updateEtagAndLastModifiedFromResponse(request); + blob.updateLengthFromResponse(request); + final GetPageRangesResponse response = new GetPageRangesResponse(request.getInputStream()); return response.getPageRanges(); } @@ -490,7 +492,6 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op } blob.updateEtagAndLastModifiedFromResponse(request); - blob.updateLengthFromResponse(request); return null; } }; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Constants.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Constants.java index 61895ba9a162b..01f95fee1a723 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Constants.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Constants.java @@ -327,7 +327,7 @@ public static class HeaderConstants { /** * Specifies the value to use for UserAgent header. */ - public static final String USER_AGENT_VERSION = "Client v0.1.3.1"; + public static final String USER_AGENT_VERSION = "Client v0.1.3.2"; } /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableOperation.java index 3bffd84a306b6..6482964e423b1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableOperation.java @@ -256,9 +256,9 @@ private TableResult performDelete(final CloudTableClient client, final String ta public TableResult execute(final CloudTableClient client, final TableOperation operation, final OperationContext opContext) throws Exception { - final HttpURLConnection request = TableRequest.delete(client.getTransformedEndPoint(opContext), tableName, - generateRequestIdentity(isTableEntry, tableIdentity, false), operation.getEntity().getEtag(), - options.getTimeoutIntervalInMs(), null, options, opContext); + final HttpURLConnection request = TableRequest.delete(client.getTransformedEndPoint(opContext), + tableName, generateRequestIdentity(isTableEntry, tableIdentity, false), operation.getEntity() + .getEtag(), options.getTimeoutIntervalInMs(), null, options, opContext); client.getCredentials().signRequestLite(request, -1L, opContext); @@ -323,8 +323,8 @@ private TableResult performInsert(final CloudTableClient client, final String ta @Override public TableResult execute(final CloudTableClient client, final TableOperation operation, final OperationContext opContext) throws Exception { - final HttpURLConnection request = TableRequest.insert(client.getTransformedEndPoint(opContext), tableName, - generateRequestIdentity(isTableEntry, tableIdentity, false), + final HttpURLConnection request = TableRequest.insert(client.getTransformedEndPoint(opContext), + tableName, generateRequestIdentity(isTableEntry, tableIdentity, false), operation.opType != TableOperationType.INSERT ? operation.getEntity().getEtag() : null, operation.opType.getUpdateType(), options.getTimeoutIntervalInMs(), null, options, opContext); @@ -410,8 +410,8 @@ private TableResult performMerge(final CloudTableClient client, final String tab public TableResult execute(final CloudTableClient client, final TableOperation operation, final OperationContext opContext) throws Exception { - final HttpURLConnection request = TableRequest.merge(client.getTransformedEndPoint(opContext), tableName, - generateRequestIdentity(false, null, false), operation.getEntity().getEtag(), + final HttpURLConnection request = TableRequest.merge(client.getTransformedEndPoint(opContext), + tableName, generateRequestIdentity(false, null, false), operation.getEntity().getEtag(), options.getTimeoutIntervalInMs(), null, options, opContext); client.getCredentials().signRequestLite(request, -1L, opContext); @@ -476,8 +476,8 @@ private TableResult performUpdate(final CloudTableClient client, final String ta public TableResult execute(final CloudTableClient client, final TableOperation operation, final OperationContext opContext) throws Exception { - final HttpURLConnection request = TableRequest.update(client.getTransformedEndPoint(opContext), tableName, - generateRequestIdentity(false, null, false), operation.getEntity().getEtag(), + final HttpURLConnection request = TableRequest.update(client.getTransformedEndPoint(opContext), + tableName, generateRequestIdentity(false, null, false), operation.getEntity().getEtag(), options.getTimeoutIntervalInMs(), null, options, opContext); client.getCredentials().signRequestLite(request, -1L, opContext); @@ -686,7 +686,8 @@ protected TableResult parseResponse(final XMLStreamReader xmlr, final int httpSt resObj = new TableResult(httpStatusCode); resObj.setResult(this.getEntity()); - if (this.opType != TableOperationType.DELETE) { + if (this.opType != TableOperationType.DELETE && etagFromHeader != null) { + resObj.setEtag(etagFromHeader); this.getEntity().setEtag(etagFromHeader); } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainerTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainerTests.java index 9d945f61a53a9..cc3fbc3a62cd9 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainerTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainerTests.java @@ -719,6 +719,43 @@ public void eventOccurred(SendingRequestEvent eventArg) { } } + @Test + public void testBlobInputStream() throws URISyntaxException, StorageException, IOException { + final int blobLength = 16 * 1024; + final Random randGenerator = new Random(); + String blobName = "testblob" + Integer.toString(randGenerator.nextInt(50000)); + blobName = blobName.replace('-', '_'); + + final CloudBlobContainer containerRef = bClient.getContainerReference(BlobTestBase.testSuiteContainerName); + + final CloudBlockBlob blobRef = containerRef.getBlockBlobReference(blobName); + + final byte[] buff = new byte[blobLength]; + randGenerator.nextBytes(buff); + buff[0] = -1; + buff[1] = -128; + final ByteArrayInputStream sourceStream = new ByteArrayInputStream(buff); + + final BlobRequestOptions options = new BlobRequestOptions(); + final OperationContext operationContext = new OperationContext(); + options.setStoreBlobContentMD5(true); + options.setTimeoutIntervalInMs(90000); + options.setRetryPolicyFactory(new RetryNoRetry()); + blobRef.uploadFullBlob(sourceStream, blobLength, null, options, operationContext); + + BlobInputStream blobStream = blobRef.openInputStream(); + + for (int i = 0; i < blobLength; i++) { + int data = blobStream.read(); + Assert.assertTrue(data >= 0); + Assert.assertEquals(buff[i], (byte) data); + } + + Assert.assertEquals(-1, blobStream.read()); + + blobRef.delete(); + } + @Test public void testCurrentOperationByteCount() throws URISyntaxException, StorageException, IOException { final int blockLength = 4 * 1024 * 1024; @@ -750,24 +787,24 @@ public void testCurrentOperationByteCount() throws URISyntaxException, StorageEx BlobRequestOptions options = new BlobRequestOptions(); options.setTimeoutIntervalInMs(1000); options.setRetryPolicyFactory(new RetryNoRetry()); + + ByteArrayOutputStream downloadedDataStream = new ByteArrayOutputStream(); try { - final ByteArrayOutputStream downloadedDataStream = new ByteArrayOutputStream(); blobRef.download(downloadedDataStream, null, options, operationContext); } catch (Exception e) { - Assert.assertEquals(0, operationContext.getCurrentOperationByteCount()); + Assert.assertEquals(downloadedDataStream.size(), operationContext.getCurrentOperationByteCount()); } operationContext = new OperationContext(); options = new BlobRequestOptions(); options.setTimeoutIntervalInMs(90000); - final ByteArrayOutputStream downloadedDataStream = new ByteArrayOutputStream(); + downloadedDataStream = new ByteArrayOutputStream(); blobRef.download(downloadedDataStream, null, options, operationContext); Assert.assertEquals(blockLength * numberOfBlocks, operationContext.getCurrentOperationByteCount()); blobRef.delete(); } - } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java index b107e30527419..06163b9b7ff45 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java @@ -1127,6 +1127,8 @@ public void testPeekMessagesFromEmptyQueue() throws URISyntaxException, StorageE @Test public void testUpdateMessage() throws URISyntaxException, StorageException, UnsupportedEncodingException { + queue.clear(); + String messageContent = "messagetest"; CloudQueueMessage message1 = new CloudQueueMessage(messageContent); queue.addMessage(message1); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableOperationTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableOperationTests.java index 10a6b4734e3a0..47f852a25a445 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableOperationTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableOperationTests.java @@ -145,6 +145,7 @@ public void insertOrMerge() throws StorageException { TableResult insertResult = tClient.execute(testSuiteTableName, TableOperation.insertOrMerge(baseEntity)); Assert.assertEquals(insertResult.getHttpStatusCode(), HttpURLConnection.HTTP_NO_CONTENT); + Assert.assertNotNull(insertResult.getEtag()); // Insert or replace Entity - ENTITY EXISTS -> WILL REPLACE tClient.execute(testSuiteTableName, TableOperation.insertOrMerge(secondEntity)); @@ -206,6 +207,7 @@ public void insertOrReplace() throws StorageException { TableResult insertResult = tClient.execute(testSuiteTableName, TableOperation.insertOrReplace(baseEntity)); Assert.assertEquals(insertResult.getHttpStatusCode(), HttpURLConnection.HTTP_NO_CONTENT); + Assert.assertNotNull(insertResult.getEtag()); // Insert or replace Entity - ENTITY EXISTS -> WILL REPLACE tClient.execute(testSuiteTableName, TableOperation.insertOrReplace(secondEntity)); @@ -259,7 +261,10 @@ public void merge() throws StorageException { secondEntity.setRowKey(baseEntity.getRowKey()); secondEntity.setEtag(baseEntity.getEtag()); - tClient.execute(testSuiteTableName, TableOperation.merge(secondEntity)); + TableResult mergeResult = tClient.execute(testSuiteTableName, TableOperation.merge(secondEntity)); + + Assert.assertEquals(mergeResult.getHttpStatusCode(), HttpURLConnection.HTTP_NO_CONTENT); + Assert.assertNotNull(mergeResult.getEtag()); TableResult res2 = tClient.execute(testSuiteTableName, TableOperation.retrieve(secondEntity.getPartitionKey(), secondEntity.getRowKey(), DynamicTableEntity.class)); @@ -456,7 +461,10 @@ public void replace() throws StorageException { // Remove property and update retrievedEntity.getProperties().remove("D"); - tClient.execute(testSuiteTableName, TableOperation.replace(retrievedEntity)); + TableResult replaceResult = tClient.execute(testSuiteTableName, TableOperation.replace(retrievedEntity)); + + Assert.assertEquals(replaceResult.getHttpStatusCode(), HttpURLConnection.HTTP_NO_CONTENT); + Assert.assertNotNull(replaceResult.getEtag()); // Retrieve Entity queryResult = tClient From 11b1a31811b2fd060542b3e9769a7170ef19d7c9 Mon Sep 17 00:00:00 2001 From: Joe Giardino Date: Mon, 25 Feb 2013 11:26:51 -0800 Subject: [PATCH 20/43] CR feedback: Update tasks to provide result affinity --- .../services/blob/client/CloudBlob.java | 36 +++++++++---------- .../services/blob/client/CloudBlobClient.java | 2 +- .../blob/client/CloudBlobContainer.java | 33 +++++++++-------- .../services/blob/client/CloudBlockBlob.java | 6 ++-- .../services/blob/client/CloudPageBlob.java | 6 ++-- .../services/core/storage/ServiceClient.java | 14 ++++---- .../utils/implementation/ExecutionEngine.java | 23 +++++------- .../implementation/StorageOperation.java | 8 +++-- .../services/queue/client/CloudQueue.java | 30 ++++++++-------- .../queue/client/CloudQueueClient.java | 2 +- .../services/table/client/CloudTable.java | 4 +-- .../table/client/CloudTableClient.java | 2 +- .../table/client/QueryTableOperation.java | 2 +- .../table/client/TableBatchOperation.java | 2 +- .../services/table/client/TableOperation.java | 26 +++++++------- 15 files changed, 97 insertions(+), 99 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java index b84fd9836ef18..81c1d6453c66f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java @@ -298,7 +298,7 @@ public String execute(final CloudBlobClient client, final CloudBlob blob, final client.getCredentials().signRequest(request, 0L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { this.setNonExceptionedRetryableFailure(true); @@ -410,7 +410,7 @@ public Long execute(final CloudBlobClient client, final CloudBlob blob, final Op client.getCredentials().signRequest(request, 0L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { this.setNonExceptionedRetryableFailure(true); @@ -544,7 +544,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op BlobRequest.addMetadata(request, blob.metadata, opContext); client.getCredentials().signRequest(request, 0); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { this.setNonExceptionedRetryableFailure(true); @@ -623,7 +623,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op client.getCredentials().signRequest(request, 0); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { this.setNonExceptionedRetryableFailure(true); @@ -698,7 +698,7 @@ public CloudBlob execute(final CloudBlobClient client, final CloudBlob blob, client.getCredentials().signRequest(request, 0L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { this.setNonExceptionedRetryableFailure(true); @@ -787,7 +787,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op client.getCredentials().signRequest(request, -1L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { this.setNonExceptionedRetryableFailure(true); @@ -878,7 +878,7 @@ public Boolean execute(final CloudBlobClient client, final CloudBlob blob, final client.getCredentials().signRequest(request, -1L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_ACCEPTED) { return true; @@ -961,7 +961,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op blobOptions.getTimeoutIntervalInMs(), blob.snapshotID, accessCondition, blobOptions, opContext); client.getCredentials().signRequest(request, -1L); - final InputStream streamRef = ExecutionEngine.getInputStream(request, opContext, this); + final InputStream streamRef = ExecutionEngine.getInputStream(request, opContext, this.getResult()); final String contentMD5 = request.getHeaderField(Constants.HeaderConstants.CONTENT_MD5); final Boolean validateMD5 = !blobOptions.getDisableContentMD5Validation() @@ -1140,7 +1140,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op client.getCredentials().signRequest(request, -1L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); @@ -1297,7 +1297,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op client.getCredentials().signRequest(request, -1L); - final InputStream sourceStream = ExecutionEngine.getInputStream(request, opContext, this); + final InputStream sourceStream = ExecutionEngine.getInputStream(request, opContext, this.getResult()); int totalRead = 0; int nextRead = buffer.length - bufferOffset; @@ -1431,7 +1431,7 @@ public Boolean execute(final CloudBlobClient client, final CloudBlob blob, final client.getCredentials().signRequest(request, -1L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_OK) { final BlobAttributes retrievedAttributes = BlobResponse.getAttributes(request, blob.getUri(), @@ -1918,7 +1918,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op client.getCredentials().signRequest(request, 0L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); @@ -1998,7 +1998,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op client.getCredentials().signRequest(request, 0L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); @@ -2087,7 +2087,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op client.getCredentials().signRequest(request, 0L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); @@ -2214,7 +2214,7 @@ public Long execute(final CloudBlobClient client, final CloudBlob blob, final Op client.getCredentials().signRequest(request, 0L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CONFLICT) { final StorageException potentialConflictException = StorageException.translateException(request, @@ -2364,7 +2364,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op HttpURLConnection.HTTP_FORBIDDEN, null, null); } - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { this.setNonExceptionedRetryableFailure(true); @@ -2438,7 +2438,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op BlobRequest.addMetadata(request, blob.metadata, opContext); client.getCredentials().signRequest(request, 0L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); @@ -2512,7 +2512,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op BlobRequest.addMetadata(request, blob.metadata, opContext); client.getCredentials().signRequest(request, 0L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java index d9130ed5f9546..c000b97c98edc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java @@ -388,7 +388,7 @@ ResultSegment listContainersCore(final String prefix, this.getCredentials().signRequest(listContainerRequest, -1L); - ExecutionEngine.processRequest(listContainerRequest, opContext, taskReference); + ExecutionEngine.processRequest(listContainerRequest, opContext, taskReference.getResult()); if (taskReference.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { taskReference.setNonExceptionedRetryableFailure(true); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java index 1cf83f19e7cb6..b1d1a7a6c8db1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java @@ -224,7 +224,7 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta ContainerRequest.addMetadata(request, container.metadata, opContext); client.getCredentials().signRequest(request, 0L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { this.setNonExceptionedRetryableFailure(true); @@ -298,7 +298,7 @@ public Boolean execute(final CloudBlobClient client, final CloudBlobContainer co ContainerRequest.addMetadata(request, container.metadata, opContext); client.getCredentials().signRequest(request, 0L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); // Validate response code here if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CREATED) { @@ -390,7 +390,7 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta client.getCredentials().signRequest(request, -1L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { this.setNonExceptionedRetryableFailure(true); @@ -460,7 +460,7 @@ public Boolean execute(final CloudBlobClient client, final CloudBlobContainer co client.getCredentials().signRequest(request, -1L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_ACCEPTED) { container.updatePropertiesFromResponse(request); @@ -533,7 +533,7 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta client.getCredentials().signRequest(request, -1L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); @@ -610,7 +610,7 @@ public BlobContainerPermissions execute(final CloudBlobClient client, final Clou client.getCredentials().signRequest(request, -1L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); @@ -689,7 +689,7 @@ public Boolean execute(final CloudBlobClient client, final CloudBlobContainer co client.getCredentials().signRequest(request, -1L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_OK) { container.updatePropertiesFromResponse(request); @@ -1108,7 +1108,7 @@ ResultSegment listBlobsCore(final String prefix, final boolean use this.blobServiceClient.getCredentials().signRequest(listBlobsRequest, -1L); - ExecutionEngine.processRequest(listBlobsRequest, opContext, taskReference); + ExecutionEngine.processRequest(listBlobsRequest, opContext, taskReference.getResult()); if (taskReference.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { taskReference.setNonExceptionedRetryableFailure(true); @@ -1533,7 +1533,7 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta ContainerRequest.addMetadata(request, container.metadata, opContext); client.getCredentials().signRequest(request, 0L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); @@ -1613,7 +1613,7 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta final OutputStream outStreamRef = request.getOutputStream(); outStreamRef.write(aclBytes); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); @@ -1710,7 +1710,7 @@ public String execute(final CloudBlobClient client, final CloudBlobContainer con client.getCredentials().signRequest(request, 0L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { this.setNonExceptionedRetryableFailure(true); @@ -1732,8 +1732,7 @@ public String execute(final CloudBlobClient client, final CloudBlobContainer con * * @param accessCondition * An {@link AccessCondition} object that represents the access conditions for the container. The lease - * ID is - * required to be set with an access condition. + * ID is required to be set with an access condition. * * @throws StorageException * If a storage service error occurred. @@ -1793,7 +1792,7 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta client.getCredentials().signRequest(request, 0L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); @@ -1875,7 +1874,7 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta client.getCredentials().signRequest(request, 0L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); @@ -1960,7 +1959,7 @@ public Long execute(final CloudBlobClient client, final CloudBlobContainer conta client.getCredentials().signRequest(request, 0L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { this.setNonExceptionedRetryableFailure(true); @@ -2052,7 +2051,7 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta client.getCredentials().signRequest(request, 0L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java index 03408a6aa4644..9ee73d83c1d15 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java @@ -204,7 +204,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op Utility.writeToOutputStream(blockListInputStream, request.getOutputStream(), descriptor.getLength(), false, false, null, opContext); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { this.setNonExceptionedRetryableFailure(true); @@ -293,7 +293,7 @@ public ArrayList execute(final CloudBlobClient client, final CloudBl client.getCredentials().signRequest(request, -1L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); @@ -624,7 +624,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op Utility.writeToOutputStream(sourceStream, request.getOutputStream(), length, true /* rewindSourceStream */, false /* calculateMD5 */, null, opContext); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { this.setNonExceptionedRetryableFailure(true); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java index b68248998d016..e17b0a9b612f7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java @@ -272,7 +272,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op client.getCredentials().signRequest(request, 0L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { this.setNonExceptionedRetryableFailure(true); @@ -352,7 +352,7 @@ public ArrayList execute(final CloudBlobClient client, final CloudBlo client.getCredentials().signRequest(request, -1L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); @@ -482,7 +482,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op client.getCredentials().signRequest(request, 0L); } - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { this.setNonExceptionedRetryableFailure(true); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java index 9e86e9de1dd34..8a6df9f916f3e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java @@ -144,7 +144,7 @@ public ServiceProperties execute(final ServiceClient client, final Void v, final .getRequestOptions().getTimeoutIntervalInMs(), null, opContext); client.getCredentials().signRequest(request, -1); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); @@ -242,13 +242,13 @@ public void setRetryPolicyFactory(final RetryPolicyFactory retryPolicyFactory) { /** * Sets the timeout to use when making requests to the storage service. *

- * The server timeout interval begins at the time that the complete request has been received by the service, and the - * server begins processing the response. If the timeout interval elapses before the response is returned to the + * The server timeout interval begins at the time that the complete request has been received by the service, and + * the server begins processing the response. If the timeout interval elapses before the response is returned to the * client, the operation times out. The timeout interval resets with each retry, if the request is retried. * - * The default timeout interval for a request made via the service client is 90 seconds. You can change this value on - * the service client by setting this property, so that all subsequent requests made via the service client will use - * the new timeout interval. You can also change this value for an individual request, by setting the + * The default timeout interval for a request made via the service client is 90 seconds. You can change this value + * on the service client by setting this property, so that all subsequent requests made via the service client will + * use the new timeout interval. You can also change this value for an individual request, by setting the * {@link RequestOptions#timeoutIntervalInMs} property. * * If you are downloading a large blob, you should increase the value of the timeout beyond the default value. @@ -330,7 +330,7 @@ public Void execute(final ServiceClient client, final Void v, final OperationCon Utility.writeToOutputStream(dataInputStream, request.getOutputStream(), descriptor.getLength(), false /* rewindSourceStream */, false /* calculateMD5 */, null, opContext); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { this.setNonExceptionedRetryableFailure(true); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java index 6addf94b43bcf..9d3ad41e569ab 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java @@ -106,7 +106,7 @@ public static RESULT_TYPE executeWithRet while (true) { try { // reset result flags - task.initialize(); + task.initialize(opContext); final RESULT_TYPE result = task.execute(client, parentObject, opContext); @@ -214,19 +214,17 @@ public static RESULT_TYPE executeWithRet * the request to process * @param opContext * an object used to track the execution of the operation - * @param operation - * the operation in which to set the current RequestResult object + * @param currResult + * A {@link RequestResult} object that represents the current request result. * @return the input stream from the request * @throws IOException * if there is an error making the connection */ public static InputStream getInputStream(final HttpURLConnection request, final OperationContext opContext, - final StorageOperation operation) throws IOException { - final RequestResult currResult = new RequestResult(); + final RequestResult currResult) throws IOException { + opContext.setCurrentRequestObject(request); currResult.setStartDate(new Date()); - opContext.appendRequestResult(currResult); - operation.setResult(currResult); if (opContext.getSendingRequestEventHandler().hasListeners()) { opContext.getSendingRequestEventHandler() @@ -295,19 +293,16 @@ public static void getResponseCode(final RequestResult currResult, final HttpURL * the request to process * @param opContext * an object used to track the execution of the operation - * @param operation - * the operation in which to set the current RequestResult object + * @param currResult + * A {@link RequestResult} object that represents the current request result. * @throws IOException * if there is an error making the connection */ public static void processRequest(final HttpURLConnection request, final OperationContext opContext, - final StorageOperation operation) throws IOException { + final RequestResult currResult) throws IOException { - final RequestResult currResult = new RequestResult(); - currResult.setStartDate(new Date()); - opContext.appendRequestResult(currResult); opContext.setCurrentRequestObject(request); - operation.setResult(currResult); + currResult.setStartDate(new Date()); if (opContext.getSendingRequestEventHandler().hasListeners()) { opContext.getSendingRequestEventHandler() diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java index 32ff5a00459a0..99ca5bc92ccf2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java @@ -109,10 +109,14 @@ public final RequestResult getResult() { /** * Resets the operation status flags between operations. */ - protected final void initialize() { - this.setResult(new RequestResult()); + protected final void initialize(OperationContext opContext) { + RequestResult currResult = new RequestResult(); + this.setResult(currResult); + opContext.appendRequestResult(currResult); + this.setException(null); this.setNonExceptionedRetryableFailure(false); + } /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java index b0dfe652f9565..c29f1067844c6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java @@ -220,7 +220,7 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final final OutputStream outStreamRef = request.getOutputStream(); outStreamRef.write(messageBytes); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { this.setNonExceptionedRetryableFailure(true); @@ -286,7 +286,7 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final client.getCredentials().signRequest(request, -1L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { this.setNonExceptionedRetryableFailure(true); @@ -351,7 +351,7 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final QueueRequest.addMetadata(request, queue.metadata, opContext); client.getCredentials().signRequest(request, 0L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED && this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { @@ -424,7 +424,7 @@ public Boolean execute(final CloudQueueClient client, final CloudQueue queue, QueueRequest.addMetadata(request, queue.metadata, opContext); client.getCredentials().signRequest(request, 0L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CREATED) { return true; @@ -509,7 +509,7 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final client.getCredentials().signRequest(request, -1L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { this.setNonExceptionedRetryableFailure(true); @@ -580,7 +580,7 @@ public Boolean execute(final CloudQueueClient client, final CloudQueue queue, client.getCredentials().signRequest(request, -1L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NO_CONTENT) { return true; @@ -667,7 +667,7 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final client.getCredentials().signRequest(request, -1L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { this.setNonExceptionedRetryableFailure(true); @@ -733,7 +733,7 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final client.getCredentials().signRequest(request, -1L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); @@ -806,7 +806,7 @@ public Boolean execute(final CloudQueueClient client, final CloudQueue queue, client.getCredentials().signRequest(request, -1L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_OK) { return Boolean.valueOf(true); @@ -1021,7 +1021,7 @@ public ArrayList execute(final CloudQueueClient client, final client.getCredentials().signRequest(request, -1L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); @@ -1155,7 +1155,7 @@ public ArrayList execute(final CloudQueueClient client, final client.getCredentials().signRequest(request, -1L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); @@ -1293,7 +1293,7 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final client.getCredentials().signRequest(request, 0L); } - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { this.setNonExceptionedRetryableFailure(true); @@ -1366,7 +1366,7 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final QueueRequest.addMetadata(request, queue.metadata, opContext); client.getCredentials().signRequest(request, 0L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { this.setNonExceptionedRetryableFailure(true); @@ -1445,7 +1445,7 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final final OutputStream outStreamRef = request.getOutputStream(); outStreamRef.write(aclBytes); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { this.setNonExceptionedRetryableFailure(true); @@ -1515,7 +1515,7 @@ public QueuePermissions execute(final CloudQueueClient client, final CloudQueue client.getCredentials().signRequest(request, -1L); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java index 5d161d81ccb27..addec40b3b9cd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java @@ -227,7 +227,7 @@ ResultSegment listQueuesCore(final String prefix, final QueueListing this.getCredentials().signRequest(listQueueRequest, -1L); - ExecutionEngine.processRequest(listQueueRequest, opContext, taskReference); + ExecutionEngine.processRequest(listQueueRequest, opContext, taskReference.getResult()); if (taskReference.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { taskReference.setNonExceptionedRetryableFailure(true); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTable.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTable.java index 4481d252421d1..f13eac657acfc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTable.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTable.java @@ -493,7 +493,7 @@ public Void execute(final CloudTableClient client, final CloudTable table, final final OutputStream outStreamRef = request.getOutputStream(); outStreamRef.write(aclBytes); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { this.setNonExceptionedRetryableFailure(true); @@ -564,7 +564,7 @@ public TablePermissions execute(final CloudTableClient client, final CloudTable client.getCredentials().signRequestLite(request, -1L, opContext); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTableClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTableClient.java index c4b103f321618..26a506cc39a65 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTableClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTableClient.java @@ -800,7 +800,7 @@ protected ResultSegment executeQuerySegmentedCore( this.getCredentials().signRequestLite(queryRequest, -1L, opContext); - ExecutionEngine.processRequest(queryRequest, opContext, taskReference); + ExecutionEngine.processRequest(queryRequest, opContext, taskReference.getResult()); if (taskReference.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { throw TableServiceException.generateTableServiceException(true, taskReference.getResult(), null, diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/QueryTableOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/QueryTableOperation.java index dd74e256fc1d0..14c130540b18c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/QueryTableOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/QueryTableOperation.java @@ -189,7 +189,7 @@ tableName, generateRequestIdentity(isTableEntry, operation.getPartitionKey(), fa client.getCredentials().signRequestLite(request, -1L, opContext); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_OK) { // Parse response for updates diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableBatchOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableBatchOperation.java index 544e0201d42de..a2e814a92e00a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableBatchOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableBatchOperation.java @@ -399,7 +399,7 @@ public ArrayList execute(final CloudTableClient client, final Table MimeHelper.writeBatchToStream(request.getOutputStream(), tableName, batch, batchID, changeSet, opContext); - final InputStream streamRef = ExecutionEngine.getInputStream(request, opContext, this); + final InputStream streamRef = ExecutionEngine.getInputStream(request, opContext, this.getResult()); ArrayList responseParts = null; try { final String contentType = request.getHeaderField(Constants.HeaderConstants.CONTENT_TYPE); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableOperation.java index c4ce82e4df378..88cc7e7dce22e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableOperation.java @@ -256,13 +256,13 @@ private TableResult performDelete(final CloudTableClient client, final String ta public TableResult execute(final CloudTableClient client, final TableOperation operation, final OperationContext opContext) throws Exception { - final HttpURLConnection request = TableRequest.delete(client.getTransformedEndPoint(opContext), tableName, - generateRequestIdentity(isTableEntry, tableIdentity, false), operation.getEntity().getEtag(), - options.getTimeoutIntervalInMs(), null, options, opContext); + final HttpURLConnection request = TableRequest.delete(client.getTransformedEndPoint(opContext), + tableName, generateRequestIdentity(isTableEntry, tableIdentity, false), operation.getEntity() + .getEtag(), options.getTimeoutIntervalInMs(), null, options, opContext); client.getCredentials().signRequestLite(request, -1L, opContext); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND || this.getResult().getStatusCode() == HttpURLConnection.HTTP_CONFLICT) { @@ -323,8 +323,8 @@ private TableResult performInsert(final CloudTableClient client, final String ta @Override public TableResult execute(final CloudTableClient client, final TableOperation operation, final OperationContext opContext) throws Exception { - final HttpURLConnection request = TableRequest.insert(client.getTransformedEndPoint(opContext), tableName, - generateRequestIdentity(isTableEntry, tableIdentity, false), + final HttpURLConnection request = TableRequest.insert(client.getTransformedEndPoint(opContext), + tableName, generateRequestIdentity(isTableEntry, tableIdentity, false), operation.opType != TableOperationType.INSERT ? operation.getEntity().getEtag() : null, operation.opType.getUpdateType(), options.getTimeoutIntervalInMs(), null, options, opContext); @@ -333,7 +333,7 @@ public TableResult execute(final CloudTableClient client, final TableOperation o AtomPubParser.writeSingleEntityToStream(operation.getEntity(), isTableEntry, request.getOutputStream(), opContext); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (operation.opType == TableOperationType.INSERT) { if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CONFLICT) { throw TableServiceException.generateTableServiceException(false, this.getResult(), operation, @@ -410,8 +410,8 @@ private TableResult performMerge(final CloudTableClient client, final String tab public TableResult execute(final CloudTableClient client, final TableOperation operation, final OperationContext opContext) throws Exception { - final HttpURLConnection request = TableRequest.merge(client.getTransformedEndPoint(opContext), tableName, - generateRequestIdentity(false, null, false), operation.getEntity().getEtag(), + final HttpURLConnection request = TableRequest.merge(client.getTransformedEndPoint(opContext), + tableName, generateRequestIdentity(false, null, false), operation.getEntity().getEtag(), options.getTimeoutIntervalInMs(), null, options, opContext); client.getCredentials().signRequestLite(request, -1L, opContext); @@ -419,7 +419,7 @@ public TableResult execute(final CloudTableClient client, final TableOperation o AtomPubParser.writeSingleEntityToStream(operation.getEntity(), false, request.getOutputStream(), opContext); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND || this.getResult().getStatusCode() == HttpURLConnection.HTTP_CONFLICT) { @@ -476,8 +476,8 @@ private TableResult performUpdate(final CloudTableClient client, final String ta public TableResult execute(final CloudTableClient client, final TableOperation operation, final OperationContext opContext) throws Exception { - final HttpURLConnection request = TableRequest.update(client.getTransformedEndPoint(opContext), tableName, - generateRequestIdentity(false, null, false), operation.getEntity().getEtag(), + final HttpURLConnection request = TableRequest.update(client.getTransformedEndPoint(opContext), + tableName, generateRequestIdentity(false, null, false), operation.getEntity().getEtag(), options.getTimeoutIntervalInMs(), null, options, opContext); client.getCredentials().signRequestLite(request, -1L, opContext); @@ -485,7 +485,7 @@ public TableResult execute(final CloudTableClient client, final TableOperation o AtomPubParser.writeSingleEntityToStream(operation.getEntity(), false, request.getOutputStream(), opContext); - ExecutionEngine.processRequest(request, opContext, this); + ExecutionEngine.processRequest(request, opContext, this.getResult()); if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND || this.getResult().getStatusCode() == HttpURLConnection.HTTP_CONFLICT) { From 19ef20ccc634b93fbed4b60e38b3b6abd5e2d234 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 26 Feb 2013 13:11:12 -0800 Subject: [PATCH 21/43] fix the broken unit test due to nimbus server upgrade. --- .../services/media/AssetIntegrationTest.java | 2 +- .../media/ContentKeyIntegrationTest.java | 41 ++++++++++++++----- .../media/MediaProcessorIntegrationTest.java | 2 +- .../services/media/TaskIntegrationTest.java | 15 +++---- .../scenarios/MediaServiceWrapper.java | 2 +- 5 files changed, 41 insertions(+), 21 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java index 2c012d168f514..f262d415b8ea7 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java @@ -288,7 +288,7 @@ public void deleteAssetFailedWithInvalidId() throws ServiceException { @Test public void linkAssetContentKeySuccess() throws ServiceException, URISyntaxException { // Arrange - String originalTestName = testAssetPrefix + "linkAssetContentKeyInvalidIdFailed"; + String originalTestName = testAssetPrefix + "linkAssetContentKeySuccess"; AssetInfo assetInfo = service.create(Asset.create().setName(originalTestName) .setOptions(AssetOption.StorageEncrypted)); String contentKeyId = String.format("nb:kid:UUID:%s", UUID.randomUUID()); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java index 3f479a6ea8b79..d7c6f40b96d7d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java @@ -27,6 +27,7 @@ import com.microsoft.windowsazure.services.media.models.ContentKey; import com.microsoft.windowsazure.services.media.models.ContentKeyInfo; import com.microsoft.windowsazure.services.media.models.ContentKeyType; +import com.microsoft.windowsazure.services.media.models.ProtectionKey; import com.microsoft.windowsazure.services.media.models.ProtectionKeyType; public class ContentKeyIntegrationTest extends IntegrationTestBase { @@ -65,15 +66,17 @@ public void canCreateContentKey() throws Exception { // Arrange String testCanCreateContentKeyId = createRandomContentKeyId(); String testCanCreateContentKeyName = "testCanCreateContentKey"; + String protectionKeyId = service.action(ProtectionKey.getProtectionKeyId(testContentKeyType)); // Act - ContentKeyInfo contentKeyInfo = service.create(ContentKey.create(testCanCreateContentKeyId, testContentKeyType, - testEncryptedContentKey).setName(testCanCreateContentKeyName)); + ContentKeyInfo contentKeyInfo = service.create(ContentKey + .create(testCanCreateContentKeyId, testContentKeyType, testEncryptedContentKey) + .setName(testCanCreateContentKeyName).setProtectionKeyId(protectionKeyId)); // Assert verifyContentKeyProperties("ContentKey", testCanCreateContentKeyId, testContentKeyType, - testEncryptedContentKey, testCanCreateContentKeyName, "", ProtectionKeyType.fromCode(0), "", - contentKeyInfo); + testEncryptedContentKey, testCanCreateContentKeyName, protectionKeyId, ProtectionKeyType.fromCode(0), + "", contentKeyInfo); } @Test @@ -81,8 +84,10 @@ public void canGetSingleContentKeyById() throws Exception { // Arrange String expectedName = testContentKeyPrefix + "GetOne"; String testGetSingleContentKeyByIdId = createRandomContentKeyId(); - ContentKeyInfo ContentKeyToGet = service.create(ContentKey.create(testGetSingleContentKeyByIdId, - testContentKeyType, testEncryptedContentKey).setName(expectedName)); + String protectionKeyId = service.action(ProtectionKey.getProtectionKeyId(testContentKeyType)); + ContentKeyInfo ContentKeyToGet = service.create(ContentKey + .create(testGetSingleContentKeyByIdId, testContentKeyType, testEncryptedContentKey) + .setName(expectedName).setProtectionKeyId(protectionKeyId)); // Act ContentKeyInfo retrievedContentKeyInfo = service.get(ContentKey.get(ContentKeyToGet.getId())); @@ -90,7 +95,8 @@ public void canGetSingleContentKeyById() throws Exception { // Assert assertEquals(ContentKeyToGet.getId(), retrievedContentKeyInfo.getId()); verifyContentKeyProperties("ContentKey", testGetSingleContentKeyByIdId, testContentKeyType, - testEncryptedContentKey, expectedName, "", ProtectionKeyType.fromCode(0), "", retrievedContentKeyInfo); + testEncryptedContentKey, expectedName, protectionKeyId, ProtectionKeyType.fromCode(0), "", + retrievedContentKeyInfo); } @Test @@ -102,18 +108,22 @@ public void cannotGetSingleContentKeyByInvalidId() throws Exception { @Test public void canRetrieveListOfContentKeys() throws Exception { + // Arrange String[] ContentKeyNames = new String[] { testContentKeyPrefix + "ListOne", testContentKeyPrefix + "ListTwo" }; + String protectionKeyId = service.action(ProtectionKey.getProtectionKeyId(testContentKeyType)); List expectedContentKeys = new ArrayList(); for (int i = 0; i < ContentKeyNames.length; i++) { String testCanRetrieveListOfContentKeysId = createRandomContentKeyId(); ContentKeyInfo contentKey = service.create(ContentKey.create(testCanRetrieveListOfContentKeysId, - testContentKeyType, testEncryptedContentKey)); + testContentKeyType, testEncryptedContentKey).setProtectionKeyId(protectionKeyId)); expectedContentKeys.add(contentKey); } + // Act List actualContentKeys = service.list(ContentKey.list()); + // Assert verifyListResultContains("listContentKeyss", expectedContentKeys, actualContentKeys, new ComponentDelegate() { @Override public void verifyEquals(String message, Object expected, Object actual) { @@ -124,32 +134,41 @@ public void verifyEquals(String message, Object expected, Object actual) { @Test public void canUseQueryParametersWhenListingContentKeys() throws Exception { + // Arrange String[] ContentKeyNames = new String[] { testContentKeyPrefix + "ListThree", testContentKeyPrefix + "ListFour", testContentKeyPrefix + "ListFive", testContentKeyPrefix + "ListSix", testContentKeyPrefix + "ListSeven" }; + String protectionKeyId = service.action(ProtectionKey.getProtectionKeyId(testContentKeyType)); List expectedContentKeys = new ArrayList(); for (int i = 0; i < ContentKeyNames.length; i++) { ContentKeyInfo contentKeyInfo = service.create(ContentKey.create(createRandomContentKeyId(), - testContentKeyType, testEncryptedContentKey)); + testContentKeyType, testEncryptedContentKey).setProtectionKeyId(protectionKeyId)); expectedContentKeys.add(contentKeyInfo); } + // Act List actualContentKeys = service.list(ContentKey.list().setTop(2)); + // Assert assertEquals(2, actualContentKeys.size()); } @Test public void canDeleteContentKeyById() throws Exception { + // Arrange + String protectionKeyId = service.action(ProtectionKey.getProtectionKeyId(testContentKeyType)); String contentKeyName = testContentKeyPrefix + "ToDelete"; - ContentKeyInfo contentKeyToDelete = service.create(ContentKey.create(createRandomContentKeyId(), - testContentKeyType, testEncryptedContentKey).setName(contentKeyName)); + ContentKeyInfo contentKeyToDelete = service.create(ContentKey + .create(createRandomContentKeyId(), testContentKeyType, testEncryptedContentKey) + .setName(contentKeyName).setProtectionKeyId(protectionKeyId)); List listContentKeysResult = service.list(ContentKey.list()); int ContentKeyCountBaseline = listContentKeysResult.size(); + // Act service.delete(ContentKey.delete(contentKeyToDelete.getId())); + // Assert listContentKeysResult = service.list(ContentKey.list()); assertEquals("listPoliciesResult.size", ContentKeyCountBaseline - 1, listContentKeysResult.size()); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java index 052fdc0811ef0..176220765c00b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java @@ -73,6 +73,6 @@ public void listMediaProcessorWithOptionSuccess() throws ServiceException { assertEquals("listMediaProcessors size", 1, listMediaProcessorsResult.size()); MediaProcessorInfo mediaProcessorInfo = listMediaProcessorsResult.get(0); verifyMediaProcessorInfo("mediaProcessorInfo", "nb:mpid:UUID:aec03716-7c5e-4f68-b592-f4850eba9f10", - "Storage Decryption", "Storage Decryption", "", "Microsoft", "1.5.3", mediaProcessorInfo); + "Storage Decryption", "Storage Decryption", "", "Microsoft", "1.5.3.0", mediaProcessorInfo); } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java index ad9ca21b6750c..2c576c8c193b7 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java @@ -71,7 +71,7 @@ public void createTaskSuccess() throws ServiceException, UnsupportedEncodingExce // Optional parameters String configuration = new String(Base64.encode(commonConfiguration), "UTF8"); String name = "My encoding Task " + UUID.randomUUID().toString(); - int priority = 0; + int jobPriority = 3; TaskOption options = TaskOption.ProtectedConfiguration; // Use a fake id, to simulate real use. String encryptionKeyId = "nb:kid:UUID:" + UUID.randomUUID().toString(); @@ -81,7 +81,7 @@ public void createTaskSuccess() throws ServiceException, UnsupportedEncodingExce String initializationVector = new String(Base64.encode(new byte[16]), "UTF8"); CreateBatchOperation taskCreator = Task.create(mediaProcessorId, taskBody).setConfiguration(configuration) - .setName(name).setPriority(priority).setOptions(options).setEncryptionKeyId(encryptionKeyId) + .setName(name).setPriority(jobPriority).setOptions(options).setEncryptionKeyId(encryptionKeyId) .setEncryptionScheme(encryptionScheme).setEncryptionVersion(encryptionVersion) .setInitializationVector(initializationVector); jobCreator.addTaskCreator(taskCreator); @@ -92,8 +92,9 @@ public void createTaskSuccess() throws ServiceException, UnsupportedEncodingExce // Assert assertEquals("taskInfos count", 1, taskInfos.size()); - verifyTaskPropertiesJustStarted("taskInfo", mediaProcessorId, options, taskBody, configuration, name, priority, - encryptionKeyId, encryptionScheme, encryptionVersion, initializationVector, taskInfos.get(0)); + verifyTaskPropertiesJustStarted("taskInfo", mediaProcessorId, options, taskBody, configuration, name, + jobPriority, encryptionKeyId, encryptionScheme, encryptionVersion, initializationVector, + taskInfos.get(0)); } @Test @@ -108,7 +109,7 @@ public void createTwoTasksSuccess() throws ServiceException { String configuration = commonConfiguration; String baseName = "My encoding Task " + UUID.randomUUID().toString(); String[] suffixes = new String[] { " 1", " 2" }; - int priority = 0; + int jobPriority = 3; TaskOption options = TaskOption.None; List taskCreators = new ArrayList(); @@ -128,7 +129,7 @@ public void createTwoTasksSuccess() throws ServiceException { assertEquals("taskInfos count", taskCreators.size(), taskInfos.size()); for (int i = 0; i < taskCreators.size(); i++) { verifyTaskPropertiesJustStartedNoEncryption("taskInfo", mediaProcessorId, options, taskBodies[i], - configuration, baseName + suffixes[i], priority, taskInfos.get(i)); + configuration, baseName + suffixes[i], jobPriority, taskInfos.get(i)); } } @@ -184,7 +185,7 @@ public void cancelTaskSuccess() throws ServiceException, InterruptedException { List taskInfos = service.list(Task.list(cancellingJobInfo.getTasksLink())); for (TaskInfo taskInfo : taskInfos) { verifyTaskPropertiesNoEncryption("canceled task", mediaProcessorId, TaskOption.None, taskBody, - configuration, name, 0, new Date(), null, 0.0, 0.0, null, TaskState.Canceled, taskInfo); + configuration, name, 3, new Date(), null, 0.0, 0.0, null, TaskState.Canceled, taskInfo); } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java index 16ba0ddcdf920..19933421282f0 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java @@ -278,7 +278,7 @@ public Task.CreateBatchOperation createTaskOptions(String taskName, int inputAss configuration = "VC1 Broadband SD 4x3"; break; case StorageDecryption: - processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_STORAGE_DECRYPTION, "1.5.3"); + processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_STORAGE_DECRYPTION, "1.5.3.0"); configuration = null; break; default: From 4f692bb39d8a9c4e9206190944c2dc33f16f4e10 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 26 Feb 2013 13:24:32 -0800 Subject: [PATCH 22/43] fix another unit test due to nimbus server upgrade. --- .../windowsazure/services/media/AssetIntegrationTest.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java index f262d415b8ea7..b9bcbb3bfeef8 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java @@ -47,6 +47,7 @@ import com.microsoft.windowsazure.services.media.models.Locator; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; +import com.microsoft.windowsazure.services.media.models.ProtectionKey; import com.microsoft.windowsazure.services.media.models.Task; import com.microsoft.windowsazure.services.media.models.Task.CreateBatchOperation; @@ -291,9 +292,12 @@ public void linkAssetContentKeySuccess() throws ServiceException, URISyntaxExcep String originalTestName = testAssetPrefix + "linkAssetContentKeySuccess"; AssetInfo assetInfo = service.create(Asset.create().setName(originalTestName) .setOptions(AssetOption.StorageEncrypted)); + + String protectionKeyId = service.action(ProtectionKey.getProtectionKeyId(ContentKeyType.StorageEncryption)); String contentKeyId = String.format("nb:kid:UUID:%s", UUID.randomUUID()); String encryptedContentKey = "dummyEncryptedContentKey"; - service.create(ContentKey.create(contentKeyId, ContentKeyType.StorageEncryption, encryptedContentKey)); + service.create(ContentKey.create(contentKeyId, ContentKeyType.StorageEncryption, encryptedContentKey) + .setProtectionKeyId(protectionKeyId)); // Act service.action(Asset.linkContentKey(assetInfo.getId(), contentKeyId)); From 742b0e2f39bf7b10d580b32fa12c48f02b6566d5 Mon Sep 17 00:00:00 2001 From: Chris Tavares Date: Wed, 27 Feb 2013 11:42:30 -0800 Subject: [PATCH 23/43] Clean up service bus assets created as part of test at the end. --- .../serviceBus/IntegrationTestBase.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java index ddff90ded3445..aa8c21ec5cbbc 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java @@ -16,6 +16,7 @@ import static com.microsoft.windowsazure.services.serviceBus.Util.*; +import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; @@ -54,7 +55,7 @@ public void initialize() throws Exception { for (TopicInfo topic : iterateTopics(service)) { String topicName = topic.getPath(); if (topicName.startsWith("Test") || topicName.startsWith("test")) { - service.deleteQueue(topicName); + service.deleteTopic(topicName); } } if (!testAlphaExists) { @@ -62,6 +63,24 @@ public void initialize() throws Exception { } } + @AfterClass + public static void cleanUpTestArtifacts() throws Exception { + Configuration config = createConfiguration(); + ServiceBusContract service = ServiceBusService.create(config); + for (QueueInfo queue : iterateQueues(service)) { + String queueName = queue.getPath(); + if (queueName.startsWith("Test") || queueName.startsWith("test")) { + service.deleteQueue(queueName); + } + } + for (TopicInfo topic : iterateTopics(service)) { + String topicName = topic.getPath(); + if (topicName.startsWith("Test") || topicName.startsWith("test")) { + service.deleteTopic(topicName); + } + } + } + protected static Configuration createConfiguration() throws Exception { Configuration config = Configuration.load(); overrideWithEnv(config, ServiceBusConfiguration.CONNECTION_STRING); From 782319d0de20f30de1de59f473be5c0a935d192f Mon Sep 17 00:00:00 2001 From: Joe Giardino Date: Wed, 27 Feb 2013 14:36:05 -0800 Subject: [PATCH 24/43] CR feedback remove extra line --- .../core/storage/utils/implementation/StorageOperation.java | 1 - 1 file changed, 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java index 99ca5bc92ccf2..803bbdfa5481c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java @@ -116,7 +116,6 @@ protected final void initialize(OperationContext opContext) { this.setException(null); this.setNonExceptionedRetryableFailure(false); - } /** From 57335fe0b513c523b89d5a0bc484b148a9cb7cf7 Mon Sep 17 00:00:00 2001 From: Joe Giardino Date: Thu, 28 Feb 2013 14:04:37 -0800 Subject: [PATCH 25/43] Update Changelog for latest fixes --- ChangeLog.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index 05c6b42a094cb..c2a7ce47e8e6a 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,4 +1,7 @@ 2013.02.22 Version 0.4.1 + * BlobOutputStream now commits block list using LATEST instead of UNCOMMITTED + * Added RequestResult to StorageEvents + * Fixed race condition when accessing OperationContext RequestResults * Fixed the return value of BlobInputStream.read * Fixed CloudPageBlob.downloadPageRanges to retrieve the blob length * Fixed MD5 validation in BlobInputStream From 3e422edc43df4ee067ea30199584b48743245730 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 6 Mar 2013 10:22:47 -0800 Subject: [PATCH 26/43] fix for issue 188, broker properties mapper --- .../serviceBus/implementation/BrokerPropertiesMapper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java index a01aa2aed43b0..eefbae6266845 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java @@ -28,7 +28,7 @@ public class BrokerPropertiesMapper { public BrokerProperties fromString(String value) throws IllegalArgumentException { ObjectMapper mapper = new ObjectMapper(); try { - return mapper.readValue(value.getBytes(), BrokerProperties.class); + return mapper.readValue(value.getBytes("UTF-8"), BrokerProperties.class); } catch (JsonParseException e) { throw new IllegalArgumentException(e); From 32b0c8be339fd2c2bfe1012ec107e5104d8b0939 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 6 Mar 2013 10:29:13 -0800 Subject: [PATCH 27/43] fix for issue 189, unicode issues in BrokeredMessage --- .../services/serviceBus/models/BrokeredMessage.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java index a2518f45afd97..3c222a52e7930 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java @@ -16,6 +16,7 @@ import java.io.ByteArrayInputStream; import java.io.InputStream; +import java.io.UnsupportedEncodingException; import java.util.Date; import java.util.HashMap; import java.util.Map; @@ -70,7 +71,12 @@ public BrokeredMessage(byte[] body) { */ public BrokeredMessage(String body) { this(new BrokerProperties()); - this.body = (body == null) ? null : new ByteArrayInputStream(body.getBytes()); + try { + this.body = (body == null) ? null : new ByteArrayInputStream(body.getBytes("UTF-8")); + } + catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); + } } /** From 7595d281c8a84dc1ded5121887f4ab04a3b7c1d9 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 6 Mar 2013 10:52:13 -0800 Subject: [PATCH 28/43] fix for issue 191, unicode issues in BlobOperationRestProxy.java --- .../implementation/BlobOperationRestProxy.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobOperationRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobOperationRestProxy.java index 24adf87f4a232..5b865241508f4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobOperationRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobOperationRestProxy.java @@ -16,6 +16,7 @@ package com.microsoft.windowsazure.services.blob.implementation; import java.io.InputStream; +import java.io.UnsupportedEncodingException; import java.util.HashMap; import java.util.Map; @@ -808,7 +809,8 @@ public void breakLease(String container, String blob, String leaseId) throws Ser @Override @Deprecated - public void breakLease(String container, String blob, String leaseId, BlobServiceOptions options) throws ServiceException { + public void breakLease(String container, String blob, String leaseId, BlobServiceOptions options) + throws ServiceException { breakLease(container, blob, options); } @@ -819,8 +821,8 @@ public BreakLeaseResult breakLease(String container, String blob) throws Service @Override public BreakLeaseResult breakLease(String container, String blob, BlobServiceOptions options) - throws ServiceException { - ClientResponse response = doLeaseOperation("break", container, blob, null, options, null); + throws ServiceException { + ClientResponse response = doLeaseOperation("break", container, blob, null, options, null); BreakLeaseResult result = new BreakLeaseResult(); result.setRemainingLeaseTimeInSeconds(Integer.parseInt(response.getHeaders().getFirst("x-ms-lease-time"))); @@ -836,7 +838,8 @@ private AcquireLeaseResult putLeaseImpl(String leaseAction, String container, St return result; } - private ClientResponse doLeaseOperation(String leaseAction, String container, String blob, String leaseId, BlobServiceOptions options, AccessCondition accessCondition) { + private ClientResponse doLeaseOperation(String leaseAction, String container, String blob, String leaseId, + BlobServiceOptions options, AccessCondition accessCondition) { String path = createPathFromContainer(container); WebResource webResource = getResource(options).path(path).path(blob).queryParam("comp", "lease"); @@ -941,7 +944,12 @@ public void createBlobBlock(String container, String blob, String blockId, Input CreateBlobBlockOptions options) throws ServiceException { String path = createPathFromContainer(container); WebResource webResource = getResource(options).path(path).path(blob).queryParam("comp", "block"); - webResource = addOptionalQueryParam(webResource, "blockid", new String(Base64.encode(blockId))); + try { + webResource = addOptionalQueryParam(webResource, "blockid", new String(Base64.encode(blockId), "UTF-8")); + } + catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); + } Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); From dbff29a150ea6f682ea713873f40eff3b6511883 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 6 Mar 2013 17:15:21 -0800 Subject: [PATCH 29/43] update the unicode issues in HmacSHA256Sign file, issue 192#. --- .../blob/implementation/HmacSHA256Sign.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HmacSHA256Sign.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HmacSHA256Sign.java index 71a68bd061ccd..e40607c675220 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HmacSHA256Sign.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HmacSHA256Sign.java @@ -2,15 +2,15 @@ * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License 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. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License 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.microsoft.windowsazure.services.blob.implementation; @@ -33,8 +33,8 @@ public String sign(String stringToSign) { Mac hmac = Mac.getInstance("hmacSHA256"); hmac.init(new SecretKeySpec(Base64.decode(accessKey), "hmacSHA256")); - byte[] digest = hmac.doFinal(stringToSign.getBytes("UTF8")); - return new String(Base64.encode(digest)); + byte[] digest = hmac.doFinal(stringToSign.getBytes("UTF-8")); + return new String(Base64.encode(digest), "UTF-8"); } catch (Exception e) { throw new IllegalArgumentException("accessKey", e); From 3ff10d54740284ef88f77028a1b874f18dc0917f Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 6 Mar 2013 17:33:01 -0800 Subject: [PATCH 30/43] fix base64 string adapter encoding issue, issue #193. --- .../utils/pipeline/Base64StringAdapter.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Base64StringAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Base64StringAdapter.java index 975bc675e4bbd..f9aedb2faf946 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Base64StringAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Base64StringAdapter.java @@ -2,15 +2,15 @@ * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License 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. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License 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.microsoft.windowsazure.services.core.utils.pipeline; @@ -25,7 +25,7 @@ public class Base64StringAdapter extends XmlAdapter { @Override public String marshal(String arg0) throws Exception { - return new String(Base64.encode(arg0)); + return new String(Base64.encode(arg0), "UTF-8"); } @Override From 225aa9aef3aca18a9af284a8eabb825fa0c69d7b Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 6 Mar 2013 17:40:54 -0800 Subject: [PATCH 31/43] fix issue #194, unicode issue in DefaultEdmValueConverter.java --- .../windowsazure/services/table/Exports.java | 4 +- .../DefaultEdmValueConterter.java | 90 ------------------- .../implementation/AtomReaderWriterTests.java | 2 +- 3 files changed, 3 insertions(+), 93 deletions(-) delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/DefaultEdmValueConterter.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/Exports.java index 485104a66a291..6be3e3c25264c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/Exports.java @@ -17,7 +17,7 @@ import com.microsoft.windowsazure.services.core.Builder; import com.microsoft.windowsazure.services.core.UserAgentFilter; import com.microsoft.windowsazure.services.table.implementation.AtomReaderWriter; -import com.microsoft.windowsazure.services.table.implementation.DefaultEdmValueConterter; +import com.microsoft.windowsazure.services.table.implementation.DefaultEdmValueConverter; import com.microsoft.windowsazure.services.table.implementation.DefaultXMLStreamFactory; import com.microsoft.windowsazure.services.table.implementation.HttpReaderWriter; import com.microsoft.windowsazure.services.table.implementation.MimeReaderWriter; @@ -39,7 +39,7 @@ public void register(Builder.Registry registry) { registry.add(AtomReaderWriter.class); registry.add(MimeReaderWriter.class); registry.add(HttpReaderWriter.class); - registry.add(EdmValueConverter.class, DefaultEdmValueConterter.class); + registry.add(EdmValueConverter.class, DefaultEdmValueConverter.class); registry.add(UserAgentFilter.class); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/DefaultEdmValueConterter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/DefaultEdmValueConterter.java deleted file mode 100644 index 8d1aff2334cb4..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/DefaultEdmValueConterter.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Copyright Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License 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.microsoft.windowsazure.services.table.implementation; - -import java.text.ParseException; -import java.util.Date; -import java.util.UUID; - -import javax.inject.Inject; - -import com.microsoft.windowsazure.services.blob.implementation.ISO8601DateConverter; -import com.microsoft.windowsazure.services.table.EdmValueConverter; -import com.microsoft.windowsazure.services.table.models.EdmType; -import com.sun.jersey.core.util.Base64; - -public class DefaultEdmValueConterter implements EdmValueConverter { - - private final ISO8601DateConverter iso8601DateConverter; - - @Inject - public DefaultEdmValueConterter(ISO8601DateConverter iso8601DateConverter) { - this.iso8601DateConverter = iso8601DateConverter; - } - - @Override - public String serialize(String edmType, Object value) { - if (value == null) - return null; - - String serializedValue; - if (value instanceof Date) { - serializedValue = iso8601DateConverter.format((Date) value); - } - else if (value instanceof byte[]) { - serializedValue = new String(Base64.encode((byte[]) value)); - } - else { - serializedValue = value.toString(); - } - - return serializedValue; - } - - @Override - public Object deserialize(String edmType, String value) { - if (edmType == null) - return value; - - if (EdmType.DATETIME.equals(edmType)) { - try { - return iso8601DateConverter.parse(value); - } - catch (ParseException e) { - throw new RuntimeException(e); - } - } - else if (EdmType.BOOLEAN.equals(edmType)) { - return Boolean.parseBoolean(value); - } - else if (EdmType.DOUBLE.equals(edmType)) { - return Double.parseDouble(value); - } - else if (EdmType.INT32.equals(edmType)) { - return Integer.parseInt(value); - } - else if (EdmType.INT64.equals(edmType)) { - return Long.parseLong(value); - } - else if (EdmType.BINARY.equals(edmType)) { - return Base64.decode(value); - } - else if (EdmType.GUID.equals(edmType)) { - return UUID.fromString(value); - } - - return value; - } -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/implementation/AtomReaderWriterTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/implementation/AtomReaderWriterTests.java index 17578984f68c5..1a2fd1ef0895d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/implementation/AtomReaderWriterTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/implementation/AtomReaderWriterTests.java @@ -32,7 +32,7 @@ public class AtomReaderWriterTests extends IntegrationTestBase { public void parseTableEntriesWorks() throws Exception { // Arrange AtomReaderWriter atom = new AtomReaderWriter(new DefaultXMLStreamFactory(), new DefaultDateFactory(), - new ISO8601DateConverter(), new DefaultEdmValueConterter(new ISO8601DateConverter())); + new ISO8601DateConverter(), new DefaultEdmValueConverter(new ISO8601DateConverter())); String feed = "\r\n" + "\r\n" + " Tables\r\n" From 0ecdd94a252532b6b0b4518244b0444812ce9317 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 6 Mar 2013 17:41:47 -0800 Subject: [PATCH 32/43] add the missing DefaultEdmValueConverter.java file --- .../DefaultEdmValueConverter.java | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/DefaultEdmValueConverter.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/DefaultEdmValueConverter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/DefaultEdmValueConverter.java new file mode 100644 index 0000000000000..cdf08312d8ae1 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/DefaultEdmValueConverter.java @@ -0,0 +1,90 @@ +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License 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.microsoft.windowsazure.services.table.implementation; + +import java.text.ParseException; +import java.util.Date; +import java.util.UUID; + +import javax.inject.Inject; + +import com.microsoft.windowsazure.services.blob.implementation.ISO8601DateConverter; +import com.microsoft.windowsazure.services.table.EdmValueConverter; +import com.microsoft.windowsazure.services.table.models.EdmType; +import com.sun.jersey.core.util.Base64; + +public class DefaultEdmValueConverter implements EdmValueConverter { + + private final ISO8601DateConverter iso8601DateConverter; + + @Inject + public DefaultEdmValueConverter(ISO8601DateConverter iso8601DateConverter) { + this.iso8601DateConverter = iso8601DateConverter; + } + + @Override + public String serialize(String edmType, Object value) { + if (value == null) + return null; + + String serializedValue; + if (value instanceof Date) { + serializedValue = iso8601DateConverter.format((Date) value); + } + else if (value instanceof byte[]) { + serializedValue = new String(Base64.encode((byte[]) value)); + } + else { + serializedValue = value.toString(); + } + + return serializedValue; + } + + @Override + public Object deserialize(String edmType, String value) { + if (edmType == null) + return value; + + if (EdmType.DATETIME.equals(edmType)) { + try { + return iso8601DateConverter.parse(value); + } + catch (ParseException e) { + throw new RuntimeException(e); + } + } + else if (EdmType.BOOLEAN.equals(edmType)) { + return Boolean.parseBoolean(value); + } + else if (EdmType.DOUBLE.equals(edmType)) { + return Double.parseDouble(value); + } + else if (EdmType.INT32.equals(edmType)) { + return Integer.parseInt(value); + } + else if (EdmType.INT64.equals(edmType)) { + return Long.parseLong(value); + } + else if (EdmType.BINARY.equals(edmType)) { + return Base64.decode(value); + } + else if (EdmType.GUID.equals(edmType)) { + return UUID.fromString(value); + } + + return value; + } +} From 398e7218710a9e21b4cb52048bbbe0c94fedd5fa Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" Date: Fri, 8 Mar 2013 14:10:16 -0800 Subject: [PATCH 33/43] Updating POM version --- microsoft-azure-api/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index c2ae959ce9d90..1900ba335e498 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -17,7 +17,7 @@ 4.0.0 com.microsoft.windowsazure microsoft-windowsazure-api - 0.4.0 + 0.4.1 jar Microsoft Windows Azure Client API From baff38824e8741cf2dc3e61d0292ab7e088ab452 Mon Sep 17 00:00:00 2001 From: Guang Yang Date: Mon, 11 Mar 2013 07:35:05 -0700 Subject: [PATCH 34/43] update changelog for 0.4.1 --- ChangeLog.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index c2a7ce47e8e6a..fb88dee6195b4 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,4 +1,6 @@ -2013.02.22 Version 0.4.1 +2013.03.12 Version 0.4.1 + * Added connection string support for Windows Azure Service Bus + * Fixed Windows Azure Storage Table encoding issue for special characters * BlobOutputStream now commits block list using LATEST instead of UNCOMMITTED * Added RequestResult to StorageEvents * Fixed race condition when accessing OperationContext RequestResults @@ -11,7 +13,7 @@ * Added support for Windows Azure Media Services * Updated dependencies to non-beta stable versions * Add a Sending Request Event to OperationContext in Storage Client code - * Fix a bug in the STorage client in blob download resume for blobs greater than 2GB + * Fix a bug in the Storage client in blob download resume for blobs greater than 2GB 2012.10.29 Version 0.3.3 * In the blob client, fixed a bug which allows users to call write APIs on a blob snapshot reference From 19442730a5a73665c56084bd144e44d7eff32ab9 Mon Sep 17 00:00:00 2001 From: Guang Yang Date: Mon, 11 Mar 2013 11:44:41 -0700 Subject: [PATCH 35/43] update change log and readme.md based on PR review feedback --- ChangeLog.txt | 11 +++++++---- README.md | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index fb88dee6195b4..3c8bdcaea4f9f 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,6 +1,9 @@ 2013.03.12 Version 0.4.1 - * Added connection string support for Windows Azure Service Bus - * Fixed Windows Azure Storage Table encoding issue for special characters + * Added "Azure-SDK-For-Java/" To User-Agent HTTP header + * Added connection string support for Service Bus + * Added new methods to break lease for Storage Blob which doesn't require a lease id and returns the result as an object. Deprecated the old breakLease() methods. + * Added a new method to get the historical events for Media Services + * Fixed Storage Table encoding issue for special characters * BlobOutputStream now commits block list using LATEST instead of UNCOMMITTED * Added RequestResult to StorageEvents * Fixed race condition when accessing OperationContext RequestResults @@ -12,8 +15,8 @@ 2013.01.18 Version 0.4.0 * Added support for Windows Azure Media Services * Updated dependencies to non-beta stable versions - * Add a Sending Request Event to OperationContext in Storage Client code - * Fix a bug in the Storage client in blob download resume for blobs greater than 2GB + * Added a Sending Request Event to OperationContext in Storage Client code + * Fixed a bug in the Storage client in blob download resume for blobs greater than 2GB 2012.10.29 Version 0.3.3 * In the blob client, fixed a bug which allows users to call write APIs on a blob snapshot reference diff --git a/README.md b/README.md index ff2c5d7242be9..22ab0a06a9ece 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ within your project you can also have them installed by the Java package manager com.microsoft.windowsazure microsoft-windowsazure-api - 0.4.0 + 0.4.1 ##Minimum Requirements From dd74ec319bcec461543ae6824b12e219bc9df90d Mon Sep 17 00:00:00 2001 From: Guang Yang Date: Mon, 11 Mar 2013 13:00:44 -0700 Subject: [PATCH 36/43] fixing policheck issues --- ChangeLog.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 3c8bdcaea4f9f..060ccb7d7bafc 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -6,7 +6,7 @@ * Fixed Storage Table encoding issue for special characters * BlobOutputStream now commits block list using LATEST instead of UNCOMMITTED * Added RequestResult to StorageEvents - * Fixed race condition when accessing OperationContext RequestResults + * Fixed racing condition when accessing OperationContext RequestResults * Fixed the return value of BlobInputStream.read * Fixed CloudPageBlob.downloadPageRanges to retrieve the blob length * Fixed MD5 validation in BlobInputStream From f0d6ca3b061d955deaf670190cb83627d3205ba7 Mon Sep 17 00:00:00 2001 From: Guang Yang Date: Mon, 11 Mar 2013 13:03:17 -0700 Subject: [PATCH 37/43] fixing policheck issues --- ChangeLog.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 060ccb7d7bafc..2c15b781280a6 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -6,7 +6,7 @@ * Fixed Storage Table encoding issue for special characters * BlobOutputStream now commits block list using LATEST instead of UNCOMMITTED * Added RequestResult to StorageEvents - * Fixed racing condition when accessing OperationContext RequestResults + * Fixed issue when accessing OperationContext RequestResults * Fixed the return value of BlobInputStream.read * Fixed CloudPageBlob.downloadPageRanges to retrieve the blob length * Fixed MD5 validation in BlobInputStream From be09f31fe097b71b274186fcd879eed0dab113cf Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 11 Mar 2013 16:52:32 -0700 Subject: [PATCH 38/43] throw exception when you create or update null message. --- .../ChunkedGoalStateDeserializer.java | 16 +++--- .../XmlGoalStateDeserializer.java | 16 +++--- .../queue/implementation/QueueRestProxy.java | 14 ++++-- .../queue/QueueServiceIntegrationTest.java | 49 ++++++++++++++++--- 4 files changed, 67 insertions(+), 28 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ChunkedGoalStateDeserializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ChunkedGoalStateDeserializer.java index 38ed6c4a4812c..9d592a94327db 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ChunkedGoalStateDeserializer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ChunkedGoalStateDeserializer.java @@ -2,15 +2,15 @@ * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License 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. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License 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.microsoft.windowsazure.serviceruntime; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializer.java index 700e9e33d1863..688e5dfc6ef5f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializer.java @@ -2,15 +2,15 @@ * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License 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. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License 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.microsoft.windowsazure.serviceruntime; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java index 5f3c663c37db3..454f51e44c9d7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java @@ -87,7 +87,8 @@ public QueueRestProxy(HttpURLConnectionClient channel, ServiceFilter[] filters, public QueueContract withFilter(ServiceFilter filter) { ServiceFilter[] newFilters = Arrays.copyOf(filters, filters.length + 1); newFilters[filters.length] = filter; - return new QueueRestProxy(this.channel, newFilters, this.accountName, this.url, this.sharedKeyFilter, this.dateMapper); + return new QueueRestProxy(this.channel, newFilters, this.accountName, this.url, this.sharedKeyFilter, + this.dateMapper); } private void ThrowIfError(ClientResponse r) { @@ -261,7 +262,10 @@ public void createMessage(String queue, String messageText) throws ServiceExcept @Override public void createMessage(String queue, String messageText, CreateMessageOptions options) throws ServiceException { if (queue == null) - throw new NullPointerException(); + throw new NullPointerException("queue"); + if (messageText == null) { + throw new NullPointerException("messageText"); + } WebResource webResource = getResource(options).path(queue).path("messages"); webResource = addOptionalQueryParam(webResource, "visibilitytimeout", options.getVisibilityTimeoutInSeconds()); @@ -286,9 +290,11 @@ public UpdateMessageResult updateMessage(String queue, String messageId, String public UpdateMessageResult updateMessage(String queue, String messageId, String popReceipt, String messageText, int visibilityTimeoutInSeconds, QueueServiceOptions options) throws ServiceException { if (queue == null) - throw new NullPointerException(); + throw new NullPointerException("queue"); if (messageId == null) - throw new NullPointerException(); + throw new NullPointerException("messageId"); + if (messageText == null) + throw new NullPointerException("messageText"); WebResource webResource = getResource(options).path(queue).path("messages").path(messageId); webResource = addOptionalQueryParam(webResource, "popreceipt", popReceipt); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java index 0380a7be8942e..ecfeb03a02596 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java @@ -2,15 +2,15 @@ * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License 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. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License 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.microsoft.windowsazure.services.queue; @@ -25,7 +25,9 @@ import org.junit.AfterClass; import org.junit.BeforeClass; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import com.microsoft.windowsazure.services.core.Configuration; import com.microsoft.windowsazure.services.queue.models.CreateQueueOptions; @@ -58,6 +60,9 @@ public class QueueServiceIntegrationTest extends IntegrationTestBase { private static String[] creatableQueues; private static String[] testQueues; + @Rule + public ExpectedException expectedException = ExpectedException.none(); + @BeforeClass public static void setup() throws Exception { // Setup container names array (list of container names used by @@ -315,6 +320,17 @@ public void createMessageWorks() throws Exception { // Assert } + @Test + public void createNullMessageException() throws Exception { + // Arrange + Configuration config = createConfiguration(); + QueueContract service = QueueService.create(config); + + // Act + expectedException.expect(NullPointerException.class); + service.createMessage(TEST_QUEUE_FOR_MESSAGES, null); + } + @Test public void listMessagesWorks() throws Exception { // Arrange @@ -508,6 +524,23 @@ public void deleteMessageWorks() throws Exception { assertEquals(3, result2.getQueueMessages().size()); } + @Test + public void updateNullMessageException() throws Exception { + // Arrange + Configuration config = createConfiguration(); + QueueContract service = QueueService.create(config); + String messageId = "messageId"; + + String popReceipt = "popReceipt"; + String messageText = null; + int visibilityTimeoutInSeconds = 10; + + // Act + expectedException.expect(NullPointerException.class); + service.updateMessage(TEST_QUEUE_FOR_MESSAGES_8, messageId, popReceipt, messageText, visibilityTimeoutInSeconds); + + } + @Test public void updateMessageWorks() throws Exception { // Arrange From c8561a20350b5fcb6587714cb212f4c62f92d0a1 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 21 Mar 2013 17:21:12 -0700 Subject: [PATCH 39/43] fix the global date parsing issue. --- .../BrokerPropertiesMapper.java | 5 + .../BrokerPropertiesMapperTest.java | 118 +++++++++++++----- 2 files changed, 89 insertions(+), 34 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java index eefbae6266845..3dfa6ea80c5f4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java @@ -17,6 +17,8 @@ import java.io.IOException; import java.io.StringWriter; import java.io.Writer; +import java.text.SimpleDateFormat; +import java.util.Locale; import org.codehaus.jackson.JsonGenerationException; import org.codehaus.jackson.JsonParseException; @@ -26,7 +28,10 @@ public class BrokerPropertiesMapper { public BrokerProperties fromString(String value) throws IllegalArgumentException { + ObjectMapper mapper = new ObjectMapper(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US); + mapper.setDateFormat(simpleDateFormat); try { return mapper.readValue(value.getBytes("UTF-8"), BrokerProperties.class); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/BrokerPropertiesMapperTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/BrokerPropertiesMapperTest.java index cef5f5f3b42b4..ce827d0430ec5 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/BrokerPropertiesMapperTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/BrokerPropertiesMapperTest.java @@ -2,15 +2,15 @@ * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License 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. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License 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.microsoft.windowsazure.services.serviceBus; @@ -18,14 +18,40 @@ import java.util.Calendar; import java.util.Date; +import java.util.Locale; import java.util.TimeZone; +import org.junit.BeforeClass; import org.junit.Test; import com.microsoft.windowsazure.services.serviceBus.implementation.BrokerProperties; import com.microsoft.windowsazure.services.serviceBus.implementation.BrokerPropertiesMapper; public class BrokerPropertiesMapperTest { + + private final String testBrokerPropertiesString = "{" + "\"CorrelationId\": \"corid\"," + + "\"SessionId\": \"sesid\"," + "\"DeliveryCount\": 5," + + "\"LockedUntilUtc\": \" Fri, 14 Oct 2011 12:34:56 GMT\"," + "\"LockToken\": \"loctok\"," + + "\"MessageId\": \"mesid\"," + "\"Label\": \"lab\"," + "\"ReplyTo\": \"repto\"," + + "\"SequenceNumber\": 7," + "\"TimeToLive\": 8.123," + "\"To\": \"to\"," + + "\"ScheduledEnqueueTimeUtc\": \" Sun, 06 Nov 1994 08:49:37 GMT\"," + + "\"ReplyToSessionId\": \"reptosesid\"," + "\"MessageLocation\": \"mesloc\"," + + "\"LockLocation\": \"locloc\"" + "}"; + + private static Date schedTimeUtc, lockedUntilUtc; + + @BeforeClass + public static void setup() { + Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT")); + calendar.set(1994, 10, 6, 8, 49, 37); + schedTimeUtc = calendar.getTime(); + + Calendar calendar2 = Calendar.getInstance(TimeZone.getTimeZone("GMT")); + calendar2.set(2011, 9, 14, 12, 34, 56); + lockedUntilUtc = calendar2.getTime(); + + } + @Test public void jsonStringMapsToBrokerPropertiesObject() { // Arrange @@ -61,33 +87,8 @@ public void deserializingAllPossibleValues() { // Arrange BrokerPropertiesMapper mapper = new BrokerPropertiesMapper(); - Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT")); - calendar.set(1994, 10, 6, 8, 49, 37); - Date schedTimeUtc = calendar.getTime(); - - Calendar calendar2 = Calendar.getInstance(TimeZone.getTimeZone("GMT")); - calendar2.set(2011, 9, 14, 12, 34, 56); - Date lockedUntilUtc = calendar2.getTime(); - // Act - BrokerProperties properties = mapper.fromString( - "{" + - "\"CorrelationId\": \"corid\"," + - "\"SessionId\": \"sesid\"," + - "\"DeliveryCount\": 5," + - "\"LockedUntilUtc\": \" Fri, 14 Oct 2011 12:34:56 GMT\"," + - "\"LockToken\": \"loctok\"," + - "\"MessageId\": \"mesid\"," + - "\"Label\": \"lab\"," + - "\"ReplyTo\": \"repto\"," + - "\"SequenceNumber\": 7," + - "\"TimeToLive\": 8.123," + - "\"To\": \"to\"," + - "\"ScheduledEnqueueTimeUtc\": \" Sun, 06 Nov 1994 08:49:37 GMT\"," + - "\"ReplyToSessionId\": \"reptosesid\"," + - "\"MessageLocation\": \"mesloc\"," + - "\"LockLocation\": \"locloc\"" + - "}"); + BrokerProperties properties = mapper.fromString(testBrokerPropertiesString); // Assert assertNotNull(properties); @@ -124,4 +125,53 @@ public void missingDatesDeserializeAsNull() { assertNull(properties.getLockedUntilUtc()); assertNull(properties.getScheduledEnqueueTimeUtc()); } + + @Test + public void deserializeDateInKrKrLocaleCorrectly() { + // Arrange + BrokerPropertiesMapper mapper = new BrokerPropertiesMapper(); + Locale defaultLocale = Locale.getDefault(); + Locale.setDefault(Locale.KOREA); + + // Act + BrokerProperties brokerProperties = mapper.fromString(testBrokerPropertiesString); + Locale.setDefault(defaultLocale); + + // Assert + long lockedUntilDelta = brokerProperties.getLockedUntilUtc().getTime() - lockedUntilUtc.getTime(); + assertTrue(Math.abs(lockedUntilDelta) < 2000); + } + + @Test + public void deserializeDateInEnUsLocaleCorrectly() { + // Arrange + BrokerPropertiesMapper mapper = new BrokerPropertiesMapper(); + Locale defaultLocale = Locale.getDefault(); + Locale.setDefault(Locale.US); + + // Act + BrokerProperties brokerProperties = mapper.fromString(testBrokerPropertiesString); + Locale.setDefault(defaultLocale); + + // Assert + long lockedUntilDelta = brokerProperties.getLockedUntilUtc().getTime() - lockedUntilUtc.getTime(); + assertTrue(Math.abs(lockedUntilDelta) < 2000); + + } + + @Test + public void deserializeDateInZhCnLocaleCorrectly() { + // Arrange + BrokerPropertiesMapper mapper = new BrokerPropertiesMapper(); + Locale defaultLocale = Locale.getDefault(); + Locale.setDefault(Locale.CHINA); + + // Act + BrokerProperties brokerProperties = mapper.fromString(testBrokerPropertiesString); + Locale.setDefault(defaultLocale); + + // Assert + long lockedUntilDelta = brokerProperties.getLockedUntilUtc().getTime() - lockedUntilUtc.getTime(); + assertTrue(Math.abs(lockedUntilDelta) < 2000); + } } From cce6e7c661cb721e4944eaf99d76204945267f54 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 21 Mar 2013 18:12:32 -0700 Subject: [PATCH 40/43] fix the javadoc documentation issue. --- microsoft-azure-api/pom.xml | 2 +- .../com/microsoft/windowsazure/services/core/package.html | 5 +++++ .../windowsazure/services/core/storage/package.html | 5 +++++ .../services/media/entityoperations/package.html | 5 +++++ .../windowsazure/services/media/models/package.html | 5 +++++ .../com/microsoft/windowsazure/services/media/package.html | 5 +++++ 6 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/package.html create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/package.html create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/package.html create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/package.html create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/package.html diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index 1900ba335e498..a931921be3c42 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -169,7 +169,7 @@ maven-javadoc-plugin 2.8 - *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization + *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.storage /**
* Copyright Microsoft Corporation
* diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/package.html b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/package.html new file mode 100644 index 0000000000000..513ca5833c7a6 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/package.html @@ -0,0 +1,5 @@ + + +This package contains the core classes across difference services. + + diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/package.html b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/package.html new file mode 100644 index 0000000000000..b1450b0ca78a2 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/package.html @@ -0,0 +1,5 @@ + + +This package contains the blob service core class and interface, + + diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/package.html b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/package.html new file mode 100644 index 0000000000000..e7819f1479631 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/package.html @@ -0,0 +1,5 @@ + + +This package contains the media service OData operation class, interface, and utility classes. + + diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/package.html b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/package.html new file mode 100644 index 0000000000000..719e4d9b595c2 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/package.html @@ -0,0 +1,5 @@ + + +This package contains the media service data transfer object classes. + + diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/package.html b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/package.html new file mode 100644 index 0000000000000..324cb3246c05c --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/package.html @@ -0,0 +1,5 @@ + + +This package contains the media services, interface, and associated configuration and utility classes. + + From dcc2a0729bd5dccc3ab8891a433ddf1134219f39 Mon Sep 17 00:00:00 2001 From: "Jason Cooke [Microsoft]" Date: Mon, 25 Mar 2013 11:18:09 -0700 Subject: [PATCH 41/43] Updating version number to 0.4.2 --- README.md | 2 +- microsoft-azure-api/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 22ab0a06a9ece..a8805eb2e3262 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ within your project you can also have them installed by the Java package manager com.microsoft.windowsazure microsoft-windowsazure-api - 0.4.1 + 0.4.2 ##Minimum Requirements diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index a931921be3c42..8306962d4382d 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -17,7 +17,7 @@ 4.0.0 com.microsoft.windowsazure microsoft-windowsazure-api - 0.4.1 + 0.4.2 jar Microsoft Windows Azure Client API From 3e767805dbfa303c84495837ca580f61a63afb8f Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 25 Mar 2013 15:36:06 -0700 Subject: [PATCH 42/43] fix the failure of a few global unit tests. --- .../CustomPropertiesMapper.java | 25 ++++++++++--------- .../CustomPropertiesMapperTest.java | 16 ++++++------ 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapper.java index a12fbb4ee8199..89e6fec612bcd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapper.java @@ -2,15 +2,15 @@ * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License 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. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License 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.microsoft.windowsazure.services.serviceBus.implementation; @@ -19,6 +19,7 @@ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; +import java.util.Locale; import java.util.TimeZone; public class CustomPropertiesMapper { @@ -53,14 +54,14 @@ else if (type == Boolean.class) { return value.toString(); } else if (Calendar.class.isAssignableFrom(type)) { - DateFormat format = new SimpleDateFormat(RFC_1123); + DateFormat format = new SimpleDateFormat(RFC_1123, Locale.US); Calendar calendar = (Calendar) value; format.setTimeZone(calendar.getTimeZone()); String formatted = format.format(calendar.getTime()); return "\"" + formatted + "\""; } else if (Date.class.isAssignableFrom(type)) { - DateFormat format = new SimpleDateFormat(RFC_1123); + DateFormat format = new SimpleDateFormat(RFC_1123, Locale.US); format.setTimeZone(TimeZone.getTimeZone("GMT")); String formatted = format.format((Date) value); return "\"" + formatted + "\""; @@ -78,7 +79,7 @@ public Object fromString(String value) throws ParseException { if (value.startsWith("\"") && value.endsWith("\"")) { String text = value.substring(1, value.length() - 1); if (isRFC1123(text)) { - SimpleDateFormat format = new SimpleDateFormat(RFC_1123); + SimpleDateFormat format = new SimpleDateFormat(RFC_1123, Locale.US); return format.parse(text); } @@ -103,7 +104,7 @@ private boolean isRFC1123(String text) { return false; } try { - SimpleDateFormat format = new SimpleDateFormat(RFC_1123); + SimpleDateFormat format = new SimpleDateFormat(RFC_1123, Locale.US); format.parse(text); return true; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapperTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapperTest.java index 2ab3572c34db7..323912b282773 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapperTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapperTest.java @@ -2,15 +2,15 @@ * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License 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. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License 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.microsoft.windowsazure.services.serviceBus.implementation; From 9998b88d07dbeb361de8f0d165f65157c22ee311 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 27 Mar 2013 11:56:46 -0700 Subject: [PATCH 43/43] fix unit test failures due to media service upgrade. --- .../services/media/MediaProcessorIntegrationTest.java | 2 +- .../windowsazure/services/scenarios/MediaServiceWrapper.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java index 176220765c00b..824c34d2dc935 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java @@ -73,6 +73,6 @@ public void listMediaProcessorWithOptionSuccess() throws ServiceException { assertEquals("listMediaProcessors size", 1, listMediaProcessorsResult.size()); MediaProcessorInfo mediaProcessorInfo = listMediaProcessorsResult.get(0); verifyMediaProcessorInfo("mediaProcessorInfo", "nb:mpid:UUID:aec03716-7c5e-4f68-b592-f4850eba9f10", - "Storage Decryption", "Storage Decryption", "", "Microsoft", "1.5.3.0", mediaProcessorInfo); + "Storage Decryption", "Storage Decryption", "", "Microsoft", "1.6", mediaProcessorInfo); } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java index 19933421282f0..c71781c96fe61 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java @@ -278,7 +278,7 @@ public Task.CreateBatchOperation createTaskOptions(String taskName, int inputAss configuration = "VC1 Broadband SD 4x3"; break; case StorageDecryption: - processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_STORAGE_DECRYPTION, "1.5.3.0"); + processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_STORAGE_DECRYPTION, "1.6"); configuration = null; break; default: