public ConnectionHandler(Socket socket, Cache cache, Protocol protocol) { this.socket = socket; this.cache = cache; this.protocol = protocol; if (logger == null) { logger = this.cache.getLogger(); } }
private LogWriter getLogger() { if (cache == null) { return null; } return cache.getLogger(); }
/** * Getter for logger * */ public LogWriter getLogger() { return this.cache.getLogger(); }
public static LogWriter getLogger() { return cache.getLogger(); }
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; }
static LogWriter getLogger() { return _cache.getLogger(); }
@Override public void apply(Cache cache) { Region<String, DeltaSessionInterface> region = getRegion(cache); try { region.destroy(this.key); if (cache.getLogger().fineEnabled()) { StringBuilder builder = new StringBuilder(); builder.append("Applied ").append(this); cache.getLogger().fine(builder.toString()); } } catch (EntryNotFoundException e) { StringBuilder builder = new StringBuilder(); builder.append(this).append(": Session ").append(this.key).append(" was not found"); cache.getLogger().warning(builder.toString()); } }
private LogWrapper(Cache cache) { logger = Logger.getLogger(this.getClass().getCanonicalName()); if (cache != null && !cache.isClosed()) { logger.addHandler(cache.getLogger().getHandler()); CommandResponseWriterHandler handler = new CommandResponseWriterHandler(); handler.setFilter(record -> record.getLevel().intValue() >= Level.FINE.intValue()); handler.setLevel(Level.FINE); logger.addHandler(handler); } logger.setUseParentHandlers(false); }
@Override public void apply(Cache cache) { Region<String, CachedDeserializable> region = getRegion(cache); region.put(this.key, CachedDeserializableFactory.create(this.gatewayDelta, (InternalCache) cache), true); if (cache.getLogger().fineEnabled()) { StringBuilder builder = new StringBuilder(); builder.append("Applied ").append(this); cache.getLogger().fine(builder.toString()); } }
private void log(EntryEvent event) { StringBuilder builder = new StringBuilder(); builder.append("DebugCacheListener: Received ").append(event.getOperation()).append(" for key=") .append(event.getKey()); if (event.getNewValue() != null) { builder.append("; value=").append(event.getNewValue()); } event.getRegion().getCache().getLogger().info(builder.toString()); }
@Override public void execute(FunctionContext context) { RegionConfiguration configuration = (RegionConfiguration) context.getArguments(); if (this.cache.getLogger().fineEnabled()) { StringBuilder builder = new StringBuilder(); builder.append("Function ").append(ID).append(" received request: ").append(configuration); this.cache.getLogger().fine(builder.toString()); } // Create or retrieve region RegionStatus status = createOrRetrieveRegion(configuration); // Dump XML if (DUMP_SESSION_CACHE_XML) { writeCacheXml(); } // Return status context.getResultSender().lastResult(status); }
protected Cache createCache() { cache = new CacheFactory(props).create(); ds = cache.getDistributedSystem(); logWriter = cache.getLogger(); return cache; }
private void startGemFire() { this.cache = GemFireCacheImpl.getInstance(); if (this.cache == null) { CacheFactory cacheFactory = new CacheFactory(); this.cache = cacheFactory.create(); } logger = this.cache.getLogger(); }
public static Region createRegion(Cache cache, RegionConfiguration configuration) { // Use the createRegion method so that the RegionAttributes creation can be reused by validate. RegionAttributes requestedRegionAttributes = getRegionAttributes(cache, configuration); Region region = cache.createRegion(configuration.getRegionName(), requestedRegionAttributes); // Log the cache xml if debugging is enabled. I'd like to be able to just // log the region, but that API is not available. if (configuration.getEnableDebugListener()) { cache.getLogger().info("Created new session region: " + region); cache.getLogger().info(generateCacheXml(cache)); } return region; }
private void executeHA(FunctionContext context) { RegionFunctionContext rcontext = (RegionFunctionContext) context; Region region = rcontext.getDataSet(); region.getCache().getLogger().fine("executeHA#execute( " + rcontext + " )"); try { Thread.sleep(10); } catch (InterruptedException e) { e.printStackTrace(); } rcontext.getResultSender().lastResult(rcontext.getArguments()); }
public RegionSubRegionSnapshot(Region reg) { this(); this.name = reg.getName(); if (reg instanceof PartitionedRegion) { PartitionedRegion p_reg = (PartitionedRegion) reg; this.entryCount = p_reg.entryCount(true); } else { this.entryCount = reg.entrySet().size(); } final LogWriter logger = reg.getCache().getLogger(); if ((logger != null) && logger.fineEnabled()) { logger.fine("RegionSubRegionSnapshot Region entry count =" + this.entryCount + " for region =" + this.name); } }
@Override public void afterCreate(EntryEvent event) { if ((Long) event.getKey() == 900) { cache.getLogger().fine(" Gateway sender is killed by a test"); cache.close(); cache.getDistributedSystem().disconnect(); } } };
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); } }
public MemoryHog printTenuredSize() { this.cache.getLogger().info( "Tenured data size: " + this.tenuredData.getName() + ": " + this.tenuredData.size()); return this; } }