/** * Logs a batch of events to the <code>LogWriterI18n</code>. * * @param events * The batch of events to log **/ protected void logBatchFine(String message, List events) { if (getLogger().fineEnabled()) { StringBuilder buffer = new StringBuilder(); buffer.append(message); buffer.append(events.size()).append(" events"); buffer.append(" (batch #" + getBatchId()); buffer.append("):\n"); for (Iterator i = events.iterator(); i.hasNext();) { GatewayEventImpl ge = (GatewayEventImpl)i.next(); buffer.append("\tEvent ").append(ge.getEventId()).append(":"); buffer.append(ge.getKey()).append("->"); buffer.append(ge.getDeserializedValueForLogging()); buffer.append("\n"); } getLogger().fine(buffer.toString()); } }
/** * Initialize the Executor that handles listener events. Only used by * non-primary gateways */ private void initializeListenerExecutor() { // Create the ThreadGroups final ThreadGroup loggerGroup = LogWriterImpl.createThreadGroup( "Gateway Listener Group", getLogger()); // Create the Executor ThreadFactory tf = new ThreadFactory() { public Thread newThread(Runnable command) { Thread thread = new Thread(loggerGroup, command, "Queued Gateway Listener Thread"); thread.setDaemon(true); return thread; } }; LinkedBlockingQueue q = new LinkedBlockingQueue(); this._executor = new ThreadPoolExecutor(1, 1/*max unused*/, 120, TimeUnit.SECONDS, q, tf); }
getLogger().info(LocalizedStrings.GatewayImpl_GATEWAY_FAILOVER_INITIATED_PROCESSING_0_UNPROCESSED_EVENTS, this.unprocessedEvents.size()); GatewayStats statistics = getGateway().getStatistics(); getLogger().info(LocalizedStrings.GatewayImpl_GATEWAY_FAILOVER_INITIATED_ADDING_0_UNPROCESSED_EVENTS, this.unprocessedEvents.size()); Iterator it = this.unprocessedEvents.values().iterator(); while (it.hasNext() && !stopped()) { getLogger().warning( LocalizedStrings.GatewayImpl_EVENT_FAILED_TO_BE_INITIALIZED_0, gatewayEvent, e); if (getLogger().fineEnabled()) { getLogger().fine(getGateway() + ": Queueing unprocessed event: " + gatewayEvent); getLogger().warning( LocalizedStrings.GatewayImpl_EVENT_DROPPED_DURING_FAILOVER_0, gatewayEvent, ex); getLogger().warning( LocalizedStrings.GatewayImpl_EVENT_DROPPED_DURING_FAILOVER_0, gatewayEvent, ex); if (getLogger().infoEnabled()) { getLogger().info(LocalizedStrings.GatewayImpl_0__MARKING__1__EVENTS_AS_POSSIBLE_DUPLICATES, new Object[] {getGateway(), Integer.valueOf(this._eventQueue.size())}); getLogger().info(LocalizedStrings.GatewayImpl_GATEWAY_FAILOVER_COMPLETED);
if (getLogger().fineEnabled()) { getLogger().fine("Attempting to peek a batch of " + batchSize + " events"); events); boolean success = this._eventDispatcher.dispatchBatch(events, true); if (getLogger().fineEnabled()) { getLogger().fine("During normal processing, " + (success ? "" : "un") + "successfully dispatched " + events.size() + " events (batch #" + getBatchId() + ")" + " queue size=" + eventQueueSize()); GatewayEventImpl ge = (GatewayEventImpl) o; if (ge.getCreationTime()+alertThreshold < currentTime) { getLogger().warning( LocalizedStrings.GatewayImpl_EVENT_QUEUE_ALERT_OPERATION_0_REGION_1_KEY_2_VALUE_3_TIME_4, new Object[] { getLogger().info( LocalizedStrings.GatewayImpl_THE_EVENT_QUEUE_SIZE_HAS_DROPPED_BELOW_THE_THRESHOLD_0, QUEUE_SIZE_THRESHOLD); if (getLogger().fineEnabled()) { getLogger().fine("Finished processing events (batch #" + getBatchId() + ")"); getLogger().info(LocalizedStrings. GatewayImpl_TERMINATED_DUE_TO_REGIONDESTROYEDEXCEPTION); setIsStopped(true);
if (getLogger().finerEnabled()) { try { gatewayEvent.initialize(); getLogger().finer(GatewayImpl.this + ": fromSecondary " + " event " + gatewayEvent.getEventId() + ":" + gatewayEvent.getKey() + "->" if (getLogger().warningEnabled()) { try { gatewayEvent.initialize(); getLogger().warning( LocalizedStrings. GatewayImpl_EVENT_FAILED_TO_BE_INITIALIZED_0, gatewayEvent, e); getLogger().warning( LocalizedStrings.GatewayImpl_0_THE_UNPROCESSED_EVENTS_MAP_ALREADY_CONTAINED_AN_EVENT_FROM_THE_HUB_1_SO_IGNORING_NEW_EVENT_2, new Object[] {GatewayImpl.this, GatewayImpl.this.getGatewayHubId(), gatewayEvent}); if (getLogger().finerEnabled()) { try { gatewayEvent.initialize(); getLogger().finer(GatewayImpl.this + ": Secondary created event " + gatewayEvent.getEventId() + ":" + gatewayEvent.getKey() + "->"
if (getLogger().finerEnabled()) { try { gatewayEvent.initialize(); if (getLogger().finerEnabled()) { getLogger().finer(GatewayImpl.this + ": fromPrimary " + " event " + gatewayEvent.getEventId() + ":" + gatewayEvent.getKey() + "->" if (getLogger().finerEnabled()) { try { gatewayEvent.initialize(); getLogger().finer(GatewayImpl.this + ": Primary create/update event " + gatewayEvent.getEventId() + ":" + gatewayEvent.getKey()
if (getLogger().fineEnabled()) { getLogger().fine("Beginning to process the message queue"); getLogger().warning(LocalizedStrings. GatewayImpl_ABOUT_TO_PROCESS_THE_MESSAGE_QUEUE_BUT_NOT_THE_PRIMARY); getLogger().info( LocalizedStrings. GatewayImpl_A_CANCELLATION_OCCURRED_STOPPING_THE_DISPATCHER); setIsStopped(true); getLogger().severe( LocalizedStrings. GatewayImpl_MESSAGE_DISPATCH_FAILED_DUE_TO_UNEXPECTED_EXCEPTION, e);
if (getLogger().fineEnabled()) { getLogger().fine(this + ":Notifying the dispatcher to terminate"); if (getLogger().fineEnabled()) { getLogger().fine(this + ":Joining with the dispatcher thread upto limit of 5 seconds"); this.join(5000); // wait for our thread to stop if (this.isAlive()) { getLogger().warning( LocalizedStrings.GatewayImpl_0_DISPATCHER_STILL_ALIVE_EVEN_AFTER_JOIN_OF_5_SECONDS, this); if (getLogger().warningEnabled()) { getLogger().warning( LocalizedStrings.GatewayImpl_0_INTERRUPTEDEXCEPTION_IN_JOINING_WITH_DISPATCHER_THREAD, this); if (getLogger().fineEnabled()) { getLogger().fine("Stopped dispatching: " + this);
if (getLogger().fineEnabled()) { getLogger().fine(getGateway() + ": Queueing event (" + (statistics.getEventsQueued() + 1) + "): " + gatewayEvent); if (getLogger().fineEnabled()) { getLogger().fine(getGateway() + ": Queued event (" + (statistics.getEventsQueued()) + "): " + gatewayEvent); statistics.setQueueSize(queueSize); if (!this._eventQueueSizeWarning && queueSize >= QUEUE_SIZE_THRESHOLD) { getLogger().warning( LocalizedStrings.GatewayImpl_0_THE_EVENT_QUEUE_SIZE_HAS_REACHED_THE_THRESHOLD_1, new Object[] {getGateway(), Integer.valueOf(QUEUE_SIZE_THRESHOLD)});
protected void closeProcessor() { if (getLogger().fineEnabled()) { getLogger().fine("Closing dispatcher"); } try { try { if (this._eventQueue.peek() != null) { getLogger() .warning(LocalizedStrings.GatewayImpl_DESTROYING_GATEWAYEVENTDISPATCHER_WITH_ACTIVELY_QUEUED_DATA); } } catch (InterruptedException e) { /* * ignore, this will never be thrown by * SingleWriteSingleReadRegionQueue */ // TODO if this won't be thrown, assert it. } } catch (CacheException ignore) { // just checking in case we should log a warning } finally { this._eventQueue.close(); if (getLogger().fineEnabled()) { getLogger().fine("Closed dispatcher"); } } }
protected GatewayEventCallbackDispatcher(GatewayEventProcessor eventProcessor) { this.eventProcessor = eventProcessor; this.logger = eventProcessor.getLogger(); initializeEventListeners(); }
protected GatewayEventRemoteDispatcher(GatewayEventProcessor eventProcessor) { this.eventProcessor = eventProcessor; this.logger = eventProcessor.getLogger(); try { initializeConnection(); } catch(GatewayException e) { if(e.getCause() instanceof GemFireSecurityException || e instanceof GatewayConfigurationException) { throw e; } } }