View Javadoc

1   package org.apache.jcs.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  import java.io.Serializable;
24  
25  import org.apache.jcs.engine.stats.behavior.IStats;
26  
27  /***
28   * Interface for a cache event queue. An event queue is used to propagate
29   * ordered cache events to one and only one target listener.
30   */
31  public interface ICacheEventQueue
32  {
33      /***
34       * Does not use a thread pool.
35       */
36      public static final int SINGLE_QUEUE_TYPE = 0;
37  
38      /***
39       * Uses a thread pool
40       */
41      public static final int POOLED_QUEUE_TYPE = 1;
42  
43      /***
44       * Return the type of event queue we are using, either single or pooled.
45       * <p>
46       * @return
47       */
48      public abstract int getQueueType();
49  
50      /***
51       * Adds a feature to the PutEvent attribute of the ICacheEventQueue object
52       * <p>
53       * @param ce
54       *            The feature to be added to the PutEvent attribute
55       * @throws IOException
56       */
57      public void addPutEvent( ICacheElement ce )
58          throws IOException;
59  
60      /***
61       * Adds a feature to the RemoveEvent attribute of the ICacheEventQueue
62       * object
63       * <p>
64       * @param key
65       *            The feature to be added to the RemoveEvent attribute
66       * @throws IOException
67       */
68      public void addRemoveEvent( Serializable key )
69          throws IOException;
70  
71      /***
72       * Adds a feature to the RemoveAllEvent attribute of the ICacheEventQueue
73       * object
74       * <p>
75       * @throws IOException
76       */
77      public void addRemoveAllEvent()
78          throws IOException;
79  
80      /***
81       * Adds a feature to the DisposeEvent attribute of the ICacheEventQueue
82       * object
83       * <p>
84       * @throws IOException
85       */
86      public void addDisposeEvent()
87          throws IOException;
88  
89      /***
90       * Gets the listenerId attribute of the ICacheEventQueue object
91       *
92       * @return The listenerId value
93       */
94      public long getListenerId();
95  
96      /*** Description of the Method */
97      public void destroy();
98  
99      /***
100      * Gets the alive attribute of the ICacheEventQueue object. Alive just
101      * indicates that there are active threads. This is less important that if
102      * the queue is working.
103      * <p>
104      * @return The alive value
105      */
106     public boolean isAlive();
107 
108     /***
109      * A Queue is working unless it has reached its max failure count.
110      * <p>
111      * @return boolean
112      */
113     public boolean isWorking();
114 
115     /***
116      * Returns the number of elements in the queue.  If the queue cannot
117      * determine the size accurately it will return 1.
118      * <p>
119      * @return number of items in the queue.
120      */
121     public int size();
122 
123     /***
124      * Are there elements in the queue.
125      * <p>
126      * @return true if there are stil elements.
127      */
128     public boolean isEmpty();
129 
130     /***
131      * Returns the historical and statistical data for an event queue cache.
132      * <p>
133      * @return
134      */
135     public IStats getStatistics();
136 }