public ServerBridge(final CacheServerImpl cacheServer, final MBeanStatsMonitor monitor) { this(cacheServer.getAcceptor(), monitor); }
@Override public /* synchronized causes deadlock */ void fillInProfile(Profile profile) { assert profile instanceof CacheServerProfile; CacheServerProfile bp = (CacheServerProfile) profile; bp.setHost(getExternalAddress(false)); bp.setPort(getPort()); bp.setGroups(getCombinedGroups()); bp.setMaxConnections(maxConnections); bp.setInitialLoad(loadMonitor.getLastLoad()); bp.setLoadPollInterval(getLoadPollInterval()); bp.serialNumber = getSerialNumber(); bp.finishInit(); }
/** * Returns an array of all the groups of this cache server. This includes those from the groups * gemfire property and those explicitly added to this server. */ public String[] getCombinedGroups() { ArrayList<String> groupList = new ArrayList<String>(); if (!this.isGatewayReceiver) { for (String g : MemberAttributes.parseGroups(null, getSystem().getConfig().getGroups())) { if (!groupList.contains(g)) { groupList.add(g); } } } for (String g : getGroups()) { if (!groupList.contains(g)) { groupList.add(g); } } String[] groups = new String[groupList.size()]; return groupList.toArray(groups); }
private String getConfig() { ClientSubscriptionConfig csc = this.getClientSubscriptionConfig(); String str = "port=" + getPort() + " max-connections=" + getMaxConnections() + " max-threads=" + getMaxThreads() + " notify-by-subscription=" + getNotifyBySubscription() + " socket-buffer-size=" + getSocketBufferSize() + " maximum-time-between-pings=" + getMaximumTimeBetweenPings() + " maximum-message-count=" + getMaximumMessageCount() + " message-time-to-live=" + getMessageTimeToLive() + " eviction-policy=" + csc.getEvictionPolicy() + " capacity=" + csc.getCapacity() + " overflow directory="; if (csc.getDiskStoreName() != null) { str += csc.getDiskStoreName(); } else { str += csc.getOverflowDirectory(); } str += " groups=" + Arrays.asList(getGroups()) + " loadProbe=" + loadProbe + " loadPollInterval=" + loadPollInterval + " tcpNoDelay=" + tcpNoDelay; return str; }
/** * 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); }
this.port = impl.getPort(); this.bindAddress = impl.getBindAddress(); this.hostnameForClients = impl.getHostnameForClients(); if (CacheServerImpl.ENABLE_NOTIFY_BY_SUBSCRIPTION_FALSE) { this.notifyBySubscription = impl.getNotifyBySubscription(); this.socketBufferSize = impl.getSocketBufferSize(); this.maximumTimeBetweenPings = impl.getMaximumTimeBetweenPings(); this.isRunning = impl.isRunning(); this.maxConnections = impl.getMaxConnections(); this.maxThreads = impl.getMaxThreads(); this.id = System.identityHashCode(impl); this.maximumMessageCount = impl.getMaximumMessageCount(); this.messageTimeToLive = impl.getMessageTimeToLive(); this.groups = impl.getGroups(); this.loadProbe = getProbe(impl.getLoadProbe()); this.loadPollInterval = impl.getLoadPollInterval(); this.tcpNoDelay = impl.getTcpNoDelay(); ClientSubscriptionConfig cscimpl = impl.getClientSubscriptionConfig(); this.clientSubscriptionConfig.setEvictionPolicy(cscimpl.getEvictionPolicy()); this.clientSubscriptionConfig.setCapacity(cscimpl.getCapacity());
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();
serverImpl.setPort(parameters.getPort()); if (parameters.getMaxThreads() != null && parameters.getMaxThreads() != CacheServer.DEFAULT_MAX_THREADS) serverImpl.setMaxThreads(parameters.getMaxThreads()); if (parameters.getMaxConnections() != null && parameters.getMaxConnections() != CacheServer.DEFAULT_MAX_CONNECTIONS) serverImpl.setMaxConnections(parameters.getMaxConnections()); if (parameters.getMaxMessageCount() != null && parameters.getMaxMessageCount() != CacheServer.DEFAULT_MAXIMUM_MESSAGE_COUNT) serverImpl.setMaximumMessageCount(parameters.getMaxMessageCount()); if (parameters.getSocketBufferSize() != null && parameters.getSocketBufferSize() != CacheServer.DEFAULT_SOCKET_BUFFER_SIZE) serverImpl.setSocketBufferSize(parameters.getSocketBufferSize()); if (parameters.getBindAddress() != null && parameters.getBindAddress() != CacheServer.DEFAULT_BIND_ADDRESS) serverImpl.setBindAddress(parameters.getBindAddress().trim()); if (parameters.getMessageTimeToLive() != null && parameters.getMessageTimeToLive() != CacheServer.DEFAULT_MESSAGE_TIME_TO_LIVE) serverImpl.setMessageTimeToLive(parameters.getMessageTimeToLive()); if (parameters.getHostnameForClients() != null && parameters.getHostnameForClients() != CacheServer.DEFAULT_HOSTNAME_FOR_CLIENTS) serverImpl.setHostnameForClients(parameters.getHostnameForClients());
Assert.assertTrue(this.cache != null); this.serialNumber = createSerialNumber(); if (DynamicRegionFactory.get().isOpen()) { FORCE_LOAD_UPDATE_FREQUENCY, advisor); List overflowAttributesList = new LinkedList(); ClientSubscriptionConfig csc = this.getClientSubscriptionConfig(); overflowAttributesList.add(0, csc.getEvictionPolicy()); overflowAttributesList.add(1, valueOf(csc.getCapacity())); this.acceptor = new AcceptorImpl(getPort(), getBindAddress(), getNotifyBySubscription(), getSocketBufferSize(), getMaximumTimeBetweenPings(), this.cache, getMaxConnections(), getMaxThreads(), getMaximumMessageCount(), getMessageTimeToLive(), this.loadMonitor, overflowAttributesList, this.isGatewayReceiver, this.gatewayTransportFilters, this.tcpNoDelay, serverConnectionFactory, 120000); this.loadMonitor.start(new ServerLocation(getExternalAddress(), getPort()), acceptor.getStats()); .config(String.format("CacheServer Configuration: %s", getConfig()));
private static void findLocalDurableQueues(ClientProxyMembershipID proxyId, ArrayList<ServerLocation> matches) { InternalCache cache = GemFireCacheImpl.getInstance(); if (cache != null) { List l = cache.getCacheServers(); if (l != null) { Iterator i = l.iterator(); while (i.hasNext()) { CacheServerImpl bs = (CacheServerImpl) i.next(); if (bs.getAcceptor().getCacheClientNotifier().getClientProxy(proxyId) != null) { ServerLocation loc = new ServerLocation(bs.getExternalAddress(), bs.getPort()); matches.add(loc); } } } } }
@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()); }
impl.configureFrom(declaredCacheServer); impl.setIsDefaultServer(); if (!impl.isRunning()) { impl.start();
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; }
/** * Gets the address that this cache server can be contacted on from external processes. * * @since GemFire 5.7 */ public String getExternalAddress() { return getExternalAddress(true); }
@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()); } }
CacheServerImpl bridge = (CacheServerImpl) cacheServer; if (System.identityHashCode(bridge) == config.getId()) { bridge.configureFrom(config); bridge.start(); m.bridgeInfo = new RemoteBridgeServer(bridge); break; CacheServerImpl bridge = (CacheServerImpl) cacheServer; if (System.identityHashCode(bridge) == config.getId()) { bridge.stop(); m.bridgeInfo = new RemoteBridgeServer(bridge); break;
/** * 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()); } } } } }
@Override public String toString() { ClientSubscriptionConfig csc = this.getClientSubscriptionConfig(); String str = "CacheServer on port=" + getPort() + " client subscription config policy=" + csc.getEvictionPolicy() + " client subscription config capacity=" + csc.getCapacity(); if (csc.getDiskStoreName() != null) { str += " client subscription config overflow disk store=" + csc.getDiskStoreName(); } else { str += " client subscription config overflow directory=" + csc.getOverflowDirectory(); } return str; }
/** * 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."); } }
@Override public DistributionManager getDistributionManager() { return getSystem().getDistributionManager(); }