Skip to content

Commit

Permalink
Merge pull request #664 from begoldsm/autorest
Browse files Browse the repository at this point in the history
Updates for javadoc
  • Loading branch information
jianghaolu committed Apr 21, 2016
2 parents 08cbb2d + 036d125 commit 913cb61
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 66 deletions.
5 changes: 0 additions & 5 deletions azure-mgmt-datalake-store-uploader/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-client-authentication</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -29,33 +39,39 @@ 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.
* At the end of this operation, input streams will be deleted.
*
* @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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 <c>true</c> [use segment block back off retry strategy].
* @param useSegmentBlockBackOffRetryStrategy if set to <code>true</code> [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.
Expand All @@ -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 <c>true</c> if [to use segment block back off retry strategy]; otherwise, <c>false</c>.
* @return <code>true</code> if [to use segment block back off retry strategy]; otherwise, <code>false</code>.
*/
public boolean isUseSegmentBlockBackOffRetryStrategy() {
return useSegmentBlockBackOffRetryStrategy;
Expand Down Expand Up @@ -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;
Expand All @@ -216,7 +216,7 @@ protected void setThreadCount(int threadCount) {
/**
* Gets a value indicating whether to overwrite the target stream if it already exists.
*
* @return <c>true</c> if this instance is overwrite; otherwise, <c>false</c>.
* @return <code>true</code> if this instance is overwrite; otherwise, <code>false</code>.
*/
public boolean isOverwrite() {
return overwrite;
Expand All @@ -234,7 +234,7 @@ private void setOverwrite(boolean overwrite) {
/**
* Gets a value indicating whether to resume a previously interrupted upload.
*
* @return <c>true</c> if this instance is resume; otherwise, <c>false</c>.
* @return <code>true</code> if this instance is resume; otherwise, <code>false</code>.
*/
public boolean isResume() {
return resume;
Expand All @@ -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 <c>true</c> if this instance is binary; otherwise, <c>false</c>.
* @return <code>true</code> if this instance is binary; otherwise, <code>false</code>.
*/
public boolean isBinary() {
return binary;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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));
Expand All @@ -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));
Expand All @@ -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);
Expand All @@ -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);
}
Expand All @@ -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
Expand All @@ -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)
{
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -160,7 +162,7 @@ public void Concatenate(String targetStreamPath, String[] inputStreamPaths) thro
}
}
}
catch (Exception e)
catch (CloudException e)
{
if (StreamExists(targetStreamPath))
{
Expand All @@ -179,12 +181,12 @@ public void Concatenate(String targetStreamPath, String[] inputStreamPaths) thro
*
* @param streamPath
* @return
* @throws Exception
* @Throws CloudException
*/
public Iterable<byte[]> GetAppendBlocks(String streamPath) throws Exception {
public Iterable<byte[]> 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);
Expand All @@ -195,12 +197,12 @@ public Iterable<byte[]> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 { }
public class IntentionalException extends CloudException { }
Original file line number Diff line number Diff line change
Expand Up @@ -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}
*/
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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);
}
Expand Down
Loading

0 comments on commit 913cb61

Please sign in to comment.