/** * Wait to be told to become the primary <code>Gateway</code>. This method * is invoked by the <code>Gateway</code>'s<code>EventDispatcher</code> * to wait until it is primary before processing the queue. */ protected void waitToBecomePrimary() throws InterruptedException { if (getPrimary()) { return; } synchronized (this._primaryLock) { while (!getPrimary()) { this.getLogger().info(LocalizedStrings.GatewayImpl_0__WAITING_TO_BECOME_PRIMARY_GATEWAY, this); this._primaryLock.wait(); } } // synchronized }
@Override public void afterDestroy(EntryEvent event) { // fix bug 37603 if (GatewayImpl.this.getPrimary()) { return; } // Send event to the event dispatcher Object oldValue = event.getOldValue(); if (oldValue instanceof GatewayEventImpl) { GatewayEventImpl gatewayEvent = (GatewayEventImpl)oldValue; this._eventProcessor.handlePrimaryDestroy(gatewayEvent); } } }
@Override public void afterCreate(EntryEvent event) { // fix bug 35730 if (GatewayImpl.this.getPrimary()) { // The secondary has failed over to become the primary. There is a small // window where the secondary has become the primary, but the listener // is // still set. Ignore any updates to the map at this point. It is unknown // what the state of the map is. This may result in duplicate events // being sent. //GatewayImpl.this._logger.severe(GatewayImpl.this + ": XXXXXXXXX IS // PRIMARY BUT PROCESSING AFTER_DESTROY EVENT XXXXXXXXX: " + event); return; } // Send event to the event dispatcher GatewayEventImpl gatewayEvent = (GatewayEventImpl)event.getNewValue(); this._eventProcessor.handlePrimaryEvent(gatewayEvent); }
/** * Just remove the event from the unprocessed events map if it is present. * This method added to fix bug 37603 */ protected void basicHandlePrimaryDestroy(final GatewayEventImpl gatewayEvent) { if (getPrimary()) { // no need to do anything if we have become the primary return; } GatewayStats statistics = getGateway().getStatistics(); // Get the event from the map synchronized (unprocessedEventsLock) { if (this.unprocessedEvents == null) return; // now we can safely use the unprocessedEvents field Object v = this.unprocessedEvents.remove(gatewayEvent.getEventId()); if (v != null) { statistics.incUnprocessedEventsRemovedByPrimary(); } } }
boolean isPrimary = getGateway().getPrimary(); if(!isPrimary) { if (getGateway().getPrimary()) { isPrimary = true;
if (!getGateway().getPrimary()) { listener = new SecondaryGatewayListener(this); initializeListenerExecutor();
if (!getGateway().getPrimary()) { if (!waitForPrimary()) { return; if (!getGateway().getPrimary()) { getLogger().warning(LocalizedStrings. GatewayImpl_ABOUT_TO_PROCESS_THE_MESSAGE_QUEUE_BUT_NOT_THE_PRIMARY);
protected void basicHandlePrimaryEvent(final GatewayEventImpl gatewayEvent) { if (getPrimary()) {
if (getGateway().getPrimary()) { int numberOfPeeks = 0; try {