Search in sources :

Example 1 with LoadMonitor

use of org.apache.geode.cache.server.internal.LoadMonitor in project geode by apache.

the class CacheServerImpl method start.

@Override
public synchronized void start() throws IOException {
    Assert.assertTrue(this.cache != null);
    this.serialNumber = createSerialNumber();
    if (DynamicRegionFactory.get().isOpen()) {
        // from servers to clients instead of invalidates.
        if (!this.notifyBySubscription) {
            logger.info(LocalizedMessage.create(LocalizedStrings.CacheServerImpl_FORCING_NOTIFYBYSUBSCRIPTION_TO_SUPPORT_DYNAMIC_REGIONS));
            this.notifyBySubscription = true;
        }
    }
    this.advisor = CacheServerAdvisor.createCacheServerAdvisor(this);
    this.loadMonitor = new LoadMonitor(loadProbe, maxConnections, loadPollInterval, FORCE_LOAD_UPDATE_FREQUENCY, advisor);
    List overflowAttributesList = new LinkedList();
    ClientSubscriptionConfig csc = this.getClientSubscriptionConfig();
    overflowAttributesList.add(0, csc.getEvictionPolicy());
    overflowAttributesList.add(1, valueOf(csc.getCapacity()));
    overflowAttributesList.add(2, valueOf(this.port));
    String diskStoreName = csc.getDiskStoreName();
    if (diskStoreName != null) {
        overflowAttributesList.add(3, diskStoreName);
        // indicator to use diskstore
        overflowAttributesList.add(4, true);
    } else {
        overflowAttributesList.add(3, csc.getOverflowDirectory());
        overflowAttributesList.add(4, false);
    }
    this.acceptor = new AcceptorImpl(getPort(), getBindAddress(), getNotifyBySubscription(), getSocketBufferSize(), getMaximumTimeBetweenPings(), this.cache, getMaxConnections(), getMaxThreads(), getMaximumMessageCount(), getMessageTimeToLive(), this.loadMonitor, overflowAttributesList, this.isGatewayReceiver, this.gatewayTransportFilters, this.tcpNoDelay);
    this.acceptor.start();
    this.advisor.handshake();
    this.loadMonitor.start(new ServerLocation(getExternalAddress(), getPort()), acceptor.getStats());
    // TODO : Need to provide facility to enable/disable client health monitoring.
    // Creating ClientHealthMonitoring region.
    // Force initialization on current cache
    ClientHealthMonitoringRegion.getInstance(this.cache);
    this.cache.getLoggerI18n().config(LocalizedStrings.CacheServerImpl_CACHESERVER_CONFIGURATION___0, getConfig());
    /*
     * If the stopped bridge server is restarted, we'll need to re-register the client membership
     * listener. If the listener is already registered it won't be registered as would the case when
     * start() is invoked for the first time.
     */
    ClientMembershipListener[] membershipListeners = ClientMembership.getClientMembershipListeners();
    boolean membershipListenerRegistered = false;
    for (ClientMembershipListener membershipListener : membershipListeners) {
        // just checking by reference as the listener instance is final
        if (listener == membershipListener) {
            membershipListenerRegistered = true;
            break;
        }
    }
    if (!membershipListenerRegistered) {
        ClientMembership.registerClientMembershipListener(listener);
    }
    if (!isGatewayReceiver) {
        InternalDistributedSystem system = this.cache.getInternalDistributedSystem();
        system.handleResourceEvent(ResourceEvent.CACHE_SERVER_START, this);
    }
}
Also used : ServerLocation(org.apache.geode.distributed.internal.ServerLocation) AcceptorImpl(org.apache.geode.internal.cache.tier.sockets.AcceptorImpl) ClientSubscriptionConfig(org.apache.geode.cache.server.ClientSubscriptionConfig) ClientMembershipListener(org.apache.geode.management.membership.ClientMembershipListener) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) LoadMonitor(org.apache.geode.cache.server.internal.LoadMonitor) LinkedList(java.util.LinkedList)

Aggregations

ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 ClientSubscriptionConfig (org.apache.geode.cache.server.ClientSubscriptionConfig)1 LoadMonitor (org.apache.geode.cache.server.internal.LoadMonitor)1 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)1 ServerLocation (org.apache.geode.distributed.internal.ServerLocation)1 AcceptorImpl (org.apache.geode.internal.cache.tier.sockets.AcceptorImpl)1 ClientMembershipListener (org.apache.geode.management.membership.ClientMembershipListener)1