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 package com.sleepycat.je.rep;
8 
9 /**
10  * The different types of nodes that can be in a replication group.
11  */
12 public enum NodeType {
13 
14     /**
15      * A node that passively listens for the results of elections, but does not
16      * participate in them. It does not have a replicated environment
17      * associated with it.
18      * @see com.sleepycat.je.rep.monitor.Monitor
19      */
20     MONITOR {
21         @Override
isMonitor()22         public boolean isMonitor() {
23             return true;
24         }
25     },
26 
27     /**
28      * A full fledged member of the replication group with an associated
29      * replicated environment that can serve as both a Master and a Replica.
30      */
31     ELECTABLE {
32         @Override
isElectable()33         public boolean isElectable() {
34             return true;
35         }
36         @Override
isDataNode()37         public boolean isDataNode() {
38             return true;
39         }
40     },
41 
42     /**
43      * A member of the replication group with an associated replicated
44      * environment that serves as a Replica but does not participate in
45      * elections or durability decisions.  Secondary nodes are only remembered
46      * by the group while they maintain contact with the Master.
47      *
48      * <p>You can use SECONDARY nodes to:
49      * <ul>
50      * <li>Provide a copy of the data available at a distant location
51      * <li>Maintain an extra copy of the data to increase redundancy
52      * <li>Change the number of replicas to adjust to dynamically changing read
53      *     loads
54      * </ul>
55      *
56      * @since 6.0
57      */
58     SECONDARY {
59         @Override
isSecondary()60         public boolean isSecondary() {
61             return true;
62         }
63         @Override
isDataNode()64         public boolean isDataNode() {
65             return true;
66         }
67     };
68 
69     /**
70      * Returns whether this is the {@link #MONITOR} type.
71      *
72      * @return whether this is {@code MONITOR}
73      * @since 6.0
74      */
isMonitor()75     public boolean isMonitor() {
76         return false;
77     }
78 
79     /**
80      * Returns whether this is the {@link #ELECTABLE} type.
81      *
82      * @return whether this is {@code ELECTABLE}
83      * @since 6.0
84      */
isElectable()85     public boolean isElectable() {
86         return false;
87     }
88 
89     /**
90      * Returns whether this is the {@link #SECONDARY} type.
91      *
92      * @return whether this is {@code SECONDARY}
93      * @since 6.0
94      */
isSecondary()95     public boolean isSecondary() {
96         return false;
97     }
98 
99     /**
100      * Returns whether this type represents a data node, either {@link
101      * #ELECTABLE} or {@link #SECONDARY}.
102      *
103      * @return whether this represents a data node
104      * @since 6.0
105      */
isDataNode()106     public boolean isDataNode() {
107         return false;
108     }
109 }
110