1/*- 2 * See the file LICENSE for redistribution information. 3 * 4 * Copyright (c) 2002-2009 Oracle. All rights reserved. 5 * 6 * $Id$ 7 */ 8 9package com.sleepycat.db; 10 11import com.sleepycat.db.internal.DbConstants; 12 13/** 14The ReplicationTimeoutType defines the types of timeouts that can beconfigured for the Berkeley Db replication functionality. 15<p> 16The class is used in the {@link com.sleepycat.db.Environment#setReplicationTimeout Environment.setReplicationTimeout}method. 17*/ 18public final class ReplicationTimeoutType { 19 20 /** 21 Configure the amount of time the replication manager's transport function 22 waits to collect enough acknowledgments from replication group clients, 23 before giving up and returning a failure indication. 24 */ 25 public static final ReplicationTimeoutType ACK_TIMEOUT = 26 new ReplicationTimeoutType("ACK_TIMEOUT", DbConstants.DB_REP_ACK_TIMEOUT); 27 28 /** 29 Configure the amount of time the replication manager will delay between 30 completing a checkpoint and writing a checkpoint record into the log. This 31 delay allows clients to complete their own checkpoints before the master 32 requires completion of them. The default is 30 seconds. 33 */ 34 public static final ReplicationTimeoutType CHECKPOINT_DELAY = 35 new ReplicationTimeoutType("CHECKPOINT_DELAY", DbConstants.DB_REP_CHECKPOINT_DELAY); 36 37 /** 38 Configure the amount of time the replication manager will wait before 39 trying to re-establish a connection to another site after a 40 communication failure. 41 */ 42 public static final ReplicationTimeoutType CONNECTION_RETRY = 43 new ReplicationTimeoutType("CONNECTION_RETRY", DbConstants.DB_REP_CONNECTION_RETRY); 44 45 /** 46 The timeout period for an election. 47 */ 48 public static final ReplicationTimeoutType ELECTION_TIMEOUT = 49 new ReplicationTimeoutType("ELECTION_TIMEOUT", DbConstants.DB_REP_ELECTION_TIMEOUT); 50 51 /** 52 Configure the amount of time the replication manager will wait before 53 retrying a failed election. 54 */ 55 public static final ReplicationTimeoutType ELECTION_RETRY = 56 new ReplicationTimeoutType("ELECTION_RETRY", DbConstants.DB_REP_ELECTION_RETRY); 57 58 /** 59 The amount of time the replication manager, running at a client site, 60 waits for some message activity on the connection from the master 61 (heartbeats or other messages) before concluding that the connection 62 has been lost. When 0 (the default), no monitoring is performed. 63 */ 64 public static final ReplicationTimeoutType HEARTBEAT_MONITOR = 65 new ReplicationTimeoutType("HEARTBEAT_MONITOR", DbConstants.DB_REP_HEARTBEAT_MONITOR); 66 67 /** 68 The frequency at which the replication manager, running at a master site, 69 broadcasts a heartbeat message in an otherwise idle system. When 0 70 (the default), no heartbeat messages will be sent. 71 */ 72 public static final ReplicationTimeoutType HEARTBEAT_SEND = 73 new ReplicationTimeoutType("HEARTBEAT_SEND", DbConstants.DB_REP_HEARTBEAT_SEND); 74 75 /** 76 An optional configuration timeout period to wait for full election 77 participation the first time the replication group finds a master. By 78 default this option is turned off and normal election timeouts are used. 79 (See the 80 <a href="{@docRoot}/../programmer_reference/rep_elect.html">Elections</a> 81 section in the Berkeley DB Reference Guide for more information.) 82 */ 83 public static final ReplicationTimeoutType FULL_ELECTION_TIMEOUT = 84 new ReplicationTimeoutType("FULL_ELECTION_TIMEOUT", DbConstants.DB_REP_FULL_ELECTION_TIMEOUT); 85 86 /* package */ 87 static ReplicationTimeoutType fromInt(int type) { 88 switch(type) { 89 case DbConstants.DB_REP_ACK_TIMEOUT: 90 return ACK_TIMEOUT; 91 case DbConstants.DB_REP_ELECTION_TIMEOUT: 92 return ELECTION_TIMEOUT; 93 case DbConstants.DB_REP_ELECTION_RETRY: 94 return ELECTION_RETRY; 95 case DbConstants.DB_REP_CONNECTION_RETRY: 96 return CONNECTION_RETRY; 97 default: 98 throw new IllegalArgumentException( 99 "Unknown timeout type: " + type); 100 } 101 } 102 103 private String statusName; 104 private int id; 105 106 private ReplicationTimeoutType(final String statusName, final int id) { 107 this.statusName = statusName; 108 this.id = id; 109 } 110 111 /* package */ 112 int getId() { 113 return id; 114 } 115 116 /** {@inheritDoc} */ 117 public String toString() { 118 return "ReplicationTimeoutType." + statusName; 119 } 120} 121