Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/397.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
java.lang.RuntimeException:注册MBean时发生异常,com.scale7.cassandra.pelops.pool:type=PooledNode-my_keyspace-localhost_Java_Cassandra_Runtimeexception_Pelops - Fatal编程技术网

java.lang.RuntimeException:注册MBean时发生异常,com.scale7.cassandra.pelops.pool:type=PooledNode-my_keyspace-localhost

java.lang.RuntimeException:注册MBean时发生异常,com.scale7.cassandra.pelops.pool:type=PooledNode-my_keyspace-localhost,java,cassandra,runtimeexception,pelops,Java,Cassandra,Runtimeexception,Pelops,我正在做一个项目,我需要将数据插入Cassandra数据库。因此,我使用的是Pelops客户端 我有一个多线程代码,它将使用Pelops-client插入Cassandra数据库。我使用的是执行器服务 在我的程序中,每个线程都会在某个范围内工作,比如 Thread1 will work on 1 to 20 Thread2 will work on 21 to 40 ... ... 下面是我用来插入Cassandra数据库的代码- private static int noOfThreads

我正在做一个项目,我需要将数据插入Cassandra数据库。因此,我使用的是
Pelops客户端

我有一个多线程代码,它将使用
Pelops-client
插入Cassandra数据库。我使用的是执行器服务

在我的程序中,每个线程都会在某个范围内工作,比如

Thread1 will work on 1 to 20
Thread2 will work on 21 to 40
...
...
下面是我用来插入Cassandra数据库的代码-

private static int noOfThreads = 5;
private static int noOfTasks = 100;
private static int startRange = 1;

    public static void main(String[] args) {

        LOG.info("Loading data in Cassandra database..!!");

        ExecutorService service = Executors.newFixedThreadPool(noOfThreads);

        try {
            // queue some tasks
            for (int i = 0, nextId = startRange; i < noOfThreads; i++, nextId += noOfTasks) {

                service.submit(new CassandraTask(nextId, noOfTasks));
            }

            service.shutdown();

            service.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS);
        } catch (InterruptedException e) {
            LOG.warn("Threw a Interrupted Exception in" + CNAME + ".PelopsLnPClient: boss told me to stop...Not my fault!!");
        } catch (Exception e) {
            LOG.error("Threw a Exception in" + CNAME + e);
        } 
    }
每当我运行上面的程序时,我总是得到下面的异常-

Threw a Exception in java.lang.RuntimeException: exception while registering MBean, com.scale7.cassandra.pelops.pool:type=PooledNode-my_keyspace-localhost
有人能帮我解决这个问题吗?我到底做错了什么?我相信我在这里犯了一些小错误?如果我跑得很慢,那么我不会出现这种异常。我的意思是,在代码中放置断点。真奇怪

我和卡桑德拉一起工作1.2.3


任何帮助都将不胜感激。

您使用的是哪种客户端版本?据我所知,每个线程都为cassandra创建了一个池(同名!),并且每个线程都关闭了Pelops客户端

在main类中移动池创建,只创建一个池并从线程访问它,在最后一个线程执行execute方法之前不要调用Pelops.shutdown()


Carlo

而不是这个
System.err.println(“在“+e”中抛出异常)
你真的可以使用e.printStackTrace()并将其发布到你的问题中,这样我们就可以得到关于这个问题的更多细节吗?谢谢carlo的建议。从那以后,一切都很好。但我只是想确定我的做法是否正确?因为我可能遗漏了一些小细节。您能看一下并告诉我更新的代码是否与我创建cassandra连接和集群的方式一致吗。谢谢你的帮助。据我所知,一切都很好——你连接到Cassandra的方式很好,你可以添加一些其他配置,但前提是你需要。。。例如
String nodes=“localhost”;int端口=9_160;布尔节点发现=真;Config casconf=新配置(端口,true,0);Cluster Cluster=新集群(节点、casconf、nodeDiscovery);addPool(节约连接池、集群、键空间)
Ciao,CarloAs至于
mutator.newColumn(“lmd”,String.valueOf(new Date().getTime())
我想提醒你,你已经有了每一列的时间戳,所以你可能不需要写它!更重要的是,使用Pelops,您可以编写长写
mutator.newColumn(“lmd”,Bytes.fromLong(System.currenttimemillis())
是的,这对我来说很有意义。非常感谢Carlo的建议。关于时间戳的问题,我在哪里有每个列的时间戳?我不确定这一点。我还有一个问题与Cassandra数据库和
Pelops client
有关。我为此打开了一个新的。在这方面,我正在尝试为connect创建一个单例类去卡桑德拉数据库,你能帮我看看吗?
Threw a Exception in java.lang.RuntimeException: exception while registering MBean, com.scale7.cassandra.pelops.pool:type=PooledNode-my_keyspace-localhost