View Javadoc

1   /***
2    *  Copyright 2003-2010 Terracotta, Inc.
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   */
16  
17  package net.sf.ehcache.constructs.nonstop.store;
18  
19  import java.io.IOException;
20  import java.util.Collection;
21  import java.util.Collections;
22  import java.util.List;
23  import java.util.Map;
24  import java.util.Set;
25  
26  import net.sf.ehcache.CacheException;
27  import net.sf.ehcache.Element;
28  import net.sf.ehcache.Status;
29  import net.sf.ehcache.config.TimeoutBehaviorConfiguration.TimeoutBehaviorType;
30  import net.sf.ehcache.constructs.nonstop.ClusterOperation;
31  import net.sf.ehcache.constructs.nonstop.NonstopActiveDelegateHolder;
32  import net.sf.ehcache.constructs.nonstop.NonstopTimeoutBehaviorFactory;
33  import net.sf.ehcache.search.Attribute;
34  import net.sf.ehcache.search.NullResults;
35  import net.sf.ehcache.search.Results;
36  import net.sf.ehcache.search.attribute.AttributeExtractor;
37  import net.sf.ehcache.store.ElementValueComparator;
38  import net.sf.ehcache.store.Policy;
39  import net.sf.ehcache.store.StoreListener;
40  import net.sf.ehcache.store.StoreQuery;
41  import net.sf.ehcache.writer.CacheWriterManager;
42  
43  /***
44   * Implementation of {@link NonstopStore} which returns null for all get
45   * operations and does nothing for puts and removes.
46   *
47   * @author Abhishek Sanoujam
48   *
49   */
50  public final class NoOpOnTimeoutStore implements NonstopStore {
51  
52      /***
53       * The {@link NonstopTimeoutBehaviorFactory} to create {@link NoOpOnTimeoutStore} stores
54       */
55      public static final NonstopTimeoutBehaviorFactory FACTORY = new NonstopTimeoutBehaviorFactory() {
56          public NonstopStore createNonstopTimeoutBehaviorStore(NonstopActiveDelegateHolder nonstopActiveDelegateHolder) {
57              return NoOpOnTimeoutStore.getInstance();
58          }
59      };
60  
61      /***
62       * the singleton instance
63       */
64      private static final NoOpOnTimeoutStore INSTANCE = new NoOpOnTimeoutStore();
65  
66      /***
67       * private constructor
68       */
69      private NoOpOnTimeoutStore() {
70          //
71      }
72  
73      /***
74       * Returns the singleton instance
75       *
76       * @return the singleton instance
77       */
78      public static NoOpOnTimeoutStore getInstance() {
79          return INSTANCE;
80      }
81  
82      /***
83       * {@inheritDoc}
84       */
85      public void addStoreListener(StoreListener listener) {
86      }
87  
88      /***
89       * {@inheritDoc}
90       */
91      public boolean bufferFull() {
92          return false;
93      }
94  
95      /***
96       * {@inheritDoc}
97       */
98      public boolean containsKey(Object key) {
99          return false;
100     }
101 
102     /***
103      * {@inheritDoc}
104      */
105     public boolean containsKeyInMemory(Object key) {
106         return false;
107     }
108 
109     /***
110      * {@inheritDoc}
111      */
112     public boolean containsKeyOffHeap(Object key) {
113         return false;
114     }
115 
116     /***
117      * {@inheritDoc}
118      */
119     public boolean containsKeyOnDisk(Object key) {
120         return false;
121     }
122 
123     /***
124      * {@inheritDoc}
125      */
126     public void dispose() {
127     }
128 
129     /***
130      * {@inheritDoc}
131      */
132     public Results executeQuery(StoreQuery query) {
133         return NullResults.INSTANCE;
134     }
135 
136     /***
137      * {@inheritDoc}
138      */
139     public void expireElements() {
140     }
141 
142     /***
143      * {@inheritDoc}
144      */
145     public void flush() throws IOException {
146     }
147 
148     /***
149      * {@inheritDoc}
150      */
151     public Element get(Object key) {
152         return null;
153     }
154 
155     /***
156      * {@inheritDoc}
157      */
158     public Policy getInMemoryEvictionPolicy() {
159         return null;
160     }
161 
162     /***
163      * {@inheritDoc}
164      */
165     public int getInMemorySize() {
166         return 0;
167     }
168 
169     /***
170      * {@inheritDoc}
171      */
172     public long getInMemorySizeInBytes() {
173         return 0;
174     }
175 
176     /***
177      * {@inheritDoc}
178      */
179     public Object getInternalContext() {
180         return null;
181     }
182 
183     /***
184      * {@inheritDoc}
185      */
186     public List getKeys() {
187         return Collections.EMPTY_LIST;
188     }
189 
190     /***
191      * {@inheritDoc}
192      */
193     public Object getMBean() {
194         return null;
195     }
196 
197     /***
198      * {@inheritDoc}
199      */
200     public int getOffHeapSize() {
201         return 0;
202     }
203 
204     /***
205      * {@inheritDoc}
206      */
207     public long getOffHeapSizeInBytes() {
208         return 0;
209     }
210 
211     /***
212      * {@inheritDoc}
213      */
214     public int getOnDiskSize() {
215         return 0;
216     }
217 
218     /***
219      * {@inheritDoc}
220      */
221     public long getOnDiskSizeInBytes() {
222         return 0;
223     }
224 
225     /***
226      * {@inheritDoc}
227      */
228     public Element getQuiet(Object key) {
229         return null;
230     }
231 
232     /***
233      * {@inheritDoc}
234      */
235     public int getSize() {
236         return 0;
237     }
238 
239     /***
240      * {@inheritDoc}
241      */
242     public Status getStatus() {
243         return null;
244     }
245 
246     /***
247      * {@inheritDoc}
248      */
249     public int getTerracottaClusteredSize() {
250         return 0;
251     }
252 
253     /***
254      * {@inheritDoc}
255      */
256     public boolean isCacheCoherent() {
257         return false;
258     }
259 
260     /***
261      * {@inheritDoc}
262      */
263     public boolean isClusterCoherent() {
264         return false;
265     }
266 
267     /***
268      * {@inheritDoc}
269      */
270     public boolean isNodeCoherent() {
271         return false;
272     }
273 
274     /***
275      * {@inheritDoc}
276      */
277     public boolean put(Element element) throws CacheException {
278         return false;
279     }
280 
281     /***
282      * {@inheritDoc}
283      */
284     public void putAll(Collection<Element> elements) throws CacheException {
285     }
286 
287     /***
288      * {@inheritDoc}
289      */
290     public Element putIfAbsent(Element element) {
291         return null;
292     }
293 
294     /***
295      * {@inheritDoc}
296      */
297     public boolean putWithWriter(Element element, CacheWriterManager writerManager) throws CacheException {
298         return false;
299     }
300 
301     /***
302      * {@inheritDoc}
303      */
304     public Element remove(Object key) {
305         return null;
306     }
307 
308     /***
309      * {@inheritDoc}
310      */
311     public void removeAll(Collection<Object> keys) {
312     }
313 
314     /***
315      * {@inheritDoc}
316      */
317     public void removeAll() throws CacheException {
318     }
319 
320     /***
321      * {@inheritDoc}
322      */
323     public Element removeElement(Element element, ElementValueComparator comparator) {
324         return null;
325     }
326 
327     /***
328      * {@inheritDoc}
329      */
330     public void removeStoreListener(StoreListener listener) {
331     }
332 
333     /***
334      * {@inheritDoc}
335      */
336     public Element removeWithWriter(Object key, CacheWriterManager writerManager) throws CacheException {
337         return null;
338     }
339 
340     /***
341      * {@inheritDoc}
342      */
343     public boolean replace(Element old, Element element, ElementValueComparator comparator) {
344         return false;
345     }
346 
347     /***
348      * {@inheritDoc}
349      */
350     public Element replace(Element element) {
351         return null;
352     }
353 
354     /***
355      * {@inheritDoc}
356      */
357     public void setAttributeExtractors(Map<String, AttributeExtractor> extractors) {
358     }
359 
360     /***
361      * {@inheritDoc}
362      */
363     public void setInMemoryEvictionPolicy(Policy policy) {
364     }
365 
366     /***
367      * {@inheritDoc}
368      */
369     public void setNodeCoherent(boolean coherent) throws UnsupportedOperationException {
370     }
371 
372     /***
373      * {@inheritDoc}
374      */
375     public void waitUntilClusterCoherent() throws UnsupportedOperationException {
376     }
377 
378     /***
379      * {@inheritDoc}
380      */
381     public <T> Attribute<T> getSearchAttribute(String attributeName) {
382         return new Attribute(attributeName);
383     }
384 
385     /***
386      * {@inheritDoc}
387      */
388     public Set getLocalKeys() {
389         return Collections.EMPTY_SET;
390     }
391 
392     /***
393      * {@inheritDoc}
394      */
395     public Element unlockedGet(Object key) {
396         return null;
397     }
398 
399     /***
400      * {@inheritDoc}
401      */
402     public Element unlockedGetQuiet(Object key) {
403         return null;
404     }
405 
406     /***
407      * {@inheritDoc}
408      */
409     public Element unsafeGet(Object key) {
410         return null;
411     }
412 
413     /***
414      * {@inheritDoc}
415      */
416     public Element unsafeGetQuiet(Object key) {
417         return null;
418     }
419 
420     /***
421      * {@inheritDoc}
422      */
423     public <V> V executeClusterOperation(ClusterOperation<V> operation) {
424         return operation.performClusterOperationTimedOut(TimeoutBehaviorType.NOOP);
425     }
426 
427 }