use of org.apache.geode.cache.client.ServerConnectivityException in project geode by apache.
the class ExecuteFunctionOp method execute.
/**
* Does a execute Function 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 function of the function to be executed
* @param args specified arguments to the application function
*/
public static void execute(final PoolImpl pool, Function function, ServerFunctionExecutor executor, Object args, MemberMappedArgument memberMappedArg, boolean allServers, byte hasResult, ResultCollector rc, boolean isFnSerializationReqd, UserAttributes attributes, String[] groups) {
final AbstractOp op = new ExecuteFunctionOpImpl(function, args, memberMappedArg, hasResult, rc, isFnSerializationReqd, (byte) 0, groups, allServers, executor.isIgnoreDepartedMembers());
if (allServers && groups.length == 0) {
if (logger.isDebugEnabled()) {
logger.debug("ExecuteFunctionOp#execute : Sending Function Execution Message:{} to all servers using pool: {}", op.getMessage(), pool);
}
List callableTasks = constructAndGetFunctionTasks(pool, function, args, memberMappedArg, hasResult, rc, isFnSerializationReqd, attributes);
SingleHopClientExecutor.submitAll(callableTasks);
} else {
boolean reexecuteForServ = false;
AbstractOp reexecOp = null;
int retryAttempts = 0;
boolean reexecute = false;
int maxRetryAttempts = 0;
if (function.isHA())
maxRetryAttempts = pool.getRetryAttempts();
final boolean isDebugEnabled = logger.isDebugEnabled();
do {
try {
if (reexecuteForServ) {
if (isDebugEnabled) {
logger.debug("ExecuteFunctionOp#execute.reexecuteForServ : Sending Function Execution Message:{} to server using pool: {} with groups:{} all members:{} ignoreFailedMembers:{}", op.getMessage(), pool, Arrays.toString(groups), allServers, executor.isIgnoreDepartedMembers());
}
reexecOp = new ExecuteFunctionOpImpl(function, args, memberMappedArg, hasResult, rc, isFnSerializationReqd, (byte) 1, /* isReExecute */
groups, allServers, executor.isIgnoreDepartedMembers());
pool.execute(reexecOp, 0);
} else {
if (isDebugEnabled) {
logger.debug("ExecuteFunctionOp#execute : Sending Function Execution Message:{} to server using pool: {} with groups:{} all members:{} ignoreFailedMembers:{}", op.getMessage(), pool, Arrays.toString(groups), allServers, executor.isIgnoreDepartedMembers());
}
pool.execute(op, 0);
}
reexecute = false;
reexecuteForServ = false;
} catch (InternalFunctionInvocationTargetException e) {
if (isDebugEnabled) {
logger.debug("ExecuteFunctionOp#execute : Received InternalFunctionInvocationTargetException. The failed node is {}", e.getFailedNodeSet());
}
reexecute = true;
rc.clearResults();
} catch (ServerConnectivityException se) {
retryAttempts++;
if (isDebugEnabled) {
logger.debug("ExecuteFunctionOp#execute : Received ServerConnectivityException. The exception is {} The retryAttempt is : {} maxRetryAttempts {}", se, retryAttempts, maxRetryAttempts);
}
if (se instanceof ServerOperationException) {
throw se;
}
if ((retryAttempts > maxRetryAttempts && maxRetryAttempts != -1))
throw se;
reexecuteForServ = true;
rc.clearResults();
}
} while (reexecuteForServ);
if (reexecute && function.isHA()) {
ExecuteFunctionOp.reexecute(pool, function, executor, rc, hasResult, isFnSerializationReqd, maxRetryAttempts - 1, groups, allServers);
}
}
}
use of org.apache.geode.cache.client.ServerConnectivityException in project geode by apache.
the class PutOp method execute.
/**
* Does a region put 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 region to do the put on
* @param key the entry key to do the put on
* @param value the entry value to put
* @param event the event for this put
* @param requireOldValue
* @param expectedOldValue
* @param callbackArg an optional callback arg to pass to any cache callbacks
*/
public static Object execute(ExecutablePool pool, LocalRegion region, Object key, Object value, byte[] deltaBytes, EntryEventImpl event, Operation operation, boolean requireOldValue, Object expectedOldValue, Object callbackArg, boolean prSingleHopEnabled) {
PutOpImpl op = new PutOpImpl(region, key, value, deltaBytes, event, operation, requireOldValue, expectedOldValue, callbackArg, false, /* donot send full obj; send delta */
prSingleHopEnabled);
if (prSingleHopEnabled) {
ClientMetadataService cms = region.getCache().getClientMetadataService();
ServerLocation server = cms.getBucketServerLocation(region, Operation.UPDATE, key, value, callbackArg);
if (server != null) {
try {
PoolImpl poolImpl = (PoolImpl) pool;
boolean onlyUseExistingCnx = ((poolImpl.getMaxConnections() != -1 && poolImpl.getConnectionCount() >= poolImpl.getMaxConnections()) ? true : false);
op.setAllowDuplicateMetadataRefresh(!onlyUseExistingCnx);
return pool.executeOn(new ServerLocation(server.getHostName(), server.getPort()), op, true, onlyUseExistingCnx);
} catch (AllConnectionsInUseException e) {
} catch (ServerConnectivityException e) {
if (e instanceof ServerOperationException) {
// fixed 44656
throw e;
}
cms.removeBucketServerLocation(server);
}
}
}
return pool.execute(op);
}
use of org.apache.geode.cache.client.ServerConnectivityException in project geode by apache.
the class PoolImpl method killPrimaryEndpoint.
/**
* Test hook used to simulate a kill of the primaryEndpoint
*/
public // throws ServerException
void killPrimaryEndpoint() {
boolean ok = false;
if (this.queueManager != null) {
QueueManager.QueueConnections cons = this.queueManager.getAllConnections();
Connection con = cons.getPrimary();
if (con != null) {
final String msg = "killing primary endpoint";
logger.info("<ExpectedException action=add>{}</ExpectedException>", msg);
Exception e = new Exception(msg);
try {
processException(e, con);
} catch (ServerConnectivityException ignore) {
} finally {
logger.info("<ExpectedException action=remove>{}</ExpectedException>", msg);
}
// do some validation here that we are no longer connected to "sl"
ok = true;
}
}
if (!ok) {
throw new IllegalStateException("primaryEndpoint was null");
}
}
use of org.apache.geode.cache.client.ServerConnectivityException in project geode by apache.
the class ServerFunctionExecutor method executeOnServer.
private ResultCollector executeOnServer(String functionId, ResultCollector rc, byte hasResult, boolean isHA, boolean optimizeForWrite) {
FunctionStats stats = FunctionStats.getFunctionStats(functionId);
try {
validateExecution(null, null);
long start = stats.startTime();
stats.startFunctionExecution(true);
ExecuteFunctionOp.execute(this.pool, functionId, this, args, memberMappedArg, this.allServers, hasResult, rc, this.isFnSerializationReqd, isHA, optimizeForWrite, UserAttributes.userAttributes.get(), groups);
stats.endFunctionExecution(start, true);
rc.endResults();
return rc;
} catch (FunctionException functionException) {
stats.endFunctionExecutionWithException(true);
throw functionException;
} catch (ServerConnectivityException exception) {
throw exception;
} catch (Exception exception) {
stats.endFunctionExecutionWithException(true);
throw new FunctionException(exception);
}
}
use of org.apache.geode.cache.client.ServerConnectivityException in project geode by apache.
the class DestroyOp method execute.
/**
* Does a region entry destroy 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 region to do the entry destroy on
* @param key the entry key to do the destroy on
* @param event the event for this destroy operation
* @param callbackArg an optional callback arg to pass to any cache callbacks
*/
public static Object execute(ExecutablePool pool, LocalRegion region, Object key, Object expectedOldValue, Operation operation, EntryEventImpl event, Object callbackArg, boolean prSingleHopEnabled) {
if (logger.isDebugEnabled()) {
logger.debug("Preparing DestroyOp for {} operation={}", key, operation);
}
DestroyOpImpl op = new DestroyOpImpl(region, key, expectedOldValue, operation, event, callbackArg, prSingleHopEnabled);
if (prSingleHopEnabled) {
ClientMetadataService cms = region.getCache().getClientMetadataService();
ServerLocation server = cms.getBucketServerLocation(region, Operation.DESTROY, key, null, callbackArg);
if (server != null) {
try {
PoolImpl poolImpl = (PoolImpl) pool;
boolean onlyUseExistingCnx = ((poolImpl.getMaxConnections() != -1 && poolImpl.getConnectionCount() >= poolImpl.getMaxConnections()) ? true : false);
op.setAllowDuplicateMetadataRefresh(!onlyUseExistingCnx);
return pool.executeOn(server, op, true, onlyUseExistingCnx);
} catch (AllConnectionsInUseException e) {
} catch (ServerConnectivityException e) {
if (e instanceof ServerOperationException) {
// fixed 44656
throw e;
}
cms.removeBucketServerLocation(server);
}
}
}
return pool.execute(op);
}
Aggregations