1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 2002, 2014 Oracle and/or its affiliates.  All rights reserved.
5  *
6  */
7 
8 package com.sleepycat.je;
9 
10 import java.util.concurrent.TimeUnit;
11 
12 import com.sleepycat.je.dbi.EnvironmentImpl;
13 
14 /**
15  * The interface for Consistency policies used to provide consistency
16  * guarantees at a Replica. ReplicaConsistencyPolicies are only used by
17  * Berkeley DB JE High Availability.
18  * <p>
19  * A transaction initiated at a Replica will wait in
20  * the {@link com.sleepycat.je.Environment#beginTransaction} method until the
21  * consistency policy is satisfied.
22  * Consistency policies are specified at either a per-transaction level through
23  * {@link TransactionConfig#setConsistencyPolicy} or as an replication node
24  * wide default through {@link
25  * com.sleepycat.je.rep.ReplicationConfig#setConsistencyPolicy}
26  *
27  * @see <a href="{@docRoot}/../ReplicationGuide/consistency.html"
28  * target="_top">Managing Consistency</a>
29  */
30 public interface ReplicaConsistencyPolicy {
31 
32     /**
33      * @hidden
34      * For internal use only.
35      *
36      * Ensures that the replica is within the constraints specified by this
37      * policy. If it isn't the method waits until the constraint is satisfied
38      * by the replica.
39      *
40      * @param repInstance identifies the replicated environment that must meet
41      * this consistency requirement.
42      */
ensureConsistency(EnvironmentImpl repInstance)43     public void ensureConsistency(EnvironmentImpl repInstance)
44         throws InterruptedException;
45 
46     /**
47      * Returns the name used to identify the policy. The name is used when
48      * constructing policy property values for use in je.properties files.
49      */
getName()50     public String getName();
51 
52     /**
53      * The timeout associated with the consistency policy. If consistency
54      * cannot be established by the Replica within the timeout period, a {@link
55      * com.sleepycat.je.rep.ReplicaConsistencyException} is thrown by {@link
56      * com.sleepycat.je.Environment#beginTransaction}.
57      *
58      * @return the timeout associated with the policy
59      */
getTimeout(TimeUnit unit)60     public long getTimeout(TimeUnit unit);
61 }
62