/** * @param start the timestamp taken when the operation started */ @Override public void endCacheWriterCall(long start) { if (enableClockStats) { this.stats.incLong(cacheWriterCallTimeId, getStatTime() - start); } this.stats.incInt(cacheWriterCallsInProgressId, -1); this.stats.incInt(cacheWriterCallsCompletedId, 1); this.cachePerfStats.endCacheWriterCall(start); }
/** * Characterization test: Note that the only way to increment {@code cacheWriterCallsCompleted} is * to invoke {@code endCacheWriterCall}. */ @Test public void endCacheWriterCallIncrementsCacheWriterCallsCompleted() { cachePerfStats.endCacheWriterCall(0); assertThat(statistics.getInt(cacheWriterCallsCompletedId)).isEqualTo(1); }
private void cacheWriteBeforeRegionClear(RegionEventImpl event) throws CacheWriterException, TimeoutException { // copy into local var to prevent race condition CacheWriter writer = basicGetWriter(); if (writer != null) { final long start = getCachePerfStats().startCacheWriterCall(); try { writer.beforeRegionClear(event); } finally { getCachePerfStats().endCacheWriterCall(start); } } serverRegionClear(event); }
/** * Characterization test: {@code cacheWriterCallsCompleted} currently wraps to negative from max * integer value. */ @Test public void cacheWriterCallsCompletedWrapsFromMaxIntegerToNegativeValue() { statistics.incInt(cacheWriterCallsCompletedId, Integer.MAX_VALUE); cachePerfStats.endCacheWriterCall(0); assertThat(cachePerfStats.getCacheWriterCallsCompleted()).isNegative(); }
getCachePerfStats().endCacheWriterCall(start);
/** * @return true if cacheWrite was performed * @see DistributedRegion#cacheWriteBeforeRegionDestroy(RegionEventImpl) */ boolean cacheWriteBeforeRegionDestroy(RegionEventImpl event) throws CacheWriterException, TimeoutException { boolean result = false; // copy into local var to prevent race condition CacheWriter writer = basicGetWriter(); if (writer != null) { final long start = getCachePerfStats().startCacheWriterCall(); try { writer.beforeRegionDestroy(event); } finally { getCachePerfStats().endCacheWriterCall(start); } result = true; } serverRegionDestroy(event); return result; }
processor.release(); } finally { getCachePerfStats().endCacheWriterCall(start);
@Override boolean cacheWriteBeforeRegionDestroy(RegionEventImpl event) throws CacheWriterException, TimeoutException { boolean result = false; if (event.getOperation().isDistributed()) { CacheWriter localWriter = basicGetWriter(); Set netWriteRecipients = localWriter == null ? this.distAdvisor.adviseNetWrite() : null; if (localWriter != null || netWriteRecipients != null && !netWriteRecipients.isEmpty()) { final long start = getCachePerfStats().startCacheWriterCall(); try { SearchLoadAndWriteProcessor processor = SearchLoadAndWriteProcessor.getProcessor(); try { processor.initialize(this, "preDestroyRegion", null); processor.doNetWrite(event, netWriteRecipients, localWriter, SearchLoadAndWriteProcessor.BEFOREREGIONDESTROY); result = true; } finally { processor.release(); } } finally { getCachePerfStats().endCacheWriterCall(start); } } serverRegionDestroy(event); } return result; }
/** * This invokes a cache writer before a destroy operation. Although it has the same method * signature as the method in LocalRegion, it is invoked in a different code path. LocalRegion * invokes this method via its "entries" member, while PartitionedRegion invokes this method in * its region operation methods and messages. */ @Override boolean cacheWriteBeforeRegionDestroy(RegionEventImpl event) throws CacheWriterException, TimeoutException { if (event.getOperation().isDistributed()) { serverRegionDestroy(event); CacheWriter localWriter = basicGetWriter(); Set netWriteRecipients = localWriter == null ? this.distAdvisor.adviseNetWrite() : null; if (localWriter == null && (netWriteRecipients == null || netWriteRecipients.isEmpty())) { return false; } final long start = getCachePerfStats().startCacheWriterCall(); try { SearchLoadAndWriteProcessor processor = SearchLoadAndWriteProcessor.getProcessor(); processor.initialize(this, "preDestroyRegion", null); processor.doNetWrite(event, netWriteRecipients, localWriter, SearchLoadAndWriteProcessor.BEFOREREGIONDESTROY); processor.release(); } finally { getCachePerfStats().endCacheWriterCall(start); } return true; } return false; }
getCachePerfStats().endCacheWriterCall(start);
/** * @return true if cacheWrite was performed * @see DistributedRegion#cacheWriteBeforeDestroy(EntryEventImpl, Object) */ @Override public boolean cacheWriteBeforeDestroy(EntryEventImpl event, Object expectedOldValue) throws CacheWriterException, EntryNotFoundException, TimeoutException { boolean result = false; // copy into local var to prevent race condition CacheWriter writer = basicGetWriter(); if (writer != null && event.getOperation() != Operation.REMOVE && !event.inhibitAllNotifications()) { final long start = getCachePerfStats().startCacheWriterCall(); event.setReadOldValueFromDisk(true); try { writer.beforeDestroy(event); } finally { event.setReadOldValueFromDisk(false); getCachePerfStats().endCacheWriterCall(start); } result = true; } serverDestroy(event, expectedOldValue); return result; }
getCachePerfStats().endCacheWriterCall(start);
@Override public void cacheWriteBeforePut(EntryEventImpl event, Set netWriteRecipients, CacheWriter localWriter, boolean requireOldValue, Object expectedOldValue) throws CacheWriterException, TimeoutException { Assert.assertTrue(netWriteRecipients == null); Operation operation = event.getOperation(); boolean isPutIfAbsentOrReplace = operation == Operation.PUT_IF_ABSENT || operation == Operation.REPLACE; if (!isPutIfAbsentOrReplace && localWriter != null && !event.inhibitAllNotifications()) { final long start = getCachePerfStats().startCacheWriterCall(); final boolean newEntry = event.getOperation().isCreate(); event.setReadOldValueFromDisk(true); try { if (!newEntry) { localWriter.beforeUpdate(event); } else { localWriter.beforeCreate(event); } } finally { event.setReadOldValueFromDisk(false); getCachePerfStats().endCacheWriterCall(start); } } serverPut(event, requireOldValue, expectedOldValue); }