0
votes

I have java application that initialise all cassandra tables used in application at one by executing queries. It runs fine locally and with remote test server with Apache Cassandra 3.3. However, when I run it in the production with Cassandra 3.3 cluster having 3 nodes, it creates first 22 tables and stops always at one particular table with the error

ERROR UNAUTHORIZED: system_schema keyspace is not user-modifiable.

The query that makes this problem is:

CREATE TABLE IF NOT EXISTS userrecom_newusers(userid bigint, timestamp bigint, PRIMARY KEY (userid))

and it uses keyspace "prosolo_logs_moocs", so it doesn't have anything to do with system_schema.

Java code that creates these tables is:

this.createSchemaIfNotExists(this.getSession(), this.dbName,
                this.dbConfig.replicationFactor);
        Metadata metadata = this.getCluster().getMetadata();
        metadata.getKeyspace(keyspacename).getTables();
        this.getSession().execute("USE "+keyspacename);
        for (String ddl : this.ddls) {
            try {
                this.getSession().execute(ddl);
            } catch (Exception ex) {
                logger.error("Error during the creation of table:"
                        + keyspacename + " for DDL:" + ddl);
                ex.printStackTrace();
            }
        }

The full trace log is:

    TRACE   [2016-11-27 06:55:31,313] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:71)       [1154641956] CREATE TABLE IF NOT EXISTS userrecom_newusers(userid bigint, timestamp bigint,  PRIMARY KEY (userid))
