use of org.apache.geode.distributed.internal.ServerLocation in project geode by apache.
the class Simple2CacheServerDUnitTest method setClientServerObserver.
public static void setClientServerObserver() {
PoolImpl.AFTER_PRIMARY_IDENTIFICATION_FROM_BACKUP_CALLBACK_FLAG = true;
ClientServerObserverHolder.setInstance(new ClientServerObserverAdapter() {
public void afterPrimaryIdentificationFromBackup(ServerLocation primaryEndpoint) {
LogService.getLogger().info("After primary is set");
afterPrimaryCount++;
}
});
}
use of org.apache.geode.distributed.internal.ServerLocation in project geode by apache.
the class DurableClientSimpleDUnitTest method verifyDurableCqs.
public static void verifyDurableCqs(final List<String> durableCqNames, final String registeredCqName) {
// Verify the number of durable CQ names is one, and it matches the registered name
assertEquals(1, durableCqNames.size());
String returnedCqName = durableCqNames.get(0);
assertEquals(registeredCqName, returnedCqName);
// Get client's primary server
PoolImpl pool = CacheServerTestUtil.getPool();
ServerLocation primaryServerLocation = pool.getPrimary();
// Verify the primary server was used and no other server was used
Map<ServerLocation, ConnectionStats> statistics = pool.getEndpointManager().getAllStats();
for (Map.Entry<ServerLocation, ConnectionStats> entry : statistics.entrySet()) {
int expectedGetDurableCqInvocations = entry.getKey().equals(primaryServerLocation) ? 1 : 0;
assertEquals(expectedGetDurableCqInvocations, entry.getValue().getGetDurableCqs());
}
}
use of org.apache.geode.distributed.internal.ServerLocation in project geode by apache.
the class ClearPropagationDUnitTest method acquireConnectionsAndDestroyRegion.
public static void acquireConnectionsAndDestroyRegion(String host) {
try {
Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME);
assertNotNull(r1);
String poolName = r1.getAttributes().getPoolName();
assertNotNull(poolName);
PoolImpl pool = (PoolImpl) PoolManager.find(poolName);
assertNotNull(pool);
Connection conn1 = pool.acquireConnection(new ServerLocation(host, PORT2));
assertNotNull(conn1);
assertEquals(PORT2, conn1.getServer().getPort());
ServerRegionProxy srp = new ServerRegionProxy(Region.SEPARATOR + REGION_NAME, pool);
srp.destroyRegionOnForTestsOnly(conn1, new EventID(new byte[] { 1 }, 1, 1), null);
} catch (Exception ex) {
ex.printStackTrace();
fail("while setting acquireConnections " + ex);
}
}
use of org.apache.geode.distributed.internal.ServerLocation in project geode by apache.
the class UpdatePropagationDUnitTest method hasEndPointWithPort.
/**
* Check to see if a client is connected to an endpoint with a specific port
*/
private boolean hasEndPointWithPort(final PoolImpl pool, final int port) {
EndpointManager endpointManager = pool.getEndpointManager();
final Set<ServerLocation> servers = endpointManager.getEndpointMap().keySet();
return servers.stream().anyMatch(location -> location.getPort() == port);
}
use of org.apache.geode.distributed.internal.ServerLocation in project geode by apache.
the class ServerBlackListJUnitTest method testBlackListing.
@Test
public void testBlackListing() throws Exception {
ServerLocation location1 = new ServerLocation("localhost", 1);
FailureTracker tracker1 = blackList.getFailureTracker(location1);
tracker1.addFailure();
tracker1.addFailure();
assertEquals(Collections.EMPTY_SET, blackList.getBadServers());
tracker1.addFailure();
assertEquals(Collections.singleton(location1), blackList.getBadServers());
boolean done = false;
for (StopWatch time = new StopWatch(true); !done && time.elapsedTimeMillis() < 10000; done = (blackList.getBadServers().size() == 0)) {
Thread.sleep(200);
}
assertTrue("blackList still has bad servers", done);
assertEquals(Collections.EMPTY_SET, blackList.getBadServers());
}
Aggregations