use of org.apache.geode.distributed.DistributedSystem in project geode by apache.
the class GfshCommandJUnitTest method testGetMembers.
@Test
public void testGetMembers() {
final InternalCache mockCache = mockContext.mock(InternalCache.class, "InternalCache");
final DistributedSystem mockDistributedSystem = mockContext.mock(DistributedSystem.class, "DistributedSystem");
final DistributedMember mockMemberSelf = createMockMember("S", "Self");
final DistributedMember mockMemberOne = createMockMember("1", "One");
final DistributedMember mockMemberTwo = createMockMember("2", "Two");
mockContext.checking(new Expectations() {
{
oneOf(mockCache).getMembers();
will(returnValue(CollectionUtils.asSet(mockMemberOne, mockMemberTwo)));
oneOf(mockCache).getDistributedSystem();
will(returnValue(mockDistributedSystem));
oneOf(mockDistributedSystem).getDistributedMember();
will(returnValue(mockMemberSelf));
}
});
final GfshCommand commands = createAbstractCommandsSupport(mockCache);
final Set<DistributedMember> expectedMembers = CollectionUtils.asSet(mockMemberOne, mockMemberTwo, mockMemberSelf);
final Set<DistributedMember> actualMembers = commands.getMembers(mockCache);
assertNotNull(actualMembers);
assertEquals(expectedMembers.size(), actualMembers.size());
assertTrue(actualMembers.containsAll(expectedMembers));
}
use of org.apache.geode.distributed.DistributedSystem in project geode by apache.
the class SecurityClusterConfigDUnitTest method testStartServerWithClusterConfig.
@Test
public void testStartServerWithClusterConfig() throws Exception {
Properties props = new Properties();
// the following are needed for peer-to-peer authentication
props.setProperty("security-username", "cluster");
props.setProperty("security-password", "cluster");
props.setProperty("use-cluster-configuration", "true");
// initial security properties should only contain initial set of values
serverStarter.startServer(props, lsRule.getMember(0).getPort());
DistributedSystem ds = serverStarter.getCache().getDistributedSystem();
// after cache is created, we got the security props passed in by cluster config
Properties secProps = ds.getSecurityProperties();
assertEquals(4, secProps.size());
assertTrue(secProps.containsKey("security-manager"));
assertTrue(secProps.containsKey("security-post-processor"));
}
use of org.apache.geode.distributed.DistributedSystem in project geode by apache.
the class SecurityTestUtils method closeCache.
protected static void closeCache(final Boolean keepAlive) {
removeExpectedExceptions(ignoredExceptions);
if (cache != null && !cache.isClosed()) {
DistributedSystem sys = cache.getDistributedSystem();
cache.close(keepAlive);
sys.disconnect();
cache = null;
}
disconnectFromDS();
}
use of org.apache.geode.distributed.DistributedSystem in project geode by apache.
the class LocatorTestBase method startBridgeServer.
protected int startBridgeServer(final String[] groups, final String locators, final String[] regions, final ServerLoadProbe probe, final boolean useGroupsProperty) throws IOException {
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, locators);
if (useGroupsProperty && groups != null) {
props.setProperty(GROUPS, StringUtils.join(groups, ","));
}
DistributedSystem ds = getSystem(props);
Cache cache = CacheFactory.create(ds);
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setEnableBridgeConflation(true);
factory.setDataPolicy(DataPolicy.REPLICATE);
RegionAttributes attrs = factory.create();
for (int i = 0; i < regions.length; i++) {
cache.createRegion(regions[i], attrs);
}
CacheServer server = cache.addCacheServer();
server.setPort(0);
if (!useGroupsProperty) {
server.setGroups(groups);
}
server.setLoadProbe(probe);
server.start();
remoteObjects.put(CACHE_KEY, cache);
return new Integer(server.getPort());
}
use of org.apache.geode.distributed.DistributedSystem in project geode by apache.
the class LocatorTestBase method startBridgeClient.
protected void startBridgeClient(final Pool pool, final String[] regions) throws Exception {
Properties props = new Properties();
props.setProperty(MCAST_PORT, String.valueOf(0));
props.setProperty(LOCATORS, "");
DistributedSystem ds = getSystem(props);
Cache cache = CacheFactory.create(ds);
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.LOCAL);
factory.setPoolName(POOL_NAME);
PoolFactoryImpl pf = (PoolFactoryImpl) PoolManager.createFactory();
pf.init(pool);
LocatorDiscoveryCallback locatorCallback = new MyLocatorCallback();
remoteObjects.put(CALLBACK_KEY, locatorCallback);
pf.setLocatorDiscoveryCallback(locatorCallback);
pf.create(POOL_NAME);
RegionAttributes attrs = factory.create();
for (int i = 0; i < regions.length; i++) {
cache.createRegion(regions[i], attrs);
}
remoteObjects.put(CACHE_KEY, cache);
}
Aggregations