1 package org.apache.commons.jcs.engine.behavior; 2 3 import java.io.IOException; 4 5 /* 6 * Licensed to the Apache Software Foundation (ASF) under one 7 * or more contributor license agreements. See the NOTICE file 8 * distributed with this work for additional information 9 * regarding copyright ownership. The ASF licenses this file 10 * to you under the Apache License, Version 2.0 (the 11 * "License"); you may not use this file except in compliance 12 * with the License. You may obtain a copy of the License at 13 * 14 * http://www.apache.org/licenses/LICENSE-2.0 15 * 16 * Unless required by applicable law or agreed to in writing, 17 * software distributed under the License is distributed on an 18 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 19 * KIND, either express or implied. See the License for the 20 * specific language governing permissions and limitations 21 * under the License. 22 */ 23 24 import org.apache.commons.jcs.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 * Gets the alive attribute of the ICacheEventQueue object. Alive just 99 * indicates that there are active threads. This is less important that if 100 * the queue is working. 101 * <p> 102 * @return The alive value 103 */ 104 boolean isAlive(); 105 106 /** 107 * A Queue is working unless it has reached its max failure count. 108 * <p> 109 * @return boolean 110 */ 111 boolean isWorking(); 112 113 /** 114 * Returns the number of elements in the queue. If the queue cannot 115 * determine the size accurately it will return 1. 116 * <p> 117 * @return number of items in the queue. 118 */ 119 int size(); 120 121 /** 122 * Are there elements in the queue. 123 * <p> 124 * @return true if there are stil elements. 125 */ 126 boolean isEmpty(); 127 128 /** 129 * Returns the historical and statistical data for an event queue cache. 130 * <p> 131 * @return IStats 132 */ 133 IStats getStatistics(); 134 }