1616
1717package com .google .cloud .pubsub .spi .v1 ;
1818
19+ import com .google .api .gax .batching .BatchingSettings ;
1920import com .google .api .core .ApiFuture ;
2021import com .google .api .core .ApiFutures ;
21- import com .google .api .core .SettableApiFuture ;
22- import com .google .api .gax .batching .BatchingSettings ;
2322import com .google .api .gax .batching .FlowControlSettings ;
2423import com .google .api .gax .batching .FlowController ;
24+ import com .google .api .gax .retrying .RetrySettings ;
25+ import com .google .api .core .SettableApiFuture ;
2526import com .google .api .gax .grpc .ChannelProvider ;
2627import com .google .api .gax .grpc .ExecutorProvider ;
2728import com .google .api .gax .grpc .InstantiatingExecutorProvider ;
28- import com .google .api .gax .retrying .RetrySettings ;
2929import com .google .auth .oauth2 .GoogleCredentials ;
3030import com .google .common .annotations .VisibleForTesting ;
3131import com .google .common .base .Preconditions ;
3232import com .google .common .collect .ImmutableList ;
3333import com .google .common .util .concurrent .FutureCallback ;
3434import com .google .common .util .concurrent .Futures ;
35- import com .google .pubsub .v1 .*;
35+ import com .google .pubsub .v1 .PublishRequest ;
36+ import com .google .pubsub .v1 .PublishResponse ;
37+ import com .google .pubsub .v1 .PublisherGrpc ;
38+ import com .google .pubsub .v1 .PubsubMessage ;
39+ import com .google .pubsub .v1 .TopicName ;
3640import io .grpc .ManagedChannel ;
3741import io .grpc .Status ;
38- import org .threeten .bp .Duration ;
39-
4042import java .io .IOException ;
4143import java .util .ArrayList ;
4244import java .util .Iterator ;
5153import java .util .concurrent .locks .ReentrantLock ;
5254import java .util .logging .Level ;
5355import java .util .logging .Logger ;
56+ import org .threeten .bp .Duration ;
5457
5558/**
5659 * A Cloud Pub/Sub <a href="https://cloud.google.com/pubsub/docs/publisher">publisher</a>, that is
@@ -340,8 +343,7 @@ public void onSuccess(PublishResponse result) {
340343 + "the expected %s results. Please contact Cloud Pub/Sub support "
341344 + "if this frequently occurs" ,
342345 result .getMessageIdsCount (), outstandingBatch .size ()));
343- for (OutstandingPublish oustandingMessage :
344- outstandingBatch .outstandingPublishes ) {
346+ for (OutstandingPublish oustandingMessage : outstandingBatch .outstandingPublishes ) {
345347 oustandingMessage .publishResult .setException (t );
346348 }
347349 return ;
@@ -364,10 +366,10 @@ public void onFailure(Throwable t) {
364366 computeNextBackoffDelayMs (outstandingBatch , retrySettings , longRandom );
365367
366368 if (!isRetryable (t )
367- || retrySettings .getMaxAttempts () > 0 && outstandingBatch .getAttempt () > retrySettings .getMaxAttempts ()
369+ || retrySettings .getMaxAttempts () > 0
370+ && outstandingBatch .getAttempt () > retrySettings .getMaxAttempts ()
368371 || System .currentTimeMillis () + nextBackoffDelay
369- > outstandingBatch .creationTime
370- + retrySettings .getTotalTimeout ().toMillis ()) {
372+ > outstandingBatch .creationTime + retrySettings .getTotalTimeout ().toMillis ()) {
371373 try {
372374 for (OutstandingPublish outstandingPublish :
373375 outstandingBatch .outstandingPublishes ) {
@@ -405,10 +407,10 @@ private static final class OutstandingBatch {
405407 this .batchSizeBytes = batchSizeBytes ;
406408 }
407409
408-
409410 public int getAttempt () {
410411 return attempt ;
411412 }
413+
412414 public int size () {
413415 return outstandingPublishes .size ();
414416 }
@@ -507,7 +509,8 @@ interface LongRandom {
507509 * Constructs a new {@link Builder} using the given topic.
508510 *
509511 * <p>Example of creating a {@code Publisher}.
510- * <pre> {@code
512+ *
513+ * <pre>{@code
511514 * String projectName = "my_project";
512515 * String topicName = "my_topic";
513516 * TopicName topic = TopicName.create(projectName, topicName);
@@ -519,7 +522,6 @@ interface LongRandom {
519522 * publisher.shutdown();
520523 * }
521524 * }</pre>
522- *
523525 */
524526 public static Builder defaultBuilder (TopicName topicName ) {
525527 return new Builder (topicName );
0 commit comments