Commit 3d9f6fc5 authored by afreyssin's avatar afreyssin

First release of an OW2/Joram monitoring component as a separate bundle with...

First release of an OW2/Joram monitoring component as a separate bundle with external configuration.
parent 064a23fd
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>joram-tools-monitoring</artifactId>
<packaging>bundle</packaging>
<name>JORAM :: joram :: tools :: monitoring</name>
<description>Builds the Joram Monitoring service bundle.</description>
<parent>
<groupId>org.ow2.joram</groupId>
<artifactId>joram-tools</artifactId>
<version>5.13.0-SNAPSHOT</version>
</parent>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>${maven.bundle.plugin.version}</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Activator>org.ow2.joram.monitoring.Activator</Bundle-Activator>
<Export-Package>org.ow2.joram.monitoring</Export-Package>
<Import-Package>
fr.dyade.aaa.common,
fr.dyade.aaa.common.monitoring,
fr.dyade.aaa.agent,
fr.dyade.aaa.util.management,
org.osgi.framework,
org.objectweb.util.monolog,
org.objectweb.util.monolog.api
</Import-Package>
<!-- <DynamicImport-Package>*</DynamicImport-Package> -->
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.ow2.joram</groupId>
<artifactId>joram-client-jms</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<modules>
</modules>
</project>
\ No newline at end of file
/*
* Copyright (C) 2016 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s): ScalAgent Distributed Technologies
* Contributor(s):
*/
package org.ow2.joram.monitoring;
import org.objectweb.util.monolog.api.BasicLevel;
import org.objectweb.util.monolog.api.Logger;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import fr.dyade.aaa.common.Debug;
public class Activator implements BundleActivator{
public static final Logger logmon = Debug.getLogger(Activator.class.getName());
public static BundleContext context;
public void start(BundleContext context) throws Exception {
Activator.context = context;
try{
Monitoring.init();
}catch(Exception exc){
System.out.println("Monitoring initialization failed ");
System.out.println(exc.toString());
logmon.log(BasicLevel.ERROR, "Monitoring initialization failed", exc);
throw exc;
}
}
public void stop(BundleContext context) throws Exception {
Monitoring.stop();
Activator.context = null;
}
}
/*
* Copyright (C) 2016 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s): ScalAgent Distributed Technologies
* Contributor(s):
*/
package org.ow2.joram.monitoring;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.io.FileInputStream;
import java.util.Timer;
import java.util.Properties;
import org.objectweb.util.monolog.api.BasicLevel;
import org.objectweb.util.monolog.api.Logger;
import fr.dyade.aaa.common.Debug;
import fr.dyade.aaa.agent.AgentServer;
import fr.dyade.aaa.common.monitoring.MonitoringTimerTask;
import fr.dyade.aaa.common.monitoring.FileMonitoringTimerTask;
import fr.dyade.aaa.common.monitoring.LogMonitoringTimerTask;
import fr.dyade.aaa.common.monitoring.WindowMonitoringTimerTask;
import fr.dyade.aaa.util.management.MXWrapper;
public class Monitoring {
public static Logger logger = Debug.getLogger(Monitoring.class.getName());
private static MonitoringTimerTask fileMonitoringTimerTask = null;
private static MonitoringTimerTask logMonitoringTimerTask = null;
private static MonitoringTimerTask windowMonitoringTimerTask = null;
public static String resultPath = null;
/**
* Timer provided by the monitoring.
*/
private static Timer timer;
/**
* Method called by Activator to initialize the monitoring service.
*/
public static void init() throws Exception {
String config = AgentServer.getProperty(FileMonitoringTimerTask.MONITORING_CONFIG_PATH_PROPERTY,
FileMonitoringTimerTask.DEFAULT_MONITORING_CONFIG_PATH);
try {
// if "fileMonitoring.props" file exists configure a FileMonitoringTimerTask.
File file = new File(config);
if (file.exists()) {
long period = AgentServer.getLong(FileMonitoringTimerTask.MONITORING_CONFIG_PERIOD_PROPERTY,
FileMonitoringTimerTask.DEFAULT_MONITORING_CONFIG_PERIOD).longValue();
String results = AgentServer.getProperty(FileMonitoringTimerTask.MONITORING_RESULT_PATH_PROPERTY,
FileMonitoringTimerTask.DEFAULT_MONITORING_RESULT_PATH);
Properties monitoringProps = new Properties();
monitoringProps.load(new FileInputStream(file));
fileMonitoringTimerTask = new FileMonitoringTimerTask(getTimer(), period, monitoringProps, results);
try {
fileMonitoringTimerTask.MBean_name = "server=" + AgentServer.getName() + ",cons=FileMonitoring";
MXWrapper.registerMBean(fileMonitoringTimerTask,
"AgentServer", fileMonitoringTimerTask.MBean_name);
} catch (Exception exc) {
logger.log(BasicLevel.ERROR, AgentServer.getName() + " jmx failed", exc);
}
}
} catch (Exception exc) {
logger.log(BasicLevel.WARN, AgentServer.getName() + " Cannot read monitoring configuration file: " + config, exc);
}
config = AgentServer.getProperty(LogMonitoringTimerTask.MONITORING_CONFIG_PATH_PROPERTY,
LogMonitoringTimerTask.DEFAULT_MONITORING_CONFIG_PATH);
try {
// if "logMonitoring.props" file exists configure a LogMonitoringTimerTask.
File file = new File(config);
if (file.exists()) {
long period = AgentServer.getLong(LogMonitoringTimerTask.MONITORING_CONFIG_PERIOD_PROPERTY,
LogMonitoringTimerTask.DEFAULT_MONITORING_CONFIG_PERIOD).longValue();
String logname = AgentServer.getProperty(LogMonitoringTimerTask.MONITORING_RESULT_LOGGER_PROPERTY,
LogMonitoringTimerTask.DEFAULT_MONITORING_RESULT_LOGGER);
Logger l = Debug.getLogger(logname);
int level = AgentServer.getInteger(LogMonitoringTimerTask.MONITORING_RESULT_LEVEL_PROPERTY,
LogMonitoringTimerTask.DEFAULT_MONITORING_RESULT_LEVEL).intValue();
String msg = AgentServer.getProperty(LogMonitoringTimerTask.MONITORING_RESULT_MESSAGE_PROPERTY,
LogMonitoringTimerTask.DEFAULT_MONITORING_RESULT_MESSAGE);
Properties monitoringProps = new Properties();
monitoringProps.load(new FileInputStream(file));
logMonitoringTimerTask = new LogMonitoringTimerTask(getTimer(), period, monitoringProps, l, msg, level);
try {
logMonitoringTimerTask.MBean_name = "server=" + AgentServer.getName() + ",cons=LogMonitoring";
MXWrapper.registerMBean(logMonitoringTimerTask,
"AgentServer", logMonitoringTimerTask.MBean_name);
} catch (Exception exc) {
logger.log(BasicLevel.ERROR, AgentServer.getName() + " jmx failed", exc);
}
}
} catch (Exception exc) {
logger.log(BasicLevel.WARN, AgentServer.getName() + " Cannot read monitoring configuration file: " + config, exc);
}
config = AgentServer.getProperty(WindowMonitoringTimerTask.MONITORING_CONFIG_PATH_PROPERTY,
WindowMonitoringTimerTask.DEFAULT_MONITORING_CONFIG_PATH);
try {
// if "fileMonitoring.props" file exists configure a FileMonitoringTimerTask.
File file = new File(config);
if (file.exists()) {
long period = AgentServer.getLong(WindowMonitoringTimerTask.MONITORING_CONFIG_PERIOD_PROPERTY,
WindowMonitoringTimerTask.DEFAULT_MONITORING_CONFIG_PERIOD).longValue();
Properties monitoringProps = new Properties();
monitoringProps.load(new FileInputStream(file));
windowMonitoringTimerTask = new WindowMonitoringTimerTask(getTimer(), period, monitoringProps);
try {
windowMonitoringTimerTask.MBean_name = "server=" + AgentServer.getName() + ",cons=WindowMonitoring";
MXWrapper.registerMBean(windowMonitoringTimerTask,
"AgentServer", windowMonitoringTimerTask.MBean_name);
} catch (Exception exc) {
logger.log(BasicLevel.ERROR, AgentServer.getName() + " jmx failed", exc);
}
}
} catch (Exception exc) {
logger.log(BasicLevel.WARN, AgentServer.getName() + " Cannot read monitoring configuration file: " + config, exc);
}
}
/**
* Forces this thread to stop executing.
* This method stops all consumers and services.
*/
public static void stop() throws Exception {
try {
if (fileMonitoringTimerTask != null)
fileMonitoringTimerTask.cancel();
fileMonitoringTimerTask = null;
MXWrapper.unregisterMBean("MonitoringService", fileMonitoringTimerTask.MBean_name);
if (logMonitoringTimerTask != null)
logMonitoringTimerTask.cancel();
logMonitoringTimerTask = null;
MXWrapper.unregisterMBean("MonitoringService", logMonitoringTimerTask.MBean_name);
if (windowMonitoringTimerTask != null)
windowMonitoringTimerTask.cancel();
windowMonitoringTimerTask = null;
MXWrapper.unregisterMBean("MonitoringService", windowMonitoringTimerTask.MBean_name);
if (timer != null)
timer.cancel();
timer = null;
} catch (Throwable t) {
logger.log(BasicLevel.ERROR, "Cannot stop", t);
}
}
/**
* Returns a shared timer provided by the monitoring service.
*/
public static synchronized final Timer getTimer() {
if (timer == null) {
timer = new Timer();
}
return timer;
}
}
Manifest-Version: 1.0
Bnd-LastModified: 1472211710276
Build-Jdk: 1.8.0_65
Built-By: freyssin
Bundle-Activator: org.ow2.joram.monitoring.Activator
Bundle-Description: Builds the Joram Monitoring service bundle.
Bundle-DocURL: http://joram.ow2.org/
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
Bundle-ManifestVersion: 2
Bundle-Name: JORAM :: joram :: tools :: monitoring
Bundle-SymbolicName: joram-tools-monitoring
Bundle-Vendor: ScalAgent D.T.
Bundle-Version: 5.13.0.SNAPSHOT
Created-By: Apache Maven Bundle Plugin
Export-Package: org.ow2.joram.monitoring;uses:="org.osgi.framework,org.o
bjectweb.util.monolog.api,fr.dyade.aaa.common,fr.dyade.aaa.util.managem
ent,fr.dyade.aaa.common.monitoring,fr.dyade.aaa.agent";version="5.13.0.
SNAPSHOT"
Import-Package: fr.dyade.aaa.agent;version="[5.13,6)",fr.dyade.aaa.commo
n;version="[5.13,6)",fr.dyade.aaa.common.monitoring;version="[5.13,6)",
fr.dyade.aaa.util.management;version="[5.13,6)",org.objectweb.util.mono
log,org.objectweb.util.monolog.api,org.osgi.framework;version="[1.8,2)"
Tool: Bnd-1.50.0
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment