001: /*
002: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
003: */
004: package com.tc.objectserver.api;
005:
006: import com.tc.async.api.AddPredicate;
007: import com.tc.async.api.EventContext;
008: import com.tc.async.api.Sink;
009: import com.tc.exception.ImplementMe;
010: import com.tc.stats.Stats;
011:
012: import java.util.Collection;
013: import java.util.LinkedList;
014: import java.util.List;
015:
016: /**
017: * @author steve
018: */
019: public class TestSink implements Sink {
020: private final List queue = new LinkedList();
021:
022: public boolean addLossy(EventContext context) {
023: return false;
024: }
025:
026: public void addMany(Collection contexts) {
027: //
028: }
029:
030: public void add(EventContext context) {
031: synchronized (queue) {
032: queue.add(context);
033: queue.notifyAll();
034: }
035: }
036:
037: public EventContext waitForAdd(long millis)
038: throws InterruptedException {
039: synchronized (queue) {
040: if (queue.size() < 1) {
041: queue.wait(millis);
042: }
043: return queue.size() < 1 ? null : (EventContext) queue
044: .get(0);
045: }
046: }
047:
048: public EventContext take() throws InterruptedException {
049: synchronized (queue) {
050: while (queue.size() < 1) {
051: queue.wait();
052: }
053: return (EventContext) queue.remove(0);
054: }
055: }
056:
057: public void setAddPredicate(AddPredicate predicate) {
058: //
059: }
060:
061: public AddPredicate getPredicate() {
062: return null;
063: }
064:
065: public int size() {
066: return queue.size();
067: }
068:
069: public List getInternalQueue() {
070: return queue;
071: }
072:
073: public void clear() {
074: throw new ImplementMe();
075: }
076:
077: public void unpause() {
078: throw new ImplementMe();
079: }
080:
081: public void pause(List pauseEvents) {
082: throw new ImplementMe();
083: }
084:
085: public void enableStatsCollection(boolean enable) {
086: throw new ImplementMe();
087: }
088:
089: public Stats getStats(long frequency) {
090: throw new ImplementMe();
091: }
092:
093: public Stats getStatsAndReset(long frequency) {
094: throw new ImplementMe();
095: }
096:
097: public boolean isStatsCollectionEnabled() {
098: throw new ImplementMe();
099: }
100:
101: public void resetStats() {
102: throw new ImplementMe();
103: }
104:
105: }
|