Search in sources :

Example 51 with CacheServerImpl

use of org.apache.geode.internal.cache.CacheServerImpl in project geode by apache.

the class CacheCreationJUnitTest method userCanCreateMultipleCacheServersDeclaratively.

@Test
public void userCanCreateMultipleCacheServersDeclaratively() {
    CacheCreation cacheCreation = new CacheCreation();
    CacheServerCreation br1 = new CacheServerCreation(cacheCreation, false);
    br1.setPort(40406);
    CacheServerCreation br2 = new CacheServerCreation(cacheCreation, false);
    br1.setPort(40407);
    cacheCreation.getCacheServers().add(br1);
    cacheCreation.getCacheServers().add(br2);
    CacheServerImpl mockServer = mock(CacheServerImpl.class);
    when(this.cache.addCacheServer()).thenReturn(mockServer);
    Integer configuredServerPort = null;
    String configuredServerBindAddress = null;
    Boolean disableDefaultCacheServer = false;
    cacheCreation.startCacheServers(cacheCreation.getCacheServers(), this.cache, configuredServerPort, configuredServerBindAddress, disableDefaultCacheServer);
    verify(this.cache, times(2)).addCacheServer();
    verify(mockServer).configureFrom(br1);
    verify(mockServer).configureFrom(br2);
}
Also used : CacheServerImpl(org.apache.geode.internal.cache.CacheServerImpl) Test(org.junit.Test) UnitTest(org.apache.geode.test.junit.categories.UnitTest)

Example 52 with CacheServerImpl

use of org.apache.geode.internal.cache.CacheServerImpl in project geode by apache.

the class CacheCreationJUnitTest method defaultCacheServerIsCreatedWithConfiguredPortWhenNoDeclarativeServerIsConfigured.

@Test
public void defaultCacheServerIsCreatedWithConfiguredPortWhenNoDeclarativeServerIsConfigured() {
    CacheCreation cacheCreation = new CacheCreation();
    CacheServerImpl mockServer = mock(CacheServerImpl.class);
    when(this.cache.addCacheServer()).thenReturn(mockServer);
    List<CacheServer> cacheServers = new ArrayList<>();
    when(this.cache.getCacheServers()).thenReturn(cacheServers);
    Boolean disableDefaultCacheServer = false;
    Integer configuredServerPort = 9999;
    String configuredServerBindAddress = null;
    cacheCreation.startCacheServers(cacheCreation.getCacheServers(), this.cache, configuredServerPort, configuredServerBindAddress, disableDefaultCacheServer);
    verify(this.cache, times(1)).addCacheServer();
    verify(mockServer).setPort(9999);
}
Also used : ArrayList(java.util.ArrayList) CacheServer(org.apache.geode.cache.server.CacheServer) CacheServerImpl(org.apache.geode.internal.cache.CacheServerImpl) Test(org.junit.Test) UnitTest(org.apache.geode.test.junit.categories.UnitTest)

Example 53 with CacheServerImpl

use of org.apache.geode.internal.cache.CacheServerImpl in project geode by apache.

the class CacheCreationJUnitTest method declarativeCacheServerIsCreatedWithConfiguredServerPort.

@Test
public void declarativeCacheServerIsCreatedWithConfiguredServerPort() {
    CacheCreation cacheCreation = new CacheCreation();
    CacheServerCreation br1 = new CacheServerCreation(cacheCreation, false);
    br1.setPort(8888);
    cacheCreation.getCacheServers().add(br1);
    CacheServerImpl mockServer = mock(CacheServerImpl.class);
    when(this.cache.addCacheServer()).thenReturn(mockServer);
    Integer configuredServerPort = 9999;
    String configuredServerBindAddress = null;
    Boolean disableDefaultCacheServer = false;
    cacheCreation.startCacheServers(cacheCreation.getCacheServers(), this.cache, configuredServerPort, configuredServerBindAddress, disableDefaultCacheServer);
    verify(this.cache, times(1)).addCacheServer();
    verify(mockServer).setPort(configuredServerPort);
}
Also used : CacheServerImpl(org.apache.geode.internal.cache.CacheServerImpl) Test(org.junit.Test) UnitTest(org.apache.geode.test.junit.categories.UnitTest)

Example 54 with CacheServerImpl

use of org.apache.geode.internal.cache.CacheServerImpl in project geode by apache.

the class DurableClientTestCase method getBridgeServer.

protected static CacheServerImpl getBridgeServer() {
    CacheServerImpl bridgeServer = (CacheServerImpl) CacheServerTestUtil.getCache().getCacheServers().iterator().next();
    assertNotNull(bridgeServer);
    return bridgeServer;
}
Also used : CacheServerImpl(org.apache.geode.internal.cache.CacheServerImpl)

Example 55 with CacheServerImpl

use of org.apache.geode.internal.cache.CacheServerImpl in project geode by apache.

the class AcceptorImplDUnitTest method getAcceptorImplFromCache.

/**
   *
   * @param cache
   * @return the cache's Acceptor, if there is exactly one CacheServer. Otherwise null.
   */
public AcceptorImpl getAcceptorImplFromCache(GemFireCache cache) {
    GemFireCacheImpl gemFireCache = (GemFireCacheImpl) cache;
    List<CacheServer> cacheServers = gemFireCache.getCacheServers();
    if (cacheServers.size() != 1) {
        return null;
    }
    CacheServerImpl cacheServerImpl = (CacheServerImpl) cacheServers.get(0);
    return cacheServerImpl.getAcceptor();
}
Also used : GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl) CacheServer(org.apache.geode.cache.server.CacheServer) CacheServerImpl(org.apache.geode.internal.cache.CacheServerImpl)

Aggregations

CacheServerImpl (org.apache.geode.internal.cache.CacheServerImpl)76 Iterator (java.util.Iterator)23 Cache (org.apache.geode.cache.Cache)19 WaitCriterion (org.apache.geode.test.dunit.WaitCriterion)19 CacheServer (org.apache.geode.cache.server.CacheServer)14 IOException (java.io.IOException)13 IgnoredException (org.apache.geode.test.dunit.IgnoredException)13 CacheException (org.apache.geode.cache.CacheException)12 ArrayList (java.util.ArrayList)10 Test (org.junit.Test)8 Set (java.util.Set)7 InternalCache (org.apache.geode.internal.cache.InternalCache)7 Map (java.util.Map)6 Properties (java.util.Properties)6 AcceptorImpl (org.apache.geode.internal.cache.tier.sockets.AcceptorImpl)6 UnitTest (org.apache.geode.test.junit.categories.UnitTest)6 HashMap (java.util.HashMap)5 AttributesFactory (org.apache.geode.cache.AttributesFactory)5 RegionAttributes (org.apache.geode.cache.RegionAttributes)5 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)5