Exemple #1
0
 private synchronized void checkQuorumWhenAdded(final String nodeID, final long start) {
   if (clusterMap.containsKey(nodeID)) {
     checkQuorum();
   } else {
     vertx.setTimer(
         200,
         tid -> {
           // This can block on a monitor so it needs to run as a worker
           vertx.executeBlockingInternal(
               () -> {
                 if (System.currentTimeMillis() - start > 10000) {
                   log.warn("Timed out waiting for group information to appear");
                 } else if (!stopped) {
                   ContextImpl context = vertx.getContext();
                   try {
                     // Remove any context we have here (from the timer) otherwise will screw
                     // things up when verticles are deployed
                     ContextImpl.setContext(null);
                     checkQuorumWhenAdded(nodeID, start);
                   } finally {
                     ContextImpl.setContext(context);
                   }
                 }
                 return null;
               },
               null);
         });
   }
 }
Exemple #2
0
 @Override
 public synchronized Route failureHandler(Handler<RoutingContext> exceptionHandler) {
   if (this.failureHandler != null) {
     log.warn("Setting failureHandler for a route more than once!");
   }
   this.failureHandler = exceptionHandler;
   checkAdd();
   return this;
 }
Exemple #3
0
 @Override
 public synchronized Route handler(Handler<RoutingContext> contextHandler) {
   if (this.contextHandler != null) {
     log.warn("Setting handler for a route more than once!");
   }
   this.contextHandler = contextHandler;
   checkAdd();
   return this;
 }
 @Override
 public void postHandle(RoutingContext context) {
   PaginationContext pageContext =
       (PaginationContext) context.data().get(PaginationContext.DATA_ATTR);
   String linkHeader = pageContext.buildLinkHeader(context.request());
   if (linkHeader != null) {
     context.response().headers().add(HttpHeaders.LINK, linkHeader);
   } else {
     log.warn("You did not set the total count on PaginationContext, response won't be paginated");
   }
   context.next();
 }
 void start() {
   connection.setErrorHandler(
       th -> {
         log.debug("QUIT failed, ignoring exception", th);
         resultHandler.handle(null);
       });
   connection.write(
       "QUIT",
       message -> {
         log.debug("QUIT result: " + message);
         if (!StatusCode.isStatusOk(message)) {
           log.warn("quit failed: " + message);
         }
         resultHandler.handle(null);
       });
 }
 private void loadVerticleFactories() {
   ServiceLoader<VerticleFactory> factories = ServiceLoader.load(VerticleFactory.class);
   Iterator<VerticleFactory> iter = factories.iterator();
   while (iter.hasNext()) {
     VerticleFactory factory = iter.next();
     factory.init(vertx);
     String prefix = factory.prefix();
     if (verticleFactories.containsKey(prefix)) {
       log.warn(
           "Not loading verticle factory: "
               + factory
               + " as prefix "
               + prefix
               + " is already in use");
     } else {
       verticleFactories.put(prefix, factory);
     }
   }
 }