@Test // 50 times: 597 mills. public void listKeyspaces() throws Exception { int count = 50; // long beg = System.currentTimeMillis(); for (int i = 0; i < count; i++) { CtSession ctSession = ctSessionFactory.openSession(); System.out.println(ctSession); // List<KsDef> kds = ctSession.describe_keyspaces(); for (KsDef kd : kds) { StringBuilder buffer = new StringBuilder(); buffer.append("["); buffer.append(kd.getName()); buffer.append("] "); List<CfDef> cds = kd.getCf_defs(); int size = cds.size(); for (int j = 0; j < size; j++) { buffer.append(cds.get(j).getName()); if (j < size - 1) { buffer.append(", "); } } // System.out.println(buffer); } ctSessionFactory.closeSession(); } long end = System.currentTimeMillis(); System.out.println(count + " times: " + (end - beg) + " mills. "); }
@Test public void getKeyspace() throws Exception { CtSession ctSession = ctSessionFactory.openSession(); // long beg = System.currentTimeMillis(); String KEYSPACE = "system"; // KsDef kd = ctSession.describe_keyspace(KEYSPACE); // NotFoundException ctSessionFactory.closeSession(); // long end = System.currentTimeMillis(); System.out.println((end - beg) + " at mills."); // System.out.println(kd); }