public final TXStateInterface discoverJTA(final EntryEventImpl event) { TXStateInterface tx = event.txState; if (tx != TXStateProxy.TX_NOT_SET) { return tx; } tx = discoverJTA(); event.setTXState(tx); return tx; }
/** internally we often need to get an entry whether it is a tombstone or not */ public final Region.Entry getEntry(Object key, boolean allowTombstones) { return getEntry(key, discoverJTA(), allowTombstones); }
@Override public final Object get(Object key, Object aCallbackArgument, boolean generateCallbacks, EntryEventImpl clientEvent) throws TimeoutException, CacheLoaderException { Object result = get(key, aCallbackArgument, generateCallbacks, false, false, null, discoverJTA(), null, clientEvent, false, true/*allowReadFromHDFS*/); if (Token.isInvalid(result)) { result = null; } return result; }
/** * returns an estimate of the number of entries in this region. This method * should be prefered over size() for hdfs regions where an accurate size is * not needed. This method is not supported on a client * * @return the estimated size of this region */ public int sizeEstimate() { boolean isClient = this.imageState.isClient(); if (isClient) { throw new UnsupportedOperationException( "Method not supported on a client"); } return entryCount(discoverJTA(), null, true); }
public final Region.Entry getEntry(Object key) { try { operationStart(); return getEntry(key, discoverJTA()); } finally { operationCompleted(); } }
public boolean containsValueForKey(Object key) { discoverJTA(); return getDataView().containsValueForKey(getKeyInfo(key), this); }
public final 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 final EntryEventImpl event = EntryEventImpl.create(this, Operation.REMOVEALL_DESTROY, null, null/* newValue */, callbackArg, false, getMyId()); event.disallowOffHeapValues(); return new DistributedRemoveAllOperation(event, keys.size(), false); }
public boolean containsValueForKey(Object key) { try { operationStart(); final TXStateInterface tx = discoverJTA(); return getDataView(tx).containsValueForKey(key, null, this); } finally { operationCompleted(); } }
public final DistributedPutAllOperation newPutAllOperation(Map<?, ?> map, Object callbackArg) { if (map == null) { throw new NullPointerException(LocalizedStrings .AbstractRegion_MAP_CANNOT_BE_NULL.toLocalizedString()); } 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 final EntryEventImpl event = EntryEventImpl.create(this, Operation.PUTALL_CREATE, null, null, callbackArg, true, getMyId()); event.disallowOffHeapValues(); DistributedPutAllOperation dpao = new DistributedPutAllOperation(event, map.size(), false); return dpao; } public final DistributedPutAllOperation newPutAllForPUTDmlOperation(Map<?, ?> map, Object callbackArg) {
final void txClearRegion() { final TXStateInterface tx = discoverJTA(); if (tx != null) { tx.rmRegion(this); } // cleanup snapshot entries for the region in all transactions for (TXStateProxy txProxy : getCache().getTxManager() .getHostedTransactionsInProgress()) { txProxy.cleanSnapshotEntriesForRegion(this); } }
public final DistributedPutAllOperation newPutAllOperation(Map<?, ?> map) { if (map == null) { throw new NullPointerException(LocalizedStrings .AbstractRegion_MAP_CANNOT_BE_NULL.toLocalizedString()); } if (map.isEmpty()) { return null; } checkReadiness(); checkForLimitedOrNoAccess(); final TXStateInterface tx = 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 final EntryEventImpl event = EntryEventImpl.create(this, Operation.PUTALL_CREATE, null, null, null, true, getMyId()); event.disallowOffHeapValues(); event.setTXState(tx); return new DistributedPutAllOperation(this, event, map.size(), false); }
@Override public Object call() throws Exception { Region r = getCache().getRegion(regionName); LocalRegion lr = (LocalRegion) r; int numEntries = 0; for (int i=0; i<200; i++) { r.getCache().getLogger().info("SWAP:DOING GET NO READ:key"+i); Object val = lr.get("key"+i, null, true, false, false, null, lr.discoverJTA(), null, null, false, false/*allowReadFromHDFS*/); if (val != null) { numEntries++; } } assertEquals(50, numEntries); // entries in memory return null; } });
public Region.Entry getEntry(Object key) { validateKey(key); checkReadiness(); checkForNoAccess(); discoverJTA(); return getDataView().getEntry(getKeyInfo(key), this, false); }
public final EntryEventImpl newUpdateEntryEvent(Object key, Object value, Object aCallbackArgument) { validateArguments(key, value, aCallbackArgument); if (value == null) { throw new NullPointerException(LocalizedStrings .LocalRegion_VALUE_MUST_NOT_BE_NULL.toLocalizedString()); } 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 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(); } } /**
/** * (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() */ public int size() { checkReadiness(); checkForNoAccess(); final TXStateInterface tx = discoverJTA(); boolean isClient = this.imageState.isClient(); if (isClient) { lockRIReadLock(); // bug #40871 - test sees wrong size for region during RI } try { return entryCount(tx); } finally { if (isClient) { unlockRIReadLock(); } } }
/** * (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() */ public int size() { checkReadiness(); checkForNoAccess(); discoverJTA(); boolean isClient = this.imageState.isClient(); if (isClient) { lockRIReadLock(); // bug #40871 - test sees wrong size for region during RI } try { return entryCount(); } finally { if (isClient) { unlockRIReadLock(); } } }
/** * Test hook - returns the version stamp for an entry in the form of a * version tag * @param key * @return the entry version information */ public VersionTag getVersionTag(Object key) { try{ operationStart(); Region.Entry entry = getEntry(key, discoverJTA(), true); VersionTag tag = null; if (entry != null && entry instanceof EntrySnapshot) { tag = ((EntrySnapshot)entry).getVersionTag(); } else if (entry != null && entry instanceof NonTXEntry) { tag = ((NonTXEntry)entry).getRegionEntry().getVersionStamp().asVersionTag(); } return tag; } finally { operationCompleted(); } }
discoverJTA(); getDataView().invalidateExistingEntry(event, invokeCallbacks, forceNewEntry);
/** * @param cacheWrite * true if cacheWrite should be performed or false if cacheWrite * should not be performed * @see DistributedRegion#basicDestroy(EntryEventImpl, boolean, Object) */ void basicDestroy(final EntryEventImpl event, final boolean cacheWrite, Object expectedOldValue) throws EntryNotFoundException, CacheWriterException, TimeoutException { if (!event.isOriginRemote()) { checkIfReplicatedAndLocalDestroy(event); } if (hasSeenEvent(event)) { assert getJTAEnlistedTX() == null; if(logger.isTraceEnabled(LogMarker.DM)) { logger.trace(LogMarker.DM, "LR.basicDestroy: this cache has already seen this event {}", event); } if (this.concurrencyChecksEnabled && event.getVersionTag() != null && !event.getVersionTag().isRecorded()) { getVersionVector().recordVersion((InternalDistributedMember) event.getDistributedMember(), event.getVersionTag()); } // Bug 49449: When client retried and returned with hasSeenEvent for both LR and DR, the server should still // notifyGatewayHubs even the event could be duplicated in gateway queues1 notifyGatewaySender(EnumListenerEvent.AFTER_DESTROY, event); return; } discoverJTA(); getDataView().destroyExistingEntry(event, cacheWrite, expectedOldValue); }
public final void validatedCreate(EntryEventImpl event, long startPut) throws TimeoutException, EntryExistsException, CacheWriterException { try { if (event.getEventId() == null && generateEventID()) { event.setNewEventId(cache.getDistributedSystem()); } assert event.isFetchFromHDFS() : "validatedPut() should have been called"; // 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); } } } finally { event.release(); } }