@Override public void operationComplete(Future<Codec> future) throws Exception { if (future.get() == null) { return; } Codec subscribeCodec = future.get(); if (topicType == PubSubType.PUNSUBSCRIBE) { psubscribe(channelName, listeners, subscribeCodec); } else { subscribe(channelName, listeners, subscribeCodec); } }
@Override public void operationComplete(Future<Codec> future) throws Exception { if (future.get() == null) { return; } Codec subscribeCodec = future.get(); if (topicType == PubSubType.PUNSUBSCRIBE) { psubscribe(channelName, listeners, subscribeCodec); } else { subscribe(channelName, listeners, subscribeCodec); } }
@Override public void operationComplete(Future<List<?>> future) throws Exception { if (future.isSuccess()) { List<Long> result = (List<Long>) future.get(); for (Long res : result) { if (res != null) { count.addAndGet(res); } } } else { failed.set(future.cause()); } checkExecution(result, failed, count, executed); } };
@Override public void operationComplete(Future<List<?>> future) throws Exception { if (future.isSuccess()) { List<Long> result = (List<Long>) future.get(); for (Long res : result) { if (res != null) { count.addAndGet(res); } } } else { failed.set(future.cause()); } checkExecution(result, failed, count, executed); } };
@Override public void operationComplete(Future<List<?>> future) throws Exception { if (future.isSuccess()) { List<Long> result = (List<Long>) future.get(); for (Long res : result) { if (res != null) { count.addAndGet(res); } } } else { failed.set(future.cause()); } checkExecution(result, failed, count, executed); } };
@Override public void operationComplete(Future<List<?>> future) throws Exception { if (future.isSuccess()) { List<Long> result = (List<Long>) future.get(); for (Long res : result) { if (res != null) { count.addAndGet(res); } } } else { failed.set(future.cause()); } checkExecution(result, failed, count, executed); } };
@Override public void operationComplete(Future<Boolean> future) throws Exception { if (!future.isSuccess() || future.get()) { scheduleRetryTimeRenewal(requestId); } } });
@Override public void operationComplete(Future<Boolean> future) throws Exception { if (!future.isSuccess() || future.get()) { scheduleRetryTimeRenewal(requestId); } } });
/** This is just for use in unit-testing. */ public void waitForEachEventLoop() throws InterruptedException, ExecutionException { for (EventExecutor exec : serverGroup.clientToProxyWorkerPool) { exec.submit(() -> { // Do nothing. }).get(); } }
@Override public void operationComplete(Future<Collection<V>> future) throws Exception { if (!future.isSuccess()) { promise.tryFailure(future.cause()); return; } result.addAll(future.get()); promise.trySuccess(result); } });
@Override public void operationComplete(Future<Collection<V>> future) throws Exception { if (!future.isSuccess()) { promise.tryFailure(future.cause()); return; } result.addAll(future.get()); promise.trySuccess(result); } });
@Override public void operationComplete(F future) throws Exception { InternalLogger internalLogger = logNotifyFailure ? logger : null; if (future.isSuccess()) { V result = future.get(); for (Promise<? super V> p: promises) { PromiseNotificationUtil.trySuccess(p, result, internalLogger); } } else if (future.isCancelled()) { for (Promise<? super V> p: promises) { PromiseNotificationUtil.tryCancel(p, internalLogger); } } else { Throwable cause = future.cause(); for (Promise<? super V> p: promises) { PromiseNotificationUtil.tryFailure(p, cause, internalLogger); } } } }
/** This is just for use in unit-testing. */ public void waitForEachEventLoop() throws InterruptedException, ExecutionException { for (EventExecutor exec : serverGroup.clientToProxyWorkerPool) { exec.submit(() -> { // Do nothing. }).get(); } }
private void executeSQL(final String dataSourceName, final String sql) throws InterruptedException, ExecutionException, TimeoutException { if (!channelMap.containsKey(dataSourceName)) { channelMap.put(dataSourceName, new ArrayList<Channel>()); } SimpleChannelPool pool = CLIENT_MANAGER.getBackendNettyClient(logicSchema.getName()).getPoolMap().get(dataSourceName); Channel channel = pool.acquire().get(GLOBAL_REGISTRY.getShardingProperties().<Long>getValue(ShardingPropertiesConstant.PROXY_BACKEND_CONNECTION_TIMEOUT_SECONDS), TimeUnit.SECONDS); channelMap.get(dataSourceName).add(channel); ChannelRegistry.getInstance().putConnectionId(channel.id().asShortText(), connectionId); channel.writeAndFlush(new ComQueryPacket(sequenceId, sql)); }
private void executeSQL(final String dataSourceName, final String sql) throws InterruptedException, ExecutionException, TimeoutException { if (!channelMap.containsKey(dataSourceName)) { channelMap.put(dataSourceName, new ArrayList<Channel>()); } SimpleChannelPool pool = CLIENT_MANAGER.getBackendNettyClient(logicSchema.getName()).getPoolMap().get(dataSourceName); Channel channel = pool.acquire().get(GLOBAL_REGISTRY.getShardingProperties().<Long>getValue(ShardingPropertiesConstant.PROXY_BACKEND_CONNECTION_TIMEOUT_SECONDS), TimeUnit.SECONDS); channelMap.get(dataSourceName).add(channel); ChannelRegistry.getInstance().putConnectionId(channel.id().asShortText(), connectionId); channel.writeAndFlush(new ComQueryPacket(sequenceId, sql)); }
@Test(timeOut = 60000, expectedExceptions = ExecutionException.class) public void sendByteMessageExpectFailure() throws Exception { try (AsyncHttpClient c = asyncHttpClient()) { CountDownLatch closeLatch = new CountDownLatch(1); WebSocket websocket = getWebSocket(c, closeLatch); websocket.sendCloseFrame(); closeLatch.await(1, TimeUnit.SECONDS); websocket.sendBinaryFrame("BYTES".getBytes()).get(10, TimeUnit.SECONDS); } }
@Test(timeOut = 60000) public void streamBytes() throws Exception { try (AsyncHttpClient c = asyncHttpClient()) { getWebSocket(c).sendBinaryFrame("STREAM".getBytes(), true, 0).get(1, TimeUnit.SECONDS); } }
@Test(timeOut = 60000) public void sendPingMessage() throws Exception { try (AsyncHttpClient c = asyncHttpClient()) { getWebSocket(c).sendPingFrame("PING".getBytes()).get(10, TimeUnit.SECONDS); } }
@Test(expectedExceptions = ExecutionException.class) public void streamTextExpectFailure() throws Exception { try (AsyncHttpClient c = asyncHttpClient()) { CountDownLatch closeLatch = new CountDownLatch(1); WebSocket websocket = getWebSocket(c, closeLatch); websocket.sendCloseFrame(); closeLatch.await(1, TimeUnit.SECONDS); websocket.sendTextFrame("STREAM", true, 0).get(1, TimeUnit.SECONDS); } }
@Test(timeOut = 60000) public void sendTextMessage() throws Exception { try (AsyncHttpClient c = asyncHttpClient()) { getWebSocket(c).sendTextFrame("TEXT").get(10, TimeUnit.SECONDS); } }