Skip to content

Commit e7ffbda

Browse files
chore: remove unnecessary variable (#2400)
Change-Id: Ide37e9226983ffaa32d8d2cda03c1fd8d1ad7fff Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [ ] Make sure to open an issue as a [bug/issue](https://togithub.com/googleapis/java-bigtable/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) - [ ] Rollback plan is reviewed and LGTMed - [ ] All new data plane features have a completed end to end testing plan Fixes #<issue_number_goes_here> ☕️ If you write sample code, please follow the [samples format]( https://togithub.com/GoogleCloudPlatform/java-docs-samples/blob/main/SAMPLE_FORMAT.md).
1 parent 0ad0c95 commit e7ffbda

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/BuiltinMetricsTracer.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ class BuiltinMetricsTracer extends BigtableTracer {
6767
// Stopwatch is not thread safe so this is a workaround to check if the stopwatch changes is
6868
// flushed to memory.
6969
private final Stopwatch serverLatencyTimer = Stopwatch.createUnstarted();
70-
private boolean serverLatencyTimerIsRunning = false;
7170
private final Object timerLock = new Object();
7271

7372
private boolean flowControlIsDisabled = false;
@@ -163,9 +162,8 @@ public void attemptStarted(Object request, int attemptNumber) {
163162
}
164163
if (!flowControlIsDisabled) {
165164
synchronized (timerLock) {
166-
if (!serverLatencyTimerIsRunning) {
165+
if (!serverLatencyTimer.isRunning()) {
167166
serverLatencyTimer.start();
168-
serverLatencyTimerIsRunning = true;
169167
}
170168
}
171169
}
@@ -198,9 +196,8 @@ public void onRequest(int requestCount) {
198196
// On request is only called when auto flow control is disabled. When auto flow control is
199197
// disabled, server latency is measured between onRequest and onResponse.
200198
synchronized (timerLock) {
201-
if (!serverLatencyTimerIsRunning) {
199+
if (!serverLatencyTimer.isRunning()) {
202200
serverLatencyTimer.start();
203-
serverLatencyTimerIsRunning = true;
204201
}
205202
}
206203
}
@@ -219,10 +216,9 @@ public void responseReceived() {
219216
// latency is measured between afterResponse and responseReceived.
220217
// In all the cases, we want to stop the serverLatencyTimer here.
221218
synchronized (timerLock) {
222-
if (serverLatencyTimerIsRunning) {
219+
if (serverLatencyTimer.isRunning()) {
223220
totalServerLatencyNano.addAndGet(serverLatencyTimer.elapsed(TimeUnit.NANOSECONDS));
224221
serverLatencyTimer.reset();
225-
serverLatencyTimerIsRunning = false;
226222
}
227223
}
228224
}
@@ -235,9 +231,8 @@ public void afterResponse(long applicationLatency) {
235231
// received. If flow control is disabled but requestLeft is greater than 0,
236232
// also start the timer to count the time between afterResponse and responseReceived.
237233
synchronized (timerLock) {
238-
if (!serverLatencyTimerIsRunning) {
234+
if (!serverLatencyTimer.isRunning()) {
239235
serverLatencyTimer.start();
240-
serverLatencyTimerIsRunning = true;
241236
}
242237
}
243238
}
@@ -324,11 +319,10 @@ private void recordAttemptCompletion(@Nullable Throwable status) {
324319
// If the attempt failed, the time spent in retry should be counted in application latency.
325320
// Stop the stopwatch and decrement requestLeft.
326321
synchronized (timerLock) {
327-
if (serverLatencyTimerIsRunning) {
322+
if (serverLatencyTimer.isRunning()) {
328323
requestLeft.decrementAndGet();
329324
totalServerLatencyNano.addAndGet(serverLatencyTimer.elapsed(TimeUnit.NANOSECONDS));
330325
serverLatencyTimer.reset();
331-
serverLatencyTimerIsRunning = false;
332326
}
333327
}
334328

0 commit comments

Comments
 (0)