2424import com .google .bigtable .v2 .ClientConfiguration ;
2525import com .google .bigtable .v2 .GetClientConfigurationRequest ;
2626import com .google .bigtable .v2 .OpenSessionResponse ;
27+ import com .google .bigtable .v2 .PeerInfo ;
2728import com .google .bigtable .v2 .SessionRequest ;
2829import com .google .bigtable .v2 .SessionResponse ;
2930import com .google .cloud .bigtable .data .v2 .BigtableDataSettings ;
3031import com .google .cloud .bigtable .data .v2 .models .Query ;
3132import com .google .cloud .bigtable .data .v2 .models .Row ;
3233import com .google .cloud .bigtable .data .v2 .models .TableId ;
34+ import io .grpc .Context ;
35+ import io .grpc .ForwardingServerCall ;
3336import io .grpc .Metadata ;
37+ import io .grpc .Server ;
3438import io .grpc .ServerCall ;
3539import io .grpc .ServerCallHandler ;
3640import io .grpc .ServerInterceptor ;
3741import io .grpc .netty .shaded .io .grpc .netty .NettyServerBuilder ;
3842import io .grpc .stub .StreamObserver ;
3943import java .io .IOException ;
44+ import java .util .Base64 ;
4045import java .util .concurrent .ExecutionException ;
46+ import java .util .concurrent .Executors ;
47+ import java .util .concurrent .ScheduledExecutorService ;
4148import java .util .concurrent .TimeUnit ;
4249import org .junit .After ;
4350import org .junit .Before ;
4451import org .junit .Test ;
4552
4653public class SessionDeadlineTest {
4754
48- private io . grpc . Server server ;
55+ private Server server ;
4956 private EnhancedBigtableStubSettings defaultSettings ;
5057 private FakeDataService fakeDataService ;
5158
@@ -119,8 +126,8 @@ public void testMissedHeartbeat() throws Exception {
119126 try (EnhancedBigtableStub stub = EnhancedBigtableStub .create (settings )) {
120127 Query request = Query .create (TableId .of ("fake-table" )).rowKey ("row-key" );
121128
122- try (io . grpc . Context .CancellableContext ctx =
123- io . grpc . Context .current ()
129+ try (Context .CancellableContext ctx =
130+ Context .current ()
124131 .withDeadlineAfter (
125132 1 , TimeUnit .SECONDS , settings .getBackgroundExecutorProvider ().getExecutor ())) {
126133 ctx .run (
@@ -140,8 +147,7 @@ public void testMissedHeartbeat() throws Exception {
140147 }
141148
142149 private static class FakeDataService extends BigtableGrpc .BigtableImplBase {
143- private final java .util .concurrent .ScheduledExecutorService serverExecutor =
144- java .util .concurrent .Executors .newScheduledThreadPool (4 );
150+ private final ScheduledExecutorService serverExecutor = Executors .newScheduledThreadPool (4 );
145151
146152 public void shutdown () {
147153 serverExecutor .shutdownNow ();
@@ -195,15 +201,15 @@ public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(
195201 Metadata metadata ,
196202 ServerCallHandler <ReqT , RespT > serverCallHandler ) {
197203 return serverCallHandler .startCall (
198- new io . grpc . ForwardingServerCall .SimpleForwardingServerCall <ReqT , RespT >(serverCall ) {
204+ new ForwardingServerCall .SimpleForwardingServerCall <ReqT , RespT >(serverCall ) {
199205 @ Override
200206 public void sendHeaders (Metadata headers ) {
201207 Metadata .Key <String > peerInfoKey =
202208 Metadata .Key .of ("bigtable-peer-info" , Metadata .ASCII_STRING_MARSHALLER );
203209 String encoded =
204- java . util . Base64 .getUrlEncoder ()
210+ Base64 .getUrlEncoder ()
205211 .encodeToString (
206- com . google . bigtable . v2 . PeerInfo .newBuilder ()
212+ PeerInfo .newBuilder ()
207213 .setApplicationFrontendRegion ("us-east1" )
208214 .build ()
209215 .toByteArray ());
0 commit comments