Search in sources :

Example 61 with DistributedSystem

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));
}
Also used : Expectations(org.jmock.Expectations) DistributedMember(org.apache.geode.distributed.DistributedMember) InternalCache(org.apache.geode.internal.cache.InternalCache) DistributedSystem(org.apache.geode.distributed.DistributedSystem) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 62 with DistributedSystem

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"));
}
Also used : Properties(java.util.Properties) DistributedSystem(org.apache.geode.distributed.DistributedSystem) SecurityTest(org.apache.geode.test.junit.categories.SecurityTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 63 with DistributedSystem

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();
}
Also used : DistributedSystem(org.apache.geode.distributed.DistributedSystem)

Example 64 with DistributedSystem

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());
}
Also used : AttributesFactory(org.apache.geode.cache.AttributesFactory) RegionAttributes(org.apache.geode.cache.RegionAttributes) CacheServer(org.apache.geode.cache.server.CacheServer) Properties(java.util.Properties) DistributedSystem(org.apache.geode.distributed.DistributedSystem) Cache(org.apache.geode.cache.Cache)

Example 65 with DistributedSystem

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);
}
Also used : AttributesFactory(org.apache.geode.cache.AttributesFactory) RegionAttributes(org.apache.geode.cache.RegionAttributes) Properties(java.util.Properties) DistributedSystem(org.apache.geode.distributed.DistributedSystem) Cache(org.apache.geode.cache.Cache) PoolFactoryImpl(org.apache.geode.internal.cache.PoolFactoryImpl)

Aggregations

DistributedSystem (org.apache.geode.distributed.DistributedSystem)250 Properties (java.util.Properties)102 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)65 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)61 Test (org.junit.Test)59 Cache (org.apache.geode.cache.Cache)55 AttributesFactory (org.apache.geode.cache.AttributesFactory)34 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)30 Region (org.apache.geode.cache.Region)24 IOException (java.io.IOException)20 CacheServer (org.apache.geode.cache.server.CacheServer)20 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)20 InternalCache (org.apache.geode.internal.cache.InternalCache)16 IgnoredException (org.apache.geode.test.dunit.IgnoredException)16 ArrayList (java.util.ArrayList)15 LogWriter (org.apache.geode.LogWriter)15 DistributedMember (org.apache.geode.distributed.DistributedMember)15 LocalRegion (org.apache.geode.internal.cache.LocalRegion)15 RegionAttributes (org.apache.geode.cache.RegionAttributes)14 Pool (org.apache.geode.cache.client.Pool)14