Skip to content

Commit f1cdd81

Browse files
sduskischingor13
authored andcommitted
---
yaml --- r: 29523 b: refs/heads/autosynth-monitoring c: cef6cd0 h: refs/heads/master i: 29521: 4ef9ee6 29519: 4505c24
1 parent 28b98de commit f1cdd81

2 files changed

Lines changed: 25 additions & 25 deletions

File tree

  • branches/autosynth-monitoring/google-cloud-clients/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ refs/tags/v0.66.0: ed6a3f57cbdaa20339a1995f7d7d53b172a5b8ef
113113
refs/tags/v0.67.0: 30b56f02092efc6f3c3667650ea8b8825003e0b7
114114
refs/heads/autosynth-compute: c0ad4e5b54b2b167d47e508ca215c039404837d3
115115
refs/heads/autosynth-container: e9a9a8564756e20770320ed54eafa867040a7690
116-
refs/heads/autosynth-monitoring: 7f889b23478560861361715a9021c5477361f33e
116+
refs/heads/autosynth-monitoring: cef6cd03f92eb9ac491fcb97639769fd06cde841
117117
refs/heads/autosynth-pubsub: 8aac5a6202d83e8d67f5cb1d58f0adf9f2622aeb
118118
refs/heads/autosynth-video-intelligence: 82b145665822830c46d47eb8925edb2d842d6815
119119
refs/heads/autosynth-vision: 01ef61bcef344ceee0198f56f18bc1db20201261

branches/autosynth-monitoring/google-cloud-clients/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/Publisher.java

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -222,14 +222,7 @@ && hasBatchingBytes()
222222
}
223223
}
224224
// Setup the next duration based delivery alarm if there are messages batched.
225-
if (!messagesBatch.isEmpty()) {
226-
setupDurationBasedPublishAlarm();
227-
} else if (currentAlarmFuture != null) {
228-
logger.log(Level.FINER, "Cancelling alarm, no more messages");
229-
if (activeAlarm.getAndSet(false)) {
230-
currentAlarmFuture.cancel(false);
231-
}
232-
}
225+
setupAlarm();
233226
} finally {
234227
messagesBatchLock.unlock();
235228
}
@@ -266,22 +259,29 @@ public void run() {
266259
return publishResult;
267260
}
268261

269-
private void setupDurationBasedPublishAlarm() {
270-
if (!activeAlarm.getAndSet(true)) {
271-
long delayThresholdMs = getBatchingSettings().getDelayThreshold().toMillis();
272-
logger.log(Level.FINER, "Setting up alarm for the next {0} ms.", delayThresholdMs);
273-
currentAlarmFuture =
274-
executor.schedule(
275-
new Runnable() {
276-
@Override
277-
public void run() {
278-
logger.log(Level.FINER, "Sending messages based on schedule.");
279-
activeAlarm.getAndSet(false);
280-
publishAllOutstanding();
281-
}
282-
},
283-
delayThresholdMs,
284-
TimeUnit.MILLISECONDS);
262+
private void setupAlarm() {
263+
if (!messagesBatch.isEmpty()) {
264+
if (!activeAlarm.getAndSet(true)) {
265+
long delayThresholdMs = getBatchingSettings().getDelayThreshold().toMillis();
266+
logger.log(Level.FINER, "Setting up alarm for the next {0} ms.", delayThresholdMs);
267+
currentAlarmFuture =
268+
executor.schedule(
269+
new Runnable() {
270+
@Override
271+
public void run() {
272+
logger.log(Level.FINER, "Sending messages based on schedule.");
273+
activeAlarm.getAndSet(false);
274+
publishAllOutstanding();
275+
}
276+
},
277+
delayThresholdMs,
278+
TimeUnit.MILLISECONDS);
279+
}
280+
} else if (currentAlarmFuture != null) {
281+
logger.log(Level.FINER, "Cancelling alarm, no more messages");
282+
if (activeAlarm.getAndSet(false)) {
283+
currentAlarmFuture.cancel(false);
284+
}
285285
}
286286
}
287287

0 commit comments

Comments
 (0)