• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-WNDR4500-V1.0.1.40_1.0.68/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: ReplicationManagerStartPolicy.java,v 12.9 2008/01/17 05:04:53 mjc Exp $
7 */
8
9package com.sleepycat.db;
10
11import com.sleepycat.db.internal.DbConstants;
12
13/**
14This class provides definitions of the various start policies thatcan be specified when starting a replication client using the{@link com.sleepycat.db.Environment#replicationManagerStart Environment.replicationManagerStart} call.
15*/
16public final class ReplicationManagerStartPolicy {
17
18    /**
19    Start as a master site, and do not call for an election. Note there must
20    never be more than a single master in any replication group, and only one
21    site should ever be started with the DB_REP_MASTER flag specified.
22    */
23    public static final ReplicationManagerStartPolicy REP_MASTER =
24        new ReplicationManagerStartPolicy(
25        "REP_MASTER", DbConstants.DB_REP_MASTER);
26
27    /**
28    Start as a client site, and do not call for an election.
29    */
30    public static final ReplicationManagerStartPolicy REP_CLIENT =
31        new ReplicationManagerStartPolicy(
32        "REP_CLIENT", DbConstants.DB_REP_CLIENT);
33
34    /**
35    Start as a client, and call for an election if no master is found.
36    */
37    public static final ReplicationManagerStartPolicy REP_ELECTION =
38        new ReplicationManagerStartPolicy(
39        "REP_ELECTION", DbConstants.DB_REP_ELECTION);
40
41    /* package */
42    static ReplicationManagerStartPolicy fromInt(int type) {
43        switch(type) {
44        case DbConstants.DB_REP_MASTER:
45            return REP_MASTER;
46        case DbConstants.DB_REP_CLIENT:
47            return REP_CLIENT;
48        case DbConstants.DB_REP_ELECTION:
49            return REP_ELECTION;
50        default:
51            throw new IllegalArgumentException(
52                "Unknown rep start policy: " + type);
53        }
54    }
55
56    private String statusName;
57    private int id;
58
59    private ReplicationManagerStartPolicy(final String statusName,
60        final int id) {
61
62        this.statusName = statusName;
63        this.id = id;
64    }
65
66    /* package */
67    int getId() {
68        return id;
69    }
70
71    /** {@inheritDoc} */
72    public String toString() {
73        return "ReplicationManagerStartPolicy." + statusName;
74    }
75}
76
77