public void destroy() { getRegion().localDestroyRegion(); }
@Override protected void initializeMessageQueue(String id) { // Create the region name StringBuffer regionNameBuffer = new StringBuffer(); regionNameBuffer.append(id).append( "_SERIAL_GATEWAY_SENDER_QUEUE"); String regionName = regionNameBuffer.toString(); CacheListener listener = null; if (!this.sender.isPrimary()) { listener = new SerialSecondaryGatewayListener(this); initializeListenerExecutor(); } // Create the region queue this.queue = new SerialGatewaySenderQueue(sender, regionName, listener); if (logger.isDebugEnabled()) { logger.debug("Created queue: {}", this.queue); } }
long currentKey = -1; if (this.peekedIds.isEmpty()) { currentKey = getHeadKey(); } else { Long lastPeek = this.peekedIds.peekLast(); while (before(currentKey, getTailKey()) && (object = optimalGet(Long.valueOf(currentKey))) == null) { if (logger.isTraceEnabled()) { logger.trace("{}: Trying head key + offset: {}", this, currentKey); currentKey = inc(currentKey); if (this.stats != null) { this.stats.incEventsNotQueuedConflated();
private long putAndGetKey(Object object) throws CacheException { // Get the tail key Long key = Long.valueOf(getTailKey()); // Put the object into the region at that key this.region.put(key, (AsyncEvent)object); // Increment the tail key // It is important that we increment the tail // key after putting in the region, this is the // signal that a new object is available. incrementTailKey(); if (logger.isDebugEnabled()) { logger.debug("{}: Inserted {} -> {}",this, key, object); } if (object instanceof Conflatable) { removeOldEntry((Conflatable)object, key); } return key.longValue(); }
initializeKeys(); this.currentKey = inc(ckey); incrementTailKey(); Long k = itr.next(); if (k.longValue() == this.tailKey.get()) { incrementTailKey(); removeOldEntry((Conflatable)object, key);
initializeRegion(abstractSender, listener); this.sender = abstractSender; if (logger.isDebugEnabled()) { logger.debug("{}: Contains {} elements", this, size());
/** * Increments the value of the tail key by one. * * @throws CacheException */ private void incrementTailKey() throws CacheException { this.tailKey.set(inc(this.tailKey.get())); if (logger.isTraceEnabled()) { logger.trace("{}: Incremented TAIL_KEY for region {} to {}", this, this.region.getName(), this.tailKey); } }
/** * Returns the value of the head key. The head key points to the next entry to * be removed from the queue. * * @return the value of the head key * @throws CacheException */ private long getHeadKey() throws CacheException { long hKey; // Test whether _headKey = -1. If so, the queue has just been created. // Go into the region to get the value of HEAD_KEY. If it is null, then // this is the first attempt to access this queue. Set the _headKey and // headKey appropriately (to 0). If there is a value in the region, then // this queue has been accessed before and this instance is taking up where // a previous one left off. Set the _headKey to the value in the region. // From now on, this queue will use the value of _headKey in the VM to // determine the headKey. If the _headKey != -1, set the headKey // to the value of the _headKey. initializeKeys(); hKey = this.headKey; if (logger.isTraceEnabled()) { logger.trace("{}: Determined head key: {}", this, hKey); } return hKey; }
((SerialGatewaySenderQueue)q).cleanUp();
initializeKeys(); this.currentKey = inc(ckey); incrementTailKey(); Long k = itr.next(); if (k.longValue() == this.tailKey.get()) { incrementTailKey(); removeOldEntry((Conflatable)object, key);
private long putAndGetKey(Object object) throws CacheException { // Get the tail key Long key = Long.valueOf(getTailKey()); // Put the object into the region at that key this.region.put(key, (AsyncEvent)object); // Increment the tail key // It is important that we increment the tail // key after putting in the region, this is the // signal that a new object is available. incrementTailKey(); if (this.logger.fineEnabled()) { this.logger.fine(this + ": Inserted " + key + "->" + object); } if (object instanceof Conflatable) { removeOldEntry((Conflatable)object, key); } return key.longValue(); }
initializeRegion(abstractSender, listener); this.removalThread = new BatchRemovalThread((GemFireCacheImpl)abstractSender.getCache()); this.removalThread.start(); this.sender = (SerialGatewaySenderImpl) abstractSender; if (this.logger.fineEnabled()) { this.logger.fine(this + ": Contains " + size() + " elements");
/** * Increments the value of the head key by one. * * @throws CacheException */ private void updateHeadKey(long destroyedKey) throws CacheException { this.headKey = inc(destroyedKey); if (logger.isTraceEnabled()) { logger.trace("{}: Incremented HEAD_KEY for region {} to {}", this, this.region.getName(), this.headKey); } }
/** * Returns the value of the tail key. The tail key points to an empty where * the next queue entry will be stored. * * @return the value of the tail key * @throws CacheException */ private long getTailKey() throws CacheException { long tlKey; // Test whether tailKey = -1. If so, the queue has just been created. // Go into the region to get the value of TAIL_KEY. If it is null, then // this is the first attempt to access this queue. Set the tailKey and // tailKey appropriately (to 0). If there is a value in the region, then // this queue has been accessed before and this instance is taking up where // a previous one left off. Set the tailKey to the value in the region. // From now on, this queue will use the value of tailKey in the VM to // determine the tailKey. If the tailKey != -1, set the tailKey // to the value of the tailKey. initializeKeys(); tlKey = this.tailKey.get(); if (logger.isTraceEnabled()) { logger.trace("{}: Determined tail key: {}", this, tlKey); } return tlKey; }
((SerialGatewaySenderQueue)q).cleanUp();
long currentKey = -1; if (this.peekedIds.isEmpty()) { currentKey = getHeadKey(); } else { Long lastPeek = this.peekedIds.peekLast(); while (before(currentKey, getTailKey()) && (object = optimalGet(Long.valueOf(currentKey))) == null) { if (this.logger.finerEnabled()) { this.logger.finer(this + ": Trying head key + offset: " + currentKey); currentKey = inc(currentKey); if (this.stats != null) { this.stats.incEventsNotQueuedConflated();
public void destroy() { getRegion().localDestroyRegion(); }
/** * Increments the value of the tail key by one. * * @throws CacheException */ private void incrementTailKey() throws CacheException { this.tailKey.set(inc(this.tailKey.get())); if (this.logger.finerEnabled()) { this.logger.finer(this + ": Incremented TAIL_KEY for region " + this.region.getName() + " to " + this.tailKey); } }
/** * Returns the value of the tail key. The tail key points to an empty where * the next queue entry will be stored. * * @return the value of the tail key * @throws CacheException */ private long getTailKey() throws CacheException { long tlKey; // Test whether tailKey = -1. If so, the queue has just been created. // Go into the region to get the value of TAIL_KEY. If it is null, then // this is the first attempt to access this queue. Set the tailKey and // tailKey appropriately (to 0). If there is a value in the region, then // this queue has been accessed before and this instance is taking up where // a previous one left off. Set the tailKey to the value in the region. // From now on, this queue will use the value of tailKey in the VM to // determine the tailKey. If the tailKey != -1, set the tailKey // to the value of the tailKey. initializeKeys(); tlKey = this.tailKey.get(); if (this.logger.finerEnabled()) { this.logger.finer(this + ": Determined tail key: " + tlKey); } return tlKey; }
@Override protected void initializeMessageQueue(String id) { // Create the region name StringBuilder regionNameBuffer = new StringBuilder(); regionNameBuffer.append(id).append( "_SERIAL_GATEWAY_SENDER_QUEUE"); String regionName = regionNameBuffer.toString(); CacheListener listener = null; if (!this.sender.isPrimary()) { listener = new SerialSecondaryGatewayListener(this); initializeListenerExecutor(); } // Create the region queue this.queue = new SerialGatewaySenderQueue(sender, regionName, listener); if (getLogger().fineEnabled()) { getLogger().fine("Created queue: " + this.queue); } }