2017-03-22 9 views
0

私はvertandフレームワークをcassandraで正確に英語の実装で使用しています。(https://github.com/ef-labs/vertx-cassandra) 私はlocalhostにDefaultCassandraSessionを使用します。
sesssionを確認しようとするとは初期化されません。ここでのコード:Vertand x with cassandra englishtownの実装

public class CassandraClientVerticle extends AbstractVerticle{ 


    private CassandraSession session; 

    @Override 
    public void init(Vertx vertx, Context context) { 
     CassandraConfigurator configurator = new JsonCassandraConfigurator(vertx); 
     session = new DefaultCassandraSession(new Cluster.Builder(), configurator,vertx); 

    } 

    @Override 
    public void start() throws Exception { 
     System.out.println(session.initialized()); 
    } 


} 

、これは私がこのVERTXと呼ばれるサーバーです:

public static void main(String[] args) { 
     Server server = null; 
     try { 
      server = new Server(); 
      server.startServer(); 
     } catch(Exception e) { 
      if(server != null) { 
       server.exit("Server execution failure", e); 
      } else { 
       LOG.error("Server execution failure", e); 
      } 
     } 
    } 

    public void startServer() throws Exception { 
     conf = Configuration.init(); 

     Consumer<Vertx> runner = vertx -> { 
      try { 

       DeploymentOptions httpVerticleOptions = createHttpVerticleOptions(); 
       vertx.deployVerticle(HttpVerticle.class.getName(), httpVerticleOptions); 

       vertx.deployVerticle(CassandraClientVerticle.class.getName()); 

      } catch (Throwable t) { 
       exit("Vert.x runner failure", t); 
      } 
     }; 
     VertxOptions vertxOptions = createVertxOptions(); 
     vertx = Vertx.vertx(vertxOptions); 
     runner.accept(vertx); 

    } 

私はセッションの問題を解決することができますか?私が見つけられなかった作業例をリンクしてください。

答えて

1

それは私

public class MainVerticle extends AbstractVerticle { 

    private CassandraSession cassandraSession; 

    @Override 
    public void init(Vertx vertx, Context context) { 
     super.init(vertx, context); 

     cassandraSession = new DefaultCassandraSession(new Cluster.Builder(), new JsonCassandraConfigurator(vertx), vertx); 
    } 


    @Override 
    public void start(Future<Void> startFuture) throws Exception { 
     cassandraSession.onReady((v) -> { 
      System.out.printf("==> CASSANDRA SESSION INITIALIZED\n\t[%b]\n", cassandraSession.initialized()); 
      startFuture.complete(); 
     }); 
    } 
} 
のために働く...これを試してみてください
関連する問題