From 0627c2dd4bef9c51071dc2eef29c095984d15ffe Mon Sep 17 00:00:00 2001 From: Sydney Munro Date: Tue, 15 Aug 2023 14:09:56 -0700 Subject: [PATCH] Address some of the PR comments --- ssb/pom.xml | 1 + .../google/cloud/CloudMonitoringResult.java | 11 +++++---- .../cloud/StorageSharedBenchmarkingCli.java | 23 ++++++++++--------- .../cloud/StorageSharedBenchmarkingUtils.java | 13 ++++++----- .../main/java/com/google/cloud/Workload1.java | 23 ++++++++----------- 5 files changed, 36 insertions(+), 35 deletions(-) diff --git a/ssb/pom.xml b/ssb/pom.xml index e5dea1c631..d6d2cde589 100644 --- a/ssb/pom.xml +++ b/ssb/pom.xml @@ -17,6 +17,7 @@ 1.8 UTF-8 + diff --git a/ssb/src/main/java/com/google/cloud/CloudMonitoringResult.java b/ssb/src/main/java/com/google/cloud/CloudMonitoringResult.java index 61f0d5133b..e16c564b06 100644 --- a/ssb/src/main/java/com/google/cloud/CloudMonitoringResult.java +++ b/ssb/src/main/java/com/google/cloud/CloudMonitoringResult.java @@ -7,11 +7,12 @@ * * 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.google.cloud; diff --git a/ssb/src/main/java/com/google/cloud/StorageSharedBenchmarkingCli.java b/ssb/src/main/java/com/google/cloud/StorageSharedBenchmarkingCli.java index 62c77cc273..b7d19634e5 100644 --- a/ssb/src/main/java/com/google/cloud/StorageSharedBenchmarkingCli.java +++ b/ssb/src/main/java/com/google/cloud/StorageSharedBenchmarkingCli.java @@ -7,11 +7,12 @@ * * 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.google.cloud; @@ -64,8 +65,8 @@ public final class StorageSharedBenchmarkingCli implements Runnable { @Option( names = "-object_size", - defaultValue = "1048576...1048576", - description = "Object size in bytes to use for the workload") + defaultValue = "1048576..1048576", + description = "any positive integer, or an inclusive range such as min..max where min and max are positive integers") String objectSize; @Option( @@ -94,9 +95,9 @@ public void run() { private void runWorkload1() { RetrySettings retrySettings = StorageOptions.getDefaultRetrySettings().toBuilder().build(); - StorageOptions alwaysRetryStorageOptions = + StorageOptions retryStorageOptions = StorageOptions.newBuilder().setProjectId(project).setRetrySettings(retrySettings).build(); - Storage storageClient = alwaysRetryStorageOptions.getService(); + Storage storageClient = retryStorageOptions.getService(); Path tempDir = Paths.get(System.getProperty("java.io.tmpdir")); ListeningExecutorService executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(workers)); @@ -140,9 +141,9 @@ private Range(int min, int max) { public static Range of(int min, int max) { return new Range(min, max); } - // Takes an object size range of format min...max and creates a range object + // Takes an object size range of format min..max and creates a range object public static Range of(String range) { - Pattern p = Pattern.compile("\\.\\.\\."); + Pattern p = Pattern.compile("\\.\\."); String[] splitRangeVals = p.split(range); if (splitRangeVals.length == 2) { String min = splitRangeVals[0]; diff --git a/ssb/src/main/java/com/google/cloud/StorageSharedBenchmarkingUtils.java b/ssb/src/main/java/com/google/cloud/StorageSharedBenchmarkingUtils.java index 1eee4cb5ad..376bd80962 100644 --- a/ssb/src/main/java/com/google/cloud/StorageSharedBenchmarkingUtils.java +++ b/ssb/src/main/java/com/google/cloud/StorageSharedBenchmarkingUtils.java @@ -7,11 +7,12 @@ * * 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.google.cloud; @@ -25,7 +26,7 @@ class StorageSharedBenchmarkingUtils { public static int DEFAULT_NUMBER_OF_READS = 3; public static void cleanupObject(Storage storage, Blob created) { - storage.delete(created.getBlobId()); + storage.delete(created.getBlobId(), Storage.BlobSourceOption.generationMatch(created.getGeneration())); } public static double calculateThroughput(long size, Duration elapsedTime) { diff --git a/ssb/src/main/java/com/google/cloud/Workload1.java b/ssb/src/main/java/com/google/cloud/Workload1.java index 4f40de9561..257176d9cd 100644 --- a/ssb/src/main/java/com/google/cloud/Workload1.java +++ b/ssb/src/main/java/com/google/cloud/Workload1.java @@ -7,19 +7,16 @@ * * 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.google.cloud; -import static com.google.cloud.StorageSharedBenchmarkingUtils.DEFAULT_NUMBER_OF_READS; -import static com.google.cloud.StorageSharedBenchmarkingUtils.calculateThroughput; -import static com.google.cloud.StorageSharedBenchmarkingUtils.cleanupObject; - import com.google.cloud.storage.Blob; import com.google.cloud.storage.BlobInfo; import com.google.cloud.storage.Storage; @@ -58,11 +55,11 @@ public String call() throws Exception { System.out.println( generateCloudMonitoringResult( "WRITE", - calculateThroughput(created.getSize().longValue(), elapsedTimeUpload), + StorageSharedBenchmarkingUtils.calculateThroughput(created.getSize().longValue(), elapsedTimeUpload), created) .toString()); Path tempDir = Paths.get(System.getProperty("java.io.tmpdir")); - for (int i = 0; i <= DEFAULT_NUMBER_OF_READS; i++) { + for (int i = 0; i <= StorageSharedBenchmarkingUtils.DEFAULT_NUMBER_OF_READS; i++) { TmpFile dest = TmpFile.of(tempDir, "prefix", "bin"); startTime = clock.instant(); storage.downloadTo(created.getBlobId(), dest.getPath()); @@ -71,11 +68,11 @@ public String call() throws Exception { System.out.println( generateCloudMonitoringResult( "READ[" + i + "]", - calculateThroughput(created.getSize().longValue(), elapsedTimeDownload), + StorageSharedBenchmarkingUtils.calculateThroughput(created.getSize().longValue(), elapsedTimeDownload), created) .toString()); } - cleanupObject(storage, created); + StorageSharedBenchmarkingUtils.cleanupObject(storage, created); return "OK"; }