use of org.apache.geode.management.ManagementException in project geode by apache.
the class ManagementAgent method stopAgent.
public synchronized void stopAgent() {
stopHttpService();
if (!this.running) {
return;
}
if (logger.isDebugEnabled()) {
logger.debug("Stopping jmx manager agent");
}
try {
jmxConnectorServer.stop();
UnicastRemoteObject.unexportObject(registry, true);
} catch (Exception e) {
throw new ManagementException(e);
}
this.running = false;
}
use of org.apache.geode.management.ManagementException in project geode by apache.
the class ManagementAgent method startHttpService.
private void startHttpService(boolean isServer) {
final SystemManagementService managementService = (SystemManagementService) ManagementService.getManagementService(CacheFactory.getAnyInstance());
final ManagerMXBean managerBean = managementService.getManagerMXBean();
if (this.config.getHttpServicePort() != 0) {
if (logger.isDebugEnabled()) {
logger.debug("Attempting to start HTTP service on port ({}) at bind-address ({})...", this.config.getHttpServicePort(), this.config.getHttpServiceBindAddress());
}
// Find the Management WAR file
final String gemfireWar = agentUtil.findWarLocation("geode-web");
if (gemfireWar == null) {
if (logger.isDebugEnabled()) {
logger.debug("Unable to find GemFire Management REST API WAR file; the Management REST Interface for GemFire will not be accessible.");
}
}
// Find the Pulse WAR file
final String pulseWar = agentUtil.findWarLocation("geode-pulse");
if (pulseWar == null) {
final String message = "Unable to find Pulse web application WAR file; Pulse for GemFire will not be accessible";
setStatusMessage(managerBean, message);
if (logger.isDebugEnabled()) {
logger.debug(message);
}
} else if (securityService.isIntegratedSecurity()) {
System.setProperty("spring.profiles.active", "pulse.authentication.gemfire");
}
// Find developer REST WAR file
final String gemfireAPIWar = agentUtil.findWarLocation("geode-web-api");
if (gemfireAPIWar == null) {
final String message = "Unable to find GemFire Developer REST API WAR file; the Developer REST Interface for GemFire will not be accessible.";
setStatusMessage(managerBean, message);
if (logger.isDebugEnabled()) {
logger.debug(message);
}
}
try {
if (agentUtil.isWebApplicationAvailable(gemfireWar, pulseWar, gemfireAPIWar)) {
final String bindAddress = this.config.getHttpServiceBindAddress();
final int port = this.config.getHttpServicePort();
boolean isRestWebAppAdded = false;
this.httpServer = JettyHelper.initJetty(bindAddress, port, SSLConfigurationFactory.getSSLConfigForComponent(SecurableCommunicationChannel.WEB));
if (agentUtil.isWebApplicationAvailable(gemfireWar)) {
this.httpServer = JettyHelper.addWebApplication(this.httpServer, "/gemfire", gemfireWar);
this.httpServer = JettyHelper.addWebApplication(this.httpServer, "/geode-mgmt", gemfireWar);
}
if (agentUtil.isWebApplicationAvailable(pulseWar)) {
this.httpServer = JettyHelper.addWebApplication(this.httpServer, "/pulse", pulseWar);
}
if (isServer && this.config.getStartDevRestApi()) {
if (agentUtil.isWebApplicationAvailable(gemfireAPIWar)) {
this.httpServer = JettyHelper.addWebApplication(this.httpServer, "/geode", gemfireAPIWar);
this.httpServer = JettyHelper.addWebApplication(this.httpServer, "/gemfire-api", gemfireAPIWar);
isRestWebAppAdded = true;
}
} else {
final String message = "Developer REST API web application will not start when start-dev-rest-api is not set and node is not server";
setStatusMessage(managerBean, message);
if (logger.isDebugEnabled()) {
logger.debug(message);
}
}
if (logger.isDebugEnabled()) {
logger.debug("Starting HTTP embedded server on port ({}) at bind-address ({})...", ((ServerConnector) this.httpServer.getConnectors()[0]).getPort(), bindAddress);
}
System.setProperty(PULSE_EMBEDDED_PROP, "true");
System.setProperty(PULSE_PORT_PROP, "" + config.getJmxManagerPort());
final SocketCreator jmxSocketCreator = SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.JMX);
final SocketCreator locatorSocketCreator = SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR);
System.setProperty(PULSE_USESSL_MANAGER, jmxSocketCreator.useSSL() + "");
System.setProperty(PULSE_USESSL_LOCATOR, locatorSocketCreator.useSSL() + "");
this.httpServer = JettyHelper.startJetty(this.httpServer);
// clients to connect to Pulse
if (agentUtil.isWebApplicationAvailable(pulseWar)) {
managerBean.setPulseURL("http://".concat(getHost(bindAddress)).concat(":").concat(String.valueOf(port)).concat("/pulse/"));
}
// set cache property for developer REST service running
if (isRestWebAppAdded) {
InternalCache cache = (InternalCache) CacheFactory.getAnyInstance();
cache.setRESTServiceRunning(true);
// create region to hold query information (queryId, queryString).
// Added for the developer REST APIs
RestAgent.createParameterizedQueryRegion();
}
// set true for HTTP service running
setHttpServiceRunning(true);
}
} catch (Exception e) {
// Jetty needs to be stopped even if it has failed to
stopHttpService();
// start. Some of the threads are left behind even if
// server.start() fails due to an exception
setStatusMessage(managerBean, "HTTP service failed to start with " + e.getClass().getSimpleName() + " '" + e.getMessage() + "'");
throw new ManagementException("HTTP service failed to start", e);
}
} else {
setStatusMessage(managerBean, "Embedded HTTP server configured not to start (http-service-port=0) or (jmx-manager-http-port=0)");
}
}
use of org.apache.geode.management.ManagementException in project geode by apache.
the class MBeanJMXAdapter method unregisterAll.
/**
* Method to unregister all the local GemFire MBeans
*
*/
public void unregisterAll() {
try {
ObjectName name = new ObjectName(OBJECTNAME__PREFIX + "*");
Set<ObjectName> gemFireObjects = mbeanServer.queryNames(name, null);
for (ObjectName objectName : gemFireObjects) {
unregisterMBean(objectName);
}
} catch (MalformedObjectNameException e) {
throw new ManagementException(e);
} catch (NullPointerException e) {
throw new ManagementException(e);
}
}
use of org.apache.geode.management.ManagementException in project geode by apache.
the class FederationComponent method refreshObjectState.
/**
* This method will get called from Management Thread. This will dynamically invoke the MBeans
* getter methods and set them in ObjectState Map.
*
* In Future releases we can implement the delta propagation here
*
* @return true if the refresh detects that the state changed. It will return false if two
* consecutive refresh calls results in no state change. This indicates to the
* LocalManager whether to send the MBean state to Manager or not.
* @throws ManagementException
*/
public boolean refreshObjectState(boolean keepOldState) {
boolean changeDetected = false;
Object[] args = null;
if (keepOldState) {
oldObjectState.putAll(objectState);
}
for (Map.Entry<String, Method> gettorMethodEntry : getterMethodMap.entrySet()) {
String property = gettorMethodEntry.getKey();
Object propertyValue = null;
try {
Method m = gettorMethodEntry.getValue();
propertyValue = m.invoke(mbeanObject, args);
// To Handle open types in getter values
OpenMethod op = methodHandlerMap.get(m);
propertyValue = op.toOpenReturnValue(propertyValue);
} catch (Exception e) {
propertyValue = null;
if (logger.isTraceEnabled()) {
logger.trace(e.getMessage());
}
}
Object oldValue = objectState.put(property, propertyValue);
if (!changeDetected) {
if (propertyValue != null) {
if (!propertyValue.equals(oldValue)) {
changeDetected = true;
}
} else {
// new value is null
if (oldValue != null) {
changeDetected = true;
}
}
}
}
boolean retVal = prevRefreshChangeDetected || changeDetected;
prevRefreshChangeDetected = changeDetected;
return retVal;
}
use of org.apache.geode.management.ManagementException in project geode by apache.
the class FederatingManager method startManager.
/**
* This method will be invoked whenever a member wants to be a managing node. The exception
* Management exception has to be handled by the caller.
*/
@Override
public synchronized void startManager() {
try {
if (logger.isDebugEnabled()) {
logger.debug("Starting the Federating Manager.... ");
}
Runtime rt = Runtime.getRuntime();
this.pooledMembershipExecutor = Executors.newFixedThreadPool(rt.availableProcessors());
running = true;
startManagingActivity();
messenger.broadcastManagerInfo();
} catch (InterruptedException e) {
running = false;
throw new ManagementException(e);
} catch (Exception e) {
running = false;
throw new ManagementException(e);
}
}
Aggregations