1 /* 2 Copyright 2008 Ramon Servadei 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 package fulmine.distribution; 17 18 /** 19 * Encapsulates operations for setting network heartbeat parameters. 20 * 21 * @author Ramon Servadei 22 */ 23 public interface IHeartbeatMonitor 24 { 25 /** The default heartbeat period */ 26 long DEFAULT_HEARTBEAT_PERIOD = 5000; 27 28 /** The default number of allowed missed heartbeats */ 29 int DEFAULT_ALLOWED_MISSED_COUNT = 4; 30 31 /** 32 * Set the network heartbeat period. This local context will send out a 33 * heartbeat ping message onto the network at this rate. 34 * <p> 35 * As a general rule-of-thumb, the heartbeat period should be small and the 36 * allowed heartbeat miss count high. This provides more leniency for not 37 * cancelling a context if heartbeats are missed. 38 * 39 * @param periodInMillis 40 * the heartbeat period in milliseconds 41 */ 42 void setNetworkHeartbeatPeriod(long periodInMillis); 43 44 /** 45 * Set the allowable number of missed heartbeats from other contexts on the 46 * network before that context is deemed to be not available anymore. 47 * 48 * @see #setNetworkHeartbeatPeriod(long) 49 * @param allowedHeartbeatMissCount 50 * the number of missed heartbeats allowed before a remote 51 * context is deemed to be not available 52 */ 53 void setAllowableNetworkHeartbeatMissCount(int allowedHeartbeatMissCount); 54 55 /** 56 * Get the heartbeat period in milliseconds. 57 * 58 * @return the heartbeat period in milliseconds 59 */ 60 long getNetworkHeartbeatPeriod(); 61 62 /** 63 * Get the number of allowed missed heartbeats before a remote context is 64 * deemed to be not available. 65 * 66 * @return the number of missed heartbeats allowed before a remote context 67 * is deemed to be not available 68 */ 69 int getAllowableNetworkHeartbeatMissCount(); 70 }