private void createCache() { this.cache = (GemFireCacheImpl) new CacheFactory().set(MCAST_PORT, "0") .set(LOG_LEVEL, "warning").create(); }
private Cache getCache() { return CacheFactory.getAnyInstance(); } }
@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(); } }
protected CacheFactory getCacheFactory() { CacheFactory cf = new CacheFactory(); cf.set(MCAST_PORT, "0"); cf.set(ConfigurationProperties.LOCATORS, ""); cf.set(ConfigurationProperties.LOG_LEVEL, System.getProperty("logLevel", "info")); return cf; }
/** * Constructs a RegionFactory by creating a DistributedSystem and a Cache. If no DistributedSystem * exists it creates a DistributedSystem with default configuration, otherwise it uses the * existing DistributedSystem. The default Region configuration is used. * * @throws CacheException if unable to connect the DistributedSystem or create a Cache * @deprecated as of 6.5 use {@link Cache#createRegionFactory()} instead. */ @Deprecated public RegionFactory() throws CacheWriterException, RegionExistsException, TimeoutException { this((InternalCache) new CacheFactory().create()); }
public void createCache(final CacheFactory cacheFactory) { cache = (InternalCache) cacheFactory.create(); }
private Cache verifyCacheExists() { int timeToWait = 0; Cache cache = null; while (timeToWait < TIME_TO_WAIT_FOR_CACHE) { try { cache = CacheFactory.getAnyInstance(); break; } catch (Exception ignore) { // keep trying and hope for the best } try { Thread.sleep(250); } catch (InterruptedException ie) { Thread.currentThread().interrupt(); break; } timeToWait += 250; } if (cache == null) { cache = new CacheFactory().create(); } return cache; }
public void startServer() { CacheFactory cf = new CacheFactory(this.properties); cf.setPdxPersistent(pdxPersistent); cf.setPdxReadSerialized(pdxReadSerialized); if (pdxSerializer != null) { cf.setPdxSerializer(pdxSerializer); } cache = (InternalCache) cf.create(); DistributionConfig config = ((InternalDistributedSystem) cache.getDistributedSystem()).getConfig(); jmxPort = config.getJmxManagerPort(); httpPort = config.getHttpServicePort(); if (!noCacheServer) { server = cache.addCacheServer(); // memberPort is by default zero, which translates to "randomly select an available port," // which is why it is updated after this try block server.setPort(memberPort); try { server.start(); } catch (IOException e) { throw new RuntimeException("unable to start server", e); } memberPort = server.getPort(); } }
private final void createCache(final boolean client, final CacheFactory factory) { synchronized (JUnit4CacheTestCase.class) { try { System.setProperty(GEMFIRE_PREFIX + "DISABLE_DISCONNECT_DS_ON_CACHE_CLOSE", "true"); InternalCache newCache; if (client) { System.setProperty(GEMFIRE_PREFIX + "locators", ""); System.setProperty(GEMFIRE_PREFIX + MCAST_PORT, "0"); newCache = (InternalCache) new ClientCacheFactory(getSystem().getProperties()).create(); } else { if (factory == null) { newCache = (InternalCache) CacheFactory.create(getSystem()); } else { Properties config = getSystem().getProperties(); for (Map.Entry entry : config.entrySet()) { factory.set((String) entry.getKey(), (String) entry.getValue()); } newCache = (InternalCache) factory.create(); } } cache = newCache; } finally { System.clearProperty(GEMFIRE_PREFIX + "DISABLE_DISCONNECT_DS_ON_CACHE_CLOSE"); System.clearProperty(GEMFIRE_PREFIX + "locators"); System.clearProperty(GEMFIRE_PREFIX + MCAST_PORT); } } }
public static String init(DistributedSystem ds1, String className) throws Exception { System.out.println("Entering CacheUtils.init, DS is " + ds1); String tableName = ""; try { try { cache = CacheFactory.getInstance(ds1); } catch (CancelException cce) { cache = CacheFactory.create(ds1); } if (className != null && !className.equals("")) { String time = new Long(System.currentTimeMillis()).toString(); tableName = className + time; createTable(tableName); } } catch (Exception e) { e.printStackTrace(System.err); throw new Exception("Exception in CacheUtils::init, The Exception is " + e); } return tableName; }
/** * Constructs a new instance of {@link CacheFactory} initialized with the given Pivotal GemFire/Apache Geode * {@link Properties} used to construct, configure and initialize an instance of a {@link Cache}. * * @param gemfireProperties {@link Properties} used by the {@link CacheFactory} to configure the {@link Cache}. * @return a new instance of {@link CacheFactory} initialized with the given Pivotal GemFire/Apache Geode * {@link Properties}. * @see org.apache.geode.cache.CacheFactory * @see java.util.Properties */ protected Object createFactory(Properties gemfireProperties) { return new CacheFactory(gemfireProperties); }
/** * Constructs a RegionFactory by creating a DistributedSystem and a Cache. If no DistributedSystem * exists it creates a DistributedSystem with default configuration, otherwise it uses the * existing DistributedSystem. The Region configuration is initialized using the provided * RegionAttributes. * * @throws CacheException if unable to connect the DistributedSystem or create a Cache * @deprecated as of 6.5 use {@link Cache#createRegionFactory(RegionAttributes)} instead. */ @Deprecated public RegionFactory(RegionAttributes<K, V> regionAttributes) throws CacheWriterException, RegionExistsException, TimeoutException { this((InternalCache) new CacheFactory().create(), regionAttributes); }
public static void startCache() { try { if (cache.isClosed()) { cache = CacheFactory.create(ds); } } catch (Exception e) { e.printStackTrace(); } }
@Override protected void createOrRetrieveCache() { if (getLogger().isDebugEnabled()) { getLogger().debug("Creating cache"); } // Get the existing cache if any try { this.cache = CacheFactory.getAnyInstance(); } catch (CacheClosedException e) { } // If no cache exists, create one String message = null; if (this.cache == null || cache.isClosed()) { this.cache = new CacheFactory(createDistributedSystemProperties()).create(); message = "Created "; } else { message = "Retrieved "; } getLogger().info(message + this.cache); }
/** * Constructs a new instance of {@link CacheFactory} initialized with the given Pivotal GemFire/Apache Geode * {@link Properties} used to construct, configure and initialize an instance of a {@link Cache}. * * @param gemfireProperties {@link Properties} used by the {@link CacheFactory} to configure the {@link Cache}. * @return a new instance of {@link CacheFactory} initialized with the given Pivotal GemFire/Apache Geode * {@link Properties}. * @see org.apache.geode.cache.CacheFactory * @see java.util.Properties */ protected Object createFactory(Properties gemfireProperties) { return new CacheFactory(gemfireProperties); }
public void createCache(Properties prop) { if (null != prop && !prop.isEmpty()) { cache = new CacheFactory(prop).create(); } else { cache = new CacheFactory().set(MCAST_PORT, "0").create(); } }
/** * Constructs a RegionFactory by creating a DistributedSystem and a Cache. If a DistributedSystem * already exists with the same properties it uses that DistributedSystem, otherwise a * DistributedSystem is created using the provided properties. The default Region configuration is * used. * * @param distributedSystemProperties an instance of Properties containing * {@code DistributedSystem} configuration * @throws CacheException if unable to connect the DistributedSystem or create a Cache * @deprecated as of 6.5 use {@link CacheFactory#CacheFactory(Properties)} and * {@link Cache#createRegionFactory()} instead. */ @Deprecated public RegionFactory(Properties distributedSystemProperties) throws CacheWriterException, RegionExistsException, TimeoutException { this((InternalCache) new CacheFactory(distributedSystemProperties).create()); }
private InternalCache getCache() { return (InternalCache) CacheFactory.getAnyInstance(); }
.when(cacheFactorySpy).setPdxDiskStore(anyString()); .when(cacheFactorySpy).setPdxIgnoreUnreadFields(anyBoolean()); .when(cacheFactorySpy).setPdxPersistent(anyBoolean()); .when(cacheFactorySpy).setPdxReadSerialized(anyBoolean()); .when(cacheFactorySpy).setPdxSerializer(any(PdxSerializer.class)); storeConfiguration(cacheFactory); return rememberMockedGemFireCache(constructGemFireObjects(resolvedMockCache), useSingletonCache); }).when(cacheFactorySpy).create();
/** * Creates the {@code Cache} for this test that is not connected to other members. */ public final InternalCache createLonerCache() { synchronized (JUnit4CacheTestCase.class) { try { System.setProperty(GEMFIRE_PREFIX + "DISABLE_DISCONNECT_DS_ON_CACHE_CLOSE", "true"); InternalCache newCache = (InternalCache) CacheFactory.create(getLonerSystem()); cache = newCache; } finally { System.clearProperty(GEMFIRE_PREFIX + "DISABLE_DISCONNECT_DS_ON_CACHE_CLOSE"); } return cache; } }