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.rep;
9 
10 import java.util.concurrent.TimeUnit;
11 
12 import com.sleepycat.je.ReplicaConsistencyPolicy;
13 import com.sleepycat.je.dbi.EnvironmentImpl;
14 
15 /**
16  * A consistency policy that lets a transaction on a replica using this policy
17  * proceed regardless of the state of the Replica relative to the Master. It
18  * can also be used to access a database when a replication node is in a
19  * DETACHED state.
20  * <p>
21  * Consistency policies are specified at either a per-transaction level through
22  * {@link com.sleepycat.je.TransactionConfig#setConsistencyPolicy} or as an
23  * replication node wide default through {@link
24  * com.sleepycat.je.rep.ReplicationConfig#setConsistencyPolicy}
25  *
26  * @see <a href="{@docRoot}/../ReplicationGuide/consistency.html"
27  * target="_top">Managing Consistency</a>
28  */
29 public class NoConsistencyRequiredPolicy implements ReplicaConsistencyPolicy {
30 
31     /**
32      * The name:{@value} associated with this policy. The name can be used when
33      * constructing policy property values for use in je.properties files.
34      */
35     public static final String NAME = "NoConsistencyRequiredPolicy";
36 
37     /**
38      * Convenience instance.
39      */
40     public final static NoConsistencyRequiredPolicy NO_CONSISTENCY =
41         new NoConsistencyRequiredPolicy();
42 
43     /**
44      * Create a NoConsistencyRequiredPolicy.
45      */
NoConsistencyRequiredPolicy()46     public NoConsistencyRequiredPolicy() {
47     }
48 
49     /**
50      * Returns the name:{@value #NAME}, associated with this policy.
51      * @see #NAME
52      */
53     @Override
getName()54     public String getName() {
55         return NAME;
56     }
57 
58     @Override
59     @SuppressWarnings("unused")
ensureConsistency(EnvironmentImpl repInstance)60     public void ensureConsistency(EnvironmentImpl repInstance) {
61         /* Nothing to check. */
62         return;
63     }
64 
65     /**
66      */
67     @Override
hashCode()68     public int hashCode() {
69         final int prime = 31;
70         int result = 1;
71         result = prime * result;
72         return result;
73     }
74 
75     /**
76      */
77     @Override
equals(Object obj)78     public boolean equals(Object obj) {
79         if (this == obj) {
80             return true;
81         }
82         if (obj == null) {
83             return false;
84         }
85         if (!(obj instanceof NoConsistencyRequiredPolicy)) {
86             return false;
87         }
88         return true;
89     }
90 
91     /**
92      * Always returns 0, no timeout is needed for this policy.
93      */
94     @Override
getTimeout(@uppressWarningsR) TimeUnit unit)95     public long getTimeout(@SuppressWarnings("unused") TimeUnit unit) {
96         return 0;
97     }
98 }
99