@Override public Collection values() { checkReadiness(); checkForNoAccess(); if (!restoreSetOperationTransactionBehavior) { discoverJTA(); } return new EntriesSet(this, false, IteratorType.VALUES, false); }
public Set keys() { checkReadiness(); checkForNoAccess(); if (!restoreSetOperationTransactionBehavior) { discoverJTA(); } return new EntriesSet(this, false, IteratorType.KEYS, false); }
@Override public Set entrySet(boolean recursive) { checkReadiness(); checkForNoAccess(); if (!restoreSetOperationTransactionBehavior) { discoverJTA(); } return basicEntries(recursive); }
@Override public boolean containsValueForKey(Object key) { discoverJTA(); return getDataView().containsValueForKey(getKeyInfo(key), this); }
public DistributedPutAllOperation newPutAllOperation(Map<?, ?> map, Object callbackArg) { if (map == null) { throw new NullPointerException( "map cannot be null"); } if (map.isEmpty()) { return null; } checkReadiness(); checkForLimitedOrNoAccess(); discoverJTA(); // Create a dummy event for the PutAll operation. Always create a // PutAll operation, even if there is no distribution, so that individual // events can be tracked and handed off to callbacks in postPutAll // No need for release since disallowOffHeapValues called. final EntryEventImpl event = EntryEventImpl.create(this, Operation.PUTALL_CREATE, null, null, callbackArg, true, getMyId()); event.disallowOffHeapValues(); return new DistributedPutAllOperation(event, map.size(), false); }
private DistributedRemoveAllOperation newRemoveAllOperation(Collection<?> keys, Object callbackArg) { if (keys == null) { throw new NullPointerException("The keys Collection passed to removeAll was null."); } if (keys.isEmpty()) { return null; } checkReadiness(); checkForLimitedOrNoAccess(); discoverJTA(); // Create a dummy event for the removeAll operation. Always create a // removeAll operation, even if there is no distribution, so that individual // events can be tracked and handed off to callbacks in postRemoveAll // No need for release since disallowOffHeapValues called. final EntryEventImpl event = EntryEventImpl.create(this, Operation.REMOVEALL_DESTROY, null, null, callbackArg, false, getMyId()); event.disallowOffHeapValues(); return new DistributedRemoveAllOperation(event, keys.size(), false); }
/** * Allows null as new value to accommodate create with a null value. * * @param event the event object for this operation, with the exception that the oldValue * parameter is not yet filled in. The oldValue will be filled in by this operation. * @param lastModified the lastModified time to set with the value; if 0L then the lastModified * time will be set to now. * @return null if put not done; otherwise the put entry */ protected RegionEntry basicPutEntry(final EntryEventImpl event, final long lastModified) throws TimeoutException, CacheWriterException { discoverJTA(); TXStateInterface tx = getTXState(); // Note we are doing a load or netsearch result so it seems like we should set ifNew to true. // The entry should not yet exist. However since the non-tx code sets ifNew to false this code // will also. final boolean ifNew = false; if (isTX()) { tx.txPutEntry(event, ifNew, false, false, null); return null; } else { if (DistTXState.internalBeforeNonTXBasicPut != null) { DistTXState.internalBeforeNonTXBasicPut.run(); } return getRegionMap().basicPut(event, lastModified, ifNew, false, null, false, false); } }
@Override public Region.Entry getEntry(Object key) { validateKey(key); checkReadiness(); checkForNoAccess(); discoverJTA(); return getDataView().getEntry(getKeyInfo(key), this, false); }
/** * (description copied from entryCount() Returns the number of entries in this region. Note that * because of the concurrency properties of the {@link RegionMap}, the number of entries is only * an approximate. That is, other threads may change the number of entries in this region while * this method is being invoked. * * @see LocalRegion#entryCount() */ @Override public int size() { checkReadiness(); checkForNoAccess(); discoverJTA(); boolean isClient = this.imageState.isClient(); if (isClient) { // bug #40871 - test sees wrong size for region during RI lockRIReadLock(); } try { return entryCount(); } finally { if (isClient) { unlockRIReadLock(); } } }
@Retained EntryEventImpl newUpdateEntryEvent(Object key, Object value, Object aCallbackArgument) { validateArguments(key, value, aCallbackArgument); if (value == null) { throw new NullPointerException( "value must not be null"); } checkReadiness(); checkForLimitedOrNoAccess(); discoverJTA(); // This used to call the constructor which took the old value. It // was modified to call the other EntryEventImpl constructor so that // an id will be generated by default. Null was passed in anyway. // generate EventID @Retained final EntryEventImpl event = EntryEventImpl.create(this, Operation.UPDATE, key, value, aCallbackArgument, false, getMyId()); boolean eventReturned = false; try { extractDeltaIntoEvent(value, event); eventReturned = true; return event; } finally { if (!eventReturned) event.release(); } }
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); } } }
/** * basicInvalidate is overridden in HARegion to abort expiry of Events which have key as Long , if * it is not able to destroy from availableIDs * * @param forceNewEntry true if we are a mirror and still in the initialization phase. Called from * InvalidateOperation.InvalidateMessage */ void basicInvalidate(final EntryEventImpl event, boolean invokeCallbacks, final boolean forceNewEntry) throws EntryNotFoundException { if (!event.isOriginRemote() && !event.isDistributed() && getScope().isDistributed() && getDataPolicy().withReplication() && invokeCallbacks) { // catches case where being called by (distributed) invalidateRegion throw new IllegalStateException( "Cannot do a local invalidate on a replicated region"); } if (hasSeenEvent(event)) { if (logger.isTraceEnabled(LogMarker.DM_VERBOSE)) { logger.trace(LogMarker.DM_VERBOSE, "LR.basicInvalidate: this cache has already seen this event {}", event); } if (this.getConcurrencyChecksEnabled() && event.getVersionTag() != null && !event.getVersionTag().isRecorded()) { getVersionVector().recordVersion((InternalDistributedMember) event.getDistributedMember(), event.getVersionTag()); } return; } discoverJTA(); getDataView().invalidateExistingEntry(event, invokeCallbacks, forceNewEntry); }
discoverJTA(); getDataView().destroyExistingEntry(event, cacheWrite, expectedOldValue);
event.setNewEventId(this.cache.getDistributedSystem()); discoverJTA(); getDataView().destroyExistingEntry(event, true, value);
checkReadiness(); checkForNoAccess(); discoverJTA(); CachePerfStats stats = getCachePerfStats(); long start = stats.startGet();