@Override public CacheServer addCacheServer(boolean isGatewayReceiver) { CacheServer bridge = new CacheServerCreation(this, false); this.bridgeServers.add(bridge); return bridge; }
@Override public String toString() { return "BridgeServerCreation on port " + this.getPort() + " notify by subscription " + this.getNotifyBySubscription() + " maximum time between pings " + this.getMaximumTimeBetweenPings() + " socket buffer size " + this.getSocketBufferSize() + " maximum connections " + this.getMaxConnections() + " maximum threads " + this.getMaxThreads() + " maximum message count " + this.getMaximumMessageCount() + " message time to live " + this.getMessageTimeToLive() + " groups " + Arrays.asList(getGroups()) + " loadProbe " + loadProbe + " loadPollInterval " + loadPollInterval + this.getClientSubscriptionConfig().toString(); }
/** * Returns whether or not this cache server has the same configuration as another cache server. */ @Override public boolean sameAs(CacheServer other) { ClientSubscriptionConfig cscThis = this.getClientSubscriptionConfig(); ClientSubscriptionConfig cscOther = other.getClientSubscriptionConfig(); boolean result = isCacheServerPortEquals(other) && this.getSocketBufferSize() == other.getSocketBufferSize() && this.getMaximumTimeBetweenPings() == other.getMaximumTimeBetweenPings() && this.getNotifyBySubscription() == other.getNotifyBySubscription() && this.getMaxConnections() == other.getMaxConnections() && this.getMaxThreads() == other.getMaxThreads() && this.getMaximumMessageCount() == other.getMaximumMessageCount() && this.getMessageTimeToLive() == other.getMessageTimeToLive() && this.getTcpNoDelay() == other.getTcpNoDelay() && cscThis.getCapacity() == cscOther.getCapacity() && cscThis.getEvictionPolicy().equals(cscOther.getEvictionPolicy()); String diskStoreName = cscThis.getDiskStoreName(); if (diskStoreName != null) { result = result && diskStoreName.equals(cscOther.getDiskStoreName()); } else { result = result && cscThis.getOverflowDirectory().equals(cscOther.getOverflowDirectory()); } return result; }
setPort(other.getPort()); setBindAddress(other.getBindAddress()); setHostnameForClients(other.getHostnameForClients()); setMaxConnections(other.getMaxConnections()); setMaxThreads(other.getMaxThreads()); setNotifyBySubscription(other.getNotifyBySubscription()); setSocketBufferSize(other.getSocketBufferSize()); setTcpNoDelay(other.getTcpNoDelay()); setMaximumTimeBetweenPings(other.getMaximumTimeBetweenPings()); setMaximumMessageCount(other.getMaximumMessageCount()); setMessageTimeToLive(other.getMessageTimeToLive()); setGroups(other.getGroups()); setLoadProbe(other.getLoadProbe()); setLoadPollInterval(other.getLoadPollInterval()); ClientSubscriptionConfig cscOther = other.getClientSubscriptionConfig(); ClientSubscriptionConfig cscThis = this.getClientSubscriptionConfig();
@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); cacheCreation.startCacheServers(cacheCreation.getCacheServers(), this.cache, ServerLauncherParameters.INSTANCE.withDisableDefaultServer(false)); verify(this.cache, times(2)).addCacheServer(); verify(mockServer).configureFrom(br1); verify(mockServer).configureFrom(br2); }
defaultServer = new CacheServerCreation((InternalCache) cache, false); declarativeCacheServers.add(defaultServer); if (cacheServers != null) { for (CacheServer cacheServer : cacheServers) { if (declaredCacheServer.getPort() == cacheServer.getPort()) { startServer = false;
@Test public void cacheServerCreationIsSkippedWhenAServerExistsForAGivenPort() { CacheCreation cacheCreation = new CacheCreation(); CacheServerCreation br1 = new CacheServerCreation(cacheCreation, false); br1.setPort(40406); cacheCreation.getCacheServers().add(br1); CacheServerImpl mockServer = mock(CacheServerImpl.class); when(this.cache.addCacheServer()).thenReturn(mockServer); when(mockServer.getPort()).thenReturn(40406); List<CacheServer> cacheServers = new ArrayList<>(); cacheServers.add(mockServer); when(this.cache.getCacheServers()).thenReturn(cacheServers); cacheCreation.startCacheServers(cacheCreation.getCacheServers(), this.cache, ServerLauncherParameters.INSTANCE.withDisableDefaultServer(false)); verify(this.cache, never()).addCacheServer(); }
@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; Boolean disableDefaultCacheServer = false; cacheCreation.startCacheServers(cacheCreation.getCacheServers(), this.cache, ServerLauncherParameters.INSTANCE.withPort(configuredServerPort) .withDisableDefaultServer(disableDefaultCacheServer)); verify(this.cache, times(1)).addCacheServer(); verify(mockServer).setPort(configuredServerPort); }
CacheServerImpl cs = (CacheServerImpl) o; if (cs.isDefaultServer()) { CacheServerCreation bsc = new CacheServerCreation(cache, cs); list.add(bsc);
@Test(expected = RuntimeException.class) public void shouldThrowExceptionWhenUserTriesToDeclareMultipleCacheServersWithPort() { CacheCreation cacheCreation = new CacheCreation(); cacheCreation.getCacheServers().add(new CacheServerCreation(cacheCreation, false)); cacheCreation.getCacheServers().add(new CacheServerCreation(cacheCreation, false)); Integer configuredServerPort = 50505; String configuredServerBindAddress = "localhost[50505]"; Boolean disableDefaultCacheServer = false; cacheCreation.startCacheServers(cacheCreation.getCacheServers(), this.cache, ServerLauncherParameters.INSTANCE.withPort(configuredServerPort) .withBindAddress(configuredServerBindAddress) .withDisableDefaultServer(disableDefaultCacheServer)); }
@Test public void serverLauncherParametersShouldOverrideDefaultSettings() { CacheCreation cacheCreation = new CacheCreation(); CacheServerCreation br1 = new CacheServerCreation(cacheCreation, false); cacheCreation.getCacheServers().add(br1); CacheServerImpl mockServer = mock(CacheServerImpl.class);