public void run() { int baseKey = (index * keyCount) % keys.size(); for (int i = 0; i < requests; i++) { int keyIndex = (baseKey + (i % keyCount)) % keys.size(); String key = keys.get(keyIndex); Transaction txn = fac.create(); long start = System.currentTimeMillis(); try { txn.begin(); byte[] value = txn.read(key); txn.commit(); timeElapsed += System.currentTimeMillis() - start; if (!silent.get()) { System.out.println("[Thread-" + index + "] " + key + ": " + new String(value)); } success++; } catch (Exception e) { timeElapsed += System.currentTimeMillis() - start; if (!silent.get()) { System.out.println("[Thread-" + index + "] Error: " + e.getMessage()); } failure++; } } }
private static void readOnlyTransaction(TransactionFactory fac, String key) { Transaction txn = fac.create(); try { txn.begin(); byte[] value = txn.read(key); System.out.println(key + ": " + new String(value)); txn.commit(); } catch (TransactionException e) { System.out.println("Error: " + e.getMessage()); } }