com.netflix.loadbalancer.reactive.ExecutionInfo Java Examples
The following examples show how to use
com.netflix.loadbalancer.reactive.ExecutionInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BearerHeaderAdder.java From thorntail with Apache License 2.0 | 5 votes |
@Override public void onStartWithServer(ExecutionContext<HttpClientRequest<ByteBuf>> context, ExecutionInfo info) throws AbortExecutionException { KeycloakSecurityContext securityContext = KeycloakSecurityContextAssociation.get(); if (securityContext != null) { HttpClientRequest<ByteBuf> request = context.getRequest(); request.withHeader("Authorization", "Bearer " + securityContext.getTokenString()); context.put(KeycloakSecurityContextAssociation.class.getName(), securityContext); } else { KeycloakSecurityContextAssociation.disassociate(); } }
Example #2
Source File: BearerHeaderAdder.java From thorntail with Apache License 2.0 | 5 votes |
@Override public void onExceptionWithServer(ExecutionContext<HttpClientRequest<ByteBuf>> context, Throwable exception, ExecutionInfo info) { KeycloakSecurityContext securityContext = (KeycloakSecurityContext) context.get(KeycloakSecurityContextAssociation.class.getName()); if (securityContext != null) { KeycloakSecurityContextAssociation.associate(securityContext); } else { KeycloakSecurityContextAssociation.disassociate(); } }
Example #3
Source File: BearerHeaderAdder.java From thorntail with Apache License 2.0 | 5 votes |
@Override public void onExecutionSuccess(ExecutionContext<HttpClientRequest<ByteBuf>> context, HttpClientResponse<ByteBuf> response, ExecutionInfo info) { KeycloakSecurityContext securityContext = (KeycloakSecurityContext) context.get(KeycloakSecurityContextAssociation.class.getName()); if (securityContext != null) { KeycloakSecurityContextAssociation.associate(securityContext); } else { KeycloakSecurityContextAssociation.disassociate(); } }
Example #4
Source File: BearerHeaderAdder.java From thorntail with Apache License 2.0 | 5 votes |
@Override public void onExecutionFailed(ExecutionContext<HttpClientRequest<ByteBuf>> context, Throwable finalException, ExecutionInfo info) { KeycloakSecurityContext securityContext = (KeycloakSecurityContext) context.get(KeycloakSecurityContextAssociation.class.getName()); if (securityContext != null) { KeycloakSecurityContextAssociation.associate(securityContext); } else { KeycloakSecurityContextAssociation.disassociate(); } }
Example #5
Source File: BearerHeaderAdder.java From ARCHIVE-wildfly-swarm with Apache License 2.0 | 5 votes |
@Override public void onStartWithServer(ExecutionContext<HttpClientRequest<ByteBuf>> context, ExecutionInfo info) throws AbortExecutionException { KeycloakSecurityContext securityContext = KeycloakSecurityContextAssociation.get(); if (securityContext != null) { HttpClientRequest<ByteBuf> request = context.getRequest(); request.withHeader("Authorization", "Bearer " + securityContext.getTokenString()); context.put(KeycloakSecurityContextAssociation.class.getName(), securityContext); } else { KeycloakSecurityContextAssociation.disassociate(); } }
Example #6
Source File: BearerHeaderAdder.java From ARCHIVE-wildfly-swarm with Apache License 2.0 | 5 votes |
@Override public void onExceptionWithServer(ExecutionContext<HttpClientRequest<ByteBuf>> context, Throwable exception, ExecutionInfo info) { KeycloakSecurityContext securityContext = (KeycloakSecurityContext) context.get(KeycloakSecurityContextAssociation.class.getName()); if (securityContext != null) { KeycloakSecurityContextAssociation.associate(securityContext); } else { KeycloakSecurityContextAssociation.disassociate(); } }
Example #7
Source File: BearerHeaderAdder.java From ARCHIVE-wildfly-swarm with Apache License 2.0 | 5 votes |
@Override public void onExecutionSuccess(ExecutionContext<HttpClientRequest<ByteBuf>> context, HttpClientResponse<ByteBuf> response, ExecutionInfo info) { KeycloakSecurityContext securityContext = (KeycloakSecurityContext) context.get(KeycloakSecurityContextAssociation.class.getName()); if (securityContext != null) { KeycloakSecurityContextAssociation.associate(securityContext); } else { KeycloakSecurityContextAssociation.disassociate(); } }
Example #8
Source File: BearerHeaderAdder.java From ARCHIVE-wildfly-swarm with Apache License 2.0 | 5 votes |
@Override public void onExecutionFailed(ExecutionContext<HttpClientRequest<ByteBuf>> context, Throwable finalException, ExecutionInfo info) { KeycloakSecurityContext securityContext = (KeycloakSecurityContext) context.get(KeycloakSecurityContextAssociation.class.getName()); if (securityContext != null) { KeycloakSecurityContextAssociation.associate(securityContext); } else { KeycloakSecurityContextAssociation.disassociate(); } }
Example #9
Source File: TestExecutionListener.java From ribbon with Apache License 2.0 | 5 votes |
private void checkExecutionInfo(ExecutionInfo info) { try { assertEquals(numAttemptsOnServer.get(), info.getNumberOfPastAttemptsOnServer()); assertEquals(numServers.get(), info.getNumberOfPastServersAttempted()); } catch (Throwable e) { e.printStackTrace(); checkExecutionInfo = false; } }
Example #10
Source File: TestExecutionListener.java From ribbon with Apache License 2.0 | 5 votes |
@Override public void onStartWithServer(ExecutionContext<HttpClientRequest<I>> context, ExecutionInfo info) { checkContext(context); if (lastServer == null) { lastServer = info.getServer(); } else if (!lastServer.equals(info.getServer())) { lastServer = info.getServer(); numAttemptsOnServer.set(0); numServers.incrementAndGet(); } checkExecutionInfo(info); startWithServerCounter.incrementAndGet(); }
Example #11
Source File: TestExecutionListener.java From ribbon with Apache License 2.0 | 5 votes |
@Override public void onExceptionWithServer(ExecutionContext<HttpClientRequest<I>> context, Throwable exception, ExecutionInfo info) { checkContext(context); checkExecutionInfo(info); numAttemptsOnServer.incrementAndGet(); errors.add(exception); exceptionWithServerCounter.incrementAndGet(); }
Example #12
Source File: TestExecutionListener.java From ribbon with Apache License 2.0 | 5 votes |
@Override public void onExecutionSuccess(ExecutionContext<HttpClientRequest<I>> context, HttpClientResponse<O> response, ExecutionInfo info) { checkContext(context); checkExecutionInfo(info); this.response = response; executionSuccessCounter.incrementAndGet(); }
Example #13
Source File: TestExecutionListener.java From ribbon with Apache License 2.0 | 5 votes |
@Override public void onExecutionFailed(ExecutionContext<HttpClientRequest<I>> context, Throwable finalException, ExecutionInfo info) { checkContext(context); checkExecutionInfo(info); executionFailedCounter.incrementAndGet(); finalThrowable = finalException; }
Example #14
Source File: ListenerTest.java From ribbon with Apache License 2.0 | 4 votes |
@Test public void testAbortedExecutionOnServer() { IClientConfig config = DefaultClientConfigImpl.getClientConfigWithDefaultValues().withProperty(CommonClientConfigKey.ConnectTimeout, "100") .withProperty(CommonClientConfigKey.MaxAutoRetries, 1) .withProperty(CommonClientConfigKey.MaxAutoRetriesNextServer, 1); HttpClientRequest<ByteBuf> request = HttpClientRequest.createGet("/testAsync/person"); Server badServer = new Server("localhost:12345"); Server badServer2 = new Server("localhost:34567"); List<Server> servers = Lists.newArrayList(badServer, badServer2); BaseLoadBalancer lb = LoadBalancerBuilder.<Server>newBuilder() .withRule(new AvailabilityFilteringRule()) .withPing(new DummyPing()) .buildFixedServerListLoadBalancer(servers); IClientConfig overrideConfig = DefaultClientConfigImpl.getEmptyConfig(); TestExecutionListener listener = new TestExecutionListener(request, overrideConfig) { @Override public void onStartWithServer(ExecutionContext context, ExecutionInfo info) { throw new AbortExecutionException("exit now"); } }; List<ExecutionListener<HttpClientRequest<ByteBuf>, HttpClientResponse<ByteBuf>>> listeners = Lists.<ExecutionListener<HttpClientRequest<ByteBuf>, HttpClientResponse<ByteBuf>>>newArrayList(listener); LoadBalancingHttpClient<ByteBuf, ByteBuf> client = RibbonTransport.newHttpClient(lb, config, new NettyHttpLoadBalancerErrorHandler(config), listeners); final CountDownLatch latch = new CountDownLatch(1); final AtomicReference<Throwable> ref = new AtomicReference<Throwable>(); client.submit(request, null, overrideConfig).subscribe(new Action1<HttpClientResponse<ByteBuf>>() { @Override public void call(HttpClientResponse<ByteBuf> byteBufHttpClientResponse) { } }, new Action1<Throwable>() { @Override public void call(Throwable throwable) { ref.set(throwable); latch.countDown(); } }); try { latch.await(500, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { e.printStackTrace(); } assertTrue(ref.get() instanceof AbortExecutionException); }