TRACE   [2016-11-27 06:55:31,313] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:71)       [1154641956] CREATE TABLE IF NOT EXISTS userrecom_newusers(userid bigint, timestamp bigint,  PRIMARY KEY (userid))
TRACE   [2016-11-27 06:55:31,313] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:272)      [1154641956-1] Starting
TRACE   [2016-11-27 06:55:31,313] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:272)      [1154641956-1] Starting
TRACE   [2016-11-27 06:55:31,313] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:280)      [1154641956-1] Querying node /10.0.0.184:9042
TRACE   [2016-11-27 06:55:31,313] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:280)      [1154641956-1] Querying node /10.0.0.184:9042
TRACE   [2016-11-27 06:55:31,313] [localhost-startStop-1] driver.core.Connection (Connection.java:519)      Connection[/10.0.0.184:9042-2, inFlight=1, closed=false], stream 1088, writing request QUERY CREATE TABLE IF NOT EXISTS userrecom_newusers(userid bigint, timestamp bigint,  PRIMARY KEY (userid))([cl=LOCAL_ONE, positionalVals=[], namedVals={}, skip=false, psize=5000, state=null, serialCl=SERIAL])
TRACE   [2016-11-27 06:55:31,313] [localhost-startStop-1] driver.core.Connection (Connection.java:519)      Connection[/10.0.0.184:9042-2, inFlight=1, closed=false], stream 1088, writing request QUERY CREATE TABLE IF NOT EXISTS userrecom_newusers(userid bigint, timestamp bigint,  PRIMARY KEY (userid))([cl=LOCAL_ONE, positionalVals=[], namedVals={}, skip=false, psize=5000, state=null, serialCl=SERIAL])
TRACE   [2016-11-27 06:55:31,313] [cluster3-nio-worker-3] driver.core.Connection (Connection.java:567)      Connection[/10.0.0.184:9042-2, inFlight=1, closed=false], stream 1088, request sent successfully
TRACE   [2016-11-27 06:55:31,313] [cluster3-nio-worker-3] driver.core.Connection (Connection.java:567)      Connection[/10.0.0.184:9042-2, inFlight=1, closed=false], stream 1088, request sent successfully
TRACE   [2016-11-27 06:55:31,315] [cluster3-nio-worker-3] driver.core.Connection (Connection.java:979)      Connection[/10.0.0.184:9042-2, inFlight=1, closed=false], stream 1088, received: ERROR UNAUTHORIZED: system_schema keyspace is not user-modifiable.
TRACE   [2016-11-27 06:55:31,315] [cluster3-nio-worker-3] driver.core.Connection (Connection.java:979)      Connection[/10.0.0.184:9042-2, inFlight=1, closed=false], stream 1088, received: ERROR UNAUTHORIZED: system_schema keyspace is not user-modifiable.
TRACE   [2016-11-27 06:55:31,316] [cluster3-nio-worker-3] driver.core.RequestHandler (RequestHandler.java:166)      [1154641956-1] Setting final result
TRACE   [2016-11-27 06:55:31,316] [cluster3-nio-worker-3] driver.core.RequestHandler (RequestHandler.java:166)      [1154641956-1] Setting final result
ERROR   [2016-11-27 06:55:31,316] [localhost-startStop-1] cassandra.impl.SimpleCassandraClientImpl (CassandraDDLManagerImpl.java:274)       Error during the creation of table:prosolo_logs_mooc for DDL:CREATE TABLE IF NOT EXISTS userrecom_newusers(userid bigint, timestamp bigint,  PRIMARY KEY (userid))
com.datastax.driver.core.exceptions.UnauthorizedException: system_schema keyspace is not user-modifiable.
    at com.datastax.driver.core.exceptions.UnauthorizedException.copy(UnauthorizedException.java:59)
    at com.datastax.driver.core.exceptions.UnauthorizedException.copy(UnauthorizedException.java:25)
    at com.datastax.driver.core.DriverThrowables.propagateCause(DriverThrowables.java:37)
    at com.datastax.driver.core.DefaultResultSetFuture.getUninterruptibly(DefaultResultSetFuture.java:245)
    at com.datastax.driver.core.AbstractSession.execute(AbstractSession.java:63)
    at com.datastax.driver.core.AbstractSession.execute(AbstractSession.java:39)
    at org.prosolo.bigdata.dal.cassandra.impl.CassandraDDLManagerImpl.checkIfTablesExistsAndCreate(CassandraDDLManagerImpl.java:272)
    at org.prosolo.bigdata.dal.cassandra.impl.CassandraDDLManagerImpl.<init>(CassandraDDLManagerImpl.java:39)
    at org.prosolo.bigdata.dal.cassandra.impl.CassandraDDLManagerImpl.<init>(CassandraDDLManagerImpl.java:23)
    at org.prosolo.bigdata.dal.cassandra.impl.CassandraDDLManagerImpl$CassandraDDLManagerImplHolder.<clinit>(CassandraDDLManagerImpl.java:44)
    at org.prosolo.bigdata.dal.cassandra.impl.CassandraDDLManagerImpl.getInstance(CassandraDDLManagerImpl.java:47)
    at org.prosolo.bigdata.app.ContextLoader.contextInitialized(ContextLoader.java:40)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4842)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5303)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:940)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1816)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: com.datastax.driver.core.exceptions.UnauthorizedException: system_schema keyspace is not user-modifiable.
    at com.datastax.driver.core.Responses$Error.asException(Responses.java:134)
    at com.datastax.driver.core.DefaultResultSetFuture.onSet(DefaultResultSetFuture.java:179)
    at com.datastax.driver.core.RequestHandler.setFinalResult(RequestHandler.java:184)
    at com.datastax.driver.core.RequestHandler.access$2500(RequestHandler.java:43)
    at com.datastax.driver.core.RequestHandler$SpeculativeExecution.setFinalResult(RequestHandler.java:798)
    at com.datastax.driver.core.RequestHandler$SpeculativeExecution.onSet(RequestHandler.java:617)
    at com.datastax.driver.core.Connection$Dispatcher.channelRead0(Connection.java:1005)
    at com.datastax.driver.core.Connection$Dispatcher.channelRead0(Connection.java:928)
    at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:318)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:304)
    at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:266)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:318)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:304)
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:318)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:304)
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:276)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:263)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:318)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:304)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
    at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:831)
    at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:346)
    at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:254)
    at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
    ... 1 more

This query is executed fine from Datastax DevCenter. I'm using datastax cassandra driver 3.0.0.

Any idea what might be the problem?

UPDATE:

This is the code I'm using to connect to cluster:

