/** * Checks to see whether or not this cache server is running. If so, an * {@link IllegalStateException} is thrown. */ private void checkRunning() { if (this.isRunning()) { throw new IllegalStateException( "A cache server's configuration cannot be changed once it is running."); } }
/** * Registers a new{@code InterestRegistrationListener} with the set of * {@code InterestRegistrationListener}s. * * @param listener The{@code InterestRegistrationListener} to register * @throws IllegalStateException if the BridgeServer has not been started * @since GemFire 5.8Beta */ @Override public void registerInterestRegistrationListener(InterestRegistrationListener listener) { if (!this.isRunning()) { throw new IllegalStateException( "The cache server must be running to use this operation"); } getCacheClientNotifier().registerInterestRegistrationListener(listener); }
public String getExternalAddress(boolean checkServerRunning) { if (checkServerRunning) { if (!this.isRunning()) { String s = "A cache server's bind address is only available if it has been started"; this.cache.getCancelCriterion().checkCancelInProgress(null); throw new IllegalStateException(s); } } if (this.hostnameForClients == null || this.hostnameForClients.isEmpty()) { if (this.acceptor != null) { return this.acceptor.getExternalAddress(); } else { return null; } } else { return this.hostnameForClients; } }
public Set<String> getLocalServerGroups() { Set<String> localServerGroups = new HashSet(); InternalCache cache = getCache(); List servers; servers = cache.getCacheServers(); Collections.addAll(localServerGroups, MemberAttributes.parseGroups(null, cache.getInternalDistributedSystem().getConfig().getGroups())); for (Object object : servers) { CacheServerImpl server = (CacheServerImpl) object; if (server.isRunning() && (server.getExternalAddress() != null)) { Collections.addAll(localServerGroups, server.getGroups()); } } return localServerGroups; }
/** * Tell local cache servers about the received profile. Also if exchange profiles then add each * local cache server to reply. * * @since GemFire 5.7 */ protected void tellLocalBridgeServers(InternalCache cache, boolean removeProfile, boolean exchangeProfiles, final List<Profile> replyProfiles) { if (cache != null && !cache.isClosed()) { List<?> bridgeServers = cache.getCacheServersAndGatewayReceiver(); for (int i = 0; i < bridgeServers.size(); i++) { CacheServerImpl bsi = (CacheServerImpl) bridgeServers.get(i); if (bsi.isRunning()) { if (bsi.getProfile().equals(this)) { continue; } // negative value for port indicates fake // profile meant to only gather remote profiles during profile // exchange if (this.port > 0) { handleDistributionAdvisee(bsi, removeProfile, exchangeProfiles, replyProfiles); } else if (exchangeProfiles) { replyProfiles.add(bsi.getProfile()); } } } } }
@Test public void destroyCalledOnRunningGatewayReceiverShouldThrowException() throws IOException { InternalCache cache = mock(InternalCache.class); CacheServerImpl server = mock(CacheServerImpl.class); InternalDistributedSystem system = mock(InternalDistributedSystem.class); when(cache.getInternalDistributedSystem()).thenReturn(system); when(server.getExternalAddress()).thenReturn("hello"); when(server.isRunning()).thenReturn(true); when(cache.addCacheServer(eq(true))).thenReturn(server); GatewayReceiverImpl gateway = new GatewayReceiverImpl(cache, 2000, 2001, 5, 100, null, null, null, true); gateway.start(); try { gateway.destroy(); fail(); } catch (GatewayReceiverException e) { assertEquals("Gateway Receiver is running and needs to be stopped first", e.getMessage()); } }
@Override protected Profile instantiateProfile(InternalDistributedMember memberId, int version) { if (!this.pRegion.isShadowPR()) { InternalCache cache = getProxyBucketRegion().getCache(); List servers = null; servers = cache.getCacheServers(); HashSet<BucketServerLocation66> serverLocations = new HashSet<BucketServerLocation66>(); for (Object object : servers) { CacheServerImpl server = (CacheServerImpl) object; if (server.isRunning() && (server.getExternalAddress() != null)) { BucketServerLocation66 location = new BucketServerLocation66(getBucket().getId(), server.getPort(), server.getExternalAddress() /* .getExternalAddress(false/ checkServerRunning ) */, getBucket().isPrimary(), Integer.valueOf(version).byteValue(), server.getCombinedGroups()); serverLocations.add(location); } } if (serverLocations.size() > 0) { return new ServerBucketProfile(memberId, version, getBucket(), serverLocations); } } return new BucketProfile(memberId, version, getBucket()); }
if (!impl.isRunning()) { impl.start();
@Override public synchronized void stop() { if (!isRunning()) { return;
this.isRunning = impl.isRunning(); this.maxConnections = impl.getMaxConnections(); this.maxThreads = impl.getMaxThreads();