Ejemplo n.º 1
0
 void run()
     throws TException, NoSuchAlgorithmException, NoSuchProviderException, InvalidKeyException,
         SignatureException {
   final TBase o = construct();
   final long deviceToken = 99;
   final long notificationId = 999;
   notifier.put(deviceToken, new Notification(method, notificationId));
   final PendingNotification pendingNotification = new PendingNotification();
   pendingNotification.setId(notificationId);
   final ByteBuffer b = ByteBuffer.wrap(new TSerializer().serialize(o));
   b.mark();
   pendingNotification.setPayload(b);
   pendingNotificationDataStore.put(notificationId, pendingNotification);
   final LongId notificationLongId = new LongId(notificationId);
   final Future<T> future = new DefaultFutureResult<>();
   call(notificationLongId, sign(notificationLongId, clientId), future);
   assertTrue(future.succeeded());
   assertEquals(o, future.result());
 }
Ejemplo n.º 2
0
  @Override
  public void start(Future<Void> startedResult) {
    this.uuid = container.config().getString("uuid");
    this.mcastGroup = container.config().getString("cluster");

    this.proto =
        (VertxTransportProtocol) vertx.sharedData().getMap("org.jgroups.vertx.proto").get(uuid);

    vertx.eventBus().registerHandler("org.jgroups.vertx.multicast." + mcastGroup, this);
    vertx.eventBus().registerHandler("org.jgroups.vertx.unicast." + uuid, this);

    startedResult.setResult(null);
  }
Ejemplo n.º 3
0
  @Override
  public void start(final Future<Void> startedResult) {
    RuntimeFactory factory =
        RuntimeFactory.init(getClass().getClassLoader(), RuntimeFactory.RuntimeType.DYNJS);

    final String main = container.config().getField("main");
    if (main == null || "".equals(main)) {
      startedResult.setFailure(new IllegalArgumentException("main cannot be empty"));
      return;
    }

    NodynConfig config = new NodynConfig(new String[] {main});

    this.nodyn = factory.newRuntime(vertx, config);
    try {
      this.nodyn.setExitHandler(
          new ExitHandler() {
            @Override
            public void reallyExit(int i) {
              NodynVerticle.this.stop();
            }
          });
      this.nodyn.runAsync(
          new Callback() {
            @Override
            public Object call(CallbackResult callbackResult) {
              if (callbackResult.isError()) {
                startedResult.setFailure(callbackResult.getError());
              } else {
                startedResult.setResult(null);
              }
              return null;
            }
          });
    } catch (Throwable throwable) {
      startedResult.setFailure(throwable);
    }
  }