Skip to content

Commit 89ee1f2

Browse files
sduskischingor13
authored andcommitted
---
yaml --- r: 31867 b: refs/heads/autosynth-datastore c: cef6cd0 h: refs/heads/master i: 31865: 8d70f1b 31863: 81ae99c
1 parent 05c750c commit 89ee1f2

2 files changed

Lines changed: 25 additions & 25 deletions

File tree

  • branches/autosynth-datastore/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
@@ -127,7 +127,7 @@ refs/heads/autosynth-bigquerystorage: a345f72d7a6358e9fea9dcdae94ec85a27da3088
127127
refs/heads/autosynth-bigtable: 2a6af7e2959fd79c99b8ca5d773f29a6434b546d
128128
refs/heads/autosynth-bigtable-admin: 6379a2bc712f2736c83de0e009b4d26da4fa82ca
129129
refs/heads/autosynth-containeranalysis: 18d210f81f17cf74864d0db2c29e834302f74f2a
130-
refs/heads/autosynth-datastore: 7f889b23478560861361715a9021c5477361f33e
130+
refs/heads/autosynth-datastore: cef6cd03f92eb9ac491fcb97639769fd06cde841
131131
refs/heads/autosynth-dialogflow: 841930a680ebe370c9fc6ae824465f6bc51a5a46
132132
refs/heads/autosynth-errorreporting: 3f176c20b55dfaaa8fc32f28d82b31784b93e636
133133
refs/heads/autosynth-firestore: 983c75e4fb1076502c8cac73ef0538bdb10884f3

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