void incrementEntry()

in transaction/src/main/java/org/apache/geode_examples/transaction/Incrementer.java [52:69]


  void incrementEntry() {
    CacheTransactionManager cacheTransactionManager = cache.getCacheTransactionManager();
    for (int i = 0; i < Example.INCREMENTS; ++i) {
      boolean incremented = false;
      while (!incremented) {
        try {
          cacheTransactionManager.begin();
          final Integer oldValue = region.get(Example.KEY);
          final Integer newValue = oldValue + 1;
          region.put(Example.KEY, newValue);
          cacheTransactionManager.commit();
          incremented = true;
        } catch (CommitConflictException cce) {
          // Do nothing.
        }
      }
    }
  }