public static void execute(ExecutablePool pool, String regionFullPath, ClientMetadataService cms) { AbstractOp op = new GetClientPRMetaDataOpImpl(regionFullPath, cms); if (logger.isDebugEnabled()) { logger.debug( "GetClientPRMetaDataOp#execute : Sending GetClientPRMetaDataOp Message: {} to server using pool: {}", op.getMessage(), pool); } pool.execute(op); }
@Override public Object attempt(Connection cnx) throws Exception { if (cnx.getServer().getRequiresCredentials()) { return super.attempt(cnx); } else { return null; } }
@Override public Object attempt(Connection cnx) throws Exception { this.failed = true; this.timedOut = false; long start = startAttempt(cnx.getStats()); try { try { attemptSend(cnx); this.failed = false; } finally { endSendAttempt(cnx.getStats(), start); } this.failed = true; try { Object result = attemptReadResponse(cnx); this.failed = false; return result; } catch (SocketTimeoutException ste) { this.failed = false; this.timedOut = true; throw ste; } } finally { endAttempt(cnx.getStats(), start); } }
/** * Sets the transaction id on the message */ private void setMsgTransactionId() { if (participateInTransaction() && getMessage().getTransactionId() == TXManagerImpl.NOTX) { getMessage().setTransactionId(TXManagerImpl.getCurrentTXUniqueId()); } }
/** * Attempts to send this operation's message out on the given connection * * @param cnx the connection to use when sending * @throws Exception if the send fails */ protected void attemptSend(Connection cnx) throws Exception { setMsgTransactionId(); if (logger.isTraceEnabled(LogMarker.DISTRIBUTION_BRIDGE_SERVER_VERBOSE)) { logger.trace(LogMarker.DISTRIBUTION_BRIDGE_SERVER_VERBOSE, "Sending op={} using {}", getShortClassName(), cnx); } getMessage().setComms(cnx.getSocket(), cnx.getInputStream(), cnx.getOutputStream(), cnx.getCommBuffer(), cnx.getStats()); try { sendMessage(cnx); } finally { getMessage().unsetComms(); } }
Message msg = createResponseMessage(); if (msg != null) { msg.setComms(cnx.getSocket(), cnx.getInputStream(), cnx.getOutputStream(), if (msg instanceof ChunkedMessage) { try { return processResponse(msg, cnx); } finally { msg.unsetComms(); processSecureBytes(cnx, msg); } finally { msg.unsetComms(); processSecureBytes(cnx, msg); return processResponse(msg, cnx);
@Override public Object call() throws Exception { op.initMessagePart(); Object result = null; boolean onlyUseExistingCnx = ((pool.getMaxConnections() != -1 && pool.getConnectionCount() >= pool.getMaxConnections()) ? true : false); op.setAllowDuplicateMetadataRefresh(!onlyUseExistingCnx); try { UserAttributes.userAttributes.set(securityAttributes); result = this.pool.executeOn(server, op, true, onlyUseExistingCnx); } catch (AllConnectionsInUseException ex) { // if we reached connection limit and don't have available connection to // that server,then execute function on one of the connections available // from other servers instead of creating new connection to the original // server if (op instanceof ExecuteRegionFunctionSingleHopOpImpl) { ExecuteRegionFunctionSingleHopOpImpl newop = (ExecuteRegionFunctionSingleHopOpImpl) op; result = this.pool.execute(new ExecuteRegionFunctionOpImpl(newop)); } else { result = this.pool.execute(this.op); } } finally { UserAttributes.userAttributes.set(null); } return result; }
/** * Does a region getAll on a server using connections from the given pool to communicate with the * server. * * @param pool the pool to use to communicate with the server. * @param region the name of the region to do the getAll on * @param keys list of keys to get * @return the map of values found by the getAll if any */ public static VersionedObjectList execute(ExecutablePool pool, String region, List keys, Object callback) { AbstractOp op = new GetAllOpImpl(region, keys, callback); op.initMessagePart(); return ((VersionedObjectList) pool.execute(op)).setKeys(keys); }
} else if (isErrorResponse(msgType)) { throw new ServerOperationException(part.getString()); } else {
AbstractOp op = new PutAllOpImpl(region, map, eventId, ((PoolImpl) pool).getPRSingleHopEnabled(), skipCallbacks, callbackArg); op.initMessagePart(); return (VersionedObjectList) pool.execute(op);
/** * Process a response that contains a single Object result. * * @param msg the message containing the response * @param opName text describing this op * @return the result of the response * @throws Exception if response could not be processed or we received a response with a server * exception. */ protected Object processObjResponse(Message msg, String opName) throws Exception { Part part = msg.getPart(0); final int msgType = msg.getMessageType(); if (msgType == MessageType.RESPONSE) { return part.getObject(); } else { if (msgType == MessageType.EXCEPTION) { String s = "While performing a remote " + opName; throw new ServerOperationException(s, (Throwable) part.getObject()); // Get the exception toString part. // This was added for c++ thin client and not used in java } else if (isErrorResponse(msgType)) { throw new ServerOperationException(part.getString()); } else { throw new InternalGemFireError("Unexpected message type " + MessageType.getString(msgType)); } } }
protected AbstractOp(int msgType, int msgParts) { this.msg = new Message(msgParts, Version.CURRENT); getMessage().setMessageType(msgType); }
AbstractOp op = new RemoveAllOpImpl(region, keys, eventId, ((PoolImpl) pool).getPRSingleHopEnabled(), callbackArg); op.initMessagePart(); return (VersionedObjectList) pool.execute(op);
} else if (isErrorResponse(msgType)) { msg.receiveChunk(); Part part = msg.getPart(0);
true /* send full obj */, this.prSingleHopEnabled); op.attempt(con); if (this.region != null) { this.region.getCachePerfStats().incDeltaFullValuesSent();
public static void execute(ExecutablePool pool, String region, String functionId, ServerRegionFunctionExecutor serverRegionExecutor, byte hasResult, boolean isHA, boolean optimizeForWrite) { AbstractOp op = new ExecuteRegionFunctionNoAckOpImpl(region, functionId, serverRegionExecutor, hasResult, isHA, optimizeForWrite); try { if (logger.isDebugEnabled()) { logger.debug( "ExecuteRegionFunctionNoAckOp#execute : Sending Function Execution Message: {} to Server using pool: {}", op.getMessage(), pool); } pool.execute(op); } catch (Exception ex) { if (logger.isDebugEnabled()) { logger.debug( "ExecuteRegionFunctionNoAckOp#execute : Exception occurred while Sending Function Execution Message: {} to server using pool: {}", op.getMessage(), pool, ex); } if (ex.getMessage() != null) throw new FunctionException(ex.getMessage(), ex); else throw new FunctionException("Unexpected exception during function execution:", ex); } }
op.initMessagePart(); return ((VersionedObjectList) pool.execute(op)).setKeys(keys); } else {
logger.debug( "ExecuteRegionFunctionNoAckOp#execute : Sending Function Execution Message: {} to Server using pool: {}", op.getMessage(), pool); logger.debug( "ExecuteRegionFunctionNoAckOp#execute : Exception occurred while Sending Function Execution Message: {} to server using pool: {}", op.getMessage(), pool, ex);
if (logger.isDebugEnabled()) { logger.debug("ExecuteFunctionNoAckOp#execute : Sending Function Execution Message:" + op.getMessage() + " to all servers using pool: " + pool); if (logger.isDebugEnabled()) { logger.debug("ExecuteFunctionNoAckOp#execute : Sending Function Execution Message:" + op.getMessage() + " to server using pool: " + pool + " with groups:" + Arrays.toString(groups) + " all members:" + allServers); logger.debug( "ExecuteFunctionNoAckOp#execute : Exception occurred while Sending Function Execution Message:" + op.getMessage() + " to server using pool: " + pool, ex);
@SuppressWarnings("unchecked") public static ClientPartitionAdvisor execute(ExecutablePool pool, String regionFullPath) { AbstractOp op = new GetClientPartitionAttributesOpImpl(regionFullPath); if (logger.isDebugEnabled()) { logger.debug( "GetClientPartitionAttributesOp#execute : Sending GetClientPartitionAttributesOp Message: {} for region: {} to server using pool: {}", op.getMessage(), regionFullPath, pool); } ClientPartitionAdvisor advisor = (ClientPartitionAdvisor) pool.execute(op); if (advisor != null) { advisor.setServerGroup(((PoolImpl) pool).getServerGroup()); } return advisor; }