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  package net.sf.ehcache.writer.writebehind;
17  
18  import net.sf.ehcache.CacheEntry;
19  import net.sf.ehcache.CacheException;
20  import net.sf.ehcache.Element;
21  import net.sf.ehcache.writer.CacheWriter;
22  
23  /***
24   * An interface for write behind behavior.
25   *
26   * @author Geert Bevin
27   * @version $Id: WriteBehind.html 13146 2011-08-01 17:12:39Z oletizi $
28   */
29  public interface WriteBehind {
30      /***
31       * Start the write behind queue with a cache writer
32       *
33       * @param writer the cache writer that should be used to process the operations
34       * @see #stop
35       */
36      void start(CacheWriter writer) throws CacheException;
37  
38      /***
39       * Add a write operation for a given element.
40       *
41       * @param element the element for which a write operation will be added to the write behind queue
42       */
43      void write(Element element);
44  
45      /***
46       * Add a delete operation for the given cache entry
47       *
48       * @param entry the cache entry for which a delete operation will be added to the write behind queue
49       */
50      void delete(CacheEntry entry);
51  
52      /***
53       * Set the operations filter that should be used.
54       *
55       * @param filter the filter that will be used as of now
56       */
57      void setOperationsFilter(OperationsFilter filter);
58  
59      /***
60       * Stop the coordinator and all the internal data structures.
61       * <p/>
62       * This stops as quickly as possible without losing any previously added items. However, no guarantees are made
63       * towards the processing of these items. It's highly likely that items are still inside the internal data structures
64       * and not processed.
65       *
66       * @see #start
67       */
68      void stop() throws CacheException;
69  
70      /***
71       * Gets the best estimate for items in the queue still awaiting processing.
72       * Not including elements currently processed
73       * @return the amount of elements still awaiting processing.
74       */
75      long getQueueSize();
76  }