Пример #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
  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());
    }
  }
Пример #3
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());
   }
 }