Search in sources :

Example 6 with CacheConfig

use of org.apache.geode.internal.cache.CacheConfig in project geode by apache.

the class RecreateCacheFunction method execute.

@Override
public void execute(FunctionContext context) {
    CliFunctionResult result = null;
    InternalCache cache = GemFireCacheImpl.getInstance();
    DistributedSystem ds = cache.getDistributedSystem();
    CacheConfig cacheConfig = cache.getCacheConfig();
    try {
        cache.close("Re-create Cache", true, true);
        GemFireCacheImpl.create(ds, cacheConfig);
    } catch (RuntimeException e) {
        result = new CliFunctionResult(ds.getName(), e, e.getMessage());
        context.getResultSender().lastResult(result);
        return;
    }
    result = new CliFunctionResult(ds.getName(), true, "Cache successfully re-created.");
    context.getResultSender().lastResult(result);
}
Also used : CliFunctionResult(org.apache.geode.management.internal.cli.functions.CliFunctionResult) InternalCache(org.apache.geode.internal.cache.InternalCache) DistributedSystem(org.apache.geode.distributed.DistributedSystem) CacheConfig(org.apache.geode.internal.cache.CacheConfig)

Example 7 with CacheConfig

use of org.apache.geode.internal.cache.CacheConfig in project geode by apache.

the class DefaultServerLauncherCacheProvider method createCache.

@Override
public Cache createCache(Properties gemfireProperties, ServerLauncher serverLauncher) {
    final CacheConfig cacheConfig = serverLauncher.getCacheConfig();
    final CacheFactory cacheFactory = new CacheFactory(gemfireProperties);
    if (cacheConfig.pdxPersistentUserSet) {
        cacheFactory.setPdxPersistent(cacheConfig.isPdxPersistent());
    }
    if (cacheConfig.pdxDiskStoreUserSet) {
        cacheFactory.setPdxDiskStore(cacheConfig.getPdxDiskStore());
    }
    if (cacheConfig.pdxIgnoreUnreadFieldsUserSet) {
        cacheFactory.setPdxIgnoreUnreadFields(cacheConfig.getPdxIgnoreUnreadFields());
    }
    if (cacheConfig.pdxReadSerializedUserSet) {
        cacheFactory.setPdxReadSerialized(cacheConfig.isPdxReadSerialized());
    }
    if (cacheConfig.pdxSerializerUserSet) {
        cacheFactory.setPdxSerializer(cacheConfig.getPdxSerializer());
    }
    return cacheFactory.create();
}
Also used : CacheFactory(org.apache.geode.cache.CacheFactory) CacheConfig(org.apache.geode.internal.cache.CacheConfig)

Example 8 with CacheConfig

use of org.apache.geode.internal.cache.CacheConfig in project geode by apache.

the class WANTestBase method createReceiver_PDX.

public static int createReceiver_PDX(int locPort) {
    WANTestBase test = new WANTestBase();
    Properties props = test.getDistributedSystemProperties();
    props.setProperty(MCAST_PORT, "0");
    props.setProperty(LOCATORS, "localhost[" + locPort + "]");
    InternalDistributedSystem ds = test.getSystem(props);
    CacheConfig cacheConfig = new CacheConfig();
    File pdxDir = new File(CacheTestCase.getDiskDir(), "pdx");
    cacheConfig.setPdxPersistent(true);
    cacheConfig.setPdxDiskStore("pdxStore");
    cache = GemFireCacheImpl.create(ds, false, cacheConfig);
    cache.createDiskStoreFactory().setDiskDirs(new File[] { pdxDir }).setMaxOplogSize(1).create("pdxStore");
    GatewayReceiverFactory fact = cache.createGatewayReceiverFactory();
    int port = AvailablePortHelper.getRandomAvailablePortForDUnitSite();
    fact.setStartPort(port);
    fact.setEndPort(port);
    fact.setManualStart(true);
    GatewayReceiver receiver = fact.create();
    try {
        receiver.start();
    } catch (IOException e) {
        e.printStackTrace();
        fail("Test " + test.getName() + " failed to start GatewayReceiver on port " + port);
    }
    return port;
}
Also used : GatewayReceiverFactory(org.apache.geode.cache.wan.GatewayReceiverFactory) GatewayReceiver(org.apache.geode.cache.wan.GatewayReceiver) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) IOException(java.io.IOException) Properties(java.util.Properties) CacheConfig(org.apache.geode.internal.cache.CacheConfig) File(java.io.File)

Aggregations

CacheConfig (org.apache.geode.internal.cache.CacheConfig)8 Properties (java.util.Properties)3 InternalCache (org.apache.geode.internal.cache.InternalCache)3 File (java.io.File)2 IOException (java.io.IOException)2 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)2 CancelException (org.apache.geode.CancelException)1 ForcedDisconnectException (org.apache.geode.ForcedDisconnectException)1 GemFireConfigException (org.apache.geode.GemFireConfigException)1 GemFireIOException (org.apache.geode.GemFireIOException)1 SystemConnectException (org.apache.geode.SystemConnectException)1 Cache (org.apache.geode.cache.Cache)1 CacheClosedException (org.apache.geode.cache.CacheClosedException)1 CacheFactory (org.apache.geode.cache.CacheFactory)1 CacheXmlException (org.apache.geode.cache.CacheXmlException)1 DiskStoreFactory (org.apache.geode.cache.DiskStoreFactory)1 GatewayReceiver (org.apache.geode.cache.wan.GatewayReceiver)1 GatewayReceiverFactory (org.apache.geode.cache.wan.GatewayReceiverFactory)1 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)1 DistributedSystem (org.apache.geode.distributed.DistributedSystem)1