for (Iterator it = keyList.iterator(); it.hasNext();) { Object entryKey = it.next(); if (this.containsKey(entryKey) || allowTombstones && this.containsTombstone(entryKey)) { ret.add(entryKey); if (this.containsKey(interestArg) || (allowTombstones && this.containsTombstone(interestArg))) { ret.add(interestArg);
/** * Process an interest request consisting of a single key * * @param region the region * @param entryKey the key * @param policy the policy */ private static void handleSingleton(LocalRegion region, Object entryKey, InterestResultPolicy policy, ServerConnection servConn) throws IOException { List keyList = new ArrayList(1); if (region != null) { if (region.containsKey(entryKey) || sendTombstonesInRIResults(servConn, policy) && region.containsTombstone(entryKey)) { appendInterestResponseKey(region, entryKey, entryKey, keyList, servConn); } } // Send the last chunk (the only chunk for individual and list keys) // always send it back, even if the list is of zero size. sendRegisterInterestResponseChunk(region, entryKey, keyList, true, servConn); }
/** * Process an interest request involving a list of keys * * @param region the region * @param keyList the list of keys * @param policy the policy */ private static void handleList(LocalRegion region, List keyList, InterestResultPolicy policy, ServerConnection servConn) throws IOException { if (region instanceof PartitionedRegion) { // too bad java doesn't provide another way to do this... handleListPR((PartitionedRegion) region, keyList, policy, servConn); return; } List newKeyList = new ArrayList(MAXIMUM_CHUNK_SIZE); // Handle list of keys if (region != null) { for (Object entryKey : keyList) { if (region.containsKey(entryKey) || sendTombstonesInRIResults(servConn, policy) && region.containsTombstone(entryKey)) { appendInterestResponseKey(region, keyList, entryKey, newKeyList, servConn); } } } // Send the last chunk (the only chunk for individual and list keys) // always send it back, even if the list is of zero size. sendRegisterInterestResponseChunk(region, keyList, newKeyList, true, servConn); }
@Before public void setUp() throws Exception { this.containsKey66 = new ContainsKey66(); MockitoAnnotations.initMocks(this); when(this.region.containsKey(eq(REGION_NAME))).thenReturn(true); when(this.cache.getRegion(isA(String.class))).thenReturn(this.region); when(this.serverConnection.getCache()).thenReturn(this.cache); when(this.serverConnection.getCacheServerStats()).thenReturn(this.cacheServerStats); when(this.serverConnection.getErrorResponseMessage()).thenReturn(this.errorResponseMessage); when(this.serverConnection.getResponseMessage()).thenReturn(this.responseMessage); when(this.serverConnection.getAuthzRequest()).thenReturn(this.authzRequest); when(this.serverConnection.getClientVersion()).thenReturn(Version.CURRENT); when(this.regionNamePart.getString()).thenReturn(REGION_NAME); when(this.keyPart.getStringOrObject()).thenReturn(KEY); when(this.modePart.getInt()).thenReturn(0); when(this.message.getPart(eq(0))).thenReturn(this.regionNamePart); when(this.message.getPart(eq(1))).thenReturn(this.keyPart); when(this.message.getPart(eq(2))).thenReturn(this.modePart); }
@Before public void setUp() throws Exception { this.destroy = new Destroy(); MockitoAnnotations.initMocks(this); when(this.authzRequest.destroyAuthorize(eq(REGION_NAME), eq(KEY), eq(CALLBACK_ARG))) .thenReturn(this.destroyOperationContext); when(this.cache.getRegion(isA(String.class))).thenReturn(this.region); when(this.cache.getCancelCriterion()).thenReturn(mock(CancelCriterion.class)); when(this.callbackArgPart.getObject()).thenReturn(CALLBACK_ARG); when(this.destroyOperationContext.getCallbackArg()).thenReturn(CALLBACK_ARG); when(this.eventPart.getSerializedForm()).thenReturn(EVENT); when(this.keyPart.getStringOrObject()).thenReturn(KEY); when(this.message.getNumberOfParts()).thenReturn(4); when(this.message.getPart(eq(0))).thenReturn(this.regionNamePart); when(this.message.getPart(eq(1))).thenReturn(this.keyPart); when(this.message.getPart(eq(2))).thenReturn(this.eventPart); when(this.message.getPart(eq(3))).thenReturn(this.callbackArgPart); when(this.region.containsKey(eq(REGION_NAME))).thenReturn(true); when(this.regionNamePart.getString()).thenReturn(REGION_NAME); when(this.serverConnection.getCache()).thenReturn(this.cache); when(this.serverConnection.getCacheServerStats()).thenReturn(this.cacheServerStats); when(this.serverConnection.getAuthzRequest()).thenReturn(this.authzRequest); when(this.serverConnection.getCachedRegionHelper()).thenReturn(mock(CachedRegionHelper.class)); when(this.serverConnection.getErrorResponseMessage()).thenReturn(this.errorResponseMessage); when(this.serverConnection.getReplyMessage()).thenReturn(this.replyMessage); when(this.serverConnection.getClientVersion()).thenReturn(Version.CURRENT); }
@Override protected boolean operateOnRegion(ClusterDistributionManager dm, LocalRegion r, long startTime) throws CacheException, RemoteOperationException { if (logger.isTraceEnabled(LogMarker.DM_VERBOSE)) { logger.trace(LogMarker.DM_VERBOSE, "DistributedRemoteContainsKeyValueMessage operateOnRegion: {}", r.getFullPath()); } if (!(r instanceof PartitionedRegion)) { // prs already wait on initialization r.waitOnInitialization(); // bug #43371 - accessing a region before it's initialized } final boolean replyVal; if (this.valueCheck) { replyVal = r.containsValueForKey(this.key); } else { replyVal = r.containsKey(this.key); } if (logger.isTraceEnabled(LogMarker.DM_VERBOSE)) { logger.trace( "DistributedRemoteContainsKeyValueMessage sending reply back using processorId: {}", getProcessorId()); } RemoteContainsKeyValueReplyMessage.send(getSender(), getProcessorId(), getReplySender(dm), replyVal); // Unless there was an exception thrown, this message handles sending the // response return false; }
/** * Handles both RR and PR cases */ @SuppressWarnings(value = "NP_NULL_PARAM_DEREF", justification = "Null value handled in sendNewRegisterInterestResponseChunk()") private static void handleKVSingleton(LocalRegion region, Object entryKey, boolean serializeValues, ServerConnection servConn) throws IOException { VersionedObjectList values = new VersionedObjectList(MAXIMUM_CHUNK_SIZE, true, region == null || region.getAttributes().getConcurrencyChecksEnabled(), serializeValues); if (region != null) { if (region.containsKey(entryKey) || region.containsTombstone(entryKey)) { VersionTagHolder versionHolder = createVersionTagHolder(); ClientProxyMembershipID id = servConn == null ? null : servConn.getProxyID(); // From Get70.getValueAndIsObject() Object data = region.get(entryKey, null, true, true, true, id, versionHolder, true); VersionTag vt = versionHolder.getVersionTag(); updateValues(values, entryKey, data, vt); } } // Send the last chunk (the only chunk for individual and list keys) // always send it back, even if the list is of zero size. sendNewRegisterInterestResponseChunk(region, entryKey, values, true, servConn); }
boolean containsKey = region.containsKey(key);
switch (mode) { case KEY: containsKey = region.containsKey(key); break; case VALUE:
private static void handleKVList(final LocalRegion region, final List keyList, boolean serializeValues, final ServerConnection servConn) throws IOException { if (region instanceof PartitionedRegion) { handleKVKeysPR((PartitionedRegion) region, keyList, serializeValues, servConn); return; } VersionedObjectList values = new VersionedObjectList(MAXIMUM_CHUNK_SIZE, true, region == null || region.getAttributes().getConcurrencyChecksEnabled(), serializeValues); // Handle list of keys if (region != null) { for (Object key : keyList) { if (region.containsKey(key) || region.containsTombstone(key)) { VersionTagHolder versionHolder = createVersionTagHolder(); ClientProxyMembershipID id = servConn == null ? null : servConn.getProxyID(); Object data = region.get(key, null, true, true, true, id, versionHolder, true); VersionTag versionTag = versionHolder.getVersionTag(); updateValues(values, key, data, versionTag); if (values.size() == MAXIMUM_CHUNK_SIZE) { // Send the chunk and clear the list // values.setKeys(null); // Now we need to send keys too. sendNewRegisterInterestResponseChunk(region, keyList, values, false, servConn); values.clear(); } } } } // Send the last chunk (the only chunk for individual and list keys) // always send it back, even if the list is of zero size. sendNewRegisterInterestResponseChunk(region, keyList, values, true, servConn); }
if (valuePart.isNull() && region.containsKey(key)) {
if (valuePart.isNull() && region.containsKey(key)) {
if (valuePart.isNull() && operation != Operation.PUT_IF_ABSENT && region.containsKey(key)) {