/** * update stats */ private void updateStatsForPut(long startPut) { getCachePerfStats().endPut(startPut, false); }
/** * Characterization test: Note that the only way to increment {@code putTime} is to invoke * {@code endPut}. */ @Test public void endPutIncrementsPutTime() { cachePerfStats.endPut(0, false); assertThat(statistics.getLong(putTimeId)).isEqualTo(CLOCK_TIME); }
/** * Characterization test: Note that the only way to increment {@code updates} is to invoke * {@code endPut}. */ @Test public void endPutIncrementsUpdates() { cachePerfStats.endPut(0, true); assertThat(statistics.getInt(updatesId)).isEqualTo(1); }
/** * Characterization test: Note that the only way to increment {@code puts} is to invoke * {@code endPut}. */ @Test public void endPutIncrementsPuts() { cachePerfStats.endPut(0, false); assertThat(statistics.getInt(putsId)).isEqualTo(1); }
@Before public void setup() { event = mock(EntryEventImpl.class); region = mock(DistributedRegion.class); RegionAttributes attr = mock(RegionAttributes.class); CachePerfStats stats = mock(CachePerfStats.class); when(event.isOriginRemote()).thenReturn(false); when(stats.endPut(anyLong(), eq(false))).thenReturn(0L); message = new UpdateOperation.UpdateMessage(); message.event = event; when(region.isAllEvents()).thenReturn(true); when(region.getAttributes()).thenReturn(attr); when(region.isUsedForPartitionedRegionBucket()).thenReturn(false); when(region.getDataPolicy()).thenReturn(DataPolicy.REPLICATE); when(region.getConcurrencyChecksEnabled()).thenReturn(true); when(region.getCachePerfStats()).thenReturn(stats); when(attr.getDataPolicy()).thenReturn(DataPolicy.REPLICATE); when(event.getOperation()).thenReturn(Operation.CREATE); }
/** * Characterization test: {@code updates} currently wraps to negative from max integer value. */ @Test public void updatesWrapsFromMaxIntegerToNegativeValue() { statistics.incInt(updatesId, Integer.MAX_VALUE); cachePerfStats.endPut(0, true); assertThat(cachePerfStats.getUpdates()).isNegative(); }
/** * Characterization test: {@code puts} currently wraps to negative from max integer value. */ @Test public void putsWrapsFromMaxIntegerToNegativeValue() { statistics.incInt(putsId, Integer.MAX_VALUE); cachePerfStats.endPut(0, false); assertThat(cachePerfStats.getPuts()).isNegative(); }
/** * @param start the timestamp taken when the operation started * @param isUpdate true if the put was an update (origin remote) */ @Override public long endPut(long start, boolean isUpdate) { long total = 0; if (isUpdate) { this.stats.incInt(updatesId, 1); if (enableClockStats) { total = getStatTime() - start; this.stats.incLong(updateTimeId, total); } } else { this.stats.incInt(putsId, 1); if (enableClockStats) { total = getStatTime() - start; this.stats.incLong(putTimeId, total); } } this.cachePerfStats.endPut(start, isUpdate); return total; }
private void putNewValueInRegion(boolean isCreate, EntryEventImpl clientEvent, long lastModified, EntryEventImpl event) { RegionEntry re = null; // Set eventId. Required for interested clients. event.setNewEventId(cache.getDistributedSystem()); long startPut = CachePerfStats.getStatTime(); validateKey(event.getKey()); // this next step also distributes the object to other processes, if necessary try { re = basicPutEntry(event, lastModified); // Update client event with latest version tag from re. if (re != null && clientEvent != null) { clientEvent.setVersionTag(event.getVersionTag()); } if (!isTX()) { getCachePerfStats().endPut(startPut, event.isOriginRemote()); } } catch (ConcurrentCacheModificationException e) { // the cache was modified while we were searching for this entry and // the netsearch result was elided. Return the current value from the cache updateEventWithCurrentRegionEntry(event, clientEvent); } catch (CacheWriterException cwe) { if (logger.isDebugEnabled()) { logger.debug("findObjectInSystem: writer exception putting entry {} : {}", event, cwe); } } if (isCreate) { recordMiss(re, event.getKey()); } }
private void validatedCreate(EntryEventImpl event, long startPut) throws TimeoutException, EntryExistsException, CacheWriterException { if (event.getEventId() == null && generateEventID()) { event.setNewEventId(this.cache.getDistributedSystem()); } // Fix for 42448 - Only make create with null a local invalidate for // normal regions. Otherwise, it will become a distributed invalidate. if (getDataPolicy() == DataPolicy.NORMAL) { event.setLocalInvalid(true); } discoverJTA(); if (!basicPut(event, true, // ifNew false, // ifOld null, // expectedOldValue true // requireOldValue TODO txMerge why is oldValue required for // create? I think so that the EntryExistsException will have it. )) { throw new EntryExistsException(event.getKey().toString(), event.getOldValue()); } else { if (!getDataView().isDeferredStats()) { getCachePerfStats().endPut(startPut, false); } } }
Object validatedPut(EntryEventImpl event, long startPut) throws TimeoutException, CacheWriterException { if (event.getEventId() == null && generateEventID()) { event.setNewEventId(this.cache.getDistributedSystem()); } Object oldValue = null; if (basicPut(event, false, // ifNew false, // ifOld null, // expectedOldValue false // requireOldValue )) { if (!event.isOldValueOffHeap()) { // don't copy it to heap just to return from put. // TODO: come up with a better way to do this. oldValue = event.getOldValue(); } if (!getDataView().isDeferredStats()) { getCachePerfStats().endPut(startPut, false); } } return handleNotAvailable(oldValue); }
} else { if (!getDataView().isDeferredStats()) { getCachePerfStats().endPut(startPut, false);
} else { if (!getDataView().isDeferredStats()) { getCachePerfStats().endPut(startPut, false);
boolean overwriteDestroyed = true; // okay to overwrite the DESTROYED token if (basicUpdate(event, ifNew, ifOld, lastModified, overwriteDestroyed)) { getCachePerfStats().endPut(startPut, event.isOriginRemote());
} else { if (!getDataView().isDeferredStats()) { getCachePerfStats().endPut(startPut, false);
getCachePerfStats().endPut(startPut, false); this.stopper.checkCancelInProgress(null);
getCachePerfStats().endPut(startPut, false); this.stopper.checkCancelInProgress(null);
getCachePerfStats().endPut(startPut, false); this.stopper.checkCancelInProgress(null);
getCachePerfStats().endPut(startPut, event.isOriginRemote()); } else { this.stopper.checkCancelInProgress(null);
getCachePerfStats().endPut(startPut, event.isOriginRemote()); } else { this.stopper.checkCancelInProgress(null);