Examples of VertxException


Examples of io.vertx.core.VertxException

    vertx.eventBus().<Boolean>send("vertstartok", "foo", res -> {
      if (res.result().body()) {
        startFuture.complete();
        vertx.eventBus().publish("vertstarted", vertx.context().deploymentID());
      } else {
        startFuture.fail(new VertxException("foo"));
      }
    });
  }
View Full Code Here

Examples of io.vertx.core.VertxException

      // Replace with broken source flile
      try {
        Files.copy(Paths.get(resolvePath("src/test/resources/redeployverticles/BrokenRedeploySourceVerticle.java")),
          new File(cpDir, "RedeploySourceVerticle.java").toPath(), StandardCopyOption.REPLACE_EXISTING);
      } catch (Exception e) {
        throw new VertxException(e);
      }
      vertx.setTimer(2000, id -> {
        // Copy back the fixed file
        try {
          Files.copy(Paths.get(resolvePath("src/test/resources/redeployverticles/RedeploySourceVerticle.java")),
            new File(cpDir, "RedeploySourceVerticle.java").toPath(), StandardCopyOption.REPLACE_EXISTING);
        } catch (Exception e) {
          throw new VertxException(e);
        }
      });
    }, 1, 0, 1);
  }
View Full Code Here

Examples of io.vertx.core.VertxException

      File f = new File(dir, fileName);
      FileWriter fw = new FileWriter(f, true);
      fw.write(TestUtils.randomAlphaString(500));
      fw.close();
    } catch (Exception e) {
      throw new VertxException(e);
    }
  }
View Full Code Here

Examples of io.vertx.core.VertxException

  }

  // Process the failover of a deployment
  private void processFailover(JsonObject failedVerticle) {
    if (failDuringFailover) {
      throw new VertxException("Oops!");
    }
    // This method must block until the failover is complete - i.e. the verticle is successfully redeployed
    final String verticleName = failedVerticle.getString("verticle_name");
    final CountDownLatch latch = new CountDownLatch(1);
    final AtomicReference<Throwable> err = new AtomicReference<>();
    // Now deploy this verticle on this node
    ContextImpl ctx = vertx.getContext();
    vertx.setContext(null);
    JsonObject options = failedVerticle.getJsonObject("options");
    doDeployVerticle(verticleName, new DeploymentOptions(options), result -> {
      if (result.succeeded()) {
        log.info("Successfully redeployed verticle " + verticleName + " after failover");
      } else {
        log.error("Failed to redeploy verticle after failover", result.cause());
        err.set(result.cause());
      }
      latch.countDown();
      Throwable t = err.get();
      if (t != null) {
        throw new VertxException(t);
      }
    });
    vertx.setContext(ctx);
    try {
      if (!latch.await(120, TimeUnit.SECONDS)) {
        throw new VertxException("Timed out waiting for redeploy on failover");
      }
    } catch (InterruptedException e) {
      throw new IllegalStateException(e);
    }
  }
View Full Code Here

Examples of io.vertx.core.VertxException

    }
    try {
      File file = new File(url.toURI());
      return file.getAbsolutePath();
    } catch (URISyntaxException e) {
      throw new VertxException(e);
    }
  }
View Full Code Here

Examples of io.vertx.core.VertxException

  private URL parseUrl(String surl) {
    // Note - parsing a URL this way is slower than specifying host, port and relativeURI
    try {
      return new URL(surl);
    } catch (MalformedURLException e) {
      throw new VertxException("Invalid url: " + surl);
    }
  }
View Full Code Here

Examples of io.vertx.core.VertxException

        trustMgrs = createUntrustRevokedCertTrustManager(trustMgrs, crls);
      }
      context.init(keyMgrs, trustMgrs, new SecureRandom());
      return context;
    } catch (Exception e) {
      throw new VertxException(e);
    }
  }
View Full Code Here

Examples of io.vertx.core.VertxException

    void timedOut() {
      synchronized (lock) {
        if (!acquired) {
          timedOut = true;
          context.runOnContext(v -> resultHandler.handle(Future.completedFuture(new VertxException("Timed out waiting to get lock"))));
        }
      }
    }
View Full Code Here

Examples of io.vertx.core.VertxException

          cacheFile.getParentFile().mkdirs();
        }
        try {
          Files.copy(is, cacheFile.toPath());
        } catch (IOException e) {
          throw new VertxException("Failed to copy file", e);
        }
        return cacheFile;
      }
    }
    return file;
View Full Code Here

Examples of org.vertx.java.core.VertxException

        @Override
        public void handle(AsyncResult<Boolean> result) {
          if (result.failed()) {
            new DefaultFutureResult<Void>(result.cause()).setHandler(doneHandler);
          } else if (!result.result()) {
            new DefaultFutureResult<Void>(new VertxException("File not found.")).setHandler(doneHandler);
          } else {
            // In order to send a file, we need to create a new output group.
            // The group will guarantee that all messages within it go to the
            // same target component instances. And since messages are guaranteed
            // to be ordered, we can stream the file to the appropriate out port.
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.