コード例 #1
0
ファイル: MDCCClient.java プロジェクト: vaibhavarora/mdcc
 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
ファイル: MDCCClient.java プロジェクト: vaibhavarora/mdcc
 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
ファイル: MDCCClient.java プロジェクト: vaibhavarora/mdcc
 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
ファイル: MDCCClient.java プロジェクト: vaibhavarora/mdcc
  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
ファイル: MDCCClient.java プロジェクト: vaibhavarora/mdcc
 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());
   }
 }