-
Notifications
You must be signed in to change notification settings - Fork 1.1k
storage: add benchwrapper #6062
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| # storage-benchwrapper | ||
|
|
||
| storage-benchwrapper is a gRPC wrapper around the storage library for benchmarking purposes. | ||
|
|
||
| ## Running | ||
|
|
||
| ``` | ||
| mvn clean install -DskipTests=true (one time) | ||
| cd google-cloud-testing/storage-benchwrapper | ||
| export STORAGE_EMULATOR_HOST=localhost:8080 | ||
| mvn clean install exec:java -DskipTests=true -Dport=8081 | ||
| ``` | ||
|
|
||
| ## Generating .proto sources | ||
|
|
||
| Sources are generated as part of the protobuf-maven-plugin plugin, but if you'd | ||
| like to generate them yourself to see the output you can run: | ||
|
|
||
| ``` | ||
| cd google-cloud-testing/storage-benchwrapper | ||
| protoc \ | ||
| --plugin=protoc-gen-grpc-java=build/exe/java_plugin/protoc-gen-grpc-java \ | ||
| --java_out=src/main/java \ | ||
| --grpc-java_out=src/main/java \ | ||
jeanbza marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| --proto_path=src/main/proto \ | ||
| src/main/proto/*.proto | ||
| ``` | ||
|
|
||
| Note that you'll need to delete these, or uncomment the plugin, since multiple | ||
| definitions of the same class are not allowed. | ||
|
|
||
| Note that these should not be committed into git. | ||
jeanbza marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| Note that you can also `mvn compile -DskipTests=true` and see sources in | ||
| `target/generated-sources/`. | ||
|
|
||
| ## Debugging HTTP requests | ||
|
|
||
| To debug HTTP requests, place a `logging.properties` at | ||
| `google-cloud-testing/storage-benchwrapper/logging.properties` with the | ||
| following contents: | ||
|
|
||
| ``` | ||
| # Properties file which configures the operation of the JDK logging facility. | ||
| # The system will look for this config file to be specified as a system property: | ||
| # -Djava.util.logging.config.file=${project_loc:googleplus-simple-cmdline-sample}/logging.properties | ||
|
|
||
| # Set up the console handler (uncomment "level" to show more fine-grained messages) | ||
| handlers = java.util.logging.ConsoleHandler | ||
| java.util.logging.ConsoleHandler.level = CONFIG | ||
|
|
||
| # Set up logging of HTTP requests and responses (uncomment "level" to show) | ||
| com.google.api.client.http.level = CONFIG | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| <?xml version="1.0"?> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
| <artifactId>benchwrapper</artifactId> | ||
| <version>0.0.0</version> | ||
jeanbza marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <packaging>jar</packaging> | ||
| <groupId>com.google.cloud</groupId> | ||
|
|
||
jeanbza marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <properties> | ||
| <grpcVersion>1.23.0</grpcVersion> | ||
| <protobufVersion>3.9.1</protobufVersion> | ||
| </properties> | ||
|
|
||
| <build> | ||
| <extensions> | ||
| <extension> | ||
| <groupId>kr.motd.maven</groupId> | ||
| <artifactId>os-maven-plugin</artifactId> | ||
| <version>1.5.0.Final</version> | ||
| </extension> | ||
| </extensions> | ||
|
|
||
| <plugins> | ||
| <!-- Auto-generate classes from .protos --> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-compiler-plugin</artifactId> | ||
| <version>3.8.0</version> | ||
| <configuration> | ||
| <source>1.8</source> | ||
| <target>1.8</target> | ||
| </configuration> | ||
| </plugin> | ||
| <plugin> | ||
| <groupId>org.xolstice.maven.plugins</groupId> | ||
jeanbza marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <artifactId>protobuf-maven-plugin</artifactId> | ||
| <version>0.6.1</version> | ||
| <configuration> | ||
| <protocArtifact>com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}</protocArtifact> | ||
| <pluginId>grpc-java</pluginId> | ||
| <pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpcVersion}:exe:${os.detected.classifier}</pluginArtifact> | ||
| </configuration> | ||
| <executions> | ||
| <execution> | ||
| <goals> | ||
| <goal>compile</goal> | ||
| <goal>compile-custom</goal> | ||
| </goals> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
|
|
||
| <!-- Protobuf runtime --> | ||
| <plugin> | ||
| <groupId>org.codehaus.mojo</groupId> | ||
| <artifactId>exec-maven-plugin</artifactId> | ||
| <version>1.6.0</version> | ||
| <executions> | ||
| <execution> | ||
| <goals> | ||
| <goal>exec</goal> | ||
| </goals> | ||
| </execution> | ||
| </executions> | ||
| <configuration> | ||
| <mainClass>com.google.cloud.benchwrapper.Main</mainClass> | ||
| <executable>maven</executable> | ||
| <skip>false</skip> | ||
| </configuration> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
|
|
||
| <dependencies> | ||
| <!-- storage --> | ||
| <dependency> | ||
| <groupId>com.google.cloud</groupId> | ||
| <artifactId>google-cloud-storage</artifactId> | ||
| <version>1.85.0</version> | ||
| </dependency> | ||
|
|
||
| <!-- protobuf --> | ||
| <dependency> | ||
| <groupId>com.google.protobuf</groupId> | ||
| <artifactId>protobuf-java</artifactId> | ||
| <version>${protobufVersion}</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>io.grpc</groupId> | ||
| <artifactId>grpc-protobuf</artifactId> | ||
| <version>${grpcVersion}</version> | ||
| </dependency> | ||
|
|
||
| <!-- grpc --> | ||
| <dependency> | ||
| <groupId>io.grpc</groupId> | ||
| <artifactId>grpc-netty-shaded</artifactId> | ||
| <version>${grpcVersion}</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>io.grpc</groupId> | ||
| <artifactId>grpc-stub</artifactId> | ||
| <version>${grpcVersion}</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>io.grpc</groupId> | ||
| <artifactId>grpc-netty</artifactId> | ||
| <version>${grpcVersion}</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>io.netty</groupId> | ||
| <artifactId>netty-tcnative-boringssl-static</artifactId> | ||
| <version>2.0.25.Final</version> | ||
| </dependency> | ||
| </dependencies> | ||
| </project> | ||
63 changes: 63 additions & 0 deletions
63
...-cloud-testing/storage-benchwrapper/src/main/java/com/google/cloud/benchwrapper/Main.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| /* | ||
| * Copyright 2019 Google LLC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * 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. | ||
| */ | ||
|
|
||
| package com.google.cloud.benchwrapper; | ||
|
|
||
| import java.util.Properties; | ||
| import io.grpc.Server; | ||
| import io.grpc.netty.NettyServerBuilder; | ||
|
|
||
| class Main { | ||
| public static void main(String[] args) throws Exception { | ||
| Properties properties = new Properties(System.getProperties()); | ||
| String port = properties.getProperty("port"); | ||
| if (port == null || port.equals("")) { | ||
| System.err.println("Usage: mvn clean install exec:java -DskipTests=true -Dport=8081"); | ||
| System.exit(1); | ||
| } | ||
|
|
||
| String storageEmulatorHost = System.getenv("STORAGE_EMULATOR_HOST"); | ||
| if (storageEmulatorHost == null || storageEmulatorHost.equals("")) { | ||
| // We could use system properties here too, but every other language uses | ||
| // an environment variable called STORAGE_EMULATOR_HOST, so the | ||
| // consistency is nice to maintain. | ||
| System.err.println("Please set STORAGE_EMULATOR_HOST=localhost:8080"); | ||
| System.exit(1); | ||
| } | ||
|
|
||
| System.out.println("Server starting up..."); | ||
|
|
||
| int portInt = Integer.parseInt(port); | ||
| final Server server = NettyServerBuilder | ||
| .forPort(portInt) | ||
| .addService(new StorageBenchWrapperImpl(storageEmulatorHost)) | ||
| .build() | ||
| .start(); | ||
|
|
||
| System.out.println("Server starting up... done. Listening on " + port); | ||
| Runtime.getRuntime().addShutdownHook(new Thread() { | ||
| @Override | ||
| public void run() { | ||
| // Use stderr here since the logger may have been reset by its JVM shutdown hook. | ||
| System.err.println("Shutting down gRPC server since JVM is shutting down"); | ||
| server.shutdown(); | ||
| } | ||
| }); | ||
|
|
||
| server.awaitTermination(); | ||
| } | ||
| } | ||
|
|
69 changes: 69 additions & 0 deletions
69
...age-benchwrapper/src/main/java/com/google/cloud/benchwrapper/StorageBenchWrapperImpl.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| /* | ||
| * Copyright 2019 Google LLC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * 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. | ||
| */ | ||
|
|
||
| package com.google.cloud.benchwrapper; | ||
|
|
||
| import io.grpc.stub.StreamObserver; | ||
| import java.io.IOException; | ||
| import java.nio.ByteBuffer; | ||
|
|
||
| import com.google.cloud.benchwrapper.StorageBenchWrapperGrpc.StorageBenchWrapperImplBase; | ||
| import com.google.cloud.ReadChannel; | ||
| import com.google.cloud.storage.Blob; | ||
| import com.google.cloud.storage.BlobId; | ||
| import com.google.cloud.storage.Storage; | ||
| import com.google.cloud.storage.StorageException; | ||
| import com.google.cloud.storage.StorageOptions; | ||
|
|
||
| class StorageBenchWrapperImpl extends StorageBenchWrapperImplBase { | ||
| private Storage client; | ||
jeanbza marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| public StorageBenchWrapperImpl(String storageEmulatorHost) { | ||
| client = StorageOptions.newBuilder() | ||
| .setHost("http://" + storageEmulatorHost) | ||
BenWhitehead marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| .build() | ||
| .getService(); | ||
| } | ||
|
|
||
| public void write(ObjectWrite request, StreamObserver<EmptyResponse> responseObserver) { | ||
| System.out.println("write has been called"); | ||
| EmptyResponse reply = EmptyResponse.newBuilder().build(); | ||
| responseObserver.onNext(reply); | ||
| responseObserver.onCompleted(); | ||
| } | ||
|
|
||
| public void read(ObjectRead request, StreamObserver<EmptyResponse> responseObserver) { | ||
| System.out.println("read has been called"); | ||
|
|
||
| Blob blob = client.get(BlobId.of(request.getBucketName(), request.getObjectName())); | ||
|
|
||
| try (ReadChannel reader = blob.reader()) { | ||
| ByteBuffer bytes = ByteBuffer.allocate(64 * 1024); | ||
| while (reader.read(bytes) > 0) { | ||
| bytes.flip(); | ||
| // do nothing with bytes | ||
| bytes.clear(); | ||
| } | ||
| } catch (Exception e) { | ||
| e.printStackTrace(); | ||
| System.exit(1); | ||
jeanbza marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| EmptyResponse reply = EmptyResponse.newBuilder().build(); | ||
| responseObserver.onNext(reply); | ||
| responseObserver.onCompleted(); | ||
| } | ||
| } | ||
45 changes: 45 additions & 0 deletions
45
google-cloud-testing/storage-benchwrapper/src/main/proto/storage.proto
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| // Copyright 2019 Google LLC | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // 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. | ||
|
|
||
| syntax = "proto3"; | ||
|
|
||
| package storage_bench; | ||
| option java_multiple_files = true; | ||
| option java_package = "com.google.cloud.benchwrapper"; | ||
|
|
||
| message ObjectRead{ | ||
| // The bucket string identifier. | ||
| string bucketName = 1; | ||
| // The object/blob string identifier. | ||
| string objectName = 2; | ||
| } | ||
|
|
||
| message ObjectWrite{ | ||
| // The bucket string identifier. | ||
| string bucketName = 1; | ||
| // The object/blob string identifiers. | ||
| string objectName = 2; | ||
| // The string containing the upload file path. | ||
| string destination = 3; | ||
| } | ||
|
|
||
| message EmptyResponse{ | ||
| } | ||
|
|
||
| service StorageBenchWrapper{ | ||
| // Performs an upload from a specific object. | ||
| rpc Write(ObjectWrite) returns (EmptyResponse) {} | ||
| // Read a specific object. | ||
| rpc Read(ObjectRead) returns (EmptyResponse){} | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.