public void connect(String node, int dbPort, String keyspace, int replicationFactor) {
    System.out.println("CONNECTING CASSANDRA:"+node+" keyspace:"+keyspace);
    if (this.session != null) {
        return;
    }
    if (this.cluster != null) {
        return;
    }
    /*cluster = Cluster.builder().addContactPoint(node).build();*/
    this.cluster = Cluster.builder()
            .withPoolingOptions( getPoolingOptions())
            .withRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE)
            .withReconnectionPolicy(new ConstantReconnectionPolicy(100L))
            .withPort(dbPort)
            .addContactPoint(node).build();
    Metadata metadata = cluster.getMetadata();
    System.out.printf("Connected to cluster: %s\n",
            metadata.getClusterName());
    for ( Host host : metadata.getAllHosts() ) {
        System.out.printf("Datacenter: %s; Host: %s; Rack: %s\n",
                host.getDatacenter(), host.getAddress(), host.getRack());
    }
    if (keyspace != null) {
        try {
            this.session = this.cluster.connect(keyspace);
        } catch (InvalidQueryException iqu) {
            logger.error(iqu);
            this.session = this.cluster.connect();
            this.createSchemaIfNotExists(this.session, keyspace,
                    replicationFactor);
        }
    } else {
        this.session = this.cluster.connect();
    }
    this.session.execute("USE "+keyspace);
}

After I made couple of changes I'm now getting an exception

Caused by: com.datastax.driver.core.exceptions.InvalidQueryException: unconfigured table logevents

Whole error log is:

    TRACE   [2016-11-27 20:09:08,775] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:72)       [1994318425] USE prosolo_logs_mooc
