1/*- 2 * See the file LICENSE for redistribution information. 3 * 4 * Copyright (c) 2001,2008 Oracle. All rights reserved. 5 * 6 * $Id: ReplicationTransport.java,v 12.9 2008/05/06 03:46:31 sarette Exp $ 7 */ 8package com.sleepycat.db; 9 10import com.sleepycat.db.internal.DbConstants; 11 12/** 13An interface specifying a replication transmit function, which sends 14information to other members of the replication group. 15*/ 16public interface ReplicationTransport { 17 /** 18 The callback used when Berkeley DB needs to transmit a replication message. 19 This method must not call back down into Berkeley DB. It must return 0 on 20 success and non-zero on failure. If the transmission fails, the message 21 being sent is necessary to maintain database integrity, and the local log 22 is not configured for synchronous flushing, the local log will be flushed; 23 otherwise, any error from the function will be ignored. 24 <p> 25 @param environment 26 The enclosing database environment handle. 27 <p> 28 @param control 29 The first of the two data elements to be transmitted. 30 <p> 31 @param rec 32 The second of the two data elements to be transmitted. 33 <p> 34 @param lsn 35 If the type of message to be sent has an LSN associated with it, 36 then the lsn contains the LSN of the record being sent. This LSN 37 can be used to determine that certain records have been processed 38 successfully by clients. 39 <p> 40 @param envid 41 A positive integer identifier that specifies the replication 42 environment to which the message should be sent. 43 <p> 44 The value DB_EID_BROADCAST indicates that a message should be 45 broadcast to every environment in the replication group. The 46 application may use a true broadcast protocol or may send the 47 message in sequence to each machine with which it is in 48 communication. In both cases, the sending site should not be asked 49 to process the message. 50 <p> 51 @param noBuffer 52 The record being sent should be transmitted immediately and not buffered 53 or delayed. 54 <p> 55 @param permanent 56 The record being sent is critical for maintaining database integrity 57 (for example, the message includes a transaction commit). The 58 application should take appropriate action to enforce the reliability 59 guarantees it has chosen, such as waiting for acknowledgement from one 60 or more clients. 61 <p> 62 @param anywhere 63 The message is a client request that can be satisfied by another client as 64 well as by the master. 65 <p> 66 @param isRetry 67 The message is a client request that has already been made and to which no 68 response was received. 69 <p> 70 @throws DatabaseException if a failure occurs. 71 */ 72 int send(Environment environment, DatabaseEntry control, DatabaseEntry rec, 73 LogSequenceNumber lsn, int envid, boolean noBuffer, 74 boolean permanent, boolean anywhere, boolean isRetry) 75 throws DatabaseException; 76 77 /** 78 A message that should be broadcast to every environment in the 79 replication group. The application may use a true broadcast protocol or 80 may send the message in sequence to each machine with which it is in 81 communication. In both cases, the sending site should not be asked to 82 process the message. 83 */ 84 int EID_BROADCAST = DbConstants.DB_EID_BROADCAST; 85 86 /** 87 An invalid environment ID, and may be used to initialize environment ID 88 variables that are subsequently checked for validity. 89 */ 90 int EID_INVALID = DbConstants.DB_EID_INVALID; 91} 92