diff --git a/azure-mgmt-datalake-store-uploader/pom.xml b/azure-mgmt-datalake-store-uploader/pom.xml
index 760f886f2bd5..c7a213f8646c 100644
--- a/azure-mgmt-datalake-store-uploader/pom.xml
+++ b/azure-mgmt-datalake-store-uploader/pom.xml
@@ -66,11 +66,6 @@
junit
test
-
- org.mockito
- mockito-core
- test
-
com.microsoft.azure
azure-client-authentication
diff --git a/azure-mgmt-datalake-store-uploader/src/main/java/com/microsoft/azure/management/datalake/store/uploader/DataLakeStoreFrontEndAdapterImpl.java b/azure-mgmt-datalake-store-uploader/src/main/java/com/microsoft/azure/management/datalake/store/uploader/DataLakeStoreFrontEndAdapterImpl.java
index 7815df47c82a..a9e2a5eafc7e 100644
--- a/azure-mgmt-datalake-store-uploader/src/main/java/com/microsoft/azure/management/datalake/store/uploader/DataLakeStoreFrontEndAdapterImpl.java
+++ b/azure-mgmt-datalake-store-uploader/src/main/java/com/microsoft/azure/management/datalake/store/uploader/DataLakeStoreFrontEndAdapterImpl.java
@@ -91,7 +91,7 @@ public void AppendToStream(String streamPath, byte[] data, long offset, int byte
* @throws IOException
* @throws CloudException
*/
- public boolean StreamExists(String streamPath) throws IOException, CloudException {
+ public boolean StreamExists(String streamPath) throws CloudException, IOException {
try {
_client.getFileSystemOperations().getFileStatus(streamPath, _accountName);
} catch (CloudException cloudEx) {
diff --git a/azure-mgmt-datalake-store-uploader/src/main/java/com/microsoft/azure/management/datalake/store/uploader/FrontEndAdapter.java b/azure-mgmt-datalake-store-uploader/src/main/java/com/microsoft/azure/management/datalake/store/uploader/FrontEndAdapter.java
index 9e3b39fabcdf..c0b669a1a291 100644
--- a/azure-mgmt-datalake-store-uploader/src/main/java/com/microsoft/azure/management/datalake/store/uploader/FrontEndAdapter.java
+++ b/azure-mgmt-datalake-store-uploader/src/main/java/com/microsoft/azure/management/datalake/store/uploader/FrontEndAdapter.java
@@ -5,22 +5,32 @@
*/
package com.microsoft.azure.management.datalake.store.uploader;
+import com.microsoft.azure.CloudException;
+
+import java.io.IOException;
+
public interface FrontEndAdapter {
/**
* Creates a new, empty stream at the given path.
*
* @param streamPath The relative path to the stream.
* @param overwrite Whether to overwrite an existing stream.
+ * @param data The data to include in the stream during creation.
+ * @param byteCount The number of bytes from data to include (starting at 0).
+ * @throws IOException
+ * @throws CloudException
*/
- void CreateStream(String streamPath, boolean overwrite, byte[] data, int byteCount) throws Exception;
+ void CreateStream(String streamPath, boolean overwrite, byte[] data, int byteCount) throws CloudException, IOException;
/**
* Deletes an existing stream at the given path.
*
* @param streamPath The relative path to the stream.
* @param recurse if set to true recursively delete. This is used for folder streams only.
+ * @throws IOException
+ * @throws CloudException
*/
- void DeleteStream(String streamPath, boolean recurse) throws Exception;
+ void DeleteStream(String streamPath, boolean recurse) throws IOException, CloudException;
/**
* Appends the given byte array to the end of a given stream.
@@ -29,25 +39,30 @@ public interface FrontEndAdapter {
* @param data An array of bytes to be appended to the stream.
* @param offset The offset at which to append to the stream.
* @param length The number of bytes to append (starting at 0).
+ * @throws IOException
+ * @throws CloudException
*/
- void AppendToStream(String streamPath, byte[] data, long offset, int length) throws Exception;
+ void AppendToStream(String streamPath, byte[] data, long offset, int length) throws IOException, CloudException;
/**
* Determines if the stream with given path exists.
*
* @param streamPath The relative path to the stream.
* @return True if the stream exists, false otherwise.
+ * @throws IOException
+ * @throws CloudException
*/
- boolean StreamExists(String streamPath) throws Exception;
+ boolean StreamExists(String streamPath) throws CloudException, IOException;
/**
* Gets a value indicating the length of a stream, in bytes.
*
* @param streamPath The relative path to the stream.
* @return The length of the stream, in bytes.
- * @throws Exception
+ * @throws IOException
+ * @throws CloudException
*/
- long GetStreamLength(String streamPath) throws Exception;
+ long GetStreamLength(String streamPath) throws IOException, CloudException;
/**
* Concatenates the given input streams (in order) into the given target stream.
@@ -55,7 +70,8 @@ public interface FrontEndAdapter {
*
* @param targetStreamPath The relative path to the target stream.
* @param inputStreamPaths An ordered array of paths to the input streams.
- * @throws Exception
+ * @throws IOException
+ * @throws CloudException
*/
- void Concatenate(String targetStreamPath, String[] inputStreamPaths) throws Exception;
+ void Concatenate(String targetStreamPath, String[] inputStreamPaths) throws IOException, CloudException;
}
diff --git a/azure-mgmt-datalake-store-uploader/src/main/java/com/microsoft/azure/management/datalake/store/uploader/UploadParameters.java b/azure-mgmt-datalake-store-uploader/src/main/java/com/microsoft/azure/management/datalake/store/uploader/UploadParameters.java
index 6b27cf84654d..ff2930c135ed 100644
--- a/azure-mgmt-datalake-store-uploader/src/main/java/com/microsoft/azure/management/datalake/store/uploader/UploadParameters.java
+++ b/azure-mgmt-datalake-store-uploader/src/main/java/com/microsoft/azure/management/datalake/store/uploader/UploadParameters.java
@@ -110,7 +110,7 @@ public UploadParameters(String inputFilePath, String targetStreamPath, String ac
* @param inputFilePath The full path to the file to be uploaded.
* @param targetStreamPath The full stream path where the file will be uploaded to.
* @param accountName Name of the account to upload to.
- * @param useSegmentBlockBackOffRetryStrategy if set to true [use segment block back off retry strategy].
+ * @param useSegmentBlockBackOffRetryStrategy if set to true [use segment block back off retry strategy].
* @param threadCount The maximum number of parallel threads to use for the upload.
* @param isOverwrite Whether to overwrite the target stream or not.
* @param isResume Indicates whether to resume a previously interrupted upload.
@@ -126,7 +126,7 @@ protected UploadParameters(String inputFilePath, String targetStreamPath, String
/**
* Gets a value indicating whether [to use segment block back off retry strategy].
*
- * @return true if [to use segment block back off retry strategy]; otherwise, false.
+ * @return true if [to use segment block back off retry strategy]; otherwise, false.
*/
public boolean isUseSegmentBlockBackOffRetryStrategy() {
return useSegmentBlockBackOffRetryStrategy;
@@ -207,7 +207,7 @@ public int getThreadCount() {
/**
* Internally sets the number of threads that are allowed for the upload.
*
- * @param threadCount
+ * @param threadCount The number of threads to use for the upload.
*/
protected void setThreadCount(int threadCount) {
this.threadCount = threadCount;
@@ -216,7 +216,7 @@ protected void setThreadCount(int threadCount) {
/**
* Gets a value indicating whether to overwrite the target stream if it already exists.
*
- * @return true if this instance is overwrite; otherwise, false.
+ * @return true if this instance is overwrite; otherwise, false.
*/
public boolean isOverwrite() {
return overwrite;
@@ -234,7 +234,7 @@ private void setOverwrite(boolean overwrite) {
/**
* Gets a value indicating whether to resume a previously interrupted upload.
*
- * @return true if this instance is resume; otherwise, false.
+ * @return true if this instance is resume; otherwise, false.
*/
public boolean isResume() {
return resume;
@@ -252,7 +252,7 @@ private void setResume(boolean resume) {
/**
* Gets a value indicating whether the input file should be treated as a binary (true) or a delimited input (false).
*
- * @return true if this instance is binary; otherwise, false.
+ * @return true if this instance is binary; otherwise, false.
*/
public boolean isBinary() {
return binary;
diff --git a/azure-mgmt-datalake-store-uploader/src/test/java/com/microsoft/azure/management/datalake/store/uploader/InMemoryFrontEnd.java b/azure-mgmt-datalake-store-uploader/src/test/java/com/microsoft/azure/management/datalake/store/uploader/InMemoryFrontEnd.java
index b144de9b83e2..c191e1002cd6 100644
--- a/azure-mgmt-datalake-store-uploader/src/test/java/com/microsoft/azure/management/datalake/store/uploader/InMemoryFrontEnd.java
+++ b/azure-mgmt-datalake-store-uploader/src/test/java/com/microsoft/azure/management/datalake/store/uploader/InMemoryFrontEnd.java
@@ -5,6 +5,8 @@
*/
package com.microsoft.azure.management.datalake.store.uploader;
+import com.microsoft.azure.CloudException;
+
import java.util.Hashtable;
import java.util.LinkedList;
@@ -20,9 +22,9 @@ public class InMemoryFrontEnd implements FrontEndAdapter {
* @param overwrite Whether to overwrite an existing stream.
* @param data
* @param byteCount
- * @throws Exception
+ * @Throws CloudException
*/
- public void CreateStream(String streamPath, boolean overwrite, byte[] data, int byteCount) throws Exception {
+ public void CreateStream(String streamPath, boolean overwrite, byte[] data, int byteCount) throws CloudException {
if (overwrite)
{
_streams.put(streamPath, new StreamData(streamPath));
@@ -31,7 +33,7 @@ public void CreateStream(String streamPath, boolean overwrite, byte[] data, int
{
if (StreamExists(streamPath))
{
- throw new Exception("stream exists");
+ throw new CloudException("stream exists");
}
_streams.put(streamPath, new StreamData(streamPath));
@@ -42,7 +44,7 @@ public void CreateStream(String streamPath, boolean overwrite, byte[] data, int
{
if (byteCount > data.length)
{
- throw new Exception("invalid byteCount");
+ throw new CloudException("invalid byteCount");
}
StreamData stream = _streams.get(streamPath);
@@ -59,12 +61,12 @@ public void CreateStream(String streamPath, boolean overwrite, byte[] data, int
*
* @param streamPath The relative path to the stream.
* @param recurse if set to true recursively delete. This is used for folder streams only.
- * @throws Exception
+ * @Throws CloudException
*/
- public void DeleteStream(String streamPath, boolean recurse) throws Exception {
+ public void DeleteStream(String streamPath, boolean recurse) throws CloudException {
if (!StreamExists(streamPath))
{
- throw new Exception("stream does not exist");
+ throw new CloudException("stream does not exist");
}
_streams.remove(streamPath);
}
@@ -75,23 +77,23 @@ public void DeleteStream(String streamPath, boolean recurse) throws Exception {
* @param data An array of bytes to be appended to the stream.
* @param offset The offset at which to append to the stream.
* @param byteCount
- * @throws Exception
+ * @Throws CloudException
*/
- public void AppendToStream(String streamPath, byte[] data, long offset, int byteCount) throws Exception {
+ public void AppendToStream(String streamPath, byte[] data, long offset, int byteCount) throws CloudException {
if (!StreamExists(streamPath))
{
- throw new Exception("stream does not exist");
+ throw new CloudException("stream does not exist");
}
if (byteCount > data.length)
{
- throw new Exception("invalid byteCount");
+ throw new CloudException("invalid byteCount");
}
StreamData stream = _streams.get(streamPath);
if (stream.Length != offset)
{
- throw new Exception("offset != stream.length");
+ throw new CloudException("offset != stream.length");
}
//always make a copy of the original buffer since it is reused
@@ -104,7 +106,7 @@ public void AppendToStream(String streamPath, byte[] data, long offset, int byte
/**
*
* @param streamPath The relative path to the stream.
- * @return
+ * @return True or false if the stream exists
*/
public boolean StreamExists(String streamPath)
{
@@ -115,12 +117,12 @@ public boolean StreamExists(String streamPath)
*
* @param streamPath The relative path to the stream.
* @return
- * @throws Exception
+ * @Throws CloudException
*/
- public long GetStreamLength(String streamPath) throws Exception {
+ public long GetStreamLength(String streamPath) throws CloudException {
if (!StreamExists(streamPath))
{
- throw new Exception("stream does not exist");
+ throw new CloudException("stream does not exist");
}
return _streams.get(streamPath).Length;
@@ -130,12 +132,12 @@ public long GetStreamLength(String streamPath) throws Exception {
*
* @param targetStreamPath The relative path to the target stream.
* @param inputStreamPaths An ordered array of paths to the input streams.
- * @throws Exception
+ * @Throws CloudException
*/
- public void Concatenate(String targetStreamPath, String[] inputStreamPaths) throws Exception {
+ public void Concatenate(String targetStreamPath, String[] inputStreamPaths) throws CloudException {
if (StreamExists(targetStreamPath))
{
- throw new Exception("target stream exists");
+ throw new CloudException("target stream exists");
}
final int bufferSize = 4 * 1024 * 1024;
@@ -150,7 +152,7 @@ public void Concatenate(String targetStreamPath, String[] inputStreamPaths) thro
{
if (!StreamExists(inputStreamPath))
{
- throw new Exception("input stream does not exist");
+ throw new CloudException("input stream does not exist");
}
StreamData stream = _streams.get(inputStreamPath);
@@ -160,7 +162,7 @@ public void Concatenate(String targetStreamPath, String[] inputStreamPaths) thro
}
}
}
- catch (Exception e)
+ catch (CloudException e)
{
if (StreamExists(targetStreamPath))
{
@@ -179,12 +181,12 @@ public void Concatenate(String targetStreamPath, String[] inputStreamPaths) thro
*
* @param streamPath
* @return
- * @throws Exception
+ * @Throws CloudException
*/
- public Iterable GetAppendBlocks(String streamPath) throws Exception {
+ public Iterable GetAppendBlocks(String streamPath) throws CloudException {
if (!StreamExists(streamPath))
{
- throw new Exception("stream does not exist");
+ throw new CloudException("stream does not exist");
}
StreamData sd = _streams.get(streamPath);
@@ -195,12 +197,12 @@ public Iterable GetAppendBlocks(String streamPath) throws Exception {
*
* @param streamPath
* @return
- * @throws Exception
+ * @Throws CloudException
*/
- public byte[] GetStreamContents(String streamPath) throws Exception {
+ public byte[] GetStreamContents(String streamPath) throws CloudException {
if (!StreamExists(streamPath))
{
- throw new Exception("stream does not exist");
+ throw new CloudException("stream does not exist");
}
StreamData sd = _streams.get(streamPath);
diff --git a/azure-mgmt-datalake-store-uploader/src/test/java/com/microsoft/azure/management/datalake/store/uploader/IntentionalException.java b/azure-mgmt-datalake-store-uploader/src/test/java/com/microsoft/azure/management/datalake/store/uploader/IntentionalException.java
index bd8d1a4539cb..f7b52cd4fd50 100644
--- a/azure-mgmt-datalake-store-uploader/src/test/java/com/microsoft/azure/management/datalake/store/uploader/IntentionalException.java
+++ b/azure-mgmt-datalake-store-uploader/src/test/java/com/microsoft/azure/management/datalake/store/uploader/IntentionalException.java
@@ -5,7 +5,9 @@
*/
package com.microsoft.azure.management.datalake.store.uploader;
+import com.microsoft.azure.CloudException;
+
/**
* An exception that we want our mocks to throw sometimes to test out various code paths.
*/
-public class IntentionalException extends Exception { }
\ No newline at end of file
+public class IntentionalException extends CloudException { }
\ No newline at end of file
diff --git a/azure-mgmt-datalake-store-uploader/src/test/java/com/microsoft/azure/management/datalake/store/uploader/MsuMockFrontEnd.java b/azure-mgmt-datalake-store-uploader/src/test/java/com/microsoft/azure/management/datalake/store/uploader/MsuMockFrontEnd.java
index 65eb586129bc..5954bfbffdc7 100644
--- a/azure-mgmt-datalake-store-uploader/src/test/java/com/microsoft/azure/management/datalake/store/uploader/MsuMockFrontEnd.java
+++ b/azure-mgmt-datalake-store-uploader/src/test/java/com/microsoft/azure/management/datalake/store/uploader/MsuMockFrontEnd.java
@@ -5,8 +5,11 @@
*/
package com.microsoft.azure.management.datalake.store.uploader;
+import com.microsoft.azure.CloudException;
import org.junit.Assert;
+import java.io.IOException;
+
/**
* A mocked front end for testing out the code paths of the {@link MultipleSegmentUploader}
*/
@@ -31,7 +34,7 @@ public MsuMockFrontEnd(FrontEndAdapter baseAdapter, boolean testRetry, int failC
CallCount = 0;
}
- public void CreateStream(String streamPath, boolean overwrite, byte[] data, int byteCount) throws Exception {
+ public void CreateStream(String streamPath, boolean overwrite, byte[] data, int byteCount) throws CloudException, IOException {
if (TestRetry) {
CallCount++;
if (CallCount <= FailCount)
@@ -43,11 +46,11 @@ public void CreateStream(String streamPath, boolean overwrite, byte[] data, int
BaseAdapter.CreateStream(streamPath, overwrite, data, byteCount);
}
- public void DeleteStream(String streamPath, boolean recurse) throws Exception {
+ public void DeleteStream(String streamPath, boolean recurse) throws IOException, CloudException {
BaseAdapter.DeleteStream(streamPath, recurse);
}
- public void AppendToStream(String streamPath, byte[] data, long offset, int byteCount) throws Exception {
+ public void AppendToStream(String streamPath, byte[] data, long offset, int byteCount) throws IOException, CloudException {
if (TestRetry) {
CallCount++;
if (CallCount <= FailCount)
@@ -59,15 +62,15 @@ public void AppendToStream(String streamPath, byte[] data, long offset, int byte
BaseAdapter.AppendToStream(streamPath, data, offset, byteCount);
}
- public boolean StreamExists(String streamPath) throws Exception {
+ public boolean StreamExists(String streamPath) throws IOException, CloudException {
return BaseAdapter.StreamExists(streamPath);
}
- public long GetStreamLength(String streamPath) throws Exception {
+ public long GetStreamLength(String streamPath) throws IOException, CloudException {
return BaseAdapter.GetStreamLength(streamPath);
}
- public void Concatenate(String targetStreamPath, String[] inputStreamPaths) throws Exception {
+ public void Concatenate(String targetStreamPath, String[] inputStreamPaths) throws IOException, CloudException {
Assert.assertTrue("Concatenate should not be called when using 1 segment", false);
BaseAdapter.Concatenate(targetStreamPath, inputStreamPaths);
}
diff --git a/azure-mgmt-datalake-store-uploader/src/test/java/com/microsoft/azure/management/datalake/store/uploader/SsuMockFrontEnd.java b/azure-mgmt-datalake-store-uploader/src/test/java/com/microsoft/azure/management/datalake/store/uploader/SsuMockFrontEnd.java
index 2885f9aa4ad2..e011902ddf80 100644
--- a/azure-mgmt-datalake-store-uploader/src/test/java/com/microsoft/azure/management/datalake/store/uploader/SsuMockFrontEnd.java
+++ b/azure-mgmt-datalake-store-uploader/src/test/java/com/microsoft/azure/management/datalake/store/uploader/SsuMockFrontEnd.java
@@ -5,6 +5,10 @@
*/
package com.microsoft.azure.management.datalake.store.uploader;
+import com.microsoft.azure.CloudException;
+
+import java.io.IOException;
+
/**
* Represents a mocked front end for testing the {@link SingleSegmentUploader}
*/
@@ -36,7 +40,7 @@ public SsuMockFrontEnd(FrontEndAdapter baseAdapter, boolean doNothing, boolean t
FailCount = failCount;
}
- public void CreateStream(String streamPath, boolean overwrite, byte[] data, int byteCount) throws Exception {
+ public void CreateStream(String streamPath, boolean overwrite, byte[] data, int byteCount) throws CloudException, IOException {
if (!DoNothing && !TestRetry) {
BaseAdapter.CreateStream(streamPath, overwrite, data, byteCount);
}
@@ -50,13 +54,13 @@ else if(TestRetry) {
}
}
- public void DeleteStream(String streamPath, boolean recurse) throws Exception {
+ public void DeleteStream(String streamPath, boolean recurse) throws CloudException, IOException {
if (!DoNothing) {
BaseAdapter.DeleteStream(streamPath, recurse);
}
}
- public void AppendToStream(String streamPath, byte[] data, long offset, int byteCount) throws Exception {
+ public void AppendToStream(String streamPath, byte[] data, long offset, int byteCount) throws CloudException, IOException {
if (!DoNothing && !TestRetry) {
BaseAdapter.AppendToStream(streamPath, data, offset, byteCount);
}
@@ -70,7 +74,7 @@ else if(TestRetry) {
}
}
- public boolean StreamExists(String streamPath) throws Exception {
+ public boolean StreamExists(String streamPath) throws CloudException, IOException {
if (!DoNothing) {
return BaseAdapter.StreamExists(streamPath);
}
@@ -78,7 +82,7 @@ public boolean StreamExists(String streamPath) throws Exception {
return true;
}
- public long GetStreamLength(String streamPath) throws Exception {
+ public long GetStreamLength(String streamPath) throws CloudException, IOException {
if (!DoNothing) {
return BaseAdapter.GetStreamLength(streamPath);
}
@@ -86,7 +90,7 @@ public long GetStreamLength(String streamPath) throws Exception {
return 0;
}
- public void Concatenate(String targetStreamPath, String[] inputStreamPaths) throws Exception {
+ public void Concatenate(String targetStreamPath, String[] inputStreamPaths) throws CloudException, IOException {
if (!DoNothing) {
BaseAdapter.Concatenate(targetStreamPath, inputStreamPaths);
}
diff --git a/azure-mgmt-datalake-store-uploader/src/test/java/com/microsoft/azure/management/datalake/store/uploader/UploaderFrontEndMock.java b/azure-mgmt-datalake-store-uploader/src/test/java/com/microsoft/azure/management/datalake/store/uploader/UploaderFrontEndMock.java
index 823bfa873385..936d9352e7e3 100644
--- a/azure-mgmt-datalake-store-uploader/src/test/java/com/microsoft/azure/management/datalake/store/uploader/UploaderFrontEndMock.java
+++ b/azure-mgmt-datalake-store-uploader/src/test/java/com/microsoft/azure/management/datalake/store/uploader/UploaderFrontEndMock.java
@@ -5,8 +5,11 @@
*/
package com.microsoft.azure.management.datalake.store.uploader;
+import com.microsoft.azure.CloudException;
import org.junit.Assert;
+import java.io.IOException;
+
/**
* A front end mock used for unit testing {@link DataLakeStoreUploader}
*/
@@ -31,7 +34,7 @@ public UploaderFrontEndMock(FrontEndAdapter baseAdapter, boolean throwInConcat,
BaseAdapter = baseAdapter;
}
- public void CreateStream(String streamPath, boolean overwrite, byte[] data, int byteCount) throws Exception {
+ public void CreateStream(String streamPath, boolean overwrite, byte[] data, int byteCount) throws CloudException, IOException {
if(ThrowInCreate) {
createStreamCount++;
@@ -44,23 +47,23 @@ public void CreateStream(String streamPath, boolean overwrite, byte[] data, int
BaseAdapter.CreateStream(streamPath, overwrite, data, byteCount);
}
- public void DeleteStream(String streamPath, boolean recurse) throws Exception {
+ public void DeleteStream(String streamPath, boolean recurse) throws CloudException, IOException {
BaseAdapter.DeleteStream(streamPath, recurse);
}
- public void AppendToStream(String streamPath, byte[] data, long offset, int byteCount) throws Exception {
+ public void AppendToStream(String streamPath, byte[] data, long offset, int byteCount) throws CloudException, IOException {
BaseAdapter.AppendToStream(streamPath, data, offset, byteCount);
}
- public boolean StreamExists(String streamPath) throws Exception {
+ public boolean StreamExists(String streamPath) throws CloudException, IOException {
return BaseAdapter.StreamExists(streamPath);
}
- public long GetStreamLength(String streamPath) throws Exception {
+ public long GetStreamLength(String streamPath) throws CloudException, IOException {
return BaseAdapter.GetStreamLength(streamPath);
}
- public void Concatenate(String targetStreamPath, String[] inputStreamPaths) throws Exception {
+ public void Concatenate(String targetStreamPath, String[] inputStreamPaths) throws CloudException, IOException {
if(ThrowInConcat) {
throw new IntentionalException();
}