ChunkedMessage functionResponseMsg = serverConnection.getFunctionResponseMessage(); ChunkedMessage chunkedResponseMsg = serverConnection.getChunkedResponseMessage(); if (functionResponseMsg.headerHasBeenSent()) { functionResponseMsg.setServerConnection(serverConnection); functionResponseMsg.setNumberOfParts(2); functionResponseMsg.setLastChunkAndNumParts(true, 2); functionResponseMsg.addObjPart(e); functionResponseMsg.addStringPart(getExceptionTrace(e)); if (logger.isDebugEnabled()) { logger.debug("{}: Sending exception chunk while reply in progress: {}", serverConnection.getName(), e.getMessage(), e); functionResponseMsg.sendChunk(serverConnection); } else { chunkedResponseMsg.setServerConnection(serverConnection); chunkedResponseMsg.setMessageType(messageType); chunkedResponseMsg.setNumberOfParts(2); chunkedResponseMsg.setLastChunkAndNumParts(true, 2); chunkedResponseMsg.setTransactionId(origMsg.getTransactionId()); chunkedResponseMsg.sendHeader(); chunkedResponseMsg.addObjPart(e); chunkedResponseMsg.addStringPart(getExceptionTrace(e)); if (logger.isDebugEnabled()) { logger.debug("{}: Sending exception chunk: {}", serverConnection.getName(), e.getMessage(), e); chunkedResponseMsg.sendChunk(serverConnection);
@Override protected Message createResponseMessage() { return new ChunkedMessage(1, Version.CURRENT); } }
private static void sendGetAllResponseChunk(Region region, ObjectPartList list, boolean lastChunk, ServerConnection servConn) throws IOException { ChunkedMessage chunkedResponseMsg = servConn.getChunkedResponseMessage(); chunkedResponseMsg.setNumberOfParts(1); chunkedResponseMsg.setLastChunk(lastChunk); chunkedResponseMsg.addObjPartNoCopying(list); if (logger.isDebugEnabled()) { logger.debug("{}: Sending {} getAll response chunk for region={}{}", servConn.getName(), (lastChunk ? " last " : " "), region.getFullPath(), (logger.isTraceEnabled() ? " values=" + list + " chunk=<" + chunkedResponseMsg + ">" : "")); } chunkedResponseMsg.sendChunk(servConn); }
/** * Sends a chunk of this message. */ public void sendChunk() throws IOException { if (isLastChunk()) { this.headerSent = false; } sendBytes(true); }
static void writeQueryResponseChunk(Object queryResponseChunk, CollectionType collectionType, boolean lastChunk, ServerConnection serverConnection) throws IOException { ChunkedMessage queryResponseMsg = serverConnection.getQueryResponseMessage(); queryResponseMsg.setNumberOfParts(2); queryResponseMsg.setLastChunk(lastChunk); queryResponseMsg.addObjPart(collectionType, false); queryResponseMsg.addObjPart(queryResponseChunk, false); queryResponseMsg.sendChunk(serverConnection); }
protected void writeFunctionExceptionResponse(ChunkedMessage message, String errormessage, Throwable e) throws IOException { if (logger.isDebugEnabled()) { logger.debug("ServerToClientFunctionResultSender sending Function Error Response: {}", errormessage); } message.clear(); message.setLastChunk(true); message.addObjPart(e); message.sendChunk(this.sc); this.sc.setAsTrue(Command.RESPONDED); }
servConn.getCache().getCancelCriterion().checkCancelInProgress(null); ChunkedMessage replyMsg = servConn.getChunkedResponseMessage(); replyMsg.setMessageType(MessageType.RESPONSE); replyMsg.setTransactionId(origMsg.getTransactionId()); int listSize = (response == null) ? 0 : response.size(); if (response != null) { replyMsg.sendHeader(); if (listSize > 0) { int chunkSize = 2 * MAXIMUM_CHUNK_SIZE; for (int i = 0; i < listSize; i += chunkSize) { boolean lastChunk = (i + chunkSize >= listSize); replyMsg.setNumberOfParts(1); replyMsg.setMessageType(MessageType.RESPONSE); replyMsg.setLastChunk(lastChunk); replyMsg.setTransactionId(origMsg.getTransactionId()); replyMsg.addObjPart(chunk); if (logger.isDebugEnabled()) { logger.debug("sending chunk at index {} last chunk={} numParts={}", i, lastChunk, replyMsg.getNumberOfParts()); replyMsg.sendChunk(servConn); replyMsg.addObjPart(null); replyMsg.setLastChunk(true); replyMsg.sendChunk(servConn);
msg.readHeader(); final int msgType = msg.getMessageType(); if (msgType == MessageType.RESPONSE) { do { msg.receiveChunk(); callback.handle(msg); } while (!msg.isLastChunk()); } else { if (msgType == MessageType.EXCEPTION) { msg.receiveChunk(); Part part = msg.getPart(0); String s = "While performing a remote " + opName; throw new ServerOperationException(s, (Throwable) part.getObject()); msg.receiveChunk(); Part part = msg.getPart(0); throw new ServerOperationException(part.getString()); } else {
cqMsg.setNumberOfParts(1); break; cqMsg.setNumberOfParts(1); break; cqMsg.setNumberOfParts(1); break; cqMsg.setNumberOfParts(1); msgStr += "Uknown query Exception."; break; cqMsg.setMessageType(msgType); cqMsg.setTransactionId(txId); cqMsg.sendHeader(); cqMsg.addStringPart(msgStr); cqMsg.setLastChunk(true); cqMsg.sendChunk(servConn); cqMsg.setLastChunk(true);
@Test public void oldSecurityShouldFailIfNotAuthorized() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(false); doThrow(new NotAuthorizedException("")).when(this.authzRequest) .registerInterestAuthorize(eq(REGION_NAME), eq(KEY), anyInt(), any()); this.registerInterest.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.authzRequest).registerInterestAuthorize(eq(REGION_NAME), eq(KEY), anyInt(), any()); ArgumentCaptor<NotAuthorizedException> argument = ArgumentCaptor.forClass(NotAuthorizedException.class); verify(this.chunkedResponseMessage).addObjPart(argument.capture()); assertThat(argument.getValue()).isExactlyInstanceOf(NotAuthorizedException.class); verify(this.chunkedResponseMessage).sendChunk(this.serverConnection); }
chunkedResponseMsg.setMessageType(MessageType.RESPONSE); chunkedResponseMsg.setTransactionId(clientMessage.getTransactionId()); chunkedResponseMsg.sendHeader();
@Test public void oldSecurityShouldSucceedIfAuthorized() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(false); this.getAll70.cmdExecute(this.message, this.serverConnection, this.securityService, 0); ArgumentCaptor<ObjectPartList> argument = ArgumentCaptor.forClass(ObjectPartList.class); verify(this.chunkedResponseMessage).addObjPartNoCopying(argument.capture()); assertThat(argument.getValue().getObjects()).hasSize(KEYS.length); for (Object key : argument.getValue().getKeys()) { assertThat(key).isIn(KEYS); } for (Object key : KEYS) { verify(this.authzRequest).getAuthorize(eq(REGION_NAME), eq(key.toString()), eq(null)); } verify(this.chunkedResponseMessage).sendChunk(eq(this.serverConnection)); }
/** * Sends a chunk of this message. */ public void sendChunk(ServerConnection servConn) throws IOException { if (this.serverConnection != servConn) throw new IllegalStateException("this.sc was not correctly set"); sendChunk(); }
.getClientProxy(serverConnection.getProxyID()).isPrimary(); if (!isPrimary) { chunkedResponseMsg.setMessageType(MessageType.RESPONSE_FROM_SECONDARY); chunkedResponseMsg.setTransactionId(clientMessage.getTransactionId()); chunkedResponseMsg.sendHeader(); chunkedResponseMsg.setLastChunk(true); if (logger.isDebugEnabled()) { logger.debug( serverConnection.getName(), regionName, key, chunkedResponseMsg); chunkedResponseMsg.sendChunk(serverConnection); } else { // isPrimary chunkedResponseMsg.setMessageType(MessageType.RESPONSE_FROM_PRIMARY); chunkedResponseMsg.setTransactionId(clientMessage.getTransactionId()); chunkedResponseMsg.sendHeader();
protected void sendHeader() throws IOException { if (logger.isDebugEnabled()) { logger.debug("ServerToClientFunctionResultSender sending header"); } this.setBuffer(); this.msg.setMessageType(messageType); this.msg.setLastChunk(false); this.msg.setNumberOfParts(1); this.msg.sendHeader(); this.headerSent = true; }
@Override public void handle(ChunkedMessage cm) throws Exception { Part part = cm.getPart(0); try { Object o = part.getObject(); if (o instanceof Throwable) { String s = "While performing a remote getAll"; exceptionRef[0] = new ServerOperationException(s, (Throwable) o); } else { VersionedObjectList chunk = (VersionedObjectList) o; chunk.replaceNullIDs(con.getEndpoint().getMemberId()); result.addAll(chunk); } } catch (Exception e) { exceptionRef[0] = new ServerOperationException("Unable to deserialize value", e); } } });
@Override protected void packHeaderInfoForSending(int msgLen, boolean isSecurityHeader) { final ByteBuffer cb = getCommBuffer(); cb.putInt(msgLen); byte isLastChunk = 0x00; if (isLastChunk()) { // isLastChunk = (byte) 0x01 ; isLastChunk = this.lastChunk; if (isSecurityHeader) { isLastChunk |= 0x02; } } // cb.put(isLastChunk() ? (byte) 0x01 : (byte) 0x00); cb.put(isLastChunk); }
@Override protected Part getSecurityPart() { if (this.isLastChunk()) return super.getSecurityPart(); else return null; }
servConn.getCache().getCancelCriterion().checkCancelInProgress(null); ChunkedMessage replyMsg = servConn.getChunkedResponseMessage(); replyMsg.setMessageType(MessageType.RESPONSE); replyMsg.setTransactionId(origMsg.getTransactionId()); int listSize = (response == null) ? 0 : response.size(); if (response != null) { replyMsg.sendHeader(); if (listSize > 0) { int chunkSize = 2 * MAXIMUM_CHUNK_SIZE; for (int i = 0; i < listSize; i += chunkSize) { boolean lastChunk = (i + chunkSize >= listSize); replyMsg.setNumberOfParts(1); replyMsg.setMessageType(MessageType.RESPONSE); replyMsg.setLastChunk(lastChunk); replyMsg.setTransactionId(origMsg.getTransactionId()); replyMsg.addObjPart(chunk); if (logger.isDebugEnabled()) { logger.debug("sending chunk at index {} last chunk={} numParts={}", i, lastChunk, replyMsg.getNumberOfParts()); replyMsg.sendChunk(servConn); replyMsg.addObjPart(null); replyMsg.setLastChunk(true); replyMsg.sendChunk(servConn);
final Exception[] exceptionRef = new Exception[1]; keySetResponseMessage.readHeader(); final int msgType = keySetResponseMessage.getMessageType(); if (msgType == MessageType.RESPONSE) { do { keySetResponseMessage.receiveChunk(); Part part = keySetResponseMessage.getPart(0); Object o = part.getObject(); if (o instanceof Throwable) { result.addAll((List) o); } while (!keySetResponseMessage.isLastChunk()); } else { if (msgType == MessageType.EXCEPTION) { keySetResponseMessage.receiveChunk(); Part part = msg.getPart(0); String s = "While performing a remote " + "keySet"; keySetResponseMessage.receiveChunk(); Part part = msg.getPart(0); throw new ServerOperationException(part.getString());