1 package org.apache.commons.jcs3.engine.behavior;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import java.io.IOException;
23
24 import org.apache.commons.jcs3.engine.stats.behavior.IStats;
25
26 /**
27 * Interface for a cache event queue. An event queue is used to propagate
28 * ordered cache events to one and only one target listener.
29 */
30 public interface ICacheEventQueue<K, V>
31 {
32 enum QueueType
33 {
34 /** Does not use a thread pool. */
35 SINGLE,
36
37 /** Uses a thread pool. */
38 POOLED
39 }
40
41 /**
42 * Return the type of event queue we are using, either single or pooled.
43 * <p>
44 * @return the queue type: single or pooled
45 */
46 QueueType getQueueType();
47
48 /**
49 * Adds a feature to the PutEvent attribute of the ICacheEventQueue object
50 * <p>
51 * @param ce
52 * The feature to be added to the PutEvent attribute
53 * @throws IOException
54 */
55 void addPutEvent( ICacheElement<K, V> ce )
56 throws IOException;
57
58 /**
59 * Adds a feature to the RemoveEvent attribute of the ICacheEventQueue
60 * object
61 * <p>
62 * @param key
63 * The feature to be added to the RemoveEvent attribute
64 * @throws IOException
65 */
66 void addRemoveEvent( K key )
67 throws IOException;
68
69 /**
70 * Adds a feature to the RemoveAllEvent attribute of the ICacheEventQueue
71 * object
72 * <p>
73 * @throws IOException
74 */
75 void addRemoveAllEvent()
76 throws IOException;
77
78 /**
79 * Adds a feature to the DisposeEvent attribute of the ICacheEventQueue
80 * object
81 * <p>
82 * @throws IOException
83 */
84 void addDisposeEvent()
85 throws IOException;
86
87 /**
88 * Gets the listenerId attribute of the ICacheEventQueue object
89 *
90 * @return The listenerId value
91 */
92 long getListenerId();
93
94 /** Description of the Method */
95 void destroy();
96
97 /**
98 * A Queue is working unless it has reached its max failure count.
99 * <p>
100 * @return boolean
101 */
102 boolean isWorking();
103
104 /**
105 * Returns the number of elements in the queue. If the queue cannot
106 * determine the size accurately it will return 1.
107 * <p>
108 * @return number of items in the queue.
109 */
110 int size();
111
112 /**
113 * Are there elements in the queue.
114 * <p>
115 * @return true if there are stil elements.
116 */
117 boolean isEmpty();
118
119 /**
120 * Returns the historical and statistical data for an event queue cache.
121 * <p>
122 * @return IStats
123 */
124 IStats getStatistics();
125 }