java.lang.RuntimeException: exception while registering MBean, com.scale7.cassandra.pelops.pool:type=PooledNode-my_keyspace-localhost -
i working on project in need insert data cassandra database. using pelops client
.
i have multithreaded code insert cassandra database using pelops client
. , using executorservice
that.
in program, each thread work on range, like
thread1 work on 1 20 thread2 work on 21 40 ... ...
below code have using insert cassandra database-
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 tasks (int = 0, nextid = startrange; < 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 interrupted exception in" + cname + ".pelopslnpclient: boss told me stop...not fault!!"); } catch (exception e) { log.error("threw exception in" + cname + e); } }
below cassandratask class
implements runnable interface
class cassandratask implements runnable { private final int id; private final int nooftasks; private final string nodes = "localhost"; private final string thrift_connection_pool = "test cluster"; private final string keyspace = "my_keyspace"; private final string column_family = "profile_user"; public cassandratask(int nextid, int nooftasks) { this.id = nextid; this.nooftasks = nooftasks; } public void run() { try { cassandraconnection(); mutator mutator = pelops.createmutator(thrift_connection_pool); (int userid = id; userid < id + nooftasks; userid++) { mutator.writecolumns(column_family, string.valueof(userid), mutator.newcolumnlist( mutator.newcolumn("unt", "{\"lv\":[{\"v\":{\"regsiteid\":null,\"userstate\":null,\"userid\":" + userid + "},\"cn\":1}],\"lmd\":20130206211109}"), mutator.newcolumn("rtising", "{\"lv\":[{\"v\":{\"thirdpartyadsonhostdomain\":null,\"hostdomainadsonthirdparty\":null,\"userid\":" + userid + "},\"cn\":2}],\"lmd\":20130206211109}"), mutator.newcolumn("selling_price_main_cats", "{\"lv\":[{\"v\":{\"regsiteid\":null,\"userstate\":null,\"userid\":" + userid + "},\"cn\":1}],\"lmd\":20130206211109}"), mutator.newcolumn("and_keyword_rules", "{\"lv\":[{\"v\":{\"regsiteid\":null,\"userstate\":null,\"userid\":" + userid + "},\"cn\":1}],\"lmd\":20130206211109}"), mutator.newcolumn("categories_purchased", "{\"lv\":[{\"v\":{\"regsiteid\":null,\"userstate\":null,\"userid\":" + userid + "},\"cn\":1}],\"lmd\":20130206211109}"), mutator.newcolumn("omer_service", "{\"lv\":[{\"v\":{\"regsiteid\":null,\"userstate\":null,\"userid\":" + userid + "},\"cn\":1}],\"lmd\":20130206211109}"), mutator.newcolumn("graphic", "{\"lv\":[{\"v\":{\"regsiteid\":null,\"userstate\":null,\"userid\":" + userid + "},\"cn\":1}],\"lmd\":20130206211109}"), mutator.newcolumn("rite_searches", "{\"lv\":[{\"v\":{\"regsiteid\":null,\"userstate\":null,\"userid\":" + userid + "},\"cn\":1}],\"lmd\":20130206211109}") )); } mutator.execute(consistencylevel.one); } catch (exception e) { system.err.println("threw exception in " + e); } { pelops.shutdown(); } } /** * making cassandra connection adding nodes * / private void cassandraconnection() { cluster cluster = new cluster(nodes, 9160); pelops.addpool(thrift_connection_pool, cluster, keyspace); } }
whenever running above program, getting below exceptions always-
threw exception in java.lang.runtimeexception: exception while registering mbean, com.scale7.cassandra.pelops.pool:type=poolednode-my_keyspace-localhost
can me out wrong doing here? believe there minor mistake making here? if running slowly don't exception. slow means, putting breakpoint in code. strange somehow.
i working cassandra 1.2.3
any appreciated.
which client version using? far can see each thread creates pool (with same name!) cassandra , each 1 shutdown pelops client.
move pool creation in main class, create 1 pool , access threads , never call pelops.shutdown() until last thread performed execute method.
carlo
Comments
Post a Comment