public boolean incMissedCycleCountForSector(long sectorIndex) {
   Boolean relevance = (Boolean) memcacheService.get(MC_KEY_SECTOR_RELEVANCE_PREFIX + sectorIndex);
   boolean result = ((relevance == null) || !relevance);
   if (result) {
     memcacheService.increment(MC_KEY_SECTOR_MISSED_CYCLE_COUNT + sectorIndex, 1L, 0L);
   }
   return result;
 }
Esempio n. 2
0
 /**
  * Increments the value by a positive delta
  *
  * @param delta
  * @return the value that the counter was changed to
  */
 public long increment(long delta) {
   Preconditions.checkArgument(delta > 0, "delta must be a positive value");
   populateMemcache();
   final Long result = memcache.increment(memcacheKey, delta);
   if (random.nextDouble() <= chanceToWrite) {
     String shardKey = prefix + random.nextInt(numShards);
     persistence.mutate(
         shardKey,
         new Function<Long, Long>() {
           @Override
           public Long apply(Long oldValue) {
             if (oldValue == null) {
               return result;
             }
             return Math.max(oldValue, result);
           }
         });
   }
   return result;
 }