예제 #1
0
 public void run() {
   int baseKey = index;
   for (int i = 0; i < requests; i++) {
     int keyIndex = (baseKey + i);
     String key = keys.get(keyIndex);
     Transaction txn = fac.create();
     long start = System.currentTimeMillis();
     try {
       txn.begin();
       String value = "random_value_" + index + "_" + i;
       txn.write(key, value.getBytes());
       txn.commit();
       timeElapsed += (System.currentTimeMillis() - start);
       if (!silent.get()) {
         System.out.println("[Thread-" + index + "] " + key + ": " + value);
       }
       success++;
     } catch (TransactionException e) {
       timeElapsed += (System.currentTimeMillis() - start);
       if (!silent.get()) {
         System.out.println("[Thread-" + index + "] Error: " + e.getMessage());
       }
       failure++;
     }
   }
 }
예제 #2
0
 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++;
     }
   }
 }
예제 #3
0
 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());
   }
 }
예제 #4
0
  private static void bigLoad(TransactionFactory fac, int numKeys) {
    Transaction txn = fac.create();
    try {
      txn.begin();

      for (int i = 0; i < numKeys; i++) {
        String key = "row" + i;
        String value = "value" + i;
        txn.write(key, value.getBytes());
      }
      txn.commit();
    } catch (TransactionException e) {
      System.out.println("Error: " + e.getMessage());
    }
  }
예제 #5
0
 private static void blindWriteTransaction(TransactionFactory fac, String key, String value) {
   Transaction txn = fac.create();
   try {
     txn.begin();
     txn.write(key, value.getBytes());
     if (Database.DELETE_VALUE_STRING.equals(value)) {
       System.out.println("Key " + key + " deleted");
     } else {
       System.out.println(key + ": " + value);
     }
     txn.commit();
   } catch (TransactionException e) {
     System.out.println("Error: " + e.getMessage());
   }
 }