/** * Process an interest request of type {@link InterestType#REGULAR_EXPRESSION} */ private static void handleRegEx(LocalRegion region, String regex, InterestResultPolicy policy, ServerConnection servConn) throws IOException { if (region instanceof PartitionedRegion) { // too bad java doesn't provide another way to do this... handleRegExPR((PartitionedRegion) region, regex, policy, servConn); return; } List keyList = new ArrayList(MAXIMUM_CHUNK_SIZE); // Handle the regex pattern if (region != null) { Pattern keyPattern = Pattern.compile(regex); for (Object entryKey : region.keySet(sendTombstonesInRIResults(servConn, policy))) { if (!(entryKey instanceof String)) { // key is not a String, cannot apply regex to this entry continue; } if (!keyPattern.matcher((String) entryKey).matches()) { // key does not match the regex, this entry should not be returned. continue; } appendInterestResponseKey(region, regex, 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, regex, keyList, true, servConn); }
public static void appendNewRegisterInterestResponseChunkFromLocal(LocalRegion region, VersionedObjectList values, Object riKeys, Set keySet, ServerConnection servConn) throws IOException { ClientProxyMembershipID requestingClient = servConn == null ? null : servConn.getProxyID(); for (Object key : keySet) { VersionTagHolder versionHolder = createVersionTagHolder(); Object value = region.get(key, null, true, true, true, requestingClient, versionHolder, true); updateValues(values, key, value, versionHolder.getVersionTag()); 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, riKeys != null ? riKeys : "ALL_KEYS", values, false, servConn); values.clear(); } } // for }
protected static void fillAndSendRegisterInterestResponseChunks(LocalRegion region, Object riKey, int interestType, InterestResultPolicy policy, ServerConnection servConn) throws IOException { fillAndSendRegisterInterestResponseChunks(region, riKey, interestType, false, policy, servConn); }
/** * Process an interest request of type ALL_KEYS * * @param region the region * @param policy the policy */ private static void handleAllKeys(LocalRegion region, InterestResultPolicy policy, ServerConnection servConn) throws IOException { List keyList = new ArrayList(MAXIMUM_CHUNK_SIZE); if (region != null) { for (Object entryKey : region.keySet(sendTombstonesInRIResults(servConn, policy))) { appendInterestResponseKey(region, "ALL_KEYS", 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, "ALL_KEYS", 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); }
boolean shouldMasquerade = shouldMasqueradeForTx(clientMessage, serverConnection); try { if (shouldMasquerade) { try { tx = txMgr.masqueradeAs(clientMessage, member, false); cmdExecute(clientMessage, serverConnection, securityService, start); tx.updateProxyServer(txMgr.getMemberId()); } finally { cmdExecute(clientMessage, serverConnection, securityService, start); | CacheLoaderException | GemFireSecurityException | PartitionOfflineException | MessageTooLargeException e) { handleExceptionNoDisconnect(clientMessage, serverConnection, e); } catch (EOFException eof) { BaseCommand.handleEOFException(clientMessage, serverConnection, eof); } catch (InterruptedIOException e) { // Solaris only BaseCommand.handleInterruptedIOException(serverConnection, e); } catch (IOException e) { BaseCommand.handleIOException(clientMessage, serverConnection, e); } catch (DistributedSystemDisconnectedException e) { BaseCommand.handleShutdownException(clientMessage, serverConnection, e); } catch (VirtualMachineError err) { SystemFailure.initiateFailure(err); BaseCommand.handleThrowable(clientMessage, serverConnection, e); } finally { EntryLogger.clearSource();
sendRegisterInterestResponseChunk(region, riKey, new ArrayList(), true, servConn); return; handleKeysValuesPolicy(region, riKey, interestType, serializeValues, servConn); return; handleList(region, (List) riKey, policy, servConn); return; handleSingleton(region, riKey, policy, servConn); return; String regEx = (String) riKey; if (regEx.equals(".*")) { handleAllKeys(region, policy, servConn); } else { handleRegEx(region, regEx, policy, servConn); handleAllKeys(region, policy, servConn); } else { handleSingleton(region, riKey, policy, servConn);
static Message readRequest(ServerConnection servConn) { Message requestMsg = null; try { requestMsg = servConn.getRequestMessage(); requestMsg.receive(servConn, MAX_INCOMING_DATA, INCOMING_DATA_LIMITER, INCOMING_MSG_LIMITER); return requestMsg; } catch (EOFException eof) { handleEOFException(null, servConn, eof); // TODO: Check if there is any need for explicitly returning } catch (InterruptedIOException e) { // Solaris only handleInterruptedIOException(servConn, e); } catch (IOException e) { handleIOException(null, servConn, e); } catch (DistributedSystemDisconnectedException e) { handleShutdownException(null, servConn, e); } catch (VirtualMachineError err) { SystemFailure.initiateFailure(err); // If this ever returns, rethrow the error. We're poisoned // now, so don't let this thread continue. throw err; } catch (Throwable e) { SystemFailure.checkFailure(); handleThrowable(null, servConn, e); } return requestMsg; }
handleKVKeysPR((PartitionedRegion) region, regex, serializeValues, servConn); return; VersionTagHolder versionHolder = createVersionTagHolder(); if (keyPattern != null) { if (!(key instanceof String)) { Object data = region.get(key, null, true, true, true, id, versionHolder, true); VersionTag versionTag = versionHolder.getVersionTag(); updateValues(values, key, data, versionTag); sendNewRegisterInterestResponseChunk(region, regex != null ? regex : "ALL_KEYS", values, false, servConn); values.clear(); sendNewRegisterInterestResponseChunk(region, regex != null ? regex : "ALL_KEYS", values, true, servConn);
protected static void writeException(Message origMsg, int msgType, Throwable e, boolean isSevere, ServerConnection serverConnection) throws IOException { Throwable theException = getClientException(serverConnection, e); Message errorMsg = serverConnection.getErrorResponseMessage(); errorMsg.setMessageType(msgType); errorMsg.setNumberOfParts(2); errorMsg.setTransactionId(origMsg.getTransactionId()); if (isSevere) { String msg = theException.getMessage(); if (msg == null) { msg = theException.toString(); } logger.fatal("Severe cache exception : {}", msg); } errorMsg.addObjPart(theException); errorMsg.addStringPart(getExceptionTrace(theException)); errorMsg.send(serverConnection); if (logger.isDebugEnabled()) { logger.debug("{}: Wrote exception: {}", serverConnection.getName(), e.getMessage(), e); } if (e instanceof MessageTooLargeException) { throw (IOException) e; } }
message.setNumberOfParts(3); message.addObjPart(e); message.addStringPart(BaseCommand.getExceptionTrace(e)); InternalFunctionInvocationTargetException fe = (InternalFunctionInvocationTargetException) e.getCause(); message.addStringPart(BaseCommand.getExceptionTrace(e)); numParts = 2;
result.addAll(bd.getValuesWithVersions().entrySet()); BaseCommand.appendNewRegisterInterestResponseChunk(this, values, regex != null ? regex : "ALL_KEYS", result, servConn);
BaseCommand.appendNewRegisterInterestResponseChunkFromLocal(this, values, "keyList", keys, servConn);
private static void appendInterestResponseKeys(LocalRegion region, Object riKey, Collection entryKeys, List collector, ServerConnection servConn) throws IOException { for (final Object entryKey : entryKeys) { appendInterestResponseKey(region, riKey, entryKey, collector, servConn); } }
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); }
/** * 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); }
private static void writeChunkedException(Message origMsg, Throwable exception, ServerConnection serverConnection, ChunkedMessage originalResponse, int numOfParts) throws IOException { Throwable e = getClientException(serverConnection, exception); ChunkedMessage chunkedResponseMsg = serverConnection.getChunkedResponseMessage(); chunkedResponseMsg.setServerConnection(serverConnection); chunkedResponseMsg.addObjPart(e); if (numOfParts == 2) { chunkedResponseMsg.addStringPart(getExceptionTrace(e)); chunkedResponseMsg.addObjPart(e); if (numOfParts == 2) { chunkedResponseMsg.addStringPart(getExceptionTrace(e));
if (oneResult instanceof InternalFunctionException) { List<Object> result2 = new ArrayList<Object>(); result2.add(BaseCommand.getExceptionTrace((Throwable) oneResult)); result2.add(memberID); this.msg.addObjPart(result2);
BaseCommand.appendNewRegisterInterestResponseChunk(this, values, "keyList", result, servConn);
Set keys = fetchAllLocalKeys(id, failures, regex); if (!keys.isEmpty()) { BaseCommand.appendNewRegisterInterestResponseChunkFromLocal(this, values, regex != null ? regex : "ALL_KEYS", keys, servConn);