Search in sources :

Example 6 with ClientSubscriptionConfig

use of org.apache.geode.cache.server.ClientSubscriptionConfig in project geode by apache.

the class CacheServerImpl method getConfig.

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;
}
Also used : ClientSubscriptionConfig(org.apache.geode.cache.server.ClientSubscriptionConfig)

Example 7 with ClientSubscriptionConfig

use of org.apache.geode.cache.server.ClientSubscriptionConfig in project geode by apache.

the class CacheServerImpl method toString.

@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;
}
Also used : ClientSubscriptionConfig(org.apache.geode.cache.server.ClientSubscriptionConfig)

Example 8 with ClientSubscriptionConfig

use of org.apache.geode.cache.server.ClientSubscriptionConfig 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)

Example 9 with ClientSubscriptionConfig

use of org.apache.geode.cache.server.ClientSubscriptionConfig in project geode by apache.

the class CacheClientNotifierDUnitTest method createCacheServerWithCSC.

private int createCacheServerWithCSC(VM vm, final boolean withCSC, final int capacity, final String policy, final String diskStoreName) {
    final int serverPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
    SerializableRunnable createCacheServer = new SerializableRunnable() {

        @Override
        public void run() throws Exception {
            CacheServerImpl server = (CacheServerImpl) cache.addCacheServer();
            server.setPort(serverPort);
            if (withCSC) {
                if (diskStoreName != null) {
                    DiskStore ds = cache.findDiskStore(diskStoreName);
                    if (ds == null) {
                        ds = cache.createDiskStoreFactory().create(diskStoreName);
                    }
                }
                ClientSubscriptionConfig csc = server.getClientSubscriptionConfig();
                csc.setCapacity(capacity);
                csc.setEvictionPolicy(policy);
                csc.setDiskStoreName(diskStoreName);
                server.setHostnameForClients("localhost");
            // server.setGroups(new String[]{"serv"});
            }
            try {
                server.start();
            } catch (IOException e) {
                org.apache.geode.test.dunit.Assert.fail("Failed to start server ", e);
            }
        }
    };
    vm.invoke(createCacheServer);
    return serverPort;
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) ClientSubscriptionConfig(org.apache.geode.cache.server.ClientSubscriptionConfig) CacheServerImpl(org.apache.geode.internal.cache.CacheServerImpl) IOException(java.io.IOException)

Example 10 with ClientSubscriptionConfig

use of org.apache.geode.cache.server.ClientSubscriptionConfig in project geode by apache.

the class CacheXml66DUnitTest method testBridgeAttributesRelatedToHAOverFlow65.

@Test
public void testBridgeAttributesRelatedToHAOverFlow65() throws Exception {
    CacheCreation cache = new CacheCreation();
    cache.setMessageSyncInterval(3445);
    CacheServer bs = cache.addCacheServer();
    ClientSubscriptionConfig csc = bs.getClientSubscriptionConfig();
    csc.setEvictionPolicy("entry");
    cache.getLogger().config("EvictionPolicy : " + csc.getEvictionPolicy());
    csc.setCapacity(501);
    cache.getLogger().config("EvictionCapacity : " + csc.getCapacity());
    File overflowDirectory = new File("overFlow");
    overflowDirectory.mkdirs();
    DiskStoreFactory dsf = cache.createDiskStoreFactory();
    File[] dirs1 = new File[] { overflowDirectory };
    DiskStore ds1 = dsf.setDiskDirs(dirs1).create(getUniqueName());
    csc.setDiskStoreName(getUniqueName());
    try {
        csc.setOverflowDirectory("overFlow");
    } catch (IllegalStateException e) {
        assertTrue(e.getMessage().contains(LocalizedStrings.DiskStore_Deprecated_API_0_Cannot_Mix_With_DiskStore_1.toLocalizedString("setOverflowDirectory", getUniqueName())));
    }
    cache.getLogger().config("Eviction disk store : " + csc.getDiskStoreName());
    bs.setPort(AvailablePortHelper.getRandomAvailableTCPPort());
    RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
    attrs.setDataPolicy(DataPolicy.NORMAL);
    cache.createVMRegion("rootNORMAL", attrs);
    testXml(cache);
    Cache c = getCache();
    assertNotNull(c);
    CacheServer server = (CacheServer) cache.getCacheServers().iterator().next();
    assertNotNull(server);
    ClientSubscriptionConfig chaqf = server.getClientSubscriptionConfig();
    assertEquals("entry", chaqf.getEvictionPolicy());
    assertEquals(501, chaqf.getCapacity());
    DiskStore dsi = cache.findDiskStore(chaqf.getDiskStoreName());
    assertEquals("overFlow", dsi.getDiskDirs()[0].toString());
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) ClientSubscriptionConfig(org.apache.geode.cache.server.ClientSubscriptionConfig) CacheServer(org.apache.geode.cache.server.CacheServer) RegionAttributesCreation(org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) ClientCacheCreation(org.apache.geode.internal.cache.xmlcache.ClientCacheCreation) File(java.io.File) DiskStoreFactory(org.apache.geode.cache.DiskStoreFactory) Cache(org.apache.geode.cache.Cache) ClientCache(org.apache.geode.cache.client.ClientCache) Test(org.junit.Test)

Aggregations

ClientSubscriptionConfig (org.apache.geode.cache.server.ClientSubscriptionConfig)18 CacheServer (org.apache.geode.cache.server.CacheServer)12 Test (org.junit.Test)9 Expectations (org.jmock.Expectations)7 DiskStore (org.apache.geode.cache.DiskStore)6 UnitTest (org.apache.geode.test.junit.categories.UnitTest)6 Cache (org.apache.geode.cache.Cache)4 ClientCache (org.apache.geode.cache.client.ClientCache)3 CacheCreation (org.apache.geode.internal.cache.xmlcache.CacheCreation)3 ClientCacheCreation (org.apache.geode.internal.cache.xmlcache.ClientCacheCreation)3 RegionAttributesCreation (org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation)3 File (java.io.File)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)2 UnknownHostException (java.net.UnknownHostException)1 LinkedList (java.util.LinkedList)1 CacheFactory (org.apache.geode.cache.CacheFactory)1 DiskStoreFactory (org.apache.geode.cache.DiskStoreFactory)1