public synchronized void getOrCreateVertx ( final VertxPlatformConfiguration config , final VertxListener listener ) { Vertx vertx = vertxPlatforms . get ( config . getVertxPlatformIdentifier ( ) ) ; if ( vertx != null ) { listener . whenReady ( vertx ) ; return ; } VertxOptions options = new VertxOptions ( ) ; options . setClustered ( config . isClustered ( ) ) ; options . setClusterHost ( config . getClusterHost ( ) ) ; options . setClusterPort ( config . getClusterPort ( ) ) ; CountDownLatch latch = new CountDownLatch ( 1 ) ; Vertx . clusteredVertx ( options , ar -> { try { if ( ar . succeeded ( ) ) { log . log ( Level . INFO , "Acquired Vert.x platform." ) ; listener . whenReady ( ar . result ( ) ) ; vertxPlatforms . put ( config . getVertxPlatformIdentifier ( ) , ar . result ( ) ) ; } else { throw new RuntimeException ( "Could not acquire Vert.x platform." , ar . cause ( ) ) ; } } finally { latch . countDown ( ) ; } } ) ; try { if ( ! latch . await ( config . getTimeout ( ) , TimeUnit . MILLISECONDS ) ) { log . log ( Level . SEVERE , "Could not acquire Vert.x platform in interval." ) ; throw new RuntimeException ( "Could not acquire Vert.x platform in interval" ) ; } } catch ( Exception ignore ) { } }
Creates a Vertx if one is not started yet .