1 /* 2 * Copyright (c) 1998-2002 The Jgroup Team. 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License version 2 as 6 * published by the Free Software Foundation. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU Lesser General Public License for more details. 12 * 13 * You should have received a copy of the GNU Lesser General Public License 14 * along with this program; if not, write to the Free Software 15 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 16 * 17 */ 18 19 package jgroup.core.arm; 20 21 import jgroup.relacs.config.AppConfig; 22 import jgroup.relacs.config.Host; 23 import jgroup.relacs.config.HostSet; 24 25 26 /** 27 * The <code>RecoveryStrategy</code> interface provides methods that 28 * must be implemented by a particular recovery service. These methods 29 * will be invoked in response to a corresponding failure event, that 30 * the method intend to rectify. <p> 31 * 32 * All implementations of this interface that are to be used through 33 * the <code>ReplicationManager</code> must implement a no-argument 34 * constructor. Initialization of a particular recovery strategy 35 * should occur in the {@link #initialize(DistributionScheme, AppConfig) initialize} 36 * method. 37 * 38 * @author Hein Meling 39 * @since Jgroup 1.2 40 * @see jgroup.arm.recovery.AbstractRecoveryStrategy 41 * @see jgroup.arm.recovery.KeepMinimalInPartition 42 * @see jgroup.arm.recovery.KeepInitialInPartition 43 */ 44 public interface RecoveryStrategy 45 { 46 47 /** 48 * Initialize the recovery strategy for the given application. 49 */ 50 public void initialize(DistributionScheme distScheme, AppConfig app); 51 52 53 /** 54 * Returns true if the associated application needs a recovery action, 55 * otherwise false is returned. 56 */ 57 public boolean needsRecovery(); 58 59 60 /** 61 * Invoked to initialize the recovery strategy implementation 62 * for the provided application. The method returns true if 63 * the group has failed. 64 */ 65 public boolean prepareRecovery(); 66 67 68 /** 69 * Handle multiple simulatenous failures; this may either be due to 70 * a network partitioning scenario or if several members of the group 71 * failed at the same time. 72 * 73 * FIXME UPDATE DOCUMENTATION: 74 * Invoked in the event that an entire group fails. This particular 75 * type of failure can be characterized as a design failure in most 76 * cases. This can be used by special recovery strategies that are 77 * capable of recovery with different versions of a replica. For 78 * instance if a replica group running version X of the application 79 * software, may be replaced by version Y of the same software, in 80 * case we get a group failure. 81 * 82 * @param hosts 83 * The set of hosts on which the application were running. 84 * 85 * @return 86 * True if recovery was successful; false otherwise. 87 */ 88 public boolean handleFailure(HostSet hosts); 89 90 91 /** 92 * Restart the given replica on the given host. This method differes 93 * from the one below in that it will try to instatiate the replica 94 * on the same host on which the failed replica was running. That is 95 * it will be invoked only when the execution service is still believed 96 * to be available on that host. 97 * 98 * @param host 99 * The host on which the replica was running. 100 * 101 * @return 102 * True if recovery was successful; false otherwise. 103 */ 104 public boolean restartReplica(Host host); 105 106 107 /** 108 * Relocate the application replica that were running on the given 109 * host. The new location should be obtain through the 110 * <code>DistributionScheme</code> provided by the replication 111 * manager. 112 * 113 * @param host 114 * The host on which the replica were running. 115 * 116 * @return 117 * True if recovery was successful; false otherwise. 118 */ 119 public boolean relocateReplica(Host host); 120 121 } // END RecoveryStrategy