Methods Summary |
---|
public void | addDisabledRule(com.sun.enterprise.config.serverbeans.ManagementRule rule)Adds to the list of disabled rules
//pass the invocation to rule manager
String ruleName = rule.getName();
String ruleDescription = rule.getDescription();
rulesManager.addDisabledRule(ruleName, ruleDescription);
|
public void | addRule(com.sun.enterprise.config.serverbeans.ManagementRule rule, com.sun.enterprise.config.ConfigContext ctxToUse)Invokes the rule managers add rule to form the runtime binding
String actionMBeanName = null;
boolean isSkip = false;
String ruleName = rule.getName();
String ruleDescription = rule.getDescription();
try {
final int ATTRIB_COUNT = 3;
com.sun.enterprise.config.serverbeans.Event event = null;
com.sun.enterprise.admin.selfmanagement.event.Event ruleEvent = null;
Map logHandback = new HashMap<String,String>(ATTRIB_COUNT);
_logger.log(Level.INFO, "smgt.service_rule_enabled",
new Object[]{ruleName, ruleDescription});
//getEvent
event = rule.getEvent();
String type = event.getType();
String description = event.getDescription();
logHandback.put(ServerTags.TYPE, type);
logHandback.put(ServerTags.RECORD_EVENT, String.valueOf(event.isRecordEvent()));
logHandback.put(ServerTags.LEVEL,event.getLevel());
//Properties eventProperities = new Properties();
ElementProperty[] eventProps = event.getElementProperty();
/*activate after dependency support provided*/
//Event event = checkEventExists(type, eventProps);
//EventBuilder eventBuilder = EventBuilder.getInstance();
ruleEvent = getEvent(type, eventProps,description, ruleName);
if (ruleEvent == null) {
//skip this rule, errorenous event props
return ;
}
Action ruleAction = rule.getAction();
if (ruleAction != null) {
actionMBeanName = ruleAction.getActionMbeanName();
}
// pass the invocation to the contained core instance
rulesManager.addRule(ruleName, description, ruleEvent,
actionMBeanName, logHandback, ctxToUse);
} catch (InstanceNotFoundException ex) {
_logger.log(Level.INFO, "smgt.internal_error", ex);
}
|
private com.sun.enterprise.admin.selfmanagement.event.Event | checkEventExist(java.lang.String type, com.sun.enterprise.config.serverbeans.ElementProperty[] eventProps)Checks if the event has been already defined for the management
rules.
//pass the invocation to the contained core instance
com.sun.enterprise.admin.selfmanagement.event.Event event =
rulesManager.checkEventExists(type, eventProps);
return event;
|
public void | deleteAction(java.lang.String rule)Deletes an action associated with the configured rule
rulesManager.deleteAction(rule);
|
public void | deleteRule(java.lang.String rule)Deletes a configured rule
//delegate it to the rule manager
rulesManager.deleteRule(rule);
|
private com.sun.enterprise.admin.selfmanagement.event.Event | getEvent(java.lang.String type, com.sun.enterprise.config.serverbeans.ElementProperty[] eventProps, java.lang.String description, java.lang.String ruleName)Obtains the configured event
com.sun.enterprise.admin.selfmanagement.event.Event eventInstance = null;
try {
eventInstance = eventBuilder.getEvent(type, eventProps, description);
} catch( IllegalArgumentException ex) {
// some issue with configuring the event props
_logger.log(Level.INFO, "smgt.errorenous_event", new Object[]
{ruleName, type});
}
return eventInstance;
|
public static com.sun.enterprise.management.selfmanagement.SelfManagementService | getService()Obtain instance to the service
return serviceInstance;
|
public void | handleActionAdd(com.sun.enterprise.config.serverbeans.ManagementRule rule, com.sun.enterprise.config.ConfigContext ctxToUse)Handle Action addition
String ruleName = rule.getName();
String description = rule.getDescription();
Action actionToAdd = rule.getAction();
//Should be the case with validator
if (actionToAdd!=null) {
String actionName = actionToAdd.getActionMbeanName();
//validator?
if (isServiceEnabled && rule.isEnabled()) {
if (actionName!=null) {
rulesManager.addAction(ruleName,actionName,ctxToUse);
}
} else {
_logger.log(Level.INFO, "smgt.erroraddaction_notenabled",
new Object[]{ruleName,actionName});
}
} else {
_logger.log(Level.SEVERE,"smgt.error_add_noactionreceived",
new Object[]{ruleName,description});
throw new RuntimeException();
}
|
public void | handleActionUpdate(com.sun.enterprise.config.serverbeans.ManagementRule rule, com.sun.enterprise.config.ConfigUpdate configUp)Handle Action upate
//not yet supported
|
void | handleEnableService(com.sun.enterprise.config.ConfigContext configCtx)handles the management rules being enabled
try {
Config instanceConfig = ServerBeansFactory.getConfigBean(configCtx);
ManagementRules selfManagementRules = instanceConfig.getManagementRules();
ManagementRule[] rules = selfManagementRules.getManagementRule();
for (ManagementRule rule : rules) {
if (rule.isEnabled()) {
addRule(rule, configCtx);
} else {
addDisabledRule(rule);
}
}
} catch (ConfigException ex) {
_logger.log(Level.WARNING,"sgmt.error_enableservice", ex);
}
|
public void | handleRuleUpdate(com.sun.enterprise.config.serverbeans.ManagementRule rule, com.sun.enterprise.config.ConfigUpdate configUp, com.sun.enterprise.config.ConfigContext ctxToUse)Handle ManagementRule update
//pass on to the delegate
rulesManager.updateRule(rule, configUp, ctxToUse);
|
public void | handleRulesUpdate(com.sun.enterprise.config.ConfigContext cfgCtx, com.sun.enterprise.config.ConfigUpdate configUp)handle Update for parent node - Management Rules
Set<String> attributesChg = configUp.getAttributeSet();
for (String attribute : attributesChg) {
if (attribute.equals(ServerTags.ENABLED)) {
String newValue = configUp.getNewValue(attribute);
if (isServiceEnabled && newValue.equals("false")) {
_logger.log(Level.INFO,"sgmt.disableservice");
synchronized(this) {
isServiceEnabled = false;
rulesManager.disableService();
}
} else if (!isServiceEnabled && newValue.equals("true")) {
_logger.log(Level.INFO,"sgmt.enableservice");
synchronized(this) {
isServiceEnabled = true;
handleEnableService(cfgCtx);
}
}
}
}
|
boolean | isServiceEnabled()
return isServiceEnabled;
|
public void | onInitialization(com.sun.enterprise.server.ServerContext sc)Server is initializing subsystems and setting up the runtime environment.
Prepare for the beginning of active use of the public methods of this
subsystem. This method is called before any of the public methods of
this subsystem are utilized.
/*
*would need support from domain.xml management_rules to support
*service properties.
*/
final String RULES_MAIL_SMTP_HOST = "mail.smtp.host";
final String RULES_ALERT_RECIPIENTS = "rules.recipients";
// initialize the Rules Manager
rulesManager = new RuleManager(this);
eventBuilder = EventBuilder.getInstance();
_logger.log(Level.FINE, "smgt.service_init");
String mailSMTPHost = java.lang.System.getProperty(RULES_MAIL_SMTP_HOST);
String alertRecip = java.lang.System.getProperty(RULES_ALERT_RECIPIENTS);
rulesManager.setMailSMTPHost(mailSMTPHost);
rulesManager.setRecipients(alertRecip);
serviceInstance = this;
_logger.log(Level.FINE, "smgt.service_initialized");
|
public void | onReady(com.sun.enterprise.server.ServerContext sc)Server is starting up applications
try {
ConfigContext instanceConfigContext = sc.getConfigContext();
Config instanceConfig = ServerBeansFactory.getConfigBean(
instanceConfigContext);
ManagementRules selfManagementRules = instanceConfig.getManagementRules();
if ( selfManagementRules != null ) {
if ( selfManagementRules.isEnabled() ) {
_logger.log(Level.INFO, "smgt.service_enabled");
isServiceEnabled = true;
ManagementRule[] rules = selfManagementRules.getManagementRule();
if (rules != null) {
for (int i = 0; i < rules.length; i++) {
ManagementRule rule = rules[i];
String ruleName = rule.getName();
String ruleDescription = rule.getDescription();
//check if rule is enabled then obtain event else skip
if (rule.isEnabled()) {
// statically read ctx is used
addRule(rule,null);
} else {
_logger.log(Level.FINE, "smgt.service_rule_disabled",
new Object[]{ruleName, ruleDescription});
//addDisabledRule(ruleName, ruleDescription);
addDisabledRule(rule);
}
}
} else {
_logger.log(Level.FINE,"smgt.service_no_rules_defined");
}
} else {
_logger.log(Level.INFO,"smgt.service_disabled");
}
} else {
_logger.log(Level.INFO, "smgt.service_not_configured");
}
//activate this after the admin backend support is achieved
AdminEventListenerRegistry.addEventListener(ManagementRuleEvent.eventType,
new ManagementRuleReconfig());
} catch (ConfigException ex) {
//just log, core can still come up, just warn at severe
_logger.log(Level.SEVERE, "smgt.config_error", ex);
//throw new ServerLifeCycleException(ex.getMessage(), ex);
} catch (Exception ex) {
_logger.log(Level.SEVERE, "sgmt.config_error, ex");
}
|
public void | onShutdown()Server is shutting down applications
_logger.log(Level.FINE, "smgt.service_ontermination");
|
public void | onStartup(com.sun.enterprise.server.ServerContext sc)Server has complted loading the applications and is ready to serve requests.
_logger.log(Level.FINE, "smgt.service_onready");
|
public void | onTermination()Server is terminating the subsystems and the runtime environment.
Gracefully terminate the active use of the public methods of this
subsystem. This method should be the last one called on a given
instance of this subsystem.
_logger.log(Level.FINE, "smgt.service_onshutdown");
|