Example usage for io.vertx.core VertxException VertxException

List of usage examples for io.vertx.core VertxException VertxException

Introduction

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

Prototype

public VertxException(Throwable cause, boolean noStackTrace) 

Source Link

Document

Create an instance given a message

Usage

From source file:com.github.mcollovati.vertx.vaadin.VaadinVerticle.java

License:Open Source License

private void readConfigurationAnnotation(JsonObject vaadinConfig) {

    VaadinServletConfiguration configAnnotation = getClass().getAnnotation(VaadinServletConfiguration.class);
    if (configAnnotation != null) {
        Method[] methods = VaadinServletConfiguration.class.getDeclaredMethods();
        for (Method method : methods) {
            VaadinServletConfiguration.InitParameterName name = method
                    .getAnnotation(VaadinServletConfiguration.InitParameterName.class);
            assert name != null : "All methods declared in VaadinServletConfiguration should have a @InitParameterName annotation";

            try {
                Object value = method.invoke(configAnnotation);

                String stringValue;
                if (value instanceof Class<?>) {
                    stringValue = ((Class<?>) value).getName();
                } else {
                    stringValue = value.toString();
                }//  w  w  w. j av a 2s  .  c  o m

                vaadinConfig.put(name.value(), stringValue);
            } catch (Exception e) {
                // This should never happen
                throw new VertxException("Could not read @VaadinServletConfiguration value " + method.getName(),
                        e);
            }
        }
    }
}

From source file:com.usebilbo.vertx.cluster.manager.IgniteClusterManager.java

License:Open Source License

@Override
public void getLockWithTimeout(String name, long timeout, Handler<AsyncResult<Lock>> handler) {
    ContextImpl context = (ContextImpl) vertx.getOrCreateContext();
    // Ordered on the internal blocking executor
    context.executeBlocking(() -> {//from w w w .  ja  va2s  . co m
        boolean locked = false;

        try {
            @SuppressWarnings("resource")
            IgniteQueue<String> queue = getQueue(name, true);

            pendingLocks.offer(name);

            locked = queue.offer(getNodeID(), timeout, TimeUnit.MILLISECONDS);

            if (!locked) {
                // EVT_NODE_LEFT/EVT_NODE_FAILED event might be already handled, so trying get lock again if
                // node left topology.
                // Use IgniteSempahore when it will be fixed.
                String ownerId = queue.peek();
                ClusterNode ownerNode = ignite().cluster().forNodeId(UUID.fromString(ownerId)).node();
                if (ownerNode == null) {
                    queue.remove(ownerId);
                    locked = queue.offer(getNodeID(), timeout, TimeUnit.MILLISECONDS);
                }
            }
        } catch (Exception e) {
            throw new VertxException("Error during getting lock " + name, e);
        } finally {
            pendingLocks.remove(name);
        }

        if (locked) {
            return new LockImpl(name);
        } else {
            throw new VertxException("Timed out waiting to get lock " + name);
        }
    }, handler);
}

From source file:io.reactiverse.pgclient.impl.codec.decoder.InitiateSslHandler.java

License:Apache License

@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
    super.channelInactive(ctx);
    // Work around for https://github.com/eclipse-vertx/vert.x/issues/2748
    upgradeFuture.tryFail(new VertxException("SSL handshake failed", true));
}