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.arm.recovery;
20
21 import jgroup.relacs.config.AppConfig;
22
23 import org.apache.log4j.Logger;
24
25
26 /**
27 * If the current number of replicas drops below the initial redundancy
28 * specified for this replica, and the number of available hosts in
29 * this partition is greater than the initial redundancy then create
30 * new replicas to compensate for the lost redundancy.
31 *
32 * @author Hein Meling
33 * @since Jgroup 1.2
34 */
35 public class KeepInitialInPartition
36 extends KeepMinimalInPartition
37 {
38
39 ////////////////////////////////////////////////////////////////////////////////////////////
40 // Logger
41 ////////////////////////////////////////////////////////////////////////////////////////////
42
43 /** Obtain logger for this class */
44 private static final Logger log = Logger.getLogger(KeepInitialInPartition.class);
45
46
47 ////////////////////////////////////////////////////////////////////////////////////////////
48 // Helper methods
49 ////////////////////////////////////////////////////////////////////////////////////////////
50
51 /**
52 * Returns the number of replicas that needs to be recovered to
53 * maintain the initial redundancy level specified. If no recovery
54 * is needed, zero is returned.
55 */
56 protected int deltaRedundancy(AppConfig app)
57 {
58 int delta = app.getInitialRedundancy() - app.getCurrentGroupSize();
59 return (delta >= 0) ? delta : 0;
60 }
61
62 } // END KeepInitialInPartition