private void handleException(Throwable t) { if (exceptionHandler != null && t instanceof Exception) { exceptionHandler.handle(t); } else { log.error("Unhandled exception", t); } }
private <T> void reportResult(Context context, Handler<AsyncResult<T>> completionHandler, AsyncResult<T> result) { context.runOnContext(v -> { try { completionHandler.handle(result); } catch (Throwable t) { log.error("Failure in calling handler", t); throw t; } }); }
private void handleException(Exception e) { handshaking = false; buffered.clear(); Handler<Throwable> handler = exceptionHandler(); if (handler != null) { context.executeFromIO(v -> { handler.handle(e); }); } else { log.error("Error in websocket handshake", e); } }
private <T> void reportFailure(Throwable t, Context context, Handler<AsyncResult<T>> completionHandler) { if (completionHandler != null) { reportResult(context, completionHandler, Future.failedFuture(t)); } else { log.error(t.getMessage(), t); } }
public void reportException(Throwable t) { Handler<Throwable> handler = this.exceptionHandler; if (handler == null) { handler = owner.exceptionHandler(); } if (handler != null) { handler.handle(t); } else { log.error("Unhandled exception", t); } }
private void deployHADeployments() { int size = toDeployOnQuorum.size(); if (size != 0) { log.info("There are " + size + " HA deploymentIDs waiting on a quorum. These will now be deployed"); Runnable task; while ((task = toDeployOnQuorum.poll()) != null) { try { task.run(); } catch (Throwable t) { log.error("Failed to run redeployment task", t); } } } }
private void startEventBus(Handler<AsyncResult<Vertx>> resultHandler) { eventBus.start(ar -> { if (ar.succeeded()) { initializeHaManager(resultHandler); } else { log.error("Failed to start event bus", ar.cause()); resultHandler.handle(Future.failedFuture(ar.cause())); } }); }
/** * Creates a new instance of {@link VertxIsolatedDeployer}. * * @return the new instance. */ protected synchronized Object newInstance() { try { classloader = (classpath == null || classpath.isEmpty()) ? ClasspathHandler.class.getClassLoader() : createClassloader(); Class<?> clazz = classloader.loadClass("io.vertx.core.impl.launcher.commands.VertxIsolatedDeployer"); return clazz.newInstance(); } catch (Exception e) { log.error("Failed to load or instantiate the isolated deployer", e); throw new IllegalStateException(e); } }
private void joinCluster(VertxOptions options, Handler<AsyncResult<Vertx>> resultHandler) { clusterManager.setVertx(this); clusterManager.join(ar -> { if (ar.succeeded()) { createHaManager(options, resultHandler); } else { log.error("Failed to join cluster", ar.cause()); resultHandler.handle(Future.failedFuture(ar.cause())); } }); }
private void closeClusterManager(Handler<AsyncResult<Void>> completionHandler) { if (clusterManager != null) { clusterManager.leave(ar -> { if (ar.failed()) { log.error("Failed to leave cluster", ar.cause()); } if (completionHandler != null) { runOnContext(v -> completionHandler.handle(Future.succeededFuture())); } }); } else if (completionHandler != null) { runOnContext(v -> completionHandler.handle(Future.succeededFuture())); } }
/** * Undeploys the previously deployed verticle. * * @param completionHandler the completion handler */ public void undeploy(Handler<AsyncResult<Void>> completionHandler) { vertx.undeploy(deploymentId, res -> { if (res.failed()) { log.error("Failed in undeploying " + deploymentId, res.cause()); } else { log.info("Succeeded in undeploying " + deploymentId); } deploymentId = null; completionHandler.handle(res); }); }
protected synchronized void handleException(Throwable t) { NetworkMetrics metrics = metrics(); if (metrics != null) { metrics.exceptionOccurred(metric, remoteAddress(), t); } if (exceptionHandler != null) { exceptionHandler.handle(t); } else { if (log.isDebugEnabled()) { log.error(t.getMessage(), t); } else { log.error(t.getMessage()); } } }
@Override public String absoluteURI() { if (absoluteURI == null) { try { absoluteURI = HttpUtils.absoluteURI(conn.getServerOrigin(), this); } catch (URISyntaxException e) { log.error("Failed to create abs uri", e); } } return absoluteURI; }
private void checkHADeployments() { try { if (attainedQuorum) { deployHADeployments(); } else { undeployHADeployments(); } } catch (Throwable t) { log.error("Failed when checking HA deploymentIDs", t); } }
public synchronized void setResult(AsyncResult<Void> result) { this.result = result; if (completionHandler != null) { if (metrics != null && result.succeeded()) { metric = metrics.handlerRegistered(address, repliedAddress); } Handler<AsyncResult<Void>> callback = completionHandler; vertx.runOnContext(v -> callback.handle(result)); } else if (result.failed()) { log.error("Failed to propagate registration for handler " + handler + " and address " + address); } else if (metrics != null) { metric = metrics.handlerRegistered(address, repliedAddress); } }
@Override public void next() { if (iter.hasNext()) { try { Handler<DeliveryContext> handler = iter.next(); if (handler != null) { handler.handle(this); } else { next(); } } catch (Throwable t) { log.error("Failure in interceptor", t); } } else { holder.getHandler().handle(message); } }
@Override public String absoluteURI() { if (method() == HttpMethod.CONNECT) { return null; } synchronized (conn) { if (absoluteURI == null) { try { absoluteURI = HttpUtils.absoluteURI(serverOrigin, this); } catch (URISyntaxException e) { log.error("Failed to create abs uri", e); } } return absoluteURI; } }
private void createHaManager(VertxOptions options, Handler<AsyncResult<Vertx>> resultHandler) { this.<Map<String, String>>executeBlocking(fut -> { fut.complete(clusterManager.getSyncMap(CLUSTER_MAP_NAME)); }, false, ar -> { if (ar.succeeded()) { Map<String, String> clusterMap = ar.result(); haManager = new HAManager(this, deploymentManager, clusterManager, clusterMap, options.getQuorumSize(), options.getHAGroup(), options.isHAEnabled()); startEventBus(resultHandler); } else { log.error("Failed to start HAManager", ar.cause()); resultHandler.handle(Future.failedFuture(ar.cause())); } }); }
protected void closeClustered(List<Vertx> clustered) throws Exception { CountDownLatch latch = new CountDownLatch(clustered.size()); for (Vertx clusteredVertx : clustered) { clusteredVertx.close(ar -> { if (ar.failed()) { log.error("Failed to shutdown vert.x", ar.cause()); } latch.countDown(); }); } assertTrue(latch.await(180, TimeUnit.SECONDS)); }
private <T> void onSubsReceived(AsyncResult<ChoosableIterable<ClusterNodeInfo>> asyncResult, OutboundDeliveryContext<T> sendContext) { if (asyncResult.succeeded()) { ChoosableIterable<ClusterNodeInfo> serverIDs = asyncResult.result(); if (serverIDs != null && !serverIDs.isEmpty()) { sendToSubs(serverIDs, sendContext); } else { if (metrics != null) { metrics.messageSent(sendContext.message.address(), !sendContext.message.isSend(), true, false); } deliverMessageLocally(sendContext); } } else { log.error("Failed to send message", asyncResult.cause()); } }