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.terracotta;
17
18 import net.sf.ehcache.Ehcache;
19 import net.sf.ehcache.cluster.CacheCluster;
20 import net.sf.ehcache.event.CacheEventListener;
21 import net.sf.ehcache.store.Store;
22 import net.sf.ehcache.transaction.SoftLockFactory;
23 import net.sf.ehcache.transaction.TransactionIDFactory;
24 import net.sf.ehcache.writer.writebehind.WriteBehind;
25
26 /***
27 * Factory for creating clustered instances
28 *
29 * @author Tim Eck
30 * @author Geert Bevin
31 * @since 1.7
32 */
33 public interface ClusteredInstanceFactory {
34
35 /***
36 * Create a Store instance for the given cache
37 *
38 * @param cache the cache will backed by the returned store
39 * @return store instance
40 */
41 Store createStore(Ehcache cache);
42
43 /***
44 * Get an api for looking at the clustered node topology.
45 */
46 CacheCluster getTopology();
47
48 /***
49 * Create an WriteBehind instance for the given cache
50 *
51 * @param cache the cache to which the write behind will be tied
52 * @return write behind instance
53 */
54 WriteBehind createWriteBehind(Ehcache cache);
55
56 /***
57 * Create a replicator for the cache events of a given cache
58 *
59 * @param cache the cache to which the replicator will be bound
60 * @return cache event replicator
61 */
62 CacheEventListener createEventReplicator(Ehcache cache);
63
64 /***
65 * Returns a universally unique identifiers for this factory.
66 *
67 * @return the identifier as a string
68 */
69 String getUUID();
70
71 /***
72 * Cleans up any resources left behind after the shutdown of the associated CacheManager
73 */
74 void shutdown();
75
76 /***
77 * Create a TransactionIDFactory
78 * @param clusterUUID a UUID unique to the cluster
79 * @return a TransactionIDFactory
80 */
81 TransactionIDFactory createTransactionIDFactory(String clusterUUID);
82
83 /***
84 * Create a SoftLockFactory for a cache
85 * @param cacheName the cache name for which to create a SoftLockFactory
86 * @return a SoftLockFactory
87 */
88 SoftLockFactory getOrCreateSoftLockFactory(String cacheName);
89 }