private Cache getCache() { return CacheFactory.getAnyInstance(); } }
public GatewayDeltaEventApplicationCacheListener() { this.cache = CacheFactory.getAnyInstance(); }
private InternalCache getCache() { return (InternalCache) CacheFactory.getAnyInstance(); }
private InternalCache getCache() { return (InternalCache) CacheFactory.getAnyInstance(); }
public GatewayDeltaForwarderCacheListener() { this(CacheFactory.getAnyInstance()); }
private InternalCache getCache() { return (InternalCache) CacheFactory.getAnyInstance(); }
protected GemFireCacheImpl getCache() { return (GemFireCacheImpl) CacheFactory.getAnyInstance(); }
private Cache getCache() { return CacheFactory.getAnyInstance(); }
public RegionConfigurationCacheListener() { this.cache = CacheFactory.getAnyInstance(); }
protected LogWriter getLogger() { if (logger == null) { Cache cache = CacheFactory.getAnyInstance(); if (cache != null) { logger = cache.getLogger(); } else { throw new IllegalStateException("Could not initialize logger"); } } return logger; }
public CreateRegionFunction() { this.cache = CacheFactory.getAnyInstance(); this.regionConfigurationsRegion = createRegionConfigurationMetadataRegion(); }
@Override public Region<?, ?> getRegion() { // The region will be null mostly for the other node where the gateway event // is serialized return this.region != null ? this.region : CacheFactory.getAnyInstance().getRegion(this.regionPath); }
private static CacheProvider createDefaultCacheProvider() { return () -> ((InternalCache) CacheFactory.getAnyInstance()) .getCacheForProcessingClientRequests(); }
protected void initializeSessionCache() { // Retrieve the cache GemFireCacheImpl cache = (GemFireCacheImpl) CacheFactory.getAnyInstance(); if (cache == null) { throw new IllegalStateException( "No cache exists. Please configure either a PeerToPeerCacheLifecycleListener or ClientServerCacheLifecycleListener in the server.xml file."); } // Create the appropriate session cache this.sessionCache = cache.isClient() ? new ClientServerSessionCache(this, cache) : new PeerToPeerSessionCache(this, cache); // Initialize the session cache this.sessionCache.initialize(); }
@Override public void execute(FunctionContext context) { ArrayList<String> vals = new ArrayList<String>(); Cache c = null; try { c = CacheFactory.getAnyInstance(); } catch (CacheClosedException ex) { vals.add("NoCacheResult"); context.getResultSender().lastResult(vals); } final Set<Region<?, ?>> regionSet = c.rootRegions(); for (Region<?, ?> r : regionSet) { vals.add(r.getName()); } context.getResultSender().lastResult(vals); }
private Object loadFromDatabase(Object ob) { Object obj = null; try { Context ctx = CacheFactory.getAnyInstance().getJNDIContext(); DataSource ds = (DataSource) ctx.lookup("java:/XAPooledDataSource"); Connection conn = ds.getConnection(); Statement stm = conn.createStatement(); ResultSet rs = stm.executeQuery("select name from " + tableName + " where id = (" + (new Integer(ob.toString())).intValue() + ")"); rs.next(); obj = rs.getString(1); stm.close(); conn.close(); return obj; } catch (Exception e) { e.printStackTrace(); } // conn.close(); return obj; }
private void bootstrapMember(InternalDistributedMember member) { // Create and execute the function Cache cache = CacheFactory.getAnyInstance(); Execution execution = FunctionService.onMember(member); ResultCollector collector = execution.execute(this); // Get the result. Nothing is being done with it. try { collector.getResult(); } catch (Exception e) { // If an exception occurs in the function, log it. cache.getLogger().warning("Caught unexpected exception:", e); } }
@Override public void removedDistributedSystem(int remoteDsId) { cache = CacheFactory.getAnyInstance(); if (remoteDsId == 2) { // When a site with distributed-system-id = -2 joins, stop gatewaysender // with remoteDsId = 2 if (cache != null) { GatewaySender sender = cache.getGatewaySender("LN_" + 2); sender.stop(); } } else { // When a site with distributed-system-id = -1 joins, stop gatewayReceiver GatewayReceiver receiver = cache.getGatewayReceivers().iterator().next(); receiver.stop(); } } }
private void verifyShutDown(MemberVM... members) { SerializableCallableIF<Boolean> isCacheOpenInThisVM = () -> { boolean cacheExists; try { Cache cacheInstance = CacheFactory.getAnyInstance(); cacheExists = cacheInstance.getDistributedSystem().isConnected(); } catch (CacheClosedException e) { cacheExists = false; } return cacheExists; }; for (MemberVM member : members) { Callable<Boolean> isMemberShutDown = () -> !member.getVM().invoke(isCacheOpenInThisVM); await().until(isMemberShutDown); } } }
@Override public void execute(FunctionContext context) { final Cache cache = CacheFactory.getAnyInstance(); if (!(cache instanceof Extensible)) { throw new FunctionException("Not extensible cache."); } final String value = (String) ((Object[]) context.getArguments())[0]; @SuppressWarnings("unchecked") final Extensible<Cache> extensible = (Extensible<Cache>) cache; final MockCacheExtension extension = new MockCacheExtension(value); extension.beforeCreate(extensible, cache); extension.onCreate(extensible, extensible); final XmlEntity xmlEntity = XmlEntity.builder().withType(ELEMENT_CACHE).withNamespace(PREFIX, NAMESPACE).build(); final ResultSender<Object> resultSender = context.getResultSender(); final String memberNameOrId = CliUtil.getMemberNameOrId(cache.getDistributedSystem().getDistributedMember()); resultSender.lastResult(new CliFunctionResult(memberNameOrId, xmlEntity, CliStrings .format("Mock cache extension created on \"{0}\"", new Object[] {memberNameOrId}))); }