Source code: org/jbossmx/cluster/watchdog/Configuration.java
1 /**
2 * JBoss, the OpenSource EJB server
3 *
4 * Distributable under LGPL license Version 2.1, February 1999.
5 * See terms of license at gnu.org.
6 */
7
8 package org.jbossmx.cluster.watchdog;
9
10 import java.util.Properties;
11
12 import java.rmi.*;
13
14 /**
15 * Class for storing hard coded configuration for Hermes.
16 *
17 * @author Stacy Curl
18 */
19 final public class Configuration
20 {
21 /** The property name which refers to the Jar path the MLet MBean should used to look for MBeans */
22 public static final String MLET_JAR_PATH_PROPERTY = "MLET_JAR_PATH";
23 /** The property name which refers to the MLeRMIt resource location */
24 public static final String MLET_RESOURCE_LOCATION_PROPERTY = "MLET_RESOURCE_LOCATION";
25
26 /** The property name which refers the whether failure in loading / starting System mbeans
27 * is tolerated. A System MBean is HTMLAdaptor server, RMIAdaptorService */
28 public static final String TOLERATE_SYSTEM_MBEAN_FAILURE_PROPERTY =
29 "TOLERATE_SYSTEM_MBEAN_FAILURE";
30 /** The property name which refers the whether failure in loading / starting Custom mbeans
31 * is tolerated */
32 public static final String TOLERATE_CUSTOM_MBEAN_FAILURE_PROPERTY =
33 "TOLERATE_CUSTOM_MBEAN_FAILURE";
34
35 /** The property name which refers to the class that will configure the agent */
36 public static final String AGENT_CONFIGURATOR_CLASS_PROPERTY = "AGENT_CONFIGURATOR_CLASS";
37
38 /** */
39 private static final String DEFAULT_HERMES_DIRECTORY = "/apps/hermes";
40 /** */
41 public static final String HERMES_DIRECTORY_PROPERTY = "HERMES_DIRECTORY";
42
43 /** The root directory of the Hermes deployment */
44 public static final String HERMES_DIRECTORY;
45
46 static
47 {
48 final Properties properties = System.getProperties();
49 HERMES_DIRECTORY = properties.getProperty(HERMES_DIRECTORY_PROPERTY,
50 DEFAULT_HERMES_DIRECTORY);
51 }
52
53 /** The directory in which Hermes configuration is stored */
54 public static final String HERMES_CONFIG_DIRECTORY = HERMES_DIRECTORY + "/config";
55
56 /** The location of the file which stores the machines the JMX Agents are running on */
57 public static final String MACHINE_PROPERTIES = HERMES_CONFIG_DIRECTORY + "/machine.properties";
58
59 /** */
60 private static final String ACTIVE_AGENT = "ActiveAgent";
61 /** */
62 private static final String FAILOVER_AGENT = "FailoverAgent";
63 /** */
64 private static final String COMPONENT_AGENT = "ComponentAgent";
65
66 /** The RMI Binding of the {@link SwapMachines} remote interface */
67 private static final String SWAPMACHINES = "SwapMachines";
68
69 /**
70 * @param projectName
71 *
72 * @return
73 */
74 public static final String getRmiActiveAgent(String projectName)
75 {
76 return "/" + getRmiProjectPrefix(projectName) + ACTIVE_AGENT;
77 }
78
79 /**
80 * @param projectName
81 *
82 * @return
83 */
84 public static final String getRmiFailoverAgent(String projectName)
85 {
86 return "/" + getRmiProjectPrefix(projectName) + FAILOVER_AGENT;
87 }
88
89 /**
90 * @param projectName
91 *
92 * @return
93 */
94 public static final String getRmiComponentAgent(String projectName)
95 {
96 return "/" + getRmiProjectPrefix(projectName) + COMPONENT_AGENT;
97 }
98
99 /**
100 * @param projectName
101 *
102 * @return
103 */
104 public static final String getRmiSwapMachines(String projectName)
105 {
106 return "/" + getRmiProjectPrefix(projectName) + SWAPMACHINES;
107 }
108
109 /**
110 * @param projectName
111 *
112 * @return
113 */
114 private static final String getRmiProjectPrefix(String projectName)
115 {
116 return ((projectName != null) && (projectName.length() != 0))
117 ? (projectName + "-")
118 : "";
119 }
120
121 /** Default Active Machine property name in MACHINE_PROPERTIES */
122 public static final String DEFAULT_ACTIVE_MACHINE_PROPERTY = "DefaultActiveMachine";
123 /** Default Failover Machine property name in MACHINE_PROPERTIES */
124 public static final String DEFAULT_FAILOVER_MACHINE_PROPERTY = "DefaultFailoverMachine";
125
126 /** The Default machine on which to perform Active monitoring */
127 private static final String DEFAULT_ACTIVE_MACHINE = "hugin";
128 /** The Default machine to failover to */
129 private static final String DEFAULT_FAILOVER_MACHINE = "munin";
130 }