// Path: end2end-test-examples/gcs/src/main/java/io/grpc/gcs/Args.java
// public static final String METHOD_RANDOM = "random";
// 
// Path: end2end-test-examples/gcs/src/main/java/io/grpc/gcs/Args.java
// public static final String METHOD_READ = "read";
// 
// Path: end2end-test-examples/gcs/src/main/java/io/grpc/gcs/Args.java
// public static final String METHOD_WRITE = "write";


import static io.grpc.gcs.Args.METHOD_RANDOM;
import static io.grpc.gcs.Args.METHOD_READ;
import static io.grpc.gcs.Args.METHOD_WRITE;
import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
import com.google.cloud.hadoop.gcsio.GoogleCloudStorageFileSystem;
import com.google.cloud.hadoop.gcsio.GoogleCloudStorageFileSystemOptions;
import com.google.cloud.hadoop.gcsio.GoogleCloudStorageOptions;
import com.google.cloud.hadoop.gcsio.GoogleCloudStorageReadOptions;
import com.google.cloud.hadoop.util.AsyncWriteChannelOptions;
import com.google.common.base.Strings;
import java.io.IOException;
import java.net.URI;
import java.nio.ByteBuffer;
import java.nio.channels.ReadableByteChannel;
import java.nio.channels.SeekableByteChannel;
import java.nio.channels.WritableByteChannel;
import java.util.Arrays;
import java.util.Random;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
                    .setGrpcChecksumsEnabled(args.checksum)
                    .build())
            .setWriteChannelOptions(
                AsyncWriteChannelOptions.builder().setGrpcChecksumsEnabled(args.checksum).build());
    if (!Strings.isNullOrEmpty(args.host2)) {
      optsBuilder.setGrpcServerAddress(args.host2);
    }
    this.gcsOpts = optsBuilder.build();
  }

  public void startCalls(ResultTable results) throws InterruptedException, IOException {
    if (args.threads == 1) {
      switch (args.method) {
        case METHOD_READ:
          makeMediaRequest(results);
          break;
        case METHOD_WRITE:
          makeWriteRequest(results, 0);
          break;
        case METHOD_RANDOM:
          makeRandomMediaRequest(results);
          break;
        default:
          logger.warning("Please provide valid methods with --method");
      }
    } else {
      ThreadPoolExecutor threadPoolExecutor =
          (ThreadPoolExecutor) Executors.newFixedThreadPool(args.threads);
      try {
        switch (args.method) {
// Path: end2end-test-examples/gcs/src/main/java/io/grpc/gcs/Args.java
// public static final String METHOD_RANDOM = "random";
// 
// Path: end2end-test-examples/gcs/src/main/java/io/grpc/gcs/Args.java
// public static final String METHOD_READ = "read";
// 
// Path: end2end-test-examples/gcs/src/main/java/io/grpc/gcs/Args.java
// public static final String METHOD_WRITE = "write";


// Path: end2end-test-examples/gcs/src/main/java/io/grpc/gcs/GcsioClient.java
import static io.grpc.gcs.Args.METHOD_RANDOM;
import static io.grpc.gcs.Args.METHOD_READ;
import static io.grpc.gcs.Args.METHOD_WRITE;
import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
import com.google.cloud.hadoop.gcsio.GoogleCloudStorageFileSystem;
import com.google.cloud.hadoop.gcsio.GoogleCloudStorageFileSystemOptions;
import com.google.cloud.hadoop.gcsio.GoogleCloudStorageOptions;
import com.google.cloud.hadoop.gcsio.GoogleCloudStorageReadOptions;
import com.google.cloud.hadoop.util.AsyncWriteChannelOptions;
import com.google.common.base.Strings;
import java.io.IOException;
import java.net.URI;
import java.nio.ByteBuffer;
import java.nio.channels.ReadableByteChannel;
import java.nio.channels.SeekableByteChannel;
import java.nio.channels.WritableByteChannel;
import java.util.Arrays;
import java.util.Random;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;

                    .setGrpcChecksumsEnabled(args.checksum)
                    .build())
            .setWriteChannelOptions(
                AsyncWriteChannelOptions.builder().setGrpcChecksumsEnabled(args.checksum).build());
    if (!Strings.isNullOrEmpty(args.host2)) {
      optsBuilder.setGrpcServerAddress(args.host2);
    }
    this.gcsOpts = optsBuilder.build();
  }

  public void startCalls(ResultTable results) throws InterruptedException, IOException {
    if (args.threads == 1) {
      switch (args.method) {
        case METHOD_READ:
          makeMediaRequest(results);
          break;
        case METHOD_WRITE:
          makeWriteRequest(results, 0);
          break;
        case METHOD_RANDOM:
          makeRandomMediaRequest(results);
          break;
        default:
          logger.warning("Please provide valid methods with --method");
      }
    } else {
      ThreadPoolExecutor threadPoolExecutor =
          (ThreadPoolExecutor) Executors.newFixedThreadPool(args.threads);
      try {
        switch (args.method) {
          case METHOD_READ: