@Override public String getName() { return getId(); }
@Override public String getFullPath() { return getId(); }
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (this == obj) { return true; } if (!(obj instanceof GatewaySender)) { return false; } AbstractGatewaySender sender = (AbstractGatewaySender) obj; if (sender.getId().equals(this.getId())) { return true; } return false; }
@Override public int hashCode() { return this.getId().hashCode(); }
/** * use in concurrent scenario where queue is to be shared among all the processors. */ protected ParallelGatewaySenderEventProcessor(AbstractGatewaySender sender, Set<Region> userRegions, int id, int nDispatcher, ThreadsMonitoring tMonitoring) { super("Event Processor for GatewaySender_" + sender.getId() + "_" + id, sender, tMonitoring); this.index = id; this.nDispatcher = nDispatcher; initializeMessageQueue(sender.getId()); }
public String getDLockServiceName() { return getClass().getName() + "_" + this.sender.getId(); }
public ConcurrentSerialGatewaySenderEventProcessor(AbstractGatewaySender sender, ThreadsMonitoring tMonitoring) { super("Event Processor for GatewaySender_" + sender.getId(), sender, tMonitoring); this.sender = sender; initializeMessageQueue(sender.getId()); queues = new HashSet<RegionQueue>(); for (SerialGatewaySenderEventProcessor processor : processors) { queues.add(processor.getQueue()); } }
/** * Constructor : Creates and initializes the thread */ public BatchRemovalThread(InternalCache c, ParallelGatewaySenderQueue queue) { super("BatchRemovalThread for GatewaySender_" + queue.sender.getId() + "_" + queue.index); this.setDaemon(true); this.cache = c; this.parallelQueue = queue; }
@Override public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append("GatewayEventProcessor[").append("gatewaySenderId=").append(sender.getId()) .append(";remoteDSId=").append(getSender().getRemoteDSId()).append(";batchSize=") .append(getSender().getBatchSize()); buffer.append("]"); return buffer.toString(); }
public Object getSubstituteValue(EntryEventImpl clonedEvent, EnumListenerEvent operation) { // Get substitution value to enqueue if necessary Object substituteValue = null; if (this.substitutionFilter != null) { try { substituteValue = this.substitutionFilter.getSubstituteValue(clonedEvent); // If null is returned from the filter, null is set in the value if (substituteValue == null) { substituteValue = GatewaySenderEventImpl.TOKEN_NULL; } } catch (Exception e) { // Log any exceptions that occur in the filter and use the original value. logger.warn(String.format( "%s: An Exception occurred while queueing %s to perform operation %s for %s", new Object[] {this, getId(), operation, clonedEvent}), e); } } return substituteValue; }
public void makeSecondary() { if (logger.isDebugEnabled()) { logger.debug("{}: Did not obtain the lock on {}. Starting as secondary gateway sender.", this.sender, this.lockToken); } // Set primary flag to false logger.info( "{} starting as secondary because primary gateway sender is available on member :{}", new Object[] {this.sender.getId(), advisePrimaryGatewaySender()}); this.isPrimary = false; new UpdateAttributesProcessor(this.sender).distribute(false); }
protected void waitForRunningStatus() { synchronized (this.eventProcessor.runningStateLock) { while (this.eventProcessor.getException() == null && this.eventProcessor.isStopped()) { try { this.eventProcessor.runningStateLock.wait(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } Exception ex = this.eventProcessor.getException(); if (ex != null) { throw new GatewaySenderException( String.format("Could not start a gateway sender %s because of exception %s", new Object[] {this.getId(), ex.getMessage()}), ex.getCause()); } } }
private void waitForRunningStatus() { for (SerialGatewaySenderEventProcessor serialProcessor : this.processors) { synchronized (serialProcessor.runningStateLock) { while (serialProcessor.getException() == null && serialProcessor.isStopped()) { try { serialProcessor.runningStateLock.wait(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } Exception ex = serialProcessor.getException(); if (ex != null) { throw new GatewaySenderException( String.format("Could not start a gateway sender %s because of exception %s", new Object[] {this.sender.getId(), ex.getMessage()}), ex.getCause()); } } } }
private void waitForRunningStatus() { for (ParallelGatewaySenderEventProcessor parallelProcessor : this.processors) { synchronized (parallelProcessor.runningStateLock) { while (parallelProcessor.getException() == null && parallelProcessor.isStopped()) { try { parallelProcessor.runningStateLock.wait(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } Exception ex = parallelProcessor.getException(); if (ex != null) { throw new GatewaySenderException( String.format("Could not start a gateway sender %s because of exception %s", new Object[] {this.sender.getId(), ex.getMessage()}), ex.getCause()); } } } }
public boolean volunteerForPrimary() { if (logger.isDebugEnabled()) { logger.debug("Sender : {} is volunteering for Primary ", this.sender.getId()); } if (advisePrimaryGatewaySender() == null) { if (!adviseEldestGatewaySender()) { if (logger.isDebugEnabled()) { logger.debug( "Sender {} is not the eldest in the system. Giving preference to eldest sender to become primary...", this.sender); } return false; } if (logger.isDebugEnabled()) { logger.debug("Sender : {} no Primary available. So going to acquire distributed lock", this.sender); } this.lockService.lock(this.lockToken, 10000, -1); return this.lockService.isHeldByCurrentThread(this.lockToken); } return false; }
private boolean isThisSenderAttached(PartitionedRegion pr) { return pr.getParallelGatewaySenderIds() .contains(getPartitionedRegion().getParallelGatewaySender().getId()); }
public void waitToBecomePrimary(AbstractGatewaySenderEventProcessor callingProcessor) throws InterruptedException { if (isPrimary()) { return; } synchronized (this.primaryLock) { logger.info("{} : Waiting to become primary gateway", this.sender.getId()); while (!isPrimary()) { this.primaryLock.wait(1000); if (sender.getEventProcessor() != null && callingProcessor.isStopped()) { logger.info("The event processor is stopped, not to wait for being primary any more."); return; } } } }
private void addOverflowStatisticsToMBean(Cache cache, PartitionedRegion prQ) { // Get the appropriate mbean and add the eviction and disk region stats to it ManagementService service = ManagementService.getManagementService(cache); if (this.sender.getId().contains(AsyncEventQueueImpl.ASYNC_EVENT_QUEUE_PREFIX)) { AsyncEventQueueMBean bean = (AsyncEventQueueMBean) service.getLocalAsyncEventQueueMXBean( AsyncEventQueueImpl.getAsyncEventQueueIdFromSenderId(this.sender.getId())); if (bean != null) { // Add the eviction stats bean.getBridge().addOverflowStatistics(prQ.getEvictionStatistics()); // Add the disk region stats bean.getBridge().addOverflowStatistics(prQ.getDiskRegionStats().getStats()); } } else { GatewaySenderMBean bean = (GatewaySenderMBean) service.getLocalGatewaySenderMXBean(this.sender.getId()); if (bean != null) { // Add the eviction stats bean.getBridge().addOverflowStatistics(prQ.getEvictionStatistics()); // Add the disk region stats bean.getBridge().addOverflowStatistics(prQ.getDiskRegionStats().getStats()); } } }
private void addOverflowStatisticsToMBean(Cache cache, AbstractGatewaySender sender) { // Get the appropriate mbean and add the overflow stats to it LocalRegion lr = (LocalRegion) this.region; ManagementService service = ManagementService.getManagementService(cache); if (sender.getId().contains(AsyncEventQueueImpl.ASYNC_EVENT_QUEUE_PREFIX)) { AsyncEventQueueMBean bean = (AsyncEventQueueMBean) service.getLocalAsyncEventQueueMXBean( AsyncEventQueueImpl.getAsyncEventQueueIdFromSenderId(sender.getId())); if (bean != null) { // Add the eviction stats bean.getBridge().addOverflowStatistics(lr.getEvictionStatistics()); // Add the disk region stats bean.getBridge().addOverflowStatistics(lr.getDiskRegion().getStats().getStats()); } } else { GatewaySenderMBean bean = (GatewaySenderMBean) service.getLocalGatewaySenderMXBean(sender.getId()); if (bean != null) { // Add the eviction stats bean.getBridge().addOverflowStatistics(lr.getEvictionStatistics()); // Add the disk region stats bean.getBridge().addOverflowStatistics(lr.getDiskRegion().getStats().getStats()); } } }