Skip to content

Commit

Permalink
SDK release for 2017-06-01.5.1. (Azure#16)
Browse files Browse the repository at this point in the history
* Add test cases for new features.

* Improve code style and wording.

* 2017-06-01.5.1 release

* Update client-runtime version and test cases.
  • Loading branch information
xingwu1 committed Jul 31, 2017
1 parent f193418 commit 826482e
Show file tree
Hide file tree
Showing 26 changed files with 1,625 additions and 55 deletions.
33 changes: 22 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
[![Build Status](https://travis-ci.org/Azure/azure-batch-sdk-for-java.svg?style=flat-square&label=build)](https://travis-ci.org/Azure/azure-batch-sdk-for-java)

#Azure Batch Libraries for Java
## Azure Batch Libraries for Java

This README is based on the latest released version Azure Batch SDK (1.0.0). If you are looking for other releases, see [More Information](#more-information)
This README is based on the latest released version Azure Batch SDK (2.1.0). If you are looking for other releases, see [More Information](#more-information)

The Azure Batch Libraries for Java is a higher-level, object-oriented API for interacting with the Azure Batch service.


> **1.0.0** is a release that supports all features of Azure Batch service with API version "2017-01-01.4.0". We will be adding support for more new features and tweaking the API associated with Azure Batch service newer release.
> **2.1.0** is a release that supports all features of Azure Batch service with API version "2017-06-01.5.1". We will be adding support for more new features and tweaking the API associated with Azure Batch service newer release.
**Azure Batch Authentication**

You need to create a Batch account through the [Azure portal](https://portal.azure.com) or Azure cli. Use the account name, key, and URL to create a `BatchSharedKeyCredentials` instance for authentication with the Azure Batch service.
You need to create a Batch account through the [Azure portal](https://portal.azure.com) or Azure cli.

* Use the account name, key, and URL to create a `BatchSharedKeyCredentials` instance for authentication with the Azure Batch service.
The `BatchClient` class is the simplest entry point for creating and interacting with Azure Batch objects.

```java
BatchSharedKeyCredentials cred = new BatchSharedKeyCredentials(batchUri, batchAccount, batchKey);
BatchClient client = BatchClient.open(cred);
```


* The other way is using AAD (Azure Active Directory) authentication to create the client. See this [document](https://docs.microsoft.com/en-us/azure/batch/batch-aad-auth) for detail.

```java
BatchApplicationTokenCredentials cred = new BatchApplicationTokenCredentials(batchEndpoint, clientId, applicationSecret, applicationDomain, null, null);
BatchClient client = BatchClient.open(cred);
```

**Create a pool using an Azure Marketplace image**

You can create a pool of Azure virtual machines which can be used to execute tasks.
Expand Down Expand Up @@ -51,25 +60,25 @@ You can find sample code that illustrates Batch usage scenarios in https://githu
# Download


**1.0.0**
**2.1.0**

If you are using released builds from 1.0.0, add the following to your POM file:
If you are using released builds from 2.1.0, add the following to your POM file:

```xml
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-batch</artifactId>
<version>1.0.0</version>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>com.microsoft.rest</groupId>
<artifactId>client-runtime</artifactId>
<version>1.0.0</version>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-client-runtime</artifactId>
<version>1.0.0</version>
<version>1.0.4</version>
</dependency>
```

Expand Down Expand Up @@ -103,7 +112,9 @@ If you would like to become an active contributor to this project please follow

| Version | SHA1 | Remarks |
|-------------------|-------------------------------------------------------------------------------------------|-------------------------------------------------------|
| 1.0.0 | [1.0.0](https://github.com/Azure/azure-sdk-for-java/tree/master) | Tagged release for 1.0.0 version of Azure Batch libraries |
| 2.1.0 | [2.1.0](https://github.com/Azure/azure-sdk-for-java/tree/master) | Tagged release for 2.1.0 version of Azure Batch libraries |
| 2.0.0 | [2.0.0](https://github.com/Azure/azure-batch-sdk-for-java/releases/tag/v2.0.0) | Tagged release for 2.0.0 version of Azure Batch libraries |
| 1.0.0 | [1.0.0](https://github.com/Azure/azure-batch-sdk-for-java/releases/tag/v1.0.0) | Tagged release for 1.0.0 version of Azure Batch libraries |
| 1.0.0-beta2 | [1.0.0-beta2](https://github.com/Azure/azure-sdk-for-java/tree/1.0.0-beta2) | Tagged release for 1.0.0-beta2 version of Azure Batch libraries |

---
Expand Down
18 changes: 5 additions & 13 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var fs = require('fs');

var mappings = {
'batchService': {
'source': 'batch/2017-05-01.5.0/swagger/BatchService.json',
'source': 'specification/batch/data-plane/Microsoft.Batch/2017-06-01.5.1/BatchService.json',
'package': 'com.microsoft.azure.batch.protocol',
'fluent': false,
'args': '-FT 1'
Expand All @@ -22,9 +22,9 @@ gulp.task('default', function() {
console.log("--autorest-args\n\tPasses additional argument to AutoRest generator");
});

var specRoot = args['spec-root'] || "https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master";
var specRoot = args['spec-root'] || "https://raw.githubusercontent.com/Azure/azure-rest-api-specs/current";
var projects = 'batchService'; // default
var autoRestVersion = '1.0.1-20170329-2300-nightly'; // default
var autoRestVersion = '1.2.2'; // default
if (args['autorest'] !== undefined) {
autoRestVersion = args['autorest'];
}
Expand All @@ -36,16 +36,8 @@ var autoRestArgs = args['autorest-args'];
var autoRestExe;

gulp.task('codegen', function(cb) {
if (autoRestVersion.match(/[0-9]+\.[0-9]+\.[0-9]+.*/) ||
autoRestVersion == 'latest') {
autoRestExe = 'autorest ---version=' + autoRestVersion;
handleInput(projects, cb);
} else {
autoRestExe = autoRestVersion + "/src/core/AutoRest/bin/Debug/netcoreapp1.0/AutoRest.dll";
autoRestExe = "dotnet " + autoRestExe;
handleInput(projects, cb);
}

autoRestExe = 'autorest';
handleInput(projects, cb);
});

var handleInput = function(projects, cb) {
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-client-runtime</artifactId>
<version>1.0.1</version>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
Expand Down
32 changes: 32 additions & 0 deletions src/main/java/com/microsoft/azure/batch/JobOperations.java
Original file line number Diff line number Diff line change
Expand Up @@ -566,4 +566,36 @@ public void patchJob(String jobId, JobPatchParameter jobPatchParameter, Iterable

this._parentBatchClient.protocolLayer().jobs().patch(jobId, jobPatchParameter, options);
}

/**
* Gets the task counts for the specified job.
* Task counts provide a count of the tasks by active, running or completed task state, and a count of tasks which succeeded or failed. Tasks in the preparing state are counted as running. If the validationStatus is unvalidated, then the Batch service has not been able to check state counts against the task states as reported in the List Tasks API. The validationStatus may be unvalidated if the job contains more than 200,000 tasks.
*
* @param jobId The ID of the job.
* @throws BatchErrorException thrown if the request is rejected by server
* @throws IOException Exception thrown when there is an error in serialization/deserialization of data sent to/received from the Batch service.
* @return the TaskCounts object if successful.
*/
public TaskCounts getTaskCounts(String jobId) throws BatchErrorException, IOException {
return getTaskCounts(jobId, null);
}

/**
* Gets the task counts for the specified job.
* Task counts provide a count of the tasks by active, running or completed task state, and a count of tasks which succeeded or failed. Tasks in the preparing state are counted as running. If the validationStatus is unvalidated, then the Batch service has not been able to check state counts against the task states as reported in the List Tasks API. The validationStatus may be unvalidated if the job contains more than 200,000 tasks.
*
* @param jobId The ID of the job.
* @param additionalBehaviors A collection of {@link BatchClientBehavior} instances that are applied to the Batch service request.
* @throws BatchErrorException thrown if the request is rejected by server
* @throws IOException Exception thrown when there is an error in serialization/deserialization of data sent to/received from the Batch service.
* @return the TaskCounts object if successful.
*/
public TaskCounts getTaskCounts(String jobId, Iterable<BatchClientBehavior> additionalBehaviors) throws BatchErrorException, IOException {
JobGetTaskCountsOptions options = new JobGetTaskCountsOptions();
BehaviorManager bhMgr = new BehaviorManager(this.customBehaviors(), additionalBehaviors);
bhMgr.applyRequestBehaviors(options);

return this._parentBatchClient.protocolLayer().jobs().getTaskCounts(jobId, options);
}

}
92 changes: 92 additions & 0 deletions src/main/java/com/microsoft/azure/batch/protocol/Jobs.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import com.microsoft.azure.batch.protocol.models.JobGetAllLifetimeStatisticsOptions;
import com.microsoft.azure.batch.protocol.models.JobGetHeaders;
import com.microsoft.azure.batch.protocol.models.JobGetOptions;
import com.microsoft.azure.batch.protocol.models.JobGetTaskCountsHeaders;
import com.microsoft.azure.batch.protocol.models.JobGetTaskCountsOptions;
import com.microsoft.azure.batch.protocol.models.JobListFromJobScheduleHeaders;
import com.microsoft.azure.batch.protocol.models.JobListFromJobScheduleNextOptions;
import com.microsoft.azure.batch.protocol.models.JobListFromJobScheduleOptions;
Expand All @@ -43,6 +45,7 @@
import com.microsoft.azure.batch.protocol.models.JobUpdateHeaders;
import com.microsoft.azure.batch.protocol.models.JobUpdateOptions;
import com.microsoft.azure.batch.protocol.models.JobUpdateParameter;
import com.microsoft.azure.batch.protocol.models.TaskCounts;
import com.microsoft.azure.ListOperationCallback;
import com.microsoft.azure.Page;
import com.microsoft.azure.PagedList;
Expand Down Expand Up @@ -1100,6 +1103,95 @@ public interface Jobs {
*/
Observable<ServiceResponseWithHeaders<Page<JobPreparationAndReleaseTaskExecutionInformation>, JobListPreparationAndReleaseTaskStatusHeaders>> listPreparationAndReleaseTaskStatusWithServiceResponseAsync(final String jobId, final JobListPreparationAndReleaseTaskStatusOptions jobListPreparationAndReleaseTaskStatusOptions);

/**
* Gets the task counts for the specified job.
* Task counts provide a count of the tasks by active, running or completed task state, and a count of tasks which succeeded or failed. Tasks in the preparing state are counted as running. If the validationStatus is unvalidated, then the Batch service has not been able to check state counts against the task states as reported in the List Tasks API. The validationStatus may be unvalidated if the job contains more than 200,000 tasks.
*
* @param jobId The ID of the job.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws BatchErrorException thrown if the request is rejected by server
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
* @return the TaskCounts object if successful.
*/
TaskCounts getTaskCounts(String jobId);

/**
* Gets the task counts for the specified job.
* Task counts provide a count of the tasks by active, running or completed task state, and a count of tasks which succeeded or failed. Tasks in the preparing state are counted as running. If the validationStatus is unvalidated, then the Batch service has not been able to check state counts against the task states as reported in the List Tasks API. The validationStatus may be unvalidated if the job contains more than 200,000 tasks.
*
* @param jobId The ID of the job.
* @param serviceCallback the async ServiceCallback to handle successful and failed responses.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceFuture} object
*/
ServiceFuture<TaskCounts> getTaskCountsAsync(String jobId, final ServiceCallback<TaskCounts> serviceCallback);

/**
* Gets the task counts for the specified job.
* Task counts provide a count of the tasks by active, running or completed task state, and a count of tasks which succeeded or failed. Tasks in the preparing state are counted as running. If the validationStatus is unvalidated, then the Batch service has not been able to check state counts against the task states as reported in the List Tasks API. The validationStatus may be unvalidated if the job contains more than 200,000 tasks.
*
* @param jobId The ID of the job.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the TaskCounts object
*/
Observable<TaskCounts> getTaskCountsAsync(String jobId);

/**
* Gets the task counts for the specified job.
* Task counts provide a count of the tasks by active, running or completed task state, and a count of tasks which succeeded or failed. Tasks in the preparing state are counted as running. If the validationStatus is unvalidated, then the Batch service has not been able to check state counts against the task states as reported in the List Tasks API. The validationStatus may be unvalidated if the job contains more than 200,000 tasks.
*
* @param jobId The ID of the job.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the TaskCounts object
*/
Observable<ServiceResponseWithHeaders<TaskCounts, JobGetTaskCountsHeaders>> getTaskCountsWithServiceResponseAsync(String jobId);
/**
* Gets the task counts for the specified job.
* Task counts provide a count of the tasks by active, running or completed task state, and a count of tasks which succeeded or failed. Tasks in the preparing state are counted as running. If the validationStatus is unvalidated, then the Batch service has not been able to check state counts against the task states as reported in the List Tasks API. The validationStatus may be unvalidated if the job contains more than 200,000 tasks.
*
* @param jobId The ID of the job.
* @param jobGetTaskCountsOptions Additional parameters for the operation
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws BatchErrorException thrown if the request is rejected by server
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
* @return the TaskCounts object if successful.
*/
TaskCounts getTaskCounts(String jobId, JobGetTaskCountsOptions jobGetTaskCountsOptions);

/**
* Gets the task counts for the specified job.
* Task counts provide a count of the tasks by active, running or completed task state, and a count of tasks which succeeded or failed. Tasks in the preparing state are counted as running. If the validationStatus is unvalidated, then the Batch service has not been able to check state counts against the task states as reported in the List Tasks API. The validationStatus may be unvalidated if the job contains more than 200,000 tasks.
*
* @param jobId The ID of the job.
* @param jobGetTaskCountsOptions Additional parameters for the operation
* @param serviceCallback the async ServiceCallback to handle successful and failed responses.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceFuture} object
*/
ServiceFuture<TaskCounts> getTaskCountsAsync(String jobId, JobGetTaskCountsOptions jobGetTaskCountsOptions, final ServiceCallback<TaskCounts> serviceCallback);

/**
* Gets the task counts for the specified job.
* Task counts provide a count of the tasks by active, running or completed task state, and a count of tasks which succeeded or failed. Tasks in the preparing state are counted as running. If the validationStatus is unvalidated, then the Batch service has not been able to check state counts against the task states as reported in the List Tasks API. The validationStatus may be unvalidated if the job contains more than 200,000 tasks.
*
* @param jobId The ID of the job.
* @param jobGetTaskCountsOptions Additional parameters for the operation
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the TaskCounts object
*/
Observable<TaskCounts> getTaskCountsAsync(String jobId, JobGetTaskCountsOptions jobGetTaskCountsOptions);

/**
* Gets the task counts for the specified job.
* Task counts provide a count of the tasks by active, running or completed task state, and a count of tasks which succeeded or failed. Tasks in the preparing state are counted as running. If the validationStatus is unvalidated, then the Batch service has not been able to check state counts against the task states as reported in the List Tasks API. The validationStatus may be unvalidated if the job contains more than 200,000 tasks.
*
* @param jobId The ID of the job.
* @param jobGetTaskCountsOptions Additional parameters for the operation
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the TaskCounts object
*/
Observable<ServiceResponseWithHeaders<TaskCounts, JobGetTaskCountsHeaders>> getTaskCountsWithServiceResponseAsync(String jobId, JobGetTaskCountsOptions jobGetTaskCountsOptions);

/**
* Lists all of the jobs in the specified account.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public BatchServiceClientImpl(RestClient restClient) {
}

protected void initialize() {
this.apiVersion = "2017-05-01.5.0";
this.apiVersion = "2017-06-01.5.1";
this.acceptLanguage = "en-US";
this.longRunningOperationRetryTimeout = 30;
this.generateClientRequestId = true;
Expand All @@ -290,8 +290,6 @@ protected void initialize() {
*/
@Override
public String userAgent() {
return String.format("Azure-SDK-For-Java/%s (%s)",
getClass().getPackage().getImplementationVersion(),
"BatchServiceClient, 2017-05-01.5.0");
return String.format("%s (%s, %s)", super.userAgent(), "BatchServiceClient", "2017-06-01.5.1");
}
}
Loading

0 comments on commit 826482e

Please sign in to comment.