Example usage for io.vertx.core Future succeededFuture

List of usage examples for io.vertx.core Future succeededFuture

Introduction

In this page you can find the example usage for io.vertx.core Future succeededFuture.

Prototype

static <T> Future<T> succeededFuture(T result) 

Source Link

Document

Created a succeeded future with the specified result.

Usage

From source file:org.eclipse.hono.deviceregistry.FileBasedRegistrationService.java

License:Open Source License

@Override
public void updateDevice(final String tenantId, final String deviceId, final JsonObject data,
        final Handler<AsyncResult<RegistrationResult>> resultHandler) {

    resultHandler.handle(Future.succeededFuture(updateDevice(tenantId, deviceId, data)));
}

From source file:org.eclipse.hono.deviceregistry.FileBasedTenantService.java

License:Open Source License

@Override
public void get(final String tenantId, final Handler<AsyncResult<TenantResult<JsonObject>>> resultHandler) {

    Objects.requireNonNull(tenantId);
    Objects.requireNonNull(resultHandler);

    resultHandler.handle(Future.succeededFuture(getTenantResult(tenantId)));
}

From source file:org.eclipse.hono.deviceregistry.FileBasedTenantService.java

License:Open Source License

@Override
public void get(final X500Principal subjectDn,
        final Handler<AsyncResult<TenantResult<JsonObject>>> resultHandler) {

    Objects.requireNonNull(subjectDn);
    Objects.requireNonNull(resultHandler);

    resultHandler.handle(Future.succeededFuture(getForCertificateAuthority(subjectDn)));
}

From source file:org.eclipse.hono.deviceregistry.FileBasedTenantService.java

License:Open Source License

@Override
public void remove(final String tenantId, final Handler<AsyncResult<TenantResult<JsonObject>>> resultHandler) {

    Objects.requireNonNull(tenantId);
    Objects.requireNonNull(resultHandler);
    resultHandler.handle(Future.succeededFuture(removeTenant(tenantId)));
}

From source file:org.eclipse.hono.deviceregistry.FileBasedTenantService.java

License:Open Source License

@Override
public void add(final String tenantId, final JsonObject tenantSpec,
        final Handler<AsyncResult<TenantResult<JsonObject>>> resultHandler) {

    Objects.requireNonNull(tenantId);
    Objects.requireNonNull(tenantSpec);
    Objects.requireNonNull(resultHandler);

    resultHandler.handle(Future.succeededFuture(add(tenantId, tenantSpec)));
}

From source file:org.eclipse.hono.deviceregistry.FileBasedTenantService.java

License:Open Source License

/**
 * Updates the tenant information./*from   ww w.  j av  a 2  s.  c o m*/
 * 
 * @param tenantId The tenant to update
 * @param tenantSpec The new tenant information
 * @param resultHandler The handler receiving the result of the operation.
 * 
 * @throws NullPointerException if either of the input parameters is {@code null}.
 */
@Override
public void update(final String tenantId, final JsonObject tenantSpec,
        final Handler<AsyncResult<TenantResult<JsonObject>>> resultHandler) {
    Objects.requireNonNull(tenantId);
    Objects.requireNonNull(tenantSpec);
    Objects.requireNonNull(resultHandler);

    resultHandler.handle(Future.succeededFuture(update(tenantId, tenantSpec)));
}

From source file:org.eclipse.hono.messaging.ForwardingDownstreamAdapter.java

License:Open Source License

private void connectToDownstream(final ProtonClientOptions options,
        final Handler<AsyncResult<ProtonConnection>> connectResultHandler) {

    downstreamConnectionFactory.connect(options, this::onRemoteClose, this::onDisconnectFromDownstreamContainer,
            connectAttempt -> {/*from  w w  w  .j a  va2  s  .  com*/
                if (connectAttempt.succeeded()) {
                    this.downstreamConnection = connectAttempt.result();
                    metrics.incrementDownStreamConnections();
                    if (connectResultHandler != null) {
                        connectResultHandler.handle(Future.succeededFuture(connectAttempt.result()));
                    }
                } else {
                    logger.info("failed to connect to downstream container: {}",
                            connectAttempt.cause().getMessage());
                    if (retryOnFailedConnectAttempt) {
                        reconnect(connectResultHandler);
                    } else if (connectResultHandler != null) {
                        connectResultHandler.handle(Future.failedFuture(connectAttempt.cause()));
                    }
                }
            });
}

From source file:org.eclipse.hono.server.ForwardingDownstreamAdapter.java

License:Open Source License

private void connectToDownstream(final ProtonClientOptions options,
        final Handler<AsyncResult<ProtonConnection>> connectResultHandler) {

    downstreamConnectionFactory.connect(options, this::onRemoteClose, this::onDisconnectFromDownstreamContainer,
            connectAttempt -> {//from  w w  w .j  a  v a2s . c o m
                if (connectAttempt.succeeded()) {
                    this.downstreamConnection = connectAttempt.result();
                    connectResultHandler.handle(Future.succeededFuture(connectAttempt.result()));
                    counterService.increment(MetricConstants.metricNameDownstreamConnections());
                } else {
                    logger.info("failed to connect to downstream container", connectAttempt.cause());
                    connectResultHandler.handle(Future.failedFuture(connectAttempt.cause()));
                }
            });
}

From source file:org.eclipse.hono.service.AbstractProtocolAdapterBase.java

License:Open Source License

/**
 * Connects to the Hono Messaging component using the configured client.
 * /*  w ww  . ja v  a2s  .c  o  m*/
 * @param connectHandler The handler to invoke with the outcome of the connection attempt.
 *                       If {@code null} and the connection attempt failed, this method
 *                       tries to re-connect until a connection is established.
 */
protected final void connectToMessaging(final Handler<AsyncResult<HonoClient>> connectHandler) {

    if (messaging == null) {
        if (connectHandler != null) {
            connectHandler.handle(Future.failedFuture("Hono Messaging client not set"));
        }
    } else if (messaging.isConnected()) {
        LOG.debug("already connected to Hono Messaging");
        if (connectHandler != null) {
            connectHandler.handle(Future.succeededFuture(messaging));
        }
    } else {
        messaging.connect(createClientOptions(), connectAttempt -> {
            if (connectHandler != null) {
                connectHandler.handle(connectAttempt);
            } else {
                LOG.debug("connected to Hono Messaging");
            }
        }, this::onDisconnectMessaging);
    }
}

From source file:org.eclipse.hono.service.AbstractProtocolAdapterBase.java

License:Open Source License

/**
 * Connects to the Device Registration service using the configured client.
 * //from www .  j a v  a 2 s . co m
 * @param connectHandler The handler to invoke with the outcome of the connection attempt.
 *                       If {@code null} and the connection attempt failed, this method
 *                       tries to re-connect until a connection is established.
 */
protected final void connectToDeviceRegistration(final Handler<AsyncResult<HonoClient>> connectHandler) {

    if (registration == null) {
        if (connectHandler != null) {
            connectHandler.handle(Future.failedFuture("Device Registration client not set"));
        }
    } else if (registration.isConnected()) {
        LOG.debug("already connected to Device Registration service");
        if (connectHandler != null) {
            connectHandler.handle(Future.succeededFuture(registration));
        }
    } else {
        registration.connect(createClientOptions(), connectAttempt -> {
            if (connectHandler != null) {
                connectHandler.handle(connectAttempt);
            } else {
                LOG.debug("connected to Device Registration service");
            }
        }, this::onDisconnectDeviceRegistry);
    }
}