Skip to content

Commit cf246fb

Browse files
sduskischingor13
authored andcommitted
---
yaml --- r: 30185 b: refs/heads/autosynth-asset c: cef6cd0 h: refs/heads/master i: 30183: 34a5de4
1 parent 53e7fe2 commit cf246fb

2 files changed

Lines changed: 25 additions & 25 deletions

File tree

  • branches/autosynth-asset/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
@@ -120,7 +120,7 @@ refs/heads/autosynth-vision: 20ee492a4f6a5cf37dce4142ffc372d7054c5ebd
120120
refs/heads/spanner: b01127f885b4611bf1852abb0ce481eeb7fcc131
121121
refs/tags/v0.68.0: 9cc799fcf68c82ab431d425fefa58ef615ce8e5b
122122
refs/tags/v0.69.0: 78f67a29e8b9c46ba01de566a2eae0fd1c03edea
123-
refs/heads/autosynth-asset: 7f889b23478560861361715a9021c5477361f33e
123+
refs/heads/autosynth-asset: cef6cd03f92eb9ac491fcb97639769fd06cde841
124124
refs/heads/autosynth-automl: 7fcabb1e54ca9ded6bec10f41590d29ece3a6367
125125
refs/heads/autosynth-bigquerydatatransfer: d88aa5aae5fd9d3c6d75bbab1a05162c6d4d948f
126126
refs/heads/autosynth-bigquerystorage: d2c53da3b012e38c662e4df0738042435f19365f

branches/autosynth-asset/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)