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.core.MergingListener; 22 import jgroup.core.View; 23 import jgroup.relacs.config.AppConfig; 24 import jgroup.relacs.config.Host; 25 import jgroup.relacs.config.HostSet; 26 27 28 /** 29 * The <code>DistributionScheme</code> interface provides a standard 30 * for implementing various distribution schemes that simplify 31 * interaction with the <code>ReplicationManager</code>. 32 * 33 * @author Hein Meling 34 * @since Jgroup 1.2 35 */ 36 public interface DistributionScheme 37 extends MergingListener 38 { 39 40 //////////////////////////////////////////////////////////////////////////////////////////// 41 // Methods related to replica distribution 42 //////////////////////////////////////////////////////////////////////////////////////////// 43 44 /** 45 * Assign the host location for the specified application. The 46 * <code>AppConfig</code> object also contains the required redundancy. 47 * 48 * @param app 49 * An <code>AppConfig</code> object specifying the class parameters 50 * and redundancy requirements, and group identifier. 51 * @return 52 * A <code>HostSet</code> specifying the locations where the replicas 53 * should be created. 54 * @exception RedundancyException 55 * Is raised if the specified redundancy could not be satisfied. 56 * @exception GroupExistsException 57 * Raised if the specified application group already exists (has been 58 * assigned to some hostset). 59 */ 60 public HostSet assignReplicas(AppConfig app) 61 throws RedundancyException, GroupExistsException; 62 63 64 /** 65 * Remove replica assignments for the specified application. 66 * 67 * @param app 68 * An <code>AppConfig</code> object specifying the class parameters 69 * and redundancy requirements, and group identifier. 70 * @return 71 * A <code>HostSet</code> specifying the locations where the replicas 72 * was located prior to the remove. 73 */ 74 public HostSet removeReplicas(AppConfig app) 75 throws UnknownGroupException; 76 77 78 public HostSet collocateReplicas(AppConfig app, AppConfig collocateWithApp) 79 throws GroupExistsException, RedundancyException, UnknownGroupException; 80 81 82 /** 83 * Reassign the application replica running on the specified host. 84 * 85 * @param app 86 * The application group to which the replica belongs. 87 * @param host 88 * The host from which to remove the replica. 89 * @return 90 * The host on which a new replica should be created. 91 * @exception UnknownGroupException 92 * The given application group is unknown. 93 * @exception RedundancyException 94 * Raised if the system could not reassign the replica to any host 95 * in the system. 96 */ 97 public Host reassignReplica(AppConfig app, Host host) 98 throws UnknownGroupException, RedundancyException; 99 100 101 /** 102 * Update the distribution scheme according to the specified view 103 * for the given application. 104 * <P> 105 * Note that the method behavior should be idempotent. 106 */ 107 public void viewChangeEvent(View view); 108 109 } // END DistributionScheme