comparison src/org/dancres/blitz/entry/EntryRepository.java @ 0:3dc0c5604566

Initial checkin of blitz 2.0 fcs - no installer yet.
author Dan Creswell <dan.creswell@gmail.com>
date Sat, 21 Mar 2009 11:00:06 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:3dc0c5604566
1 package org.dancres.blitz.entry;
2
3 import java.io.IOException;
4
5 import org.dancres.blitz.mangler.MangledField;
6 import org.dancres.blitz.mangler.MangledEntry;
7
8 import org.dancres.blitz.oid.OID;
9
10 import org.dancres.blitz.stats.Stat;
11 import org.dancres.blitz.config.EntryConstraints;
12
13 /**
14 Entry's are separated by type with all instances of a particular type
15 held in one EntryRepository instance.
16 */
17 public interface EntryRepository {
18 public static final String ROOT_TYPE = "java.lang.Object";
19
20 public EntryConstraints getConstraints();
21
22 /**
23 Called to setup schema information, create indexes etc - should only
24 be called once in response to <code>true</code> being returned from
25 <code>didntExist()</code>
26 */
27 public void setFields(MangledField[] aSetOfFields) throws IOException;
28
29 /**
30 Indicates if we were created for the first time as the result of
31 a call to <code>EntryRepositoryFactory.get()</code>. Note that this
32 flag is reset after <code>setFields()</code> is called. Thus, even
33 if an EntryRepository has been informed of children, it will still
34 return <code>true</code> until <code>setFields</code> is called.
35 */
36 public boolean noSchemaDefined();
37
38 /**
39 Tells this Repository about a subtype which has just been created
40 and would need to be search if this type were the specified template.
41 */
42 public void addSubtype(String aType) throws IOException;
43
44 /**
45 Return a list of all currently known subtypes
46 */
47 public String[] getSubtypes();
48
49 /**
50 Write returns it's result via the passed WriteEscort. i.e. If
51 it returns without IOException, the write is deemed to have succeeded.
52 The caller is responsible for recovering the appropriate information
53 from the WriteEscort.
54
55 @param anExpiry an absolute expiry time
56 */
57 public void write(MangledEntry anEntry, long anExpiry,
58 WriteEscort anEscort)
59 throws IOException;
60
61 /**
62 Locate suitable matches for the passed template and offer them
63 to the SearchVisitor. Note that there is no return value from this
64 method because the appropriate value is passed to the SearchVisitor
65 via offer which it then accepts. Thus the caller is expected to
66 interrogate the SearchVisitor implementation to determine the outcome.
67
68 @param aTemplate can be null or a wildcard MangledEntry indicating an
69 Entry<class>* search or a MangledEntry with keys which results in an
70 indexed search
71 */
72 public void find(MangledEntry aTemplate, SearchVisitor aVisitor)
73 throws IOException;
74
75 /**
76 Under some circumstances, we wish to offer a visitor the chance to
77 acquire a specific Entry identified by aOID. This step must be
78 managed by the Repository (as are finds) in order to handle such
79 issues as paging in from disk etc.
80
81 @return <code>true</code> if an offer was made. If an offer wasn't made
82 it's due to the Entry no longer being available. The caller would be
83 best advised to stop the search at this point to save I/O.
84 */
85 public boolean find(SearchVisitor aVisitor, OID aOID, MangledEntry aPreload)
86 throws IOException;
87
88 public LongtermOffer getOffer(OID anOID) throws IOException;
89
90 /**
91 @return an OpInfo if the operation was successful, <code>null</code>
92 otherwise
93 */
94 public boolean renew(OID aOID, long anExpiry) throws IOException;
95
96 /**
97 @return an OpInfo if the operation was successful, <code>null</code>
98 otherwise
99 */
100 public boolean cancel(OID aOID) throws IOException;
101
102 /**
103 @return the Entry type held in this repository
104 */
105 public String getType();
106
107 /**
108 @return the number of Entry's stored on disk
109 */
110 public int getTotalStoredEntries() throws IOException;
111
112 /**
113 @return the number of Entry's stored in total including those uncommitted
114 in cache
115 */
116 public int getTotalLiveEntries();
117 }