test_class.declarator: logger = LoggerFactory.getLogger(WindowTest.class)
test_class.modifier: private static final
test_class.original_string: private static final Logger logger = LoggerFactory.getLogger(WindowTest.class);
test_class.type: Logger
test_class.var_name: logger
test_class.file: ch-commons-util/src/test/java/com/cloudhopper/commons/util/windowing/WindowTest.java
test_class.identifier: WindowTest
test_case.body: @Test
      public void cancel() throws Exception {
          Window<Integer,String,String> window = new Window<Integer,String,String>(1);
          Integer i = new Integer(1);
          String request = "Request"+i;
  
          WindowFuture<Integer,String,String> requestFuture = window.offer(i, request, 100);
          
          // cancel it
          WindowFuture<Integer,String,String> responseFuture = window.cancel(i);
          Assert.assertEquals(new Integer(i), responseFuture.getKey());
          Assert.assertEquals(request, responseFuture.getRequest());
          Assert.assertEquals(true, responseFuture.getAcceptTimestamp() > 0);
          Assert.assertEquals(null, responseFuture.getResponse());
          Assert.assertEquals(true, responseFuture.getDoneTimestamp() > 0);
          Assert.assertEquals(true, requestFuture.isCancelled());
          Assert.assertEquals(true, requestFuture.isDone());
          Assert.assertEquals(false, requestFuture.isSuccess());
          Assert.assertTrue(requestFuture.getAcceptToDoneTime() >= 0);
  
          // this should not timeout waiting for a response
          Assert.assertTrue(requestFuture.await(50));
      }
