|
| 1 | +/* |
| 2 | + * Copyright 2023 Google LLC |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package com.google.cloud.storage.benchmarking; |
| 18 | + |
| 19 | +import com.google.common.base.MoreObjects; |
| 20 | +import java.util.Objects; |
| 21 | + |
| 22 | +final class CloudMonitoringResult { |
| 23 | + private final String library; |
| 24 | + private final String api; |
| 25 | + private final String op; |
| 26 | + |
| 27 | + private final int workers; |
| 28 | + private final int object_size; |
| 29 | + private final int app_buffer_size; |
| 30 | + private final int chunksize; |
| 31 | + private final boolean crc32c_enabled; |
| 32 | + private final boolean md5_enabled; |
| 33 | + private final int cpu_time_us; |
| 34 | + private final String bucket_name; |
| 35 | + private final String status; |
| 36 | + private final String transfer_size; |
| 37 | + private final String transfer_offset; |
| 38 | + private final String failure_msg; |
| 39 | + private final double throughput; |
| 40 | + |
| 41 | + CloudMonitoringResult( |
| 42 | + String library, |
| 43 | + String api, |
| 44 | + String op, |
| 45 | + int workers, |
| 46 | + int objectSize, |
| 47 | + int appBufferSize, |
| 48 | + int chunksize, |
| 49 | + boolean crc32cEnabled, |
| 50 | + boolean md5Enabled, |
| 51 | + int cpuTimeUs, |
| 52 | + String bucketName, |
| 53 | + String status, |
| 54 | + String transferSize, |
| 55 | + String transferOffset, |
| 56 | + String failureMsg, |
| 57 | + double throughput) { |
| 58 | + this.library = library; |
| 59 | + this.api = api; |
| 60 | + this.op = op; |
| 61 | + this.workers = workers; |
| 62 | + this.object_size = objectSize; |
| 63 | + this.app_buffer_size = appBufferSize; |
| 64 | + this.chunksize = chunksize; |
| 65 | + this.crc32c_enabled = crc32cEnabled; |
| 66 | + this.md5_enabled = md5Enabled; |
| 67 | + this.cpu_time_us = cpuTimeUs; |
| 68 | + this.bucket_name = bucketName; |
| 69 | + this.status = status; |
| 70 | + this.transfer_size = transferSize; |
| 71 | + this.transfer_offset = transferOffset; |
| 72 | + this.failure_msg = failureMsg; |
| 73 | + this.throughput = throughput; |
| 74 | + } |
| 75 | + |
| 76 | + public static Builder newBuilder() { |
| 77 | + return new Builder(); |
| 78 | + } |
| 79 | + |
| 80 | + @Override |
| 81 | + public String toString() { |
| 82 | + return MoreObjects.toStringHelper(this) |
| 83 | + .add("library", library) |
| 84 | + .add("api", api) |
| 85 | + .add("op", op) |
| 86 | + .add("workers", workers) |
| 87 | + .add("object_size", object_size) |
| 88 | + .add("app_buffer_size", app_buffer_size) |
| 89 | + .add("chunksize", chunksize) |
| 90 | + .add("crc32c_enabled", crc32c_enabled) |
| 91 | + .add("md5_enabled", md5_enabled) |
| 92 | + .add("cpu_time_us", cpu_time_us) |
| 93 | + .add("bucket_name", bucket_name) |
| 94 | + .add("status", status) |
| 95 | + .add("transfer_size", transfer_size) |
| 96 | + .add("transfer_offset", transfer_offset) |
| 97 | + .add("failure_msg", failure_msg) |
| 98 | + .add("throughput", throughput) |
| 99 | + .toString(); |
| 100 | + } |
| 101 | + |
| 102 | + @Override |
| 103 | + public boolean equals(Object o) { |
| 104 | + if (this == o) { |
| 105 | + return true; |
| 106 | + } |
| 107 | + if (!(o instanceof CloudMonitoringResult)) { |
| 108 | + return false; |
| 109 | + } |
| 110 | + CloudMonitoringResult result = (CloudMonitoringResult) o; |
| 111 | + return workers == result.workers |
| 112 | + && object_size == result.object_size |
| 113 | + && app_buffer_size == result.app_buffer_size |
| 114 | + && chunksize == result.chunksize |
| 115 | + && crc32c_enabled == result.crc32c_enabled |
| 116 | + && md5_enabled == result.md5_enabled |
| 117 | + && cpu_time_us == result.cpu_time_us |
| 118 | + && Double.compare(result.throughput, throughput) == 0 |
| 119 | + && Objects.equals(library, result.library) |
| 120 | + && Objects.equals(api, result.api) |
| 121 | + && Objects.equals(op, result.op) |
| 122 | + && Objects.equals(bucket_name, result.bucket_name) |
| 123 | + && Objects.equals(status, result.status) |
| 124 | + && Objects.equals(transfer_size, result.transfer_size) |
| 125 | + && Objects.equals(transfer_offset, result.transfer_offset) |
| 126 | + && Objects.equals(failure_msg, result.failure_msg); |
| 127 | + } |
| 128 | + |
| 129 | + @Override |
| 130 | + public int hashCode() { |
| 131 | + return Objects.hash( |
| 132 | + library, |
| 133 | + api, |
| 134 | + op, |
| 135 | + workers, |
| 136 | + object_size, |
| 137 | + app_buffer_size, |
| 138 | + chunksize, |
| 139 | + crc32c_enabled, |
| 140 | + md5_enabled, |
| 141 | + cpu_time_us, |
| 142 | + bucket_name, |
| 143 | + status, |
| 144 | + transfer_size, |
| 145 | + transfer_offset, |
| 146 | + failure_msg, |
| 147 | + throughput); |
| 148 | + } |
| 149 | + |
| 150 | + public static class Builder { |
| 151 | + |
| 152 | + private String library; |
| 153 | + private String api; |
| 154 | + private String op; |
| 155 | + private int workers; |
| 156 | + private int objectSize; |
| 157 | + private int appBufferSize; |
| 158 | + private int chunksize; |
| 159 | + private boolean crc32cEnabled; |
| 160 | + private boolean md5Enabled; |
| 161 | + private int cpuTimeUs; |
| 162 | + private String bucketName; |
| 163 | + private String status; |
| 164 | + private String transferSize; |
| 165 | + private String transferOffset; |
| 166 | + private String failureMsg; |
| 167 | + private double throughput; |
| 168 | + |
| 169 | + public Builder setLibrary(String library) { |
| 170 | + this.library = library; |
| 171 | + return this; |
| 172 | + } |
| 173 | + |
| 174 | + public Builder setApi(String api) { |
| 175 | + this.api = api; |
| 176 | + return this; |
| 177 | + } |
| 178 | + |
| 179 | + public Builder setOp(String op) { |
| 180 | + this.op = op; |
| 181 | + return this; |
| 182 | + } |
| 183 | + |
| 184 | + public Builder setWorkers(int workers) { |
| 185 | + this.workers = workers; |
| 186 | + return this; |
| 187 | + } |
| 188 | + |
| 189 | + public Builder setObjectSize(int objectSize) { |
| 190 | + this.objectSize = objectSize; |
| 191 | + return this; |
| 192 | + } |
| 193 | + |
| 194 | + public Builder setAppBufferSize(int appBufferSize) { |
| 195 | + this.appBufferSize = appBufferSize; |
| 196 | + return this; |
| 197 | + } |
| 198 | + |
| 199 | + public Builder setChunksize(int chunksize) { |
| 200 | + this.chunksize = chunksize; |
| 201 | + return this; |
| 202 | + } |
| 203 | + |
| 204 | + public Builder setCrc32cEnabled(boolean crc32cEnabled) { |
| 205 | + this.crc32cEnabled = crc32cEnabled; |
| 206 | + return this; |
| 207 | + } |
| 208 | + |
| 209 | + public Builder setMd5Enabled(boolean md5Enabled) { |
| 210 | + this.md5Enabled = md5Enabled; |
| 211 | + return this; |
| 212 | + } |
| 213 | + |
| 214 | + public Builder setCpuTimeUs(int cpuTimeUs) { |
| 215 | + this.cpuTimeUs = cpuTimeUs; |
| 216 | + return this; |
| 217 | + } |
| 218 | + |
| 219 | + public Builder setBucketName(String bucketName) { |
| 220 | + this.bucketName = bucketName; |
| 221 | + return this; |
| 222 | + } |
| 223 | + |
| 224 | + public Builder setStatus(String status) { |
| 225 | + this.status = status; |
| 226 | + return this; |
| 227 | + } |
| 228 | + |
| 229 | + public Builder setTransferSize(String transferSize) { |
| 230 | + this.transferSize = transferSize; |
| 231 | + return this; |
| 232 | + } |
| 233 | + |
| 234 | + public Builder setTransferOffset(String transferOffset) { |
| 235 | + this.transferOffset = transferOffset; |
| 236 | + return this; |
| 237 | + } |
| 238 | + |
| 239 | + public Builder setFailureMsg(String failureMsg) { |
| 240 | + this.failureMsg = failureMsg; |
| 241 | + return this; |
| 242 | + } |
| 243 | + |
| 244 | + public Builder setThroughput(double throughput) { |
| 245 | + this.throughput = throughput; |
| 246 | + return this; |
| 247 | + } |
| 248 | + |
| 249 | + public CloudMonitoringResult build() { |
| 250 | + return new CloudMonitoringResult( |
| 251 | + library, |
| 252 | + api, |
| 253 | + op, |
| 254 | + workers, |
| 255 | + objectSize, |
| 256 | + appBufferSize, |
| 257 | + chunksize, |
| 258 | + crc32cEnabled, |
| 259 | + md5Enabled, |
| 260 | + cpuTimeUs, |
| 261 | + bucketName, |
| 262 | + status, |
| 263 | + transferSize, |
| 264 | + transferOffset, |
| 265 | + failureMsg, |
| 266 | + throughput); |
| 267 | + } |
| 268 | + } |
| 269 | +} |
0 commit comments