Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带cassandra englishtown实现的Vert x_Cassandra_Vert.x - Fatal编程技术网

带cassandra englishtown实现的Vert x

带cassandra englishtown实现的Vert x,cassandra,vert.x,Cassandra,Vert.x,我使用vert x框架和cassandra englishtown实现。() 我对本地主机使用DefaultCassandraSession。 但是当尝试检查session时,未初始化。此处代码: public class CassandraClientVerticle extends AbstractVerticle{ private CassandraSession session; @Override public void init(Vertx vertx,

我使用vert x框架和cassandra englishtown实现。() 我对本地主机使用
DefaultCassandraSession

但是当尝试检查session时,未初始化。此处代码:

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);

    }
publicstaticvoidmain(字符串[]args){
服务器=空;
试一试{
服务器=新服务器();
server.startServer();
}捕获(例外e){
如果(服务器!=null){
server.exit(“服务器执行失败”,e);
}否则{
日志错误(“服务器执行失败”,e);
}
}
}
public void startServer()引发异常{
conf=Configuration.init();
消费者跑步者=顶点->{
试一试{
DeploymentOptions httpVerticleOptions=createHttpVerticleOptions();
deployVerticle(HttpVerticle.class.getName(),httpVerticleOptions);
deployVerticle(CassandraClientVerticle.class.getName());
}捕获(可丢弃的t){
退出(“垂直x转轮故障”,t);
}
};
VertxOptions VertxOptions=createVertxOptions();
vertx=vertx.vertx(vertxOptions);
接受(vertx);
}

如何解决会话问题?或者请链接我找不到的工作示例。

试试这个。。。它对我有用

public类MainVerticle扩展了AbstractVerticle{
私人合作社合作社;
@凌驾
公共void init(Vertx Vertx,上下文){
super.init(vertx,context);
cassandraSession=newdefaultcassandrasession(new Cluster.Builder(),new jsoncassandraconfigulator(vertx),vertx);
}
@凌驾
public void start(Future startFuture)引发异常{
cassandraSession.onReady((v)->{
System.out.printf(“=>CASSANDRA会话已初始化\n\t[%b]\n”,cassandraSession.INITIALIZED());
startFuture.complete();
});
}
}
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();
        });
    }
}