test_case.class_method_signature: WindowTest.cancel()
test_case.full_signature: @Test public void cancel()
test_case.identifier: cancel
test_case.invocations: offer cancel assertEquals getKey assertEquals getRequest assertEquals getAcceptTimestamp assertEquals getResponse assertEquals getDoneTimestamp assertEquals isCancelled assertEquals isDone assertEquals isSuccess assertTrue getAcceptToDoneTime assertTrue await
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void cancel()
focal_class.declarator: logger = LoggerFactory.getLogger(Window.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(Window.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: maxSize
focal_class.modifier: private final
focal_class.original_string: private final int maxSize;
focal_class.type: int
focal_class.var_name: maxSize
focal_class.declarator: futures
focal_class.modifier: private final
focal_class.original_string: private final ConcurrentHashMap<K,DefaultWindowFuture<K,R,P>> futures;
focal_class.type: ConcurrentHashMap<K,DefaultWindowFuture<K,R,P>>
focal_class.var_name: futures
focal_class.declarator: lock
focal_class.modifier: private final
focal_class.original_string: private final ReentrantLock lock;
focal_class.type: ReentrantLock
focal_class.var_name: lock
focal_class.declarator: completedCondition
focal_class.modifier: private final
focal_class.original_string: private final Condition completedCondition;
focal_class.type: Condition
focal_class.var_name: completedCondition
focal_class.declarator: pendingOffers
focal_class.modifier: private
focal_class.original_string: private AtomicInteger pendingOffers;
focal_class.type: AtomicInteger
focal_class.var_name: pendingOffers
focal_class.declarator: pendingOffersAborted
focal_class.modifier: private
focal_class.original_string: private AtomicBoolean pendingOffersAborted;
focal_class.type: AtomicBoolean
focal_class.var_name: pendingOffersAborted
focal_class.declarator: executor
focal_class.modifier: private final
focal_class.original_string: private final ScheduledExecutorService executor;
focal_class.type: ScheduledExecutorService
focal_class.var_name: executor
focal_class.declarator: monitorHandle
focal_class.modifier: private
focal_class.original_string: private ScheduledFuture<?> monitorHandle;
focal_class.type: ScheduledFuture<?>
focal_class.var_name: monitorHandle
focal_class.declarator: monitor
focal_class.modifier: private final
focal_class.original_string: private final WindowMonitor monitor;
focal_class.type: WindowMonitor
focal_class.var_name: monitor
focal_class.declarator: monitorInterval
focal_class.modifier: private final
focal_class.original_string: private final long monitorInterval;
focal_class.type: long
focal_class.var_name: monitorInterval
focal_class.declarator: listeners
focal_class.modifier: private final
focal_class.original_string: private final CopyOnWriteArrayList<UnwrappedWeakReference<WindowListener<K,R,P>>> listeners;
focal_class.type: CopyOnWriteArrayList<UnwrappedWeakReference<WindowListener<K,R,P>>>
focal_class.var_name: listeners
focal_class.file: ch-commons-util/src/main/java/com/cloudhopper/commons/util/windowing/Window.java
focal_class.identifier: Window
focal_class.class_method_signature: Window.Window(int size)
focal_class.full_signature: public  Window(int size)
focal_class.identifier: Window
focal_class.modifiers: public
focal_class.parameters: (int size)
focal_class.signature:  Window(int size)
focal_class.class_method_signature: Window.Window(int size, ScheduledExecutorService executor, long monitorInterval, WindowListener<K,R,P> listener)
focal_class.full_signature: public  Window(int size, ScheduledExecutorService executor, long monitorInterval, WindowListener<K,R,P> listener)
focal_class.identifier: Window
focal_class.modifiers: public
focal_class.parameters: (int size, ScheduledExecutorService executor, long monitorInterval, WindowListener<K,R,P> listener)
focal_class.signature:  Window(int size, ScheduledExecutorService executor, long monitorInterval, WindowListener<K,R,P> listener)
focal_class.class_method_signature: Window.Window(int size, ScheduledExecutorService executor, long monitorInterval, WindowListener<K,R,P> listener, String monitorThreadName)
focal_class.full_signature: public  Window(int size, ScheduledExecutorService executor, long monitorInterval, WindowListener<K,R,P> listener, String monitorThreadName)
focal_class.identifier: Window
focal_class.modifiers: public
focal_class.parameters: (int size, ScheduledExecutorService executor, long monitorInterval, WindowListener<K,R,P> listener, String monitorThreadName)
focal_class.signature:  Window(int size, ScheduledExecutorService executor, long monitorInterval, WindowListener<K,R,P> listener, String monitorThreadName)
focal_class.class_method_signature: Window.getMaxSize()
focal_class.full_signature: public int getMaxSize()
focal_class.identifier: getMaxSize
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getMaxSize()
focal_class.class_method_signature: Window.getSize()
focal_class.full_signature: public int getSize()
focal_class.identifier: getSize
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getSize()
focal_class.class_method_signature: Window.getFreeSize()
focal_class.full_signature: public int getFreeSize()
focal_class.identifier: getFreeSize
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getFreeSize()
focal_class.class_method_signature: Window.containsKey(K key)
focal_class.full_signature: public boolean containsKey(K key)
focal_class.identifier: containsKey
focal_class.modifiers: public
focal_class.parameters: (K key)
focal_class.return: boolean
focal_class.signature: boolean containsKey(K key)
focal_class.class_method_signature: Window.get(K key)
focal_class.full_signature: public WindowFuture<K,R,P> get(K key)
focal_class.identifier: get
focal_class.modifiers: public
focal_class.parameters: (K key)
focal_class.return: WindowFuture<K,R,P>
focal_class.signature: WindowFuture<K,R,P> get(K key)
focal_class.class_method_signature: Window.addListener(WindowListener<K,R,P> listener)
focal_class.full_signature: public void addListener(WindowListener<K,R,P> listener)
focal_class.identifier: addListener
focal_class.modifiers: public
focal_class.parameters: (WindowListener<K,R,P> listener)
focal_class.return: void
focal_class.signature: void addListener(WindowListener<K,R,P> listener)
focal_class.class_method_signature: Window.removeListener(WindowListener<K,R,P> listener)
focal_class.full_signature: public void removeListener(WindowListener<K,R,P> listener)
focal_class.identifier: removeListener
focal_class.modifiers: public
focal_class.parameters: (WindowListener<K,R,P> listener)
focal_class.return: void
focal_class.signature: void removeListener(WindowListener<K,R,P> listener)
focal_class.class_method_signature: Window.getListeners()
focal_class.full_signature:  List<UnwrappedWeakReference<WindowListener<K,R,P>>> getListeners()
focal_class.identifier: getListeners
focal_class.parameters: ()
focal_class.return: List<UnwrappedWeakReference<WindowListener<K,R,P>>>
focal_class.signature: List<UnwrappedWeakReference<WindowListener<K,R,P>>> getListeners()
focal_class.class_method_signature: Window.destroy()
focal_class.full_signature: public synchronized void destroy()
focal_class.identifier: destroy
focal_class.modifiers: public synchronized
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void destroy()
focal_class.class_method_signature: Window.startMonitor()
focal_class.full_signature: public synchronized boolean startMonitor()
focal_class.identifier: startMonitor
focal_class.modifiers: public synchronized
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean startMonitor()
focal_class.class_method_signature: Window.stopMonitor()
focal_class.full_signature: public synchronized void stopMonitor()
focal_class.identifier: stopMonitor
focal_class.modifiers: public synchronized
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void stopMonitor()
focal_class.class_method_signature: Window.createSortedSnapshot()
focal_class.full_signature: public Map<K,WindowFuture<K,R,P>> createSortedSnapshot()
focal_class.identifier: createSortedSnapshot
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Map<K,WindowFuture<K,R,P>>
focal_class.signature: Map<K,WindowFuture<K,R,P>> createSortedSnapshot()
focal_class.class_method_signature: Window.offer(K key, R request, long offerTimeoutMillis)
focal_class.full_signature: public WindowFuture offer(K key, R request, long offerTimeoutMillis)
focal_class.identifier: offer
focal_class.modifiers: public
focal_class.parameters: (K key, R request, long offerTimeoutMillis)
focal_class.return: WindowFuture
focal_class.signature: WindowFuture offer(K key, R request, long offerTimeoutMillis)
focal_class.class_method_signature: Window.offer(K key, R request, long offerTimeoutMillis, long expireTimeoutMillis)
focal_class.full_signature: public WindowFuture offer(K key, R request, long offerTimeoutMillis, long expireTimeoutMillis)
focal_class.identifier: offer
focal_class.modifiers: public
focal_class.parameters: (K key, R request, long offerTimeoutMillis, long expireTimeoutMillis)
focal_class.return: WindowFuture
focal_class.signature: WindowFuture offer(K key, R request, long offerTimeoutMillis, long expireTimeoutMillis)
focal_class.class_method_signature: Window.offer(K key, R request, long offerTimeoutMillis, long expireTimeoutMillis, boolean callerWaitingHint)
focal_class.full_signature: public WindowFuture offer(K key, R request, long offerTimeoutMillis, long expireTimeoutMillis, boolean callerWaitingHint)
focal_class.identifier: offer
focal_class.modifiers: public
focal_class.parameters: (K key, R request, long offerTimeoutMillis, long expireTimeoutMillis, boolean callerWaitingHint)
focal_class.return: WindowFuture
focal_class.signature: WindowFuture offer(K key, R request, long offerTimeoutMillis, long expireTimeoutMillis, boolean callerWaitingHint)
focal_class.class_method_signature: Window.getPendingOfferCount()
focal_class.full_signature: public int getPendingOfferCount()
focal_class.identifier: getPendingOfferCount
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getPendingOfferCount()
focal_class.class_method_signature: Window.beginPendingOffer()
focal_class.full_signature: private void beginPendingOffer()
focal_class.identifier: beginPendingOffer
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void beginPendingOffer()
focal_class.class_method_signature: Window.endPendingOffer()
focal_class.full_signature: private boolean endPendingOffer()
focal_class.identifier: endPendingOffer
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean endPendingOffer()
focal_class.class_method_signature: Window.abortPendingOffers()
focal_class.full_signature: public boolean abortPendingOffers()
focal_class.identifier: abortPendingOffers
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean abortPendingOffers()
focal_class.class_method_signature: Window.complete(K key, P response)
focal_class.full_signature: public WindowFuture<K,R,P> complete(K key, P response)
focal_class.identifier: complete
focal_class.modifiers: public
focal_class.parameters: (K key, P response)
focal_class.return: WindowFuture<K,R,P>
focal_class.signature: WindowFuture<K,R,P> complete(K key, P response)
focal_class.class_method_signature: Window.fail(K key, Throwable t)
focal_class.full_signature: public WindowFuture<K,R,P> fail(K key, Throwable t)
focal_class.identifier: fail
focal_class.modifiers: public
focal_class.parameters: (K key, Throwable t)
focal_class.return: WindowFuture<K,R,P>
focal_class.signature: WindowFuture<K,R,P> fail(K key, Throwable t)
focal_class.class_method_signature: Window.failAll(Throwable t)
focal_class.full_signature: public List<WindowFuture<K,R,P>> failAll(Throwable t)
focal_class.identifier: failAll
focal_class.modifiers: public
focal_class.parameters: (Throwable t)
focal_class.return: List<WindowFuture<K,R,P>>
focal_class.signature: List<WindowFuture<K,R,P>> failAll(Throwable t)
focal_class.class_method_signature: Window.cancel(K key)
focal_class.full_signature: public WindowFuture<K,R,P> cancel(K key)
focal_class.identifier: cancel
focal_class.modifiers: public
focal_class.parameters: (K key)
focal_class.return: WindowFuture<K,R,P>
focal_class.signature: WindowFuture<K,R,P> cancel(K key)
focal_class.class_method_signature: Window.cancelAll()
focal_class.full_signature: public List<WindowFuture<K,R,P>> cancelAll()
focal_class.identifier: cancelAll
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: List<WindowFuture<K,R,P>>
focal_class.signature: List<WindowFuture<K,R,P>> cancelAll()
focal_class.class_method_signature: Window.cancelAllExpired()
focal_class.full_signature: public List<WindowFuture<K,R,P>> cancelAllExpired()
focal_class.identifier: cancelAllExpired
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: List<WindowFuture<K,R,P>>
focal_class.signature: List<WindowFuture<K,R,P>> cancelAllExpired()
focal_class.class_method_signature: Window.removeHelper(K key)
focal_class.full_signature:  void removeHelper(K key)
focal_class.identifier: removeHelper
focal_class.parameters: (K key)
focal_class.return: void
focal_class.signature: void removeHelper(K key)
focal_method.body: public WindowFuture<K,R,P> cancel(K key) throws InterruptedException {
          if (!this.futures.containsKey(key)) {
              return null;
          }
  
          this.lock.lockInterruptibly();
          try {
              // try to remove future from window
              DefaultWindowFuture<K,R,P> future = this.futures.remove(key);
              if (future == null) {
                  return null;
              }
              
              // set failed using helper method (bypasses signalAll and requests.remove(key))
              future.cancelHelper(System.currentTimeMillis());
  
              // signal that a future is completed
              this.completedCondition.signalAll();
  
              return future;
          } finally {
              this.lock.unlock();
          }
      }
focal_method.class_method_signature: Window.cancel(K key)
focal_method.full_signature: public WindowFuture<K,R,P> cancel(K key)
focal_method.identifier: cancel
focal_method.invocations: containsKey lockInterruptibly remove cancelHelper currentTimeMillis signalAll unlock
focal_method.modifiers: public
focal_method.parameters: (K key)
focal_method.return: WindowFuture<K,R,P>
focal_method.signature: WindowFuture<K,R,P> cancel(K key)