• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/ap/gpl/timemachine/db-4.7.25.NC/java/src/com/sleepycat/db/
1/*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 2002,2008 Oracle.  All rights reserved.
5 *
6 * $Id: ReplicationManagerAckPolicy.java,v 12.7 2008/01/17 05:04:53 mjc Exp $
7 */
8
9package com.sleepycat.db;
10
11import com.sleepycat.db.internal.DbConstants;
12
13/**
14A class that provides definitions for the types of network ack policyto use
15when transmitting messages between replication sites using theReplication
16Manager.
17<p>
18Set using the {@link com.sleepycat.db.EnvironmentConfig#setReplicationManagerAckPolicy EnvironmentConfig.setReplicationManagerAckPolicy} API.
19*/
20public final class ReplicationManagerAckPolicy {
21
22    /**
23    The master should wait until all replication clients have acknowledged
24    each permanent replication message.
25    */
26    public static final ReplicationManagerAckPolicy ALL =
27        new ReplicationManagerAckPolicy("ALL", DbConstants.DB_REPMGR_ACKS_ALL);
28
29    /**
30    The master should wait until all electable peers have acknowledged
31    each permanent replication message (where "electable peer" means a
32    client capable of being subsequently elected master of the
33    replication group).
34    */
35    public static final ReplicationManagerAckPolicy ALL_PEERS =
36        new ReplicationManagerAckPolicy(
37        "ALL_PEERS", DbConstants.DB_REPMGR_ACKS_ALL_PEERS);
38
39    /**
40    The master should not wait for any client replication message
41    acknowledgments.
42    */
43    public static final ReplicationManagerAckPolicy NONE =
44        new ReplicationManagerAckPolicy(
45        "NONE", DbConstants.DB_REPMGR_ACKS_NONE);
46
47    /**
48    The master should wait until at least one client site has acknowledged
49    each permanent replication message.
50    */
51    public static final ReplicationManagerAckPolicy ONE =
52        new ReplicationManagerAckPolicy("ONE", DbConstants.DB_REPMGR_ACKS_ONE);
53
54    /**
55    The master should wait until at least one electable peer has acknowledged
56    each permanent replication message (where "electable peer" means a client
57    capable of being subsequently elected master of the replication group).
58    */
59    public static final ReplicationManagerAckPolicy ONE_PEER =
60        new ReplicationManagerAckPolicy(
61            "ONE_PEER", DbConstants.DB_REPMGR_ACKS_ONE_PEER);
62
63    /**
64    The master should wait until it has received acknowledgements from the
65    minimum number of electable peers sufficient to ensure that the effect
66    of the permanent record remains durable if an election is held (where
67    "electable peer" means a client capable of being subsequently elected
68    master of the replication group). This is the default acknowledgement
69    policy.
70    */
71    public static final ReplicationManagerAckPolicy QUORUM =
72        new ReplicationManagerAckPolicy(
73            "QUORUM", DbConstants.DB_REPMGR_ACKS_QUORUM);
74
75    /* package */
76    static ReplicationManagerAckPolicy fromInt(int type) {
77        switch(type) {
78        case DbConstants.DB_REPMGR_ACKS_ALL:
79            return ALL;
80        case DbConstants.DB_REPMGR_ACKS_ALL_PEERS:
81            return ALL_PEERS;
82        case DbConstants.DB_REPMGR_ACKS_NONE:
83            return NONE;
84        case DbConstants.DB_REPMGR_ACKS_ONE:
85            return ONE;
86        case DbConstants.DB_REPMGR_ACKS_ONE_PEER:
87            return ONE_PEER;
88        case DbConstants.DB_REPMGR_ACKS_QUORUM:
89            return QUORUM;
90        default:
91            throw new IllegalArgumentException(
92                "Unknown ACK policy: " + type);
93        }
94    }
95
96    private String statusName;
97    private int id;
98
99    private ReplicationManagerAckPolicy(final String statusName, final int id) {
100        this.statusName = statusName;
101        this.id = id;
102    }
103
104    /* package */
105    int getId() {
106        return id;
107    }
108
109    /** {@inheritDoc} */
110    public String toString() {
111        return "ReplicationManagerAckPolicy." + statusName;
112    }
113}
114
115