TRACE   [2016-11-27 20:09:08,775] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:72)       [1994318425] USE prosolo_logs_mooc
TRACE   [2016-11-27 20:09:08,775] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:262)      [1994318425-1] Starting
TRACE   [2016-11-27 20:09:08,775] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:262)      [1994318425-1] Starting
TRACE   [2016-11-27 20:09:08,775] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:270)      [1994318425-1] Querying node /10.0.0.182:9042
TRACE   [2016-11-27 20:09:08,775] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:270)      [1994318425-1] Querying node /10.0.0.182:9042
TRACE   [2016-11-27 20:09:08,775] [localhost-startStop-1] driver.core.Connection (Connection.java:472)      Connection[/10.0.0.182:9042-1, inFlight=1, closed=false] Setting keyspace prosolo_logs_mooc
TRACE   [2016-11-27 20:09:08,775] [localhost-startStop-1] driver.core.Connection (Connection.java:472)      Connection[/10.0.0.182:9042-1, inFlight=1, closed=false] Setting keyspace prosolo_logs_mooc
TRACE   [2016-11-27 20:09:08,776] [localhost-startStop-1] driver.core.Connection (Connection.java:532)      Connection[/10.0.0.182:9042-1, inFlight=1, closed=false], stream 384, writing request QUERY USE "prosolo_logs_mooc"([cl=ONE, positionalVals=[], namedVals={}, skip=false, psize=-1, state=null, serialCl=SERIAL])
TRACE   [2016-11-27 20:09:08,776] [localhost-startStop-1] driver.core.Connection (Connection.java:532)      Connection[/10.0.0.182:9042-1, inFlight=1, closed=false], stream 384, writing request QUERY USE "prosolo_logs_mooc"([cl=ONE, positionalVals=[], namedVals={}, skip=false, psize=-1, state=null, serialCl=SERIAL])
TRACE   [2016-11-27 20:09:08,776] [cluster3-nio-worker-1] driver.core.Connection (Connection.java:580)      Connection[/10.0.0.182:9042-1, inFlight=1, closed=false], stream 384, request sent successfully
TRACE   [2016-11-27 20:09:08,776] [cluster3-nio-worker-1] driver.core.Connection (Connection.java:580)      Connection[/10.0.0.182:9042-1, inFlight=1, closed=false], stream 384, request sent successfully
TRACE   [2016-11-27 20:09:08,776] [cluster3-nio-worker-1] driver.core.Connection (Connection.java:986)      Connection[/10.0.0.182:9042-1, inFlight=1, closed=false], stream 384, received: RESULT set keyspace prosolo_logs_mooc
TRACE   [2016-11-27 20:09:08,776] [cluster3-nio-worker-1] driver.core.Connection (Connection.java:986)      Connection[/10.0.0.182:9042-1, inFlight=1, closed=false], stream 384, received: RESULT set keyspace prosolo_logs_mooc
TRACE   [2016-11-27 20:09:08,777] [localhost-startStop-1] driver.core.Connection (Connection.java:532)      Connection[/10.0.0.182:9042-1, inFlight=1, closed=false], stream 448, writing request QUERY USE prosolo_logs_mooc([cl=LOCAL_ONE, positionalVals=[], namedVals={}, skip=false, psize=5000, state=null, serialCl=SERIAL])
TRACE   [2016-11-27 20:09:08,777] [localhost-startStop-1] driver.core.Connection (Connection.java:532)      Connection[/10.0.0.182:9042-1, inFlight=1, closed=false], stream 448, writing request QUERY USE prosolo_logs_mooc([cl=LOCAL_ONE, positionalVals=[], namedVals={}, skip=false, psize=5000, state=null, serialCl=SERIAL])
TRACE   [2016-11-27 20:09:08,777] [cluster3-nio-worker-1] driver.core.Connection (Connection.java:580)      Connection[/10.0.0.182:9042-1, inFlight=1, closed=false], stream 448, request sent successfully
TRACE   [2016-11-27 20:09:08,777] [cluster3-nio-worker-1] driver.core.Connection (Connection.java:580)      Connection[/10.0.0.182:9042-1, inFlight=1, closed=false], stream 448, request sent successfully
TRACE   [2016-11-27 20:09:08,777] [cluster3-nio-worker-1] driver.core.Connection (Connection.java:986)      Connection[/10.0.0.182:9042-1, inFlight=1, closed=false], stream 448, received: RESULT set keyspace prosolo_logs_mooc
TRACE   [2016-11-27 20:09:08,777] [cluster3-nio-worker-1] driver.core.Connection (Connection.java:986)      Connection[/10.0.0.182:9042-1, inFlight=1, closed=false], stream 448, received: RESULT set keyspace prosolo_logs_mooc
TRACE   [2016-11-27 20:09:08,778] [cluster3-nio-worker-1] driver.core.RequestHandler (RequestHandler.java:156)      [1994318425-1] Setting final result
TRACE   [2016-11-27 20:09:08,778] [cluster3-nio-worker-1] driver.core.RequestHandler (RequestHandler.java:156)      [1994318425-1] Setting final result
TRACE   [2016-11-27 20:09:08,778] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:72)       [1035879214] CREATE INDEX IF NOT EXISTS eventtype_id ON logevents (eventtype);
TRACE   [2016-11-27 20:09:08,778] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:72)       [1035879214] CREATE INDEX IF NOT EXISTS eventtype_id ON logevents (eventtype);
TRACE   [2016-11-27 20:09:08,778] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:262)      [1035879214-1] Starting
TRACE   [2016-11-27 20:09:08,778] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:262)      [1035879214-1] Starting
TRACE   [2016-11-27 20:09:08,778] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:270)      [1035879214-1] Querying node /10.0.0.183:9042
TRACE   [2016-11-27 20:09:08,778] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:270)      [1035879214-1] Querying node /10.0.0.183:9042
TRACE   [2016-11-27 20:09:08,778] [localhost-startStop-1] driver.core.Connection (Connection.java:472)      Connection[/10.0.0.183:9042-1, inFlight=1, closed=false] Setting keyspace prosolo_logs_mooc
TRACE   [2016-11-27 20:09:08,778] [localhost-startStop-1] driver.core.Connection (Connection.java:472)      Connection[/10.0.0.183:9042-1, inFlight=1, closed=false] Setting keyspace prosolo_logs_mooc
TRACE   [2016-11-27 20:09:08,778] [localhost-startStop-1] driver.core.Connection (Connection.java:532)      Connection[/10.0.0.183:9042-1, inFlight=1, closed=false], stream 384, writing request QUERY USE "prosolo_logs_mooc"([cl=ONE, positionalVals=[], namedVals={}, skip=false, psize=-1, state=null, serialCl=SERIAL])
TRACE   [2016-11-27 20:09:08,778] [localhost-startStop-1] driver.core.Connection (Connection.java:532)      Connection[/10.0.0.183:9042-1, inFlight=1, closed=false], stream 384, writing request QUERY USE "prosolo_logs_mooc"([cl=ONE, positionalVals=[], namedVals={}, skip=false, psize=-1, state=null, serialCl=SERIAL])
TRACE   [2016-11-27 20:09:08,779] [cluster3-nio-worker-2] driver.core.Connection (Connection.java:580)      Connection[/10.0.0.183:9042-1, inFlight=1, closed=false], stream 384, request sent successfully
TRACE   [2016-11-27 20:09:08,779] [cluster3-nio-worker-2] driver.core.Connection (Connection.java:580)      Connection[/10.0.0.183:9042-1, inFlight=1, closed=false], stream 384, request sent successfully
TRACE   [2016-11-27 20:09:08,779] [cluster3-nio-worker-2] driver.core.Connection (Connection.java:986)      Connection[/10.0.0.183:9042-1, inFlight=1, closed=false], stream 384, received: RESULT set keyspace prosolo_logs_mooc
TRACE   [2016-11-27 20:09:08,779] [cluster3-nio-worker-2] driver.core.Connection (Connection.java:986)      Connection[/10.0.0.183:9042-1, inFlight=1, closed=false], stream 384, received: RESULT set keyspace prosolo_logs_mooc
TRACE   [2016-11-27 20:09:08,780] [localhost-startStop-1] driver.core.Connection (Connection.java:532)      Connection[/10.0.0.183:9042-1, inFlight=1, closed=false], stream 448, writing request QUERY CREATE INDEX IF NOT EXISTS eventtype_id ON logevents (eventtype);([cl=LOCAL_ONE, positionalVals=[], namedVals={}, skip=false, psize=5000, state=null, serialCl=SERIAL])
TRACE   [2016-11-27 20:09:08,780] [localhost-startStop-1] driver.core.Connection (Connection.java:532)      Connection[/10.0.0.183:9042-1, inFlight=1, closed=false], stream 448, writing request QUERY CREATE INDEX IF NOT EXISTS eventtype_id ON logevents (eventtype);([cl=LOCAL_ONE, positionalVals=[], namedVals={}, skip=false, psize=5000, state=null, serialCl=SERIAL])
TRACE   [2016-11-27 20:09:08,780] [cluster3-nio-worker-2] driver.core.Connection (Connection.java:580)      Connection[/10.0.0.183:9042-1, inFlight=1, closed=false], stream 448, request sent successfully
TRACE   [2016-11-27 20:09:08,780] [cluster3-nio-worker-2] driver.core.Connection (Connection.java:580)      Connection[/10.0.0.183:9042-1, inFlight=1, closed=false], stream 448, request sent successfully
TRACE   [2016-11-27 20:09:08,781] [cluster3-nio-worker-2] driver.core.Connection (Connection.java:986)      Connection[/10.0.0.183:9042-1, inFlight=1, closed=false], stream 448, received: ERROR INVALID: unconfigured table logevents
TRACE   [2016-11-27 20:09:08,781] [cluster3-nio-worker-2] driver.core.Connection (Connection.java:986)      Connection[/10.0.0.183:9042-1, inFlight=1, closed=false], stream 448, received: ERROR INVALID: unconfigured table logevents
TRACE   [2016-11-27 20:09:08,781] [cluster3-nio-worker-2] driver.core.RequestHandler (RequestHandler.java:156)      [1035879214-1] Setting final result
TRACE   [2016-11-27 20:09:08,781] [cluster3-nio-worker-2] driver.core.RequestHandler (RequestHandler.java:156)      [1035879214-1] Setting final result
ERROR   [2016-11-27 20:09:08,782] [localhost-startStop-1] cassandra.impl.SimpleCassandraClientImpl (CassandraDDLManagerImpl.java:274)       Error during the creation of table:prosolo_logs_mooc for DDL:CREATE INDEX IF NOT EXISTS eventtype_id ON logevents (eventtype);
com.datastax.driver.core.exceptions.InvalidQueryException: unconfigured table logevents
    at com.datastax.driver.core.exceptions.InvalidQueryException.copy(InvalidQueryException.java:50)
    at com.datastax.driver.core.DriverThrowables.propagateCause(DriverThrowables.java:37)
    at com.datastax.driver.core.DefaultResultSetFuture.getUninterruptibly(DefaultResultSetFuture.java:245)
    at com.datastax.driver.core.AbstractSession.execute(AbstractSession.java:64)
    at com.datastax.driver.core.AbstractSession.execute(AbstractSession.java:39)
    at org.prosolo.bigdata.dal.cassandra.impl.CassandraDDLManagerImpl.checkIfTablesExistsAndCreate(CassandraDDLManagerImpl.java:272)
    at org.prosolo.bigdata.dal.cassandra.impl.CassandraDDLManagerImpl.<init>(CassandraDDLManagerImpl.java:39)
    at org.prosolo.bigdata.dal.cassandra.impl.CassandraDDLManagerImpl.<init>(CassandraDDLManagerImpl.java:23)
    at org.prosolo.bigdata.dal.cassandra.impl.CassandraDDLManagerImpl$CassandraDDLManagerImplHolder.<clinit>(CassandraDDLManagerImpl.java:44)
    at org.prosolo.bigdata.dal.cassandra.impl.CassandraDDLManagerImpl.getInstance(CassandraDDLManagerImpl.java:47)
    at org.prosolo.bigdata.app.ContextLoader.contextInitialized(ContextLoader.java:40)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4842)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5303)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:940)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1816)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: com.datastax.driver.core.exceptions.InvalidQueryException: unconfigured table logevents
    at com.datastax.driver.core.Responses$Error.asException(Responses.java:136)
    at com.datastax.driver.core.DefaultResultSetFuture.onSet(DefaultResultSetFuture.java:179)
    at com.datastax.driver.core.RequestHandler.setFinalResult(RequestHandler.java:174)
    at com.datastax.driver.core.RequestHandler.access$2600(RequestHandler.java:43)
    at com.datastax.driver.core.RequestHandler$SpeculativeExecution.setFinalResult(RequestHandler.java:793)
    at com.datastax.driver.core.RequestHandler$SpeculativeExecution.onSet(RequestHandler.java:627)
    at com.datastax.driver.core.Connection$Dispatcher.channelRead0(Connection.java:1012)
    at com.datastax.driver.core.Connection$Dispatcher.channelRead0(Connection.java:935)
    at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:342)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:328)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:321)
    at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:266)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:342)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:328)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:321)
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:342)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:328)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:321)
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:342)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:328)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:321)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1280)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:342)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:328)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:890)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:564)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:505)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:419)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:391)
    at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
    ... 1 more
TRACE   [2016-11-27 20:09:08,783] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:72)       [1037500672] USE prosolo_logs_mooc

UPDATE 2:

It seems that all the problems I had are related to the cluster which was not properly configured. Even though nodetool status indicated all nodes are attached, some nodes were unreachable and there was schema disagreement. After I fixed these issue, everything was fine.

1
How does your cql for creating the 23'rd table look? You are not supposed to change system_schemas manually, cassandra maintains those for you.Andreas Wederbrand

1 Answers

0
votes

Here is the Working Code in Java :

public static void main(String[] args) {
    try (Cluster cluster = Cluster.builder().addContactPoints("127.0.0.1").withCredentials("username", "password").build(); Session session = cluster.connect("test")) {
        createTableIfNotExist(cluster, session, "test");
    }
}

private static void createTableIfNotExist(Cluster cluster, Session session, String keyspace) {
    Metadata metadata = cluster.getMetadata();
    TableMetadata tableMetadata = metadata.getKeyspace(keyspace).getTable("exp");
    if (tableMetadata == null) {
        session.execute("USE " + keyspace);
        session.execute("CREATE TABLE exp(a int primary key, b int)");
    }
}