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);
}
use of org.apache.geode.cache.client.ServerConnectivityException in project geode by apache.
the class QueryUsingFunctionContextDUnitTest method testQueriesWithFilterKeysOnPRWithRebalancing.
// GEODE-575: ignores lots of exceptions, non-thread-safe test hooks
@Category(FlakyTest.class)
@Test
public void testQueriesWithFilterKeysOnPRWithRebalancing() {
IgnoredException.addIgnoredException("QueryInvocationTargetException");
IgnoredException.addIgnoredException("java.net.SocketException");
IgnoredException.addIgnoredException("ServerConnectivityException");
IgnoredException.addIgnoredException("FunctionException");
IgnoredException.addIgnoredException("IOException");
// Close cache on server1
server1.invoke(new CacheSerializableRunnable("Set QueryObserver in cache on server1") {
@Override
public void run2() throws CacheException {
class MyQueryObserver extends IndexTrackingQueryObserver {
@Override
public void startQuery(Query query) {
Region pr = CacheFactory.getAnyInstance().getRegion(PartitionedRegionName1);
Region KeyRegion = null;
for (int i = 6; i < 9; i++) {
KeyRegion = ((PartitionedRegion) pr).getBucketRegion(i);
if (KeyRegion != null)
KeyRegion.destroyRegion();
}
}
}
;
QueryObserverHolder.setInstance(new MyQueryObserver());
}
});
client.invoke(new CacheSerializableRunnable("Run function on PR") {
@Override
public void run2() throws CacheException {
Set filter = new HashSet();
ResultCollector rcollector = null;
filter.addAll(getFilter(6, 9));
for (int i = 0; i < queries.length; i++) {
try {
function = new TestQueryFunction("queryFunction");
rcollector = FunctionService.onRegion(CacheFactory.getAnyInstance().getRegion(PartitionedRegionName1)).setArguments(queries[i]).withFilter(filter).execute(function);
// Should not come here, an exception is expected from above function call.
fail("Function call did not fail for query with function context");
} catch (FunctionException ex) {
if (!((ex.getCause() instanceof QueryInvocationTargetException) || (ex.getCause() instanceof ServerConnectivityException))) {
if (ex.getCause() instanceof FunctionException) {
FunctionException fe = (FunctionException) ex.getCause();
if (!fe.getMessage().startsWith("IOException")) {
fail("Should have received an QueryInvocationTargetException but recieved" + ex.getMessage());
}
} else {
fail("Should have received an QueryInvocationTargetException but recieved" + ex.getMessage());
}
}
}
}
// For loop ends here.
}
});
// Close cache on server1
server1.invoke(new CacheSerializableRunnable("Reset Query Observer on server1") {
@Override
public void run2() throws CacheException {
QueryObserverHolder.reset();
}
});
}
use of org.apache.geode.cache.client.ServerConnectivityException in project geode by apache.
the class ServerFunctionExecutor method executeOnServerNoAck.
private void executeOnServerNoAck(Function function, byte hasResult) {
FunctionStats stats = FunctionStats.getFunctionStats(function.getId());
try {
validateExecution(function, null);
long start = stats.startTime();
stats.startFunctionExecution(false);
ExecuteFunctionNoAckOp.execute(this.pool, function, args, memberMappedArg, this.allServers, hasResult, this.isFnSerializationReqd, groups);
stats.endFunctionExecution(start, false);
} catch (FunctionException functionException) {
stats.endFunctionExecutionWithException(false);
throw functionException;
} catch (ServerConnectivityException exception) {
throw exception;
} catch (Exception exception) {
stats.endFunctionExecutionWithException(false);
throw new FunctionException(exception);
}
}
Aggregations