Skip to content

Commit

Permalink
Remove internal use method under implementations. (Azure#5940)
Browse files Browse the repository at this point in the history
  • Loading branch information
sima-zhu authored Oct 19, 2019
1 parent c7a1c80 commit f4922a4
Show file tree
Hide file tree
Showing 51 changed files with 568 additions and 564 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@
<suppress checks="com.azure.tools.checkstyle.checks.GoodLoggingCheck" files="ClientLogger.java"/>
<!-- Use the logger in Utility static method. -->
<suppress checks="com.azure.tools.checkstyle.checks.GoodLoggingCheck" files="com.azure.storage.common.Utility.java"/>
<suppress checks="com.azure.tools.checkstyle.checks.GoodLoggingCheck" files="com.azure.storage.common.implementation.StorageImplUtils.java"/>

<!-- Azure Core Test -->
<suppress checks="com.azure.tools.checkstyle.checks.GoodLoggingCheck" files=".*[/\\]core[/\\]test[/\\].*\.java"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.azure.storage.blob.models.AccessTier;
import com.azure.storage.blob.models.BlobStorageException;
import com.azure.storage.blob.models.DeleteSnapshotsOptionType;
import com.azure.storage.common.Utility;
import com.azure.storage.common.implementation.StorageImplUtils;
import reactor.core.publisher.Mono;

import java.time.Duration;
Expand Down Expand Up @@ -147,7 +147,7 @@ public PagedFlux<Response<Void>> deleteBlobs(List<String> blobUrls, DeleteSnapsh
PagedFlux<Response<Void>> deleteBlobsWithTimeout(List<String> blobUrls, DeleteSnapshotsOptionType deleteOptions,
Duration timeout, Context context) {
return new PagedFlux<>(() ->
Utility.applyOptionalTimeout(submitDeleteBlobsBatch(blobUrls, deleteOptions, context), timeout));
StorageImplUtils.applyOptionalTimeout(submitDeleteBlobsBatch(blobUrls, deleteOptions, context), timeout));
}

private Mono<PagedResponse<Response<Void>>> submitDeleteBlobsBatch(List<String> blobUrls,
Expand Down Expand Up @@ -181,7 +181,7 @@ public PagedFlux<Response<Void>> setBlobsAccessTier(List<String> blobUrls, Acces
PagedFlux<Response<Void>> setBlobsAccessTierWithTimeout(List<String> blobUrls, AccessTier accessTier,
Duration timeout, Context context) {
return new PagedFlux<>(() ->
Utility.applyOptionalTimeout(submitSetTierBatch(blobUrls, accessTier, context), timeout));
StorageImplUtils.applyOptionalTimeout(submitSetTierBatch(blobUrls, accessTier, context), timeout));
}

private Mono<PagedResponse<Response<Void>>> submitSetTierBatch(List<String> blobUrls, AccessTier accessTier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
import com.azure.storage.blob.models.AccessTier;
import com.azure.storage.blob.models.BlobStorageException;
import com.azure.storage.blob.models.DeleteSnapshotsOptionType;
import com.azure.storage.common.Utility;

import com.azure.storage.common.implementation.StorageImplUtils;
import java.time.Duration;
import java.util.List;

Expand Down Expand Up @@ -85,8 +84,8 @@ public void submitBatch(BlobBatch batch) {
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<Void> submitBatchWithResponse(BlobBatch batch, boolean throwOnAnyFailure, Duration timeout,
Context context) {
return Utility.blockWithOptionalTimeout(client.submitBatchWithResponse(batch, throwOnAnyFailure, context),
timeout);
return StorageImplUtils.blockWithOptionalTimeout(client.submitBatchWithResponse(batch,
throwOnAnyFailure, context), timeout);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import com.azure.storage.blob.models.BlobAccessConditions;
import com.azure.storage.blob.models.BlobHttpHeaders;
import com.azure.storage.blob.models.ParallelTransferOptions;
import com.azure.storage.common.Utility;
import com.azure.storage.common.implementation.StorageImplUtils;
import reactor.core.publisher.Mono;

import java.io.UncheckedIOException;
Expand Down Expand Up @@ -92,7 +92,7 @@ public void uploadFromFile(String filePath, ParallelTransferOptions parallelTran
headers, metadata, tier, accessConditions);

try {
Utility.blockWithOptionalTimeout(upload, timeout);
StorageImplUtils.blockWithOptionalTimeout(upload, timeout);
} catch (UncheckedIOException e) {
throw logger.logExceptionAsError(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import com.azure.storage.blob.specialized.BlockBlobClient;
import com.azure.storage.blob.specialized.PageBlobClient;
import com.azure.storage.blob.specialized.SpecializedBlobClientBuilder;
import com.azure.storage.common.Utility;
import com.azure.storage.common.implementation.StorageImplUtils;
import reactor.core.publisher.Mono;

import java.io.UncheckedIOException;
Expand Down Expand Up @@ -135,7 +135,7 @@ public void uploadFromFile(String filePath, ParallelTransferOptions parallelTran
filePath, parallelTransferOptions, headers, metadata, tier, accessConditions);

try {
Utility.blockWithOptionalTimeout(upload, timeout);
StorageImplUtils.blockWithOptionalTimeout(upload, timeout);
} catch (UncheckedIOException e) {
throw logger.logExceptionAsError(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import com.azure.storage.blob.models.ModifiedAccessConditions;
import com.azure.storage.blob.models.PublicAccessType;
import com.azure.storage.blob.models.StorageAccountInfo;
import com.azure.storage.common.Utility;
import com.azure.storage.common.implementation.StorageImplUtils;
import reactor.core.publisher.Mono;

import java.time.Duration;
Expand Down Expand Up @@ -139,8 +139,8 @@ public BlobAsyncClient getBlobAsyncClient(String blobName) {
*/
public BlobAsyncClient getBlobAsyncClient(String blobName, String snapshot) {
return new BlobAsyncClient(getHttpPipeline(),
Utility.appendToUrlPath(getBlobContainerUrl(), blobName).toString(), getServiceVersion(), getAccountName(),
getBlobContainerName(), blobName, snapshot, getCustomerProvidedKey());
StorageImplUtils.appendToUrlPath(getBlobContainerUrl(), blobName).toString(), getServiceVersion(),
getAccountName(), getBlobContainerName(), blobName, snapshot, getCustomerProvidedKey());
}

/**
Expand Down Expand Up @@ -718,7 +718,7 @@ private Mono<ContainersListBlobFlatSegmentResponse> listBlobsFlatSegment(String
Duration timeout) {
options = options == null ? new ListBlobsOptions() : options;

return Utility.applyOptionalTimeout(
return StorageImplUtils.applyOptionalTimeout(
this.azureBlobStorage.containers().listBlobFlatSegmentWithRestResponseAsync(null, options.getPrefix(),
marker, options.getMaxResultsPerPage(), options.getDetails().toList(),
null, null, Context.NONE), timeout);
Expand Down Expand Up @@ -846,7 +846,7 @@ private Mono<ContainersListBlobHierarchySegmentResponse> listBlobsHierarchySegme
new UnsupportedOperationException("Including snapshots in a hierarchical listing is not supported."));
}

return Utility.applyOptionalTimeout(
return StorageImplUtils.applyOptionalTimeout(
this.azureBlobStorage.containers().listBlobHierarchySegmentWithRestResponseAsync(null, delimiter,
options.getPrefix(), marker, options.getMaxResultsPerPage(), options.getDetails().toList(), null, null,
Context.NONE),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import com.azure.storage.blob.models.ListBlobsOptions;
import com.azure.storage.blob.models.PublicAccessType;
import com.azure.storage.blob.models.StorageAccountInfo;
import com.azure.storage.common.Utility;
import com.azure.storage.common.implementation.StorageImplUtils;
import reactor.core.publisher.Mono;

import java.time.Duration;
Expand Down Expand Up @@ -178,7 +178,7 @@ public boolean exists() {
public Response<Boolean> existsWithResponse(Duration timeout, Context context) {
Mono<Response<Boolean>> response = blobContainerAsyncClient.existsWithResponse(context);

return Utility.blockWithOptionalTimeout(response, timeout);
return StorageImplUtils.blockWithOptionalTimeout(response, timeout);
}

/**
Expand Down Expand Up @@ -213,7 +213,7 @@ public void create() {
public Response<Void> createWithResponse(Map<String, String> metadata, PublicAccessType accessType,
Duration timeout, Context context) {
Mono<Response<Void>> response = blobContainerAsyncClient.createWithResponse(metadata, accessType, context);
return Utility.blockWithOptionalTimeout(response, timeout);
return StorageImplUtils.blockWithOptionalTimeout(response, timeout);
}

/**
Expand Down Expand Up @@ -247,7 +247,7 @@ public Response<Void> deleteWithResponse(BlobContainerAccessConditions accessCon
Context context) {
Mono<Response<Void>> response = blobContainerAsyncClient.deleteWithResponse(accessConditions, context);

return Utility.blockWithOptionalTimeout(response, timeout);
return StorageImplUtils.blockWithOptionalTimeout(response, timeout);
}

/**
Expand Down Expand Up @@ -283,7 +283,7 @@ public Response<BlobContainerProperties> getPropertiesWithResponse(LeaseAccessCo
Mono<Response<BlobContainerProperties>> response = blobContainerAsyncClient
.getPropertiesWithResponse(leaseAccessConditions, context);

return Utility.blockWithOptionalTimeout(response, timeout);
return StorageImplUtils.blockWithOptionalTimeout(response, timeout);
}

/**
Expand Down Expand Up @@ -317,7 +317,7 @@ public Response<Void> setMetadataWithResponse(Map<String, String> metadata,
BlobContainerAccessConditions accessConditions, Duration timeout, Context context) {
Mono<Response<Void>> response = blobContainerAsyncClient.setMetadataWithResponse(metadata, accessConditions,
context);
return Utility.blockWithOptionalTimeout(response, timeout);
return StorageImplUtils.blockWithOptionalTimeout(response, timeout);
}

/**
Expand Down Expand Up @@ -356,7 +356,7 @@ public Response<BlobContainerAccessPolicies> getAccessPolicyWithResponse(
Mono<Response<BlobContainerAccessPolicies>> response = blobContainerAsyncClient
.getAccessPolicyWithResponse(leaseAccessConditions, context);

return Utility.blockWithOptionalTimeout(response, timeout);
return StorageImplUtils.blockWithOptionalTimeout(response, timeout);
}

/**
Expand Down Expand Up @@ -408,7 +408,7 @@ public Response<Void> setAccessPolicyWithResponse(PublicAccessType accessType,
Mono<Response<Void>> response = blobContainerAsyncClient
.setAccessPolicyWithResponse(accessType, identifiers, accessConditions, context);

return Utility.blockWithOptionalTimeout(response, timeout);
return StorageImplUtils.blockWithOptionalTimeout(response, timeout);
}

/**
Expand Down Expand Up @@ -558,6 +558,6 @@ public StorageAccountInfo getAccountInfo(Duration timeout) {
public Response<StorageAccountInfo> getAccountInfoWithResponse(Duration timeout, Context context) {
Mono<Response<StorageAccountInfo>> response = blobContainerAsyncClient.getAccountInfoWithResponse(context);

return Utility.blockWithOptionalTimeout(response, timeout);
return StorageImplUtils.blockWithOptionalTimeout(response, timeout);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
import com.azure.storage.blob.models.PublicAccessType;
import com.azure.storage.blob.models.StorageAccountInfo;
import com.azure.storage.blob.models.UserDelegationKey;
import com.azure.storage.common.Utility;
import com.azure.storage.common.implementation.Constants;
import com.azure.storage.common.implementation.StorageImplUtils;
import reactor.core.publisher.Mono;

import java.time.Duration;
Expand Down Expand Up @@ -111,8 +112,8 @@ public BlobContainerAsyncClient getBlobContainerAsyncClient(String containerName
}

return new BlobContainerAsyncClient(getHttpPipeline(),
Utility.appendToUrlPath(getAccountUrl(), containerName).toString(), getServiceVersion(), getAccountName(),
containerName, customerProvidedKey);
StorageImplUtils.appendToUrlPath(getAccountUrl(), containerName).toString(), getServiceVersion(),
getAccountName(), containerName, customerProvidedKey);
}

/**
Expand Down Expand Up @@ -295,7 +296,7 @@ private Mono<ServicesListBlobContainersSegmentResponse> listBlobContainersSegmen
ListBlobContainersOptions options, Duration timeout) {
options = options == null ? new ListBlobContainersOptions() : options;

return Utility.applyOptionalTimeout(
return StorageImplUtils.applyOptionalTimeout(
this.azureBlobStorage.services().listBlobContainersSegmentWithRestResponseAsync(
options.getPrefix(), marker, options.getMaxResultsPerPage(), options.getDetails().toIncludeType(), null,
null, Context.NONE), timeout);
Expand Down Expand Up @@ -438,16 +439,16 @@ public Mono<Response<UserDelegationKey>> getUserDelegationKeyWithResponse(Offset

Mono<Response<UserDelegationKey>> getUserDelegationKeyWithResponse(OffsetDateTime start, OffsetDateTime expiry,
Context context) {
Utility.assertNotNull("expiry", expiry);
StorageImplUtils.assertNotNull("expiry", expiry);
if (start != null && !start.isBefore(expiry)) {
throw logger.logExceptionAsError(
new IllegalArgumentException("`start` must be null or a datetime before `expiry`."));
}

return this.azureBlobStorage.services().getUserDelegationKeyWithRestResponseAsync(
new KeyInfo()
.setStart(start == null ? "" : Utility.ISO_8601_UTC_DATE_FORMATTER.format(start))
.setExpiry(Utility.ISO_8601_UTC_DATE_FORMATTER.format(expiry)),
.setStart(start == null ? "" : Constants.ISO_8601_UTC_DATE_FORMATTER.format(start))
.setExpiry(Constants.ISO_8601_UTC_DATE_FORMATTER.format(expiry)),
null, null, context).map(rb -> new SimpleResponse<>(rb, rb.getValue()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import com.azure.storage.blob.models.PublicAccessType;
import com.azure.storage.blob.models.StorageAccountInfo;
import com.azure.storage.blob.models.UserDelegationKey;
import com.azure.storage.common.Utility;
import com.azure.storage.common.implementation.StorageImplUtils;
import reactor.core.publisher.Mono;

import java.time.Duration;
Expand Down Expand Up @@ -221,7 +221,7 @@ public Response<BlobServiceProperties> getPropertiesWithResponse(Duration timeou

Mono<Response<BlobServiceProperties>> response = blobServiceAsyncClient.getPropertiesWithResponse(context);

return Utility.blockWithOptionalTimeout(response, timeout);
return StorageImplUtils.blockWithOptionalTimeout(response, timeout);
}

/**
Expand Down Expand Up @@ -259,7 +259,7 @@ public Response<Void> setPropertiesWithResponse(BlobServiceProperties properties
Context context) {
Mono<Response<Void>> response = blobServiceAsyncClient.setPropertiesWithResponse(properties, context);

return Utility.blockWithOptionalTimeout(response, timeout);
return StorageImplUtils.blockWithOptionalTimeout(response, timeout);
}

/**
Expand Down Expand Up @@ -297,7 +297,7 @@ public Response<UserDelegationKey> getUserDelegationKeyWithResponse(OffsetDateTi
Mono<Response<UserDelegationKey>> response = blobServiceAsyncClient.getUserDelegationKeyWithResponse(start,
expiry, context);

return Utility.blockWithOptionalTimeout(response, timeout);
return StorageImplUtils.blockWithOptionalTimeout(response, timeout);
}

/**
Expand Down Expand Up @@ -333,7 +333,7 @@ public BlobServiceStatistics getStatistics() {
public Response<BlobServiceStatistics> getStatisticsWithResponse(Duration timeout, Context context) {
Mono<Response<BlobServiceStatistics>> response = blobServiceAsyncClient.getStatisticsWithResponse(context);

return Utility.blockWithOptionalTimeout(response, timeout);
return StorageImplUtils.blockWithOptionalTimeout(response, timeout);
}

/**
Expand Down Expand Up @@ -361,7 +361,7 @@ public StorageAccountInfo getAccountInfo() {
public Response<StorageAccountInfo> getAccountInfoWithResponse(Duration timeout, Context context) {
Mono<Response<StorageAccountInfo>> response = blobServiceAsyncClient.getAccountInfoWithResponse(context);

return Utility.blockWithOptionalTimeout(response, timeout);
return StorageImplUtils.blockWithOptionalTimeout(response, timeout);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

import com.azure.core.util.Context;
import com.azure.storage.blob.models.BlobAccessConditions;
import com.azure.storage.common.Utility;

import com.azure.storage.common.implementation.StorageImplUtils;
import java.time.Duration;

/**
Expand Down Expand Up @@ -55,7 +55,7 @@ public Long getCount() {
*/
public HttpGetterInfo setCount(Long count) {
if (count != null) {
Utility.assertInBounds("count", count, 0, Long.MAX_VALUE);
StorageImplUtils.assertInBounds("count", count, 0, Long.MAX_VALUE);
}
this.count = count;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import com.azure.core.util.logging.ClientLogger;
import com.azure.storage.blob.specialized.BlockBlobClient;
import com.azure.storage.common.Utility;
import com.azure.storage.common.implementation.StorageImplUtils;
import reactor.core.publisher.Flux;

import java.nio.ByteBuffer;
Expand Down Expand Up @@ -59,13 +59,13 @@ final class UploadBufferPool {
We only need one overflow buffer because the max size of a ByteBuffer is assumed to be the size as a buffer in
the pool.
*/
Utility.assertInBounds("numBuffs", numBuffs, 2, Integer.MAX_VALUE);
StorageImplUtils.assertInBounds("numBuffs", numBuffs, 2, Integer.MAX_VALUE);
this.maxBuffs = numBuffs;
buffers = new LinkedBlockingQueue<>(numBuffs);


// These buffers will be used in calls to stageBlock, so they must be no greater than block size.
Utility.assertInBounds("buffSize", buffSize, 1, BlockBlobClient.MAX_STAGE_BLOCK_BYTES);
StorageImplUtils.assertInBounds("buffSize", buffSize, 1, BlockBlobClient.MAX_STAGE_BLOCK_BYTES);
this.buffSize = buffSize;

// We prep the queue with two buffers in case there is overflow.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import com.azure.storage.blob.ProgressReceiver;
import com.azure.storage.common.implementation.Constants;
import com.azure.storage.common.Utility;
import com.azure.storage.common.implementation.StorageImplUtils;

public class ParallelTransferOptions {

Expand Down Expand Up @@ -64,7 +64,7 @@ public ProgressReceiver getProgressReceiver() {
* @throws IllegalArgumentException when block size is less than 0 or greater than max blob block size (10MB).
*/
public ParallelTransferOptions setBlockSize(int blockSize) {
Utility.assertInBounds("blockSize", blockSize, 0, BLOB_MAX_BLOCK_SIZE);
StorageImplUtils.assertInBounds("blockSize", blockSize, 0, BLOB_MAX_BLOCK_SIZE);
this.blockSize = blockSize;
return this;
}
Expand All @@ -80,7 +80,7 @@ public ParallelTransferOptions setBlockSize(int blockSize) {
* @throws IllegalArgumentException when numBuffers is less than 2.
*/
public ParallelTransferOptions setNumBuffers(int numBuffers) {
Utility.assertInBounds("numBuffers", numBuffers, 2, Integer.MAX_VALUE);
StorageImplUtils.assertInBounds("numBuffers", numBuffers, 2, Integer.MAX_VALUE);
this.numBuffers = numBuffers;
return this;
}
Expand Down
Loading

0 comments on commit f4922a4

Please sign in to comment.