Skip to content

Commit

Permalink
Address some of the PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sydney-munro committed Aug 15, 2023
1 parent 9d53033 commit 0627c2d
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 35 deletions.
1 change: 1 addition & 0 deletions ssb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
Expand Down
11 changes: 6 additions & 5 deletions ssb/src/main/java/com/google/cloud/CloudMonitoringResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down
23 changes: 10 additions & 13 deletions ssb/src/main/java/com/google/cloud/Workload1.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand All @@ -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";
}

Expand Down

0 comments on commit 0627c2d

Please sign in to comment.