Initial prometheus monitoring impl
diff --git a/dev-tools/ansible/inventories/scigap/develop/group_vars/all/vars.yml b/dev-tools/ansible/inventories/scigap/develop/group_vars/all/vars.yml
index aef6f0d..b792304 100644
--- a/dev-tools/ansible/inventories/scigap/develop/group_vars/all/vars.yml
+++ b/dev-tools/ansible/inventories/scigap/develop/group_vars/all/vars.yml
@@ -182,6 +182,22 @@
usage_reporting_key: "{{ vault_usage_reporting_key }}"
+participant_monitoring_enabled: true
+participant_monitoring_host: "0.0.0.0"
+participant_monitoring_port: 9096
+
+pre_workflow_manager_monitoring_enabled: true
+pre_workflow_manager_monitoring_host: "0.0.0.0"
+pre_workflow_manager_monitoring_port: 9093
+
+post_workflow_manager_monitoring_enabled: true
+post_workflow_manager_monitoring_host: "0.0.0.0"
+post_workflow_manager_monitoring_port: 9094
+
+parser_workflow_manager_monitoring_enabled: true
+parser_workflow_manager_monitoring_host: "0.0.0.0"
+parser_workflow_manager_monitoring_port: 9095
+
# Subnet definitions
iu_subnets:
- "149.163.0.0/16"
diff --git a/dev-tools/ansible/inventories/scigap/production/group_vars/all/vars.yml b/dev-tools/ansible/inventories/scigap/production/group_vars/all/vars.yml
index 96bdd65..970d70c 100644
--- a/dev-tools/ansible/inventories/scigap/production/group_vars/all/vars.yml
+++ b/dev-tools/ansible/inventories/scigap/production/group_vars/all/vars.yml
@@ -185,6 +185,22 @@
usage_reporting_key: "{{ vault_usage_reporting_key }}"
+participant_monitoring_enabled: true
+participant_monitoring_host: "0.0.0.0"
+participant_monitoring_port: 9096
+
+pre_workflow_manager_monitoring_enabled: true
+pre_workflow_manager_monitoring_host: "0.0.0.0"
+pre_workflow_manager_monitoring_port: 9093
+
+post_workflow_manager_monitoring_enabled: true
+post_workflow_manager_monitoring_host: "0.0.0.0"
+post_workflow_manager_monitoring_port: 9094
+
+parser_workflow_manager_monitoring_enabled: true
+parser_workflow_manager_monitoring_host: "0.0.0.0"
+parser_workflow_manager_monitoring_port: 9095
+
# Subnet definitions
iu_subnets:
- "149.163.0.0/16"
diff --git a/dev-tools/ansible/roles/helix_setup/tasks/main.yml b/dev-tools/ansible/roles/helix_setup/tasks/main.yml
index 8d827b2..e677ebb 100644
--- a/dev-tools/ansible/roles/helix_setup/tasks/main.yml
+++ b/dev-tools/ansible/roles/helix_setup/tasks/main.yml
@@ -136,6 +136,50 @@
- { command: ./bin/post-wm-daemon.sh start, dir: "{{ helix_post_wm_version }}" }
- { command: ./bin/parser-wm-daemon.sh start, dir: "{{ helix_parser_wm_version }}" }
+- name: Openning Participant Monitoring Port
+ firewalld:
+ zone: public
+ permanent: yes
+ state: enabled
+ immediate: yes
+ rich_rule: rule family=ipv4 source address="{{ item }}" port port="{{ participant_monitoring_port }}" protocol=tcp accept
+ with_items:
+ - "{{ zk_subnets }}"
+ become: yes
+
+- name: Openning Pre Workflow Manager Monitoring Port
+ firewalld:
+ zone: public
+ permanent: yes
+ state: enabled
+ immediate: yes
+ rich_rule: rule family=ipv4 source address="{{ item }}" port port="{{ pre_workflow_manager_monitoring_port }}" protocol=tcp accept
+ with_items:
+ - "{{ zk_subnets }}"
+ become: yes
+
+- name: Openning Post Workflow Manager Monitoring Port
+ firewalld:
+ zone: public
+ permanent: yes
+ state: enabled
+ immediate: yes
+ rich_rule: rule family=ipv4 source address="{{ item }}" port port="{{ post_workflow_manager_monitoring_port }}" protocol=tcp accept
+ with_items:
+ - "{{ zk_subnets }}"
+ become: yes
+
+- name: Openning Parser Workflow Manager Monitoring Port
+ firewalld:
+ zone: public
+ permanent: yes
+ state: enabled
+ immediate: yes
+ rich_rule: rule family=ipv4 source address="{{ item }}" port port="{{ parser_workflow_manager_monitoring_port }}" protocol=tcp accept
+ with_items:
+ - "{{ zk_subnets }}"
+ become: yes
+
#- name: systemd install helix setup service scripts
# template: src={{ item.template }}
# dest=/usr/lib/systemd/system/{{ item.service }}
diff --git a/dev-tools/ansible/roles/helix_setup/templates/parser-wm/airavata-server.properties.j2 b/dev-tools/ansible/roles/helix_setup/templates/parser-wm/airavata-server.properties.j2
index afb4a5d..5f86f6b 100644
--- a/dev-tools/ansible/roles/helix_setup/templates/parser-wm/airavata-server.properties.j2
+++ b/dev-tools/ansible/roles/helix_setup/templates/parser-wm/airavata-server.properties.j2
@@ -65,3 +65,10 @@
###########################################################################
thrift.client.pool.abandoned.removal.enabled={{ thrift_client_pool_abandoned_removal_enabled }}
thrift.client.pool.abandoned.removal.logged={{ thrift_client_pool_abandoned_removal_logged }}
+
+###########################################################################
+# Platform Monitoring Configuration
+###########################################################################
+parser.workflow.manager.monitoring.enabled={{ parser_workflow_manager_monitoring_enabled }}
+parser.workflow.manager.monitoring.host={{ parser_workflow_manager_monitoring_host }}
+parser.workflow.manager.monitoring.port={{ parser_workflow_manager_monitoring_port }}
\ No newline at end of file
diff --git a/dev-tools/ansible/roles/helix_setup/templates/participant/airavata-server.properties.j2 b/dev-tools/ansible/roles/helix_setup/templates/participant/airavata-server.properties.j2
index 5f842b5..0473df1 100644
--- a/dev-tools/ansible/roles/helix_setup/templates/participant/airavata-server.properties.j2
+++ b/dev-tools/ansible/roles/helix_setup/templates/participant/airavata-server.properties.j2
@@ -106,4 +106,11 @@
###########################################################################
usage.reporting.key={{ usage_reporting_key }}
-usage.reporting.endpoint=https://xsede-xdcdb-api.xsede.org/gateway/v2/job_attributes
\ No newline at end of file
+usage.reporting.endpoint=https://xsede-xdcdb-api.xsede.org/gateway/v2/job_attributes
+
+###########################################################################
+# Platform Monitoring Configuration
+###########################################################################
+participant.monitoring.enabled={{ participant_monitoring_enabled }}
+participant.monitoring.host={{ participant_monitoring_host }}
+participant.monitoring.port={{ participant_monitoring_port }}
\ No newline at end of file
diff --git a/dev-tools/ansible/roles/helix_setup/templates/post-wm/airavata-server.properties.j2 b/dev-tools/ansible/roles/helix_setup/templates/post-wm/airavata-server.properties.j2
index 33cb199..b7fd434 100644
--- a/dev-tools/ansible/roles/helix_setup/templates/post-wm/airavata-server.properties.j2
+++ b/dev-tools/ansible/roles/helix_setup/templates/post-wm/airavata-server.properties.j2
@@ -59,3 +59,10 @@
###########################################################################
thrift.client.pool.abandoned.removal.enabled={{ thrift_client_pool_abandoned_removal_enabled }}
thrift.client.pool.abandoned.removal.logged={{ thrift_client_pool_abandoned_removal_logged }}
+
+###########################################################################
+# Platform Monitoring Configuration
+###########################################################################
+post.workflow.manager.monitoring.enabled={{ post_workflow_manager_monitoring_enabled }}
+post.workflow.manager.monitoring.host={{ post_workflow_manager_monitoring_host }}
+post.workflow.manager.monitoring.port={{ post_workflow_manager_monitoring_port }}
\ No newline at end of file
diff --git a/dev-tools/ansible/roles/helix_setup/templates/pre-wm/airavata-server.properties.j2 b/dev-tools/ansible/roles/helix_setup/templates/pre-wm/airavata-server.properties.j2
index e854e8c..610f0fb 100644
--- a/dev-tools/ansible/roles/helix_setup/templates/pre-wm/airavata-server.properties.j2
+++ b/dev-tools/ansible/roles/helix_setup/templates/pre-wm/airavata-server.properties.j2
@@ -56,3 +56,10 @@
###########################################################################
thrift.client.pool.abandoned.removal.enabled={{ thrift_client_pool_abandoned_removal_enabled }}
thrift.client.pool.abandoned.removal.logged={{ thrift_client_pool_abandoned_removal_logged }}
+
+###########################################################################
+# Platform Monitoring Configuration
+###########################################################################
+pre.workflow.manager.monitoring.enabled={{ pre_workflow_manager_monitoring_enabled }}
+pre.workflow.manager.monitoring.host={{ pre_workflow_manager_monitoring_host }}
+pre.workflow.manager.monitoring.port={{ pre_workflow_manager_monitoring_port }}
\ No newline at end of file
diff --git a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/participant/GlobalParticipant.java b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/participant/GlobalParticipant.java
index ce1372a..fb439f4 100644
--- a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/participant/GlobalParticipant.java
+++ b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/participant/GlobalParticipant.java
@@ -20,8 +20,10 @@
package org.apache.airavata.helix.impl.participant;
import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.ServerSettings;
import org.apache.airavata.helix.core.AbstractTask;
import org.apache.airavata.helix.core.participant.HelixParticipant;
+import org.apache.airavata.patform.monitoring.MonitoringServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -75,6 +77,15 @@
taskClasses.add(Class.forName(taskClassName).asSubclass(AbstractTask.class));
}
+ if (ServerSettings.getBooleanSetting("participant.monitoring.enabled")) {
+ MonitoringServer monitoringServer = new MonitoringServer(
+ ServerSettings.getSetting("participant.monitoring.host"),
+ ServerSettings.getIntSetting("participant.monitoring.port"));
+ monitoringServer.start();
+
+ Runtime.getRuntime().addShutdownHook(new Thread(monitoringServer::stop));
+ }
+
GlobalParticipant participant = new GlobalParticipant(taskClasses, null);
participant.startServer();
diff --git a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/env/EnvSetupTask.java b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/env/EnvSetupTask.java
index d6b00c5..03a35ea 100644
--- a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/env/EnvSetupTask.java
+++ b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/env/EnvSetupTask.java
@@ -25,6 +25,7 @@
import org.apache.airavata.helix.task.api.TaskHelper;
import org.apache.airavata.helix.task.api.annotation.TaskDef;
import org.apache.airavata.model.status.ProcessState;
+import org.apache.airavata.patform.monitoring.CountMonitor;
import org.apache.helix.task.TaskResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -33,10 +34,12 @@
public class EnvSetupTask extends AiravataTask {
private final static Logger logger = LoggerFactory.getLogger(EnvSetupTask.class);
+ private final static CountMonitor envSetupTaskCounter = new CountMonitor("env_setup_task_counter");
@Override
public TaskResult onRun(TaskHelper taskHelper, TaskContext taskContext) {
try {
+ envSetupTaskCounter.inc();
saveAndPublishProcessStatus(ProcessState.CONFIGURING_WORKSPACE);
AgentAdaptor adaptor = taskHelper.getAdaptorSupport().fetchAdaptor(
getTaskContext().getGatewayId(),
diff --git a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/parsing/DataParsingTask.java b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/parsing/DataParsingTask.java
index b290f16..09cfb57 100644
--- a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/parsing/DataParsingTask.java
+++ b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/parsing/DataParsingTask.java
@@ -58,6 +58,7 @@
import org.apache.airavata.model.data.replica.DataReplicaLocationModel;
import org.apache.airavata.model.data.replica.ReplicaLocationCategory;
import org.apache.airavata.model.data.replica.ReplicaPersistentType;
+import org.apache.airavata.patform.monitoring.CountMonitor;
import org.apache.airavata.registry.api.RegistryService;
import org.apache.airavata.registry.api.client.RegistryServiceClientFactory;
import org.apache.airavata.registry.api.exception.RegistryServiceException;
@@ -85,6 +86,7 @@
public class DataParsingTask extends AbstractTask {
private final static Logger logger = LoggerFactory.getLogger(DataParsingTask.class);
+ private final static CountMonitor parsingTaskCounter = new CountMonitor("parsing_task_counter");
@TaskParam(name = "Parser Id")
private String parserId;
@@ -107,7 +109,7 @@
@Override
public TaskResult onRun(TaskHelper helper) {
logger.info("Starting data parsing task " + getTaskId());
-
+ parsingTaskCounter.inc();
try {
Parser parser = getRegistryServiceClient().getParser(parserId, gatewayId);
diff --git a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/staging/ArchiveTask.java b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/staging/ArchiveTask.java
index 7d4ffa0..141bb2a 100644
--- a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/staging/ArchiveTask.java
+++ b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/staging/ArchiveTask.java
@@ -27,6 +27,7 @@
import org.apache.airavata.helix.task.api.annotation.TaskDef;
import org.apache.airavata.model.status.ProcessState;
import org.apache.airavata.model.task.DataStagingTaskModel;
+import org.apache.airavata.patform.monitoring.CountMonitor;
import org.apache.helix.task.TaskResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -40,10 +41,13 @@
private final static Logger logger = LoggerFactory.getLogger(ArchiveTask.class);
private final static long MAX_ARCHIVE_SIZE = 1024L * 1024L * 1024L * 20L; // 20GB
+ private final static CountMonitor archiveTaskCounter = new CountMonitor("archive_task_counter");
+
@Override
public TaskResult onRun(TaskHelper taskHelper, TaskContext taskContext) {
logger.info("Starting archival task " + getTaskId() + " in experiment " + getExperimentId());
+ archiveTaskCounter.inc();
saveAndPublishProcessStatus(ProcessState.OUTPUT_DATA_STAGING);
try {
diff --git a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/staging/DataStagingTask.java b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/staging/DataStagingTask.java
index 9258dd0..1df76a2 100644
--- a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/staging/DataStagingTask.java
+++ b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/staging/DataStagingTask.java
@@ -31,6 +31,7 @@
import org.apache.airavata.helix.task.api.support.AdaptorSupport;
import org.apache.airavata.model.appcatalog.storageresource.StorageResourceDescription;
import org.apache.airavata.model.task.DataStagingTaskModel;
+import org.apache.airavata.patform.monitoring.CountMonitor;
import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -47,6 +48,7 @@
public abstract class DataStagingTask extends AiravataTask {
private final static Logger logger = LoggerFactory.getLogger(DataStagingTask.class);
+ private final static CountMonitor transferSizeTaskCounter = new CountMonitor("transfer_data_size_counter");
private final static ExecutorService PASS_THROUGH_EXECUTOR =
new ThreadPoolExecutor(10, 60, 0L, TimeUnit.MILLISECONDS,
@@ -162,6 +164,8 @@
throw new TaskOnFailException("Local file does not exist at " + tempFile, false, null);
}
+ transferSizeTaskCounter.inc(localFile.length());
+
try {
logger.info("Uploading file form local temp file " + tempFile + " to " + destFile);
destAdaptor.uploadFile(tempFile, destFile);
diff --git a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/staging/InputDataStagingTask.java b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/staging/InputDataStagingTask.java
index e7e9010..7c329c6 100644
--- a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/staging/InputDataStagingTask.java
+++ b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/staging/InputDataStagingTask.java
@@ -29,6 +29,7 @@
import org.apache.airavata.model.application.io.InputDataObjectType;
import org.apache.airavata.model.status.ProcessState;
import org.apache.airavata.model.task.DataStagingTaskModel;
+import org.apache.airavata.patform.monitoring.CountMonitor;
import org.apache.helix.task.TaskResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -40,11 +41,14 @@
public class InputDataStagingTask extends DataStagingTask {
private final static Logger logger = LoggerFactory.getLogger(InputDataStagingTask.class);
+ private final static CountMonitor inputDSTaskCounter = new CountMonitor("input_ds_task_counter");
@Override
public TaskResult onRun(TaskHelper taskHelper, TaskContext taskContext) {
logger.info("Starting Input Data Staging Task " + getTaskId());
+ inputDSTaskCounter.inc();
+
saveAndPublishProcessStatus(ProcessState.INPUT_DATA_STAGING);
try {
diff --git a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/staging/OutputDataStagingTask.java b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/staging/OutputDataStagingTask.java
index a5d9d74..4419250 100644
--- a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/staging/OutputDataStagingTask.java
+++ b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/staging/OutputDataStagingTask.java
@@ -31,6 +31,7 @@
import org.apache.airavata.model.application.io.OutputDataObjectType;
import org.apache.airavata.model.status.ProcessState;
import org.apache.airavata.model.task.DataStagingTaskModel;
+import org.apache.airavata.patform.monitoring.CountMonitor;
import org.apache.helix.task.TaskResult;
import org.apache.thrift.TException;
import org.slf4j.Logger;
@@ -48,11 +49,13 @@
public class OutputDataStagingTask extends DataStagingTask {
private final static Logger logger = LoggerFactory.getLogger(OutputDataStagingTask.class);
+ private final static CountMonitor outputDSTaskCounter = new CountMonitor("output_ds_task_counter");
@Override
public TaskResult onRun(TaskHelper taskHelper, TaskContext taskContext) {
logger.info("Starting output data staging task " + getTaskId() + " in experiment " + getExperimentId());
+ outputDSTaskCounter.inc();
saveAndPublishProcessStatus(ProcessState.OUTPUT_DATA_STAGING);
try {
diff --git a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/submission/DefaultJobSubmissionTask.java b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/submission/DefaultJobSubmissionTask.java
index ae02bb5..4a76e1d 100644
--- a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/submission/DefaultJobSubmissionTask.java
+++ b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/task/submission/DefaultJobSubmissionTask.java
@@ -32,6 +32,7 @@
import org.apache.airavata.model.job.JobModel;
import org.apache.airavata.model.status.*;
import org.apache.airavata.model.workspace.GatewayUsageReportingCommand;
+import org.apache.airavata.patform.monitoring.CountMonitor;
import org.apache.helix.task.TaskResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -46,12 +47,14 @@
public class DefaultJobSubmissionTask extends JobSubmissionTask {
private final static Logger logger = LoggerFactory.getLogger(DefaultJobSubmissionTask.class);
+ private final static CountMonitor defaultJSTaskCounter = new CountMonitor("default_js_task_counter");
private static final String DEFAULT_JOB_ID = "DEFAULT_JOB_ID";
@Override
public TaskResult onRun(TaskHelper taskHelper, TaskContext taskContext) {
+ defaultJSTaskCounter.inc();
String jobId = null;
AgentAdaptor adaptor;
diff --git a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/workflow/ParserWorkflowManager.java b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/workflow/ParserWorkflowManager.java
index 772206c..1646ee1 100644
--- a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/workflow/ParserWorkflowManager.java
+++ b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/workflow/ParserWorkflowManager.java
@@ -35,6 +35,8 @@
import org.apache.airavata.model.application.io.OutputDataObjectType;
import org.apache.airavata.model.experiment.ExperimentModel;
import org.apache.airavata.model.process.ProcessModel;
+import org.apache.airavata.patform.monitoring.CountMonitor;
+import org.apache.airavata.patform.monitoring.MonitoringServer;
import org.apache.airavata.registry.api.RegistryService;
import org.apache.kafka.clients.consumer.*;
import org.apache.kafka.common.TopicPartition;
@@ -54,6 +56,7 @@
public class ParserWorkflowManager extends WorkflowManager {
private final static Logger logger = LoggerFactory.getLogger(ParserWorkflowManager.class);
+ private final static CountMonitor parserwfCounter = new CountMonitor("parser_wf_counter");
private String parserStorageResourceId = ServerSettings.getSetting("parser.storage.resource.id");
@@ -63,6 +66,16 @@
}
public static void main(String[] args) throws Exception {
+
+ if (ServerSettings.getBooleanSetting("parser.workflow.manager.monitoring.enabled")) {
+ MonitoringServer monitoringServer = new MonitoringServer(
+ ServerSettings.getSetting("parser.workflow.manager.monitoring.host"),
+ ServerSettings.getIntSetting("parser.workflow.manager.monitoring.port"));
+ monitoringServer.start();
+
+ Runtime.getRuntime().addShutdownHook(new Thread(monitoringServer::stop));
+ }
+
ParserWorkflowManager manager = new ParserWorkflowManager();
manager.init();
manager.runConsumer();
@@ -162,6 +175,7 @@
// TODO: figure out processId and register
// registerWorkflowForProcess(processId, workflow, "PARSER");
logger.info("Launched workflow " + workflow);
+ parserwfCounter.inc();
}
getRegistryClientPool().returnResource(registryClient);
diff --git a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/workflow/PostWorkflowManager.java b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/workflow/PostWorkflowManager.java
index f3b9dea..7008b98 100644
--- a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/workflow/PostWorkflowManager.java
+++ b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/workflow/PostWorkflowManager.java
@@ -47,6 +47,8 @@
import org.apache.airavata.model.task.DataStagingTaskModel;
import org.apache.airavata.model.task.TaskModel;
import org.apache.airavata.model.task.TaskTypes;
+import org.apache.airavata.patform.monitoring.CountMonitor;
+import org.apache.airavata.patform.monitoring.MonitoringServer;
import org.apache.airavata.registry.api.RegistryService;
import org.apache.kafka.clients.consumer.*;
import org.apache.kafka.common.TopicPartition;
@@ -61,6 +63,7 @@
public class PostWorkflowManager extends WorkflowManager {
private final static Logger logger = LoggerFactory.getLogger(PostWorkflowManager.class);
+ private final static CountMonitor postwfCounter = new CountMonitor("post_wf_counter");
private ExecutorService processingPool = Executors.newFixedThreadPool(10);
@@ -198,6 +201,7 @@
private void executePostWorkflow(String processId, String gateway, boolean forceRun) throws Exception {
+ postwfCounter.inc();
RegistryService.Client registryClient = getRegistryClientPool().getResource();
ProcessModel processModel;
@@ -388,6 +392,15 @@
public static void main(String[] args) throws Exception {
+ if (ServerSettings.getBooleanSetting("post.workflow.manager.monitoring.enabled")) {
+ MonitoringServer monitoringServer = new MonitoringServer(
+ ServerSettings.getSetting("post.workflow.manager.monitoring.host"),
+ ServerSettings.getIntSetting("post.workflow.manager.monitoring.port"));
+ monitoringServer.start();
+
+ Runtime.getRuntime().addShutdownHook(new Thread(monitoringServer::stop));
+ }
+
PostWorkflowManager postManager = new PostWorkflowManager();
postManager.startServer();
}
diff --git a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/workflow/PreWorkflowManager.java b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/workflow/PreWorkflowManager.java
index 9423854..3bb4c81 100644
--- a/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/workflow/PreWorkflowManager.java
+++ b/modules/airavata-helix/helix-spectator/src/main/java/org/apache/airavata/helix/impl/workflow/PreWorkflowManager.java
@@ -41,6 +41,8 @@
import org.apache.airavata.model.status.ProcessStatus;
import org.apache.airavata.model.task.TaskModel;
import org.apache.airavata.model.task.TaskTypes;
+import org.apache.airavata.patform.monitoring.CountMonitor;
+import org.apache.airavata.patform.monitoring.MonitoringServer;
import org.apache.airavata.registry.api.RegistryService;
import org.apache.thrift.TBase;
import org.apache.thrift.TException;
@@ -53,6 +55,7 @@
public class PreWorkflowManager extends WorkflowManager {
private final static Logger logger = LoggerFactory.getLogger(PreWorkflowManager.class);
+ private final static CountMonitor prewfCounter = new CountMonitor("pre_wf_counter");
private Subscriber subscriber;
@@ -78,6 +81,7 @@
private String createAndLaunchPreWorkflow(String processId, boolean forceRun) throws Exception {
+ prewfCounter.inc();
RegistryService.Client registryClient = getRegistryClientPool().getResource();
ProcessModel processModel;
@@ -216,6 +220,16 @@
}
public static void main(String[] args) throws Exception {
+
+ if (ServerSettings.getBooleanSetting("pre.workflow.manager.monitoring.enabled")) {
+ MonitoringServer monitoringServer = new MonitoringServer(
+ ServerSettings.getSetting("pre.workflow.manager.monitoring.host"),
+ ServerSettings.getIntSetting("pre.workflow.manager.monitoring.port"));
+ monitoringServer.start();
+
+ Runtime.getRuntime().addShutdownHook(new Thread(monitoringServer::stop));
+ }
+
PreWorkflowManager preWorkflowManager = new PreWorkflowManager();
preWorkflowManager.startServer();
}
diff --git a/modules/airavata-helix/platform-monitor/pom.xml b/modules/airavata-helix/platform-monitor/pom.xml
deleted file mode 100644
index 9b850c0..0000000
--- a/modules/airavata-helix/platform-monitor/pom.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?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/xsd/maven-4.0.0.xsd">
- <parent>
- <artifactId>airavata-helix</artifactId>
- <groupId>org.apache.airavata</groupId>
- <version>0.20-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>platform-monitor</artifactId>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.airavata</groupId>
- <artifactId>helix-spectator</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>javax.mail</groupId>
- <artifactId>mail</artifactId>
- <version>1.4</version>
- </dependency>
- </dependencies>
-</project>
diff --git a/modules/airavata-helix/platform-monitor/src/main/java/org/apache/airavata/helix/cluster/monitoring/ErrorNotifier.java b/modules/airavata-helix/platform-monitor/src/main/java/org/apache/airavata/helix/cluster/monitoring/ErrorNotifier.java
deleted file mode 100644
index 0293d5b..0000000
--- a/modules/airavata-helix/platform-monitor/src/main/java/org/apache/airavata/helix/cluster/monitoring/ErrorNotifier.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package org.apache.airavata.helix.cluster.monitoring;
-
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.commons.lang.exception.ExceptionUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Properties;
-import javax.mail.*;
-import javax.mail.internet.InternetAddress;
-import javax.mail.internet.MimeMessage;
-
-public class ErrorNotifier {
-
- private final static Logger logger = LoggerFactory.getLogger(ErrorNotifier.class);
-
- public void sendNotification(PlatformMonitorError monitorError) {
- if (monitorError.getError() == null) {
- logger.error("Monitor error " + monitorError.getReason());
- } else {
- logger.error("Monitor error " + monitorError.getReason(), monitorError.getError());
- }
- sendEmail(monitorError);
- }
-
- private void sendEmail(PlatformMonitorError monitorError) {
-
- try {
-
- String username = ServerSettings.getSetting("sender.email.account");
- String password = ServerSettings.getSetting("sender.email.password");
- String targetEmails = ServerSettings.getSetting("target.email.accounts");
-
- Properties props = new Properties();
- props.put("mail.smtp.auth", "true");
- props.put("mail.smtp.starttls.enable", "true");
- props.put("mail.smtp.host", "smtp.gmail.com");
- props.put("mail.smtp.port", "587");
-
- String[] targetEmailArr = targetEmails.split(",");
-
- for (String targetEmail : targetEmailArr) {
- Session session = Session.getInstance(props,
- new javax.mail.Authenticator() {
- protected PasswordAuthentication getPasswordAuthentication() {
- return new PasswordAuthentication(username, password);
- }
- });
-
- Message message = new MimeMessage(session);
- message.setFrom(new InternetAddress(username));
- message.setRecipients(Message.RecipientType.TO,
- InternetAddress.parse(targetEmail));
- message.setSubject("Possible issue in " + ServerSettings.getSetting("platform.name"));
- message.setText(monitorError.getReason() + "\n" + "Error code " + monitorError.getErrorCode() + "\n" +
- (monitorError.getError() != null ? ExceptionUtils.getFullStackTrace(monitorError.getError()) : ""));
-
- Transport.send(message);
-
- logger.info("Sent notification email to " + targetEmail);
- }
-
- } catch (Exception e) {
- logger.error("Failed to send email", e);
- }
- }
-}
diff --git a/modules/airavata-helix/platform-monitor/src/main/java/org/apache/airavata/helix/cluster/monitoring/MainMonitor.java b/modules/airavata-helix/platform-monitor/src/main/java/org/apache/airavata/helix/cluster/monitoring/MainMonitor.java
deleted file mode 100644
index 7b02f02..0000000
--- a/modules/airavata-helix/platform-monitor/src/main/java/org/apache/airavata/helix/cluster/monitoring/MainMonitor.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package org.apache.airavata.helix.cluster.monitoring;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.helix.cluster.monitoring.agents.*;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-public class MainMonitor {
-
- private final static Logger logger = LoggerFactory.getLogger(MainMonitor.class);
-
- public static void main(String args[]) throws Exception {
-
- logger.info("Starting platform monitor");
-
- List<PlatformMonitor> platformMonitors = Arrays.asList(new ApiServerMonitor(),
- new DbMonitor(), new HelixControllerMonitor(),
- new HelixParticipantMonitor(), new ZookeeperMonitor());
-
- ErrorNotifier errorNotifier = new ErrorNotifier();
-
- for (PlatformMonitor monitor : platformMonitors) {
- ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
- executorService.scheduleWithFixedDelay(() -> monitor.monitor(errorNotifier), 0,
- Integer.parseInt(ServerSettings.getSetting("platform_monitor_interval_minutes")),
- TimeUnit.MINUTES);
- }
- }
-}
\ No newline at end of file
diff --git a/modules/airavata-helix/platform-monitor/src/main/java/org/apache/airavata/helix/cluster/monitoring/PlatformMonitor.java b/modules/airavata-helix/platform-monitor/src/main/java/org/apache/airavata/helix/cluster/monitoring/PlatformMonitor.java
deleted file mode 100644
index ee9e1b6..0000000
--- a/modules/airavata-helix/platform-monitor/src/main/java/org/apache/airavata/helix/cluster/monitoring/PlatformMonitor.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.apache.airavata.helix.cluster.monitoring;
-
-public interface PlatformMonitor {
- public void monitor(ErrorNotifier notifier);
-}
diff --git a/modules/airavata-helix/platform-monitor/src/main/java/org/apache/airavata/helix/cluster/monitoring/PlatformMonitorError.java b/modules/airavata-helix/platform-monitor/src/main/java/org/apache/airavata/helix/cluster/monitoring/PlatformMonitorError.java
deleted file mode 100644
index 076d8b9..0000000
--- a/modules/airavata-helix/platform-monitor/src/main/java/org/apache/airavata/helix/cluster/monitoring/PlatformMonitorError.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package org.apache.airavata.helix.cluster.monitoring;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class PlatformMonitorError {
-
- private final static Logger logger = LoggerFactory.getLogger(PlatformMonitorError.class);
-
- private String reason;
- private String errorCode;
- private String category;
- private Throwable error;
-
- public String getReason() {
- return reason;
- }
-
- public void setReason(String reason) {
- this.reason = reason;
- }
-
- public String getErrorCode() {
- return errorCode;
- }
-
- public void setErrorCode(String errorCode) {
- this.errorCode = errorCode;
- }
-
- public String getCategory() {
- return category;
- }
-
- public void setCategory(String category) {
- this.category = category;
- }
-
- public Throwable getError() {
- return error;
- }
-
- public void setError(Throwable error) {
- this.error = error;
- }
-}
\ No newline at end of file
diff --git a/modules/airavata-helix/platform-monitor/src/main/java/org/apache/airavata/helix/cluster/monitoring/agents/ApiServerMonitor.java b/modules/airavata-helix/platform-monitor/src/main/java/org/apache/airavata/helix/cluster/monitoring/agents/ApiServerMonitor.java
deleted file mode 100644
index 6dc301b..0000000
--- a/modules/airavata-helix/platform-monitor/src/main/java/org/apache/airavata/helix/cluster/monitoring/agents/ApiServerMonitor.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package org.apache.airavata.helix.cluster.monitoring.agents;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.helix.cluster.monitoring.ErrorNotifier;
-import org.apache.airavata.helix.cluster.monitoring.PlatformMonitor;
-import org.apache.airavata.helix.cluster.monitoring.PlatformMonitorError;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.net.Socket;
-
-public class ApiServerMonitor implements PlatformMonitor {
-
- private final static Logger logger = LoggerFactory.getLogger(PlatformMonitor.class);
-
- private String apiServerHost =ServerSettings.getSetting("api.server.host");
- private String apiServerPort = ServerSettings.getSetting("api.server.port");
-
- public ApiServerMonitor() throws ApplicationSettingsException {
- }
-
- public void monitor(ErrorNotifier notifier) {
-
- logger.info("Monitoring API Server started");
- Socket s = null;
-
- try {
- s = new Socket(apiServerHost, Integer.parseInt(apiServerPort));
- } catch (IOException e) {
- PlatformMonitorError monitorError = new PlatformMonitorError();
- monitorError.setError(e);
- monitorError.setReason("Could not establish a connection with Api Server " + apiServerHost + ":" + apiServerPort);
- monitorError.setCategory("ApiServer");
- monitorError.setCategory("AS001");
- notifier.sendNotification(monitorError);
- } finally {
- if(s != null)
- try {s.close();}
- catch(Exception ignored){}
- }
-
- logger.info("Monitoring API Server finished");
-
- }
-}
diff --git a/modules/airavata-helix/platform-monitor/src/main/java/org/apache/airavata/helix/cluster/monitoring/agents/DbMonitor.java b/modules/airavata-helix/platform-monitor/src/main/java/org/apache/airavata/helix/cluster/monitoring/agents/DbMonitor.java
deleted file mode 100644
index 4d71216..0000000
--- a/modules/airavata-helix/platform-monitor/src/main/java/org/apache/airavata/helix/cluster/monitoring/agents/DbMonitor.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.apache.airavata.helix.cluster.monitoring.agents;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.helix.cluster.monitoring.ErrorNotifier;
-import org.apache.airavata.helix.cluster.monitoring.PlatformMonitor;
-import org.apache.airavata.helix.cluster.monitoring.PlatformMonitorError;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.net.Socket;
-
-public class DbMonitor implements PlatformMonitor {
-
- private final static Logger logger = LoggerFactory.getLogger(DbMonitor.class);
-
- private String dbServerHost = ServerSettings.getSetting("database.host");
- private String dbPort = ServerSettings.getSetting("database.port");
-
- public DbMonitor() throws ApplicationSettingsException {
- }
-
- public void monitor(ErrorNotifier notifier) {
-
- logger.info("Monitoring Database Server started");
-
- Socket s = null;
-
- try {
- s = new Socket(dbServerHost, Integer.parseInt(dbPort));
- } catch (IOException e) {
- PlatformMonitorError monitorError = new PlatformMonitorError();
- monitorError.setError(e);
- monitorError.setReason("Could not establish a connection with Database " + dbServerHost + ":" + dbPort);
- monitorError.setCategory("Database");
- monitorError.setCategory("DB001");
- notifier.sendNotification(monitorError);
- } finally {
- if(s != null)
- try {s.close();}
- catch(Exception ignored){}
- }
-
- logger.info("Monitoring Database Server finished");
-
- }
-}
diff --git a/modules/airavata-helix/platform-monitor/src/main/java/org/apache/airavata/helix/cluster/monitoring/agents/HelixControllerMonitor.java b/modules/airavata-helix/platform-monitor/src/main/java/org/apache/airavata/helix/cluster/monitoring/agents/HelixControllerMonitor.java
deleted file mode 100644
index 9e081b5..0000000
--- a/modules/airavata-helix/platform-monitor/src/main/java/org/apache/airavata/helix/cluster/monitoring/agents/HelixControllerMonitor.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.apache.airavata.helix.cluster.monitoring.agents;
-
-import org.apache.airavata.helix.cluster.monitoring.ErrorNotifier;
-import org.apache.airavata.helix.cluster.monitoring.PlatformMonitor;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class HelixControllerMonitor implements PlatformMonitor {
-
- private final static Logger logger = LoggerFactory.getLogger(HelixControllerMonitor.class);
-
- @Override
- public void monitor(ErrorNotifier notifier) {
- logger.info("Monitoring Controller started");
- logger.info("Monitoring Controller finished");
- }
-}
\ No newline at end of file
diff --git a/modules/airavata-helix/platform-monitor/src/main/java/org/apache/airavata/helix/cluster/monitoring/agents/HelixParticipantMonitor.java b/modules/airavata-helix/platform-monitor/src/main/java/org/apache/airavata/helix/cluster/monitoring/agents/HelixParticipantMonitor.java
deleted file mode 100644
index cb40fb4..0000000
--- a/modules/airavata-helix/platform-monitor/src/main/java/org/apache/airavata/helix/cluster/monitoring/agents/HelixParticipantMonitor.java
+++ /dev/null
@@ -1,108 +0,0 @@
-package org.apache.airavata.helix.cluster.monitoring.agents;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.helix.cluster.monitoring.ErrorNotifier;
-import org.apache.airavata.helix.cluster.monitoring.PlatformMonitor;
-import org.apache.airavata.helix.cluster.monitoring.PlatformMonitorError;
-import org.apache.airavata.helix.impl.task.mock.MockTask;
-import org.apache.airavata.helix.workflow.WorkflowOperator;
-import org.apache.helix.manager.zk.ZKHelixAdmin;
-import org.apache.helix.manager.zk.ZNRecordSerializer;
-import org.apache.helix.manager.zk.ZkClient;
-import org.apache.helix.model.InstanceConfig;
-import org.apache.helix.task.TaskState;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Collections;
-import java.util.UUID;
-
-public class HelixParticipantMonitor implements PlatformMonitor {
-
- private final static Logger logger = LoggerFactory.getLogger(HelixParticipantMonitor.class);
-
- private String helixClusterName = ServerSettings.getSetting("helix.cluster.name");
- private String instanceName = ServerSettings.getSetting("helix.participant.name");
- private String zkConnectionString = ServerSettings.getZookeeperConnection();
- private WorkflowOperator operator;
-
- public HelixParticipantMonitor() throws Exception {
- operator = new WorkflowOperator(helixClusterName, "mock-wf-operator", zkConnectionString);
- }
-
- public void monitor(ErrorNotifier notifier) {
-
- logger.info("Monitoring Participant started");
-
- PlatformMonitorError monitorError = checkConnectivity();
- if (monitorError != null) notifier.sendNotification(monitorError);
- monitorError = checkMockWorkflow();
- if (monitorError != null) notifier.sendNotification(monitorError);
-
- logger.info("Monitoring Participant finished");
-
- }
-
- private PlatformMonitorError checkConnectivity() {
- ZkClient zkclient = null;
- try {
- zkclient = new ZkClient(zkConnectionString, ZkClient.DEFAULT_SESSION_TIMEOUT,
- ZkClient.DEFAULT_CONNECTION_TIMEOUT, new ZNRecordSerializer());
- ZKHelixAdmin admin = new ZKHelixAdmin(zkclient);
-
- InstanceConfig instanceConfig = admin.getInstanceConfig(helixClusterName, instanceName);
-
- String result = new String(instanceConfig.serialize(new ZNRecordSerializer()));
-
- int startPoint = result.indexOf("HELIX_ENABLED");
- int endPoint = result.indexOf("\n", startPoint);
- String enabledStr = result.substring(startPoint, endPoint);
- if (enabledStr.contains("false")) {
- PlatformMonitorError monitorError = new PlatformMonitorError();
- monitorError.setReason("Helix participant " + instanceName + " is not active");
- monitorError.setCategory("Participant");
- monitorError.setErrorCode("P001");
- return monitorError;
- }
- } catch (Exception e) {
- PlatformMonitorError monitorError = new PlatformMonitorError();
- monitorError.setError(e);
- monitorError.setReason("Failed to fetch Helix participant " + instanceName + " information");
- monitorError.setCategory("Participant");
- monitorError.setErrorCode("P002");
- return monitorError;
- } finally {
- if (zkclient != null) {
- zkclient.close();
- }
- }
- return null;
- }
-
- private PlatformMonitorError checkMockWorkflow() {
- MockTask mockTask = new MockTask();
- mockTask.setTaskId("Mock-" + UUID.randomUUID().toString());
- try {
- String workflow = operator.launchWorkflow(UUID.randomUUID().toString(), Collections.singletonList(mockTask), true, false);
- /*TaskState state = operator.pollForWorkflowCompletion(workflow, Long.parseLong(ServerSettings.getSetting("platform_mock_workflow_timeout_ms")));
- if (state != TaskState.COMPLETED) {
- PlatformMonitorError monitorError = new PlatformMonitorError();
- monitorError.setReason("Mock workflow failed to execute with status " + state.name() + ". " +
- "Check whether Helix cluster is working properly");
- monitorError.setCategory("Participant");
- monitorError.setErrorCode("P003");
- return monitorError;
- }*/
- } catch (Exception e) {
- PlatformMonitorError monitorError = new PlatformMonitorError();
- monitorError.setError(e);
- monitorError.setReason("Failed to launch mock workflow on helix cluster " + helixClusterName + ". " +
- "Check whether Helix cluster is working properly including the availability of Controller and Participant");
- monitorError.setCategory("Participant");
- monitorError.setErrorCode("P004");
- return monitorError;
- }
- return null;
- }
-}
\ No newline at end of file
diff --git a/modules/airavata-helix/platform-monitor/src/main/java/org/apache/airavata/helix/cluster/monitoring/agents/ZookeeperMonitor.java b/modules/airavata-helix/platform-monitor/src/main/java/org/apache/airavata/helix/cluster/monitoring/agents/ZookeeperMonitor.java
deleted file mode 100644
index c21ec90..0000000
--- a/modules/airavata-helix/platform-monitor/src/main/java/org/apache/airavata/helix/cluster/monitoring/agents/ZookeeperMonitor.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package org.apache.airavata.helix.cluster.monitoring.agents;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.helix.cluster.monitoring.ErrorNotifier;
-import org.apache.airavata.helix.cluster.monitoring.PlatformMonitor;
-import org.apache.airavata.helix.cluster.monitoring.PlatformMonitorError;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.net.Socket;
-
-public class ZookeeperMonitor implements PlatformMonitor {
-
- private final static Logger logger = LoggerFactory.getLogger(ZookeeperMonitor.class);
-
- private String zkConnection = ServerSettings.getZookeeperConnection();
-
- public ZookeeperMonitor() throws ApplicationSettingsException {
- }
-
- public void monitor(ErrorNotifier notifier) {
-
- logger.info("Monitoring Zookeeper started");
-
- Socket s = null;
-
- try {
- s = new Socket(zkConnection.split(":")[0], Integer.parseInt(zkConnection.split(":")[1]));
- } catch (IOException e) {
- PlatformMonitorError monitorError = new PlatformMonitorError();
- monitorError.setError(e);
- monitorError.setReason("Could not establish a connection with Zookeeper " + zkConnection);
- monitorError.setCategory("Zookeeper");
- monitorError.setCategory("ZK001");
- notifier.sendNotification(monitorError);
- } finally {
- if(s != null)
- try {s.close();}
- catch(Exception ignored){}
- }
-
- logger.info("Monitoring Zookeeper finished");
-
- }
-}
\ No newline at end of file
diff --git a/modules/airavata-helix/platform-monitor/src/main/resources/airavata-server.properties b/modules/airavata-helix/platform-monitor/src/main/resources/airavata-server.properties
deleted file mode 100644
index afd4ecc..0000000
--- a/modules/airavata-helix/platform-monitor/src/main/resources/airavata-server.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-api.server.host=149.165.170.103
-api.server.port=9930
-database.host=149.165.171.12
-database.port=3306
-helix.cluster.name=AiravataDemoCluster
-helix.participant.name=helixparticipant
-zookeeper.server.connection=149.165.170.103:2181
-sender.email.account=CHANGE_ME
-sender.email.password=CHANGE_ME
-target.email.accounts=dimuthu.upeksha2@gmail.com,dwannipu@iu.edu
-platform.name=Testing Environment
-platform_monitor_interval_minutes=10
-platform_mock_workflow_timeout_ms=300000
\ No newline at end of file
diff --git a/modules/airavata-helix/platform-monitor/src/main/resources/logback.xml b/modules/airavata-helix/platform-monitor/src/main/resources/logback.xml
deleted file mode 100644
index e1a1b2e..0000000
--- a/modules/airavata-helix/platform-monitor/src/main/resources/logback.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-
--->
-<configuration>
-
- <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <pattern>%d [%t] %-5p %c{30} %m [%X]%n</pattern>
- </encoder>
- </appender>
-
- <appender name="LOGFILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
- <File>../logs/airavata.log</File>
- <Append>true</Append>
- <encoder>
- <pattern>%d [%t] %-5p %c{30} %m [%X]%n</pattern>
- </encoder>
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <fileNamePattern>../logs/airavata.log.%d{yyyy-MM-dd}</fileNamePattern>
- <maxHistory>30</maxHistory>
- <totalSizeCap>1GB</totalSizeCap>
- </rollingPolicy>
- </appender>
-
- <logger name="ch.qos.logback" level="WARN"/>
- <logger name="org.apache.helix" level="WARN"/>
- <logger name="org.apache.zookeeper" level="ERROR"/>
- <logger name="org.apache.airavata" level="INFO"/>
- <logger name="org.hibernate" level="ERROR"/>
- <root level="INFO">
- <appender-ref ref="CONSOLE"/>
- <appender-ref ref="LOGFILE"/>
- </root>
-</configuration>
\ No newline at end of file
diff --git a/modules/airavata-helix/pom.xml b/modules/airavata-helix/pom.xml
index b878d2e..5449e8c 100644
--- a/modules/airavata-helix/pom.xml
+++ b/modules/airavata-helix/pom.xml
@@ -40,7 +40,6 @@
<module>task-core</module>
<module>workflow-impl</module>
<module>helix-spectator</module>
- <module>platform-monitor</module>
</modules>
</project>
diff --git a/modules/airavata-helix/task-core/pom.xml b/modules/airavata-helix/task-core/pom.xml
index e4745bf..23c7cde 100644
--- a/modules/airavata-helix/task-core/pom.xml
+++ b/modules/airavata-helix/task-core/pom.xml
@@ -47,6 +47,11 @@
<artifactId>sshj-agent</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>platform-monitoring</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
<!--<build>
diff --git a/modules/airavata-helix/task-core/src/main/java/org/apache/airavata/helix/core/AbstractTask.java b/modules/airavata-helix/task-core/src/main/java/org/apache/airavata/helix/core/AbstractTask.java
index 0683957..d01f275 100644
--- a/modules/airavata-helix/task-core/src/main/java/org/apache/airavata/helix/core/AbstractTask.java
+++ b/modules/airavata-helix/task-core/src/main/java/org/apache/airavata/helix/core/AbstractTask.java
@@ -27,6 +27,7 @@
import org.apache.airavata.helix.task.api.TaskHelper;
import org.apache.airavata.helix.task.api.annotation.TaskOutPort;
import org.apache.airavata.helix.task.api.annotation.TaskParam;
+import org.apache.airavata.patform.monitoring.CountMonitor;
import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
@@ -48,6 +49,11 @@
public abstract class AbstractTask extends UserContentStore implements Task {
private final static Logger logger = LoggerFactory.getLogger(AbstractTask.class);
+ private final static CountMonitor taskInitCounter = new CountMonitor("task_init_count");
+ private final static CountMonitor taskRunCounter = new CountMonitor("task_run_count");
+ private final static CountMonitor taskCancelCounter = new CountMonitor("task_cancel_count");
+ private final static CountMonitor taskFailCounter = new CountMonitor("task_fail_count");
+ private final static CountMonitor taskCompleteCounter = new CountMonitor("task_complete_count");
private static final String NEXT_JOB = "next-job";
private static final String WORKFLOW_STARTED = "workflow-started";
@@ -71,9 +77,11 @@
public void init(HelixManager manager, String workflowName, String jobName, String taskName) {
super.init(manager, workflowName, jobName, taskName);
try {
+ taskInitCounter.inc();
TaskUtil.deserializeTaskData(this, this.callbackContext.getTaskConfig().getConfigMap());
} catch (Exception e) {
- e.printStackTrace();
+ taskFailCounter.inc();
+ logger.error("Deserialization of task parameters failed", e);
}
if (participant != null) {
participant.registerRunningTask(this);
@@ -85,6 +93,7 @@
@Override
public final TaskResult run() {
try {
+ taskRunCounter.inc();
boolean isThisNextJob = getUserContent(WORKFLOW_STARTED, Scope.WORKFLOW) == null ||
this.callbackContext.getJobConfig().getJobId()
.equals(this.callbackContext.getJobConfig().getWorkflow() + "_" + getUserContent(NEXT_JOB, Scope.WORKFLOW));
@@ -102,6 +111,7 @@
@Override
public final void cancel() {
try {
+ taskCancelCounter.inc();
logger.info("Cancelling task " + taskId);
onCancel();
} finally {
@@ -118,12 +128,14 @@
public abstract void onCancel();
protected TaskResult onSuccess(String message) {
+ taskCompleteCounter.inc();
String successMessage = "Task " + getTaskId() + " completed." + (message != null ? " Message : " + message : "");
logger.info(successMessage);
return nextTask.invoke(new TaskResult(TaskResult.Status.COMPLETED, message));
}
protected TaskResult onFail(String reason, boolean fatal) {
+ taskFailCounter.inc();
return new TaskResult(fatal ? TaskResult.Status.FATAL_FAILED : TaskResult.Status.FAILED, reason);
}
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/ApplicationSettings.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/ApplicationSettings.java
index f78b196..5b78ba4 100644
--- a/modules/commons/src/main/java/org/apache/airavata/common/utils/ApplicationSettings.java
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/ApplicationSettings.java
@@ -20,6 +20,7 @@
package org.apache.airavata.common.utils;
import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.commons.lang3.BooleanUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -324,14 +325,47 @@
public static String getSetting(String key, String defaultValue) {
return getInstance().getSettingImpl(key,defaultValue);
-
}
public static void setSetting(String key, String value) throws ApplicationSettingsException{
- getInstance().properties.setProperty(key, value);
- getInstance().saveProperties();
+ getInstance().properties.setProperty(key, value);
+ getInstance().saveProperties();
}
-
+
+
+ public static int getIntSetting(String key) throws ApplicationSettingsException {
+ String val = getInstance().getSettingImpl(key);
+ try {
+ return Integer.parseInt(val);
+ } catch (NumberFormatException e) {
+ throw new ApplicationSettingsException("Value can not be parsed to int", e);
+ }
+ }
+
+ public static boolean getBooleanSetting(String key) throws ApplicationSettingsException {
+ String val = getInstance().getSettingImpl(key);
+ return Optional.ofNullable(BooleanUtils.toBooleanObject(val))
+ .orElseThrow(() -> new ApplicationSettingsException("Value can not be parsed to Boolean"));
+ }
+
+ public static long getLongSetting(String key) throws ApplicationSettingsException {
+ String val = getInstance().getSettingImpl(key);
+ try {
+ return Long.parseLong(val);
+ } catch (NumberFormatException e) {
+ throw new ApplicationSettingsException("Value can not be parsed to long", e);
+ }
+ }
+
+ public static double getDoubleSetting(String key) throws ApplicationSettingsException {
+ String val = getInstance().getSettingImpl(key);
+ try {
+ return Double.parseDouble(val);
+ } catch (NumberFormatException e) {
+ throw new ApplicationSettingsException("Value can not be parsed to double", e);
+ }
+ }
+
public static boolean isSettingDefined(String key) throws ApplicationSettingsException{
return getInstance().properties.containsKey(key);
}
diff --git a/modules/distribution/pom.xml b/modules/distribution/pom.xml
index 706f0a3..d305d3f 100644
--- a/modules/distribution/pom.xml
+++ b/modules/distribution/pom.xml
@@ -577,21 +577,6 @@
</configuration>
</execution>
<execution>
- <id>platform-monitor-distribution-package</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- <configuration>
- <tarLongFileMode>posix</tarLongFileMode>
- <finalName>${platform.monitor.dist.name}</finalName>
- <descriptors>
- <descriptor>src/main/assembly/platform-monitor-bin-assembly.xml</descriptor>
- </descriptors>
- <attach>false</attach>
- </configuration>
- </execution>
- <execution>
<id>email-monitor-distribution-package</id>
<phase>package</phase>
<goals>
@@ -637,7 +622,6 @@
<pre.wm.dist.name>apache-airavata-pre-wm-${project.version}</pre.wm.dist.name>
<post.wm.dist.name>apache-airavata-post-wm-${project.version}</post.wm.dist.name>
<parser.wm.dist.name>apache-airavata-parser-wm-${project.version}</parser.wm.dist.name>
- <platform.monitor.dist.name>apache-airavata-platform-monitor-${project.version}</platform.monitor.dist.name>
<email.monitor.dist.name>apache-airavata-email-monitor-${project.version}</email.monitor.dist.name>
<realtime.monitor.dist.name>apache-airavata-realtime-monitor-${project.version}</realtime.monitor.dist.name>
</properties>
diff --git a/modules/distribution/src/main/assembly/controller-bin-assembly.xml b/modules/distribution/src/main/assembly/controller-bin-assembly.xml
index 1c325a1..f2616c5 100644
--- a/modules/distribution/src/main/assembly/controller-bin-assembly.xml
+++ b/modules/distribution/src/main/assembly/controller-bin-assembly.xml
@@ -159,6 +159,10 @@
<include>org.apache.zookeeper:zookeeper:jar</include>
<include>org.apache.commons:commons-pool2:jar</include>
<include>org.json:json:jar</include>
+
+ <include>org.apache.airavata:platform-monitoring:jar</include>
+ <include>io.prometheus:simpleclient:jar</include>
+ <include>io.prometheus:simpleclient_httpserver:jar</include>
</includes>
<excludes>
<exclude>mysql:mysql-connector-java:jar</exclude>
diff --git a/modules/distribution/src/main/assembly/email-monitor-bin-assembly.xml b/modules/distribution/src/main/assembly/email-monitor-bin-assembly.xml
index ae976f2..b571739 100644
--- a/modules/distribution/src/main/assembly/email-monitor-bin-assembly.xml
+++ b/modules/distribution/src/main/assembly/email-monitor-bin-assembly.xml
@@ -120,6 +120,10 @@
<include>net.logstash.logback:logstash-logback-encoder:jar</include>
<include>org.apache.commons:commons-pool2:jar</include>
<include>org.json:json:jar</include>
+
+ <include>org.apache.airavata:platform-monitoring:jar</include>
+ <include>io.prometheus:simpleclient:jar</include>
+ <include>io.prometheus:simpleclient_httpserver:jar</include>
</includes>
</dependencySet>
</dependencySets>
diff --git a/modules/distribution/src/main/assembly/parser-wm-bin-assembly.xml b/modules/distribution/src/main/assembly/parser-wm-bin-assembly.xml
index 511c998..c4fbf65 100644
--- a/modules/distribution/src/main/assembly/parser-wm-bin-assembly.xml
+++ b/modules/distribution/src/main/assembly/parser-wm-bin-assembly.xml
@@ -160,6 +160,10 @@
<include>com.github.docker-java:docker-java:jar</include>
<include>org.apache.commons:commons-pool2:jar</include>
<include>org.json:json:jar</include>
+
+ <include>org.apache.airavata:platform-monitoring:jar</include>
+ <include>io.prometheus:simpleclient:jar</include>
+ <include>io.prometheus:simpleclient_httpserver:jar</include>
</includes>
<excludes>
<exclude>mysql:mysql-connector-java:jar</exclude>
diff --git a/modules/distribution/src/main/assembly/participant-bin-assembly.xml b/modules/distribution/src/main/assembly/participant-bin-assembly.xml
index a20e6ee..532c332 100644
--- a/modules/distribution/src/main/assembly/participant-bin-assembly.xml
+++ b/modules/distribution/src/main/assembly/participant-bin-assembly.xml
@@ -210,6 +210,10 @@
<include>org.apache.commons:commons-pool2:jar</include>
<include>org.json:json:jar</include>
+
+ <include>org.apache.airavata:platform-monitoring:jar</include>
+ <include>io.prometheus:simpleclient:jar</include>
+ <include>io.prometheus:simpleclient_httpserver:jar</include>
</includes>
<excludes>
<exclude>mysql:mysql-connector-java:jar</exclude>
diff --git a/modules/distribution/src/main/assembly/platform-monitor-bin-assembly.xml b/modules/distribution/src/main/assembly/platform-monitor-bin-assembly.xml
deleted file mode 100644
index a898c13..0000000
--- a/modules/distribution/src/main/assembly/platform-monitor-bin-assembly.xml
+++ /dev/null
@@ -1,170 +0,0 @@
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-
--->
-<!DOCTYPE assembly [
- <!ELEMENT assembly (id|includeBaseDirectory|baseDirectory|formats|fileSets|dependencySets)*>
- <!ELEMENT id (#PCDATA)>
- <!ELEMENT includeBaseDirectory (#PCDATA)>
- <!ELEMENT baseDirectory (#PCDATA)>
- <!ELEMENT formats (format)*>
- <!ELEMENT format (#PCDATA)>
- <!ELEMENT fileSets (fileSet)*>
- <!ELEMENT fileSet (directory|outputDirectory|fileMode|includes)*>
- <!ELEMENT directory (#PCDATA)>
- <!ELEMENT outputDirectory (#PCDATA)>
- <!ELEMENT includes (include)*>
- <!ELEMENT include (#PCDATA)>
- <!ELEMENT dependencySets (dependencySet)*>
- <!ELEMENT dependencySet (outputDirectory|outputFileNameMapping|includes)*>
- ]>
-<assembly>
- <id>bin</id>
- <includeBaseDirectory>true</includeBaseDirectory>
- <baseDirectory>${platform.monitor.dist.name}</baseDirectory>
- <formats>
- <format>tar.gz</format>
- <format>zip</format>
- </formats>
-
- <fileSets>
- <fileSet>
- <directory>src/main/resources/platform-monitor/bin</directory>
- <outputDirectory>bin</outputDirectory>
- <fileMode>777</fileMode>
- <includes>
- <include>*.sh</include>
- </includes>
- </fileSet>
- <fileSet>
- <directory>src/main/resources/platform-monitor/conf</directory>
- <outputDirectory>conf</outputDirectory>
- <includes>
- <include>airavata-server.properties</include>
- <include>logback.xml</include>
- </includes>
- </fileSet>
- <fileSet>
- <directory>./</directory>
- <outputDirectory>logs</outputDirectory>
- <excludes>
- <exclude>*/**</exclude>
- </excludes>
- </fileSet>
- </fileSets>
-
- <dependencySets>
- <dependencySet>
- <useProjectArtifact>false</useProjectArtifact>
- <outputDirectory>lib</outputDirectory>
- <includes>
- <include>javax.activation:activation:jar</include>
- <include>org.apache.airavata:airavata-base-api:jar</include>
- <include>org.apache.airavata:agent-api:jar</include>
- <include>org.apache.airavata:airavata-commons:jar</include>
- <include>org.apache.airavata:airavata-credential-store-stubs:jar</include>
- <include>org.apache.airavata:airavata-data-models:jar</include>
- <include>org.apache.airavata:airavata-messaging-core:jar</include>
- <include>org.apache.airavata:airavata-registry-core:jar</include>
- <include>org.apache.airavata:airavata-registry-cpi:jar</include>
- <include>org.apache.airavata:airavata-server-configuration:jar</include>
- <include>com.rabbitmq:amqp-client:jar</include>
- <include>asm:asm:jar</include>
- <include>org.bouncycastle:bcpkix-jdk15on:jar</include>
- <include>org.bouncycastle:bcprov-jdk15on:jar</include>
- <include>commons-cli:commons-cli:jar</include>
- <include>commons-codec:commons-codec:jar</include>
- <include>commons-collections:commons-collections:jar</include>
- <include>commons-dbcp:commons-dbcp:jar</include>
- <include>commons-io:commons-io:jar</include>
- <include>commons-lang:commons-lang:jar</include>
- <include>commons-logging:commons-logging:jar</include>
- <include>org.apache.commons:commons-math:jar</include>
- <include>commons-pool:commons-pool:jar</include>
- <include>org.apache.curator:curator-client:jar</include>
- <include>org.apache.curator:curator-framework:jar</include>
- <include>org.apache.derby:derby:jar</include>
- <include>org.apache.derby:derbyclient:jar</include>
- <include>org.apache.derby:derbynet:jar</include>
- <include>org.apache.derby:derbytools:jar</include>
- <include>net.i2p.crypto:eddsa:jar</include>
- <include>org.apache.geronimo.specs:geronimo-jms_1.1_spec:jar</include>
- <include>org.apache.geronimo.specs:geronimo-jpa_2.0_spec:jar</include>
- <include>org.apache.geronimo.specs:geronimo-jta_1.1_spec:jar</include>
- <include>org.codehaus.groovy:groovy:jar</include>
- <include>org.codehaus.groovy:groovy-templates:jar</include>
- <include>org.codehaus.groovy:groovy-xml:jar</include>
- <include>com.google.code.gson:gson:jar</include>
- <include>com.google.guava:guava:jar</include>
- <include>org.hamcrest:hamcrest-core:jar</include>
- <include>org.apache.helix:helix-core:jar</include>
- <include>org.apache.airavata:helix-spectator:jar</include>
- <include>org.apache.httpcomponents:httpclient:jar</include>
- <include>org.apache.httpcomponents:httpcore:jar</include>
- <include>com.fasterxml.jackson.core:jackson-annotations:jar</include>
- <include>com.fasterxml.jackson.core:jackson-core:jar</include>
- <include>org.codehaus.jackson:jackson-core-asl:jar</include>
- <include>com.fasterxml.jackson.core:jackson-databind:jar</include>
- <include>org.codehaus.jackson:jackson-mapper-asl:jar</include>
- <include>jakarta-regexp:jakarta-regexp:jar</include>
- <include>jline:jline:jar</include>
- <include>org.apache.airavata:job-monitor-api:jar</include>
- <include>junit:junit:jar</include>
- <include>com.jcraft:jzlib:jar</include>
- <include>org.apache.kafka:kafka-clients:jar</include>
- <include>org.apache.thrift:libthrift:jar</include>
- <include>org.slf4j:log4j-over-slf4j:jar</include>
- <include>ch.qos.logback:logback-classic:jar</include>
- <include>ch.qos.logback:logback-core:jar</include>
- <include>com.github.danielwegener:logback-kafka-appender:jar</include>
- <include>net.logstash.logback:logstash-logback-encoder:jar</include>
- <include>org.lz4:lz4-java:jar</include>
- <include>javax.mail:mail:jar</include>
- <include>io.dropwizard.metrics:metrics-core:jar</include>
- <include>org.jboss.netty:netty:jar</include>
- <include>org.apache.openjpa:openjpa:jar</include>
- <include>org.apache.airavata:platform-monitor:jar</include>
- <include>org.apache.airavata:registry-api-service:jar</include>
- <include>org.apache.airavata:registry-api-stubs:jar</include>
- <include>net.sourceforge.serp:serp:jar</include>
- <include>org.slf4j:slf4j-api:jar</include>
- <include>org.yaml:snakeyaml:jar</include>
- <include>org.xerial.snappy:snappy-java:jar</include>
- <include>org.apache.airavata:ssh-agent:jar</include>
- <include>com.hierynomus:sshj:jar</include>
- <include>org.apache.airavata:sshj-agent:jar</include>
- <include>org.apache.airavata:task-api:jar</include>
- <include>org.apache.airavata:task-core:jar</include>
- <include>org.apache.tomcat.embed:tomcat-embed-core:jar</include>
- <include>org.apache.airavata:workflow-impl:jar</include>
- <include>org.ogce:xpp3:jar</include>
- <include>org.ogce:xpp5:jar</include>
- <include>com.101tec:zkclient:jar</include>
- <include>org.apache.zookeeper:zookeeper:jar</include>
- <include>org.apache.commons:commons-pool2:jar</include>
- <include>org.json:json:jar</include>
- </includes>
- <excludes>
- <exclude>mysql:mysql-connector-java:jar</exclude>
- <exclude>log4j:log4j:jar</exclude>
- </excludes>
- </dependencySet>
- </dependencySets>
-
-</assembly>
diff --git a/modules/distribution/src/main/assembly/post-wm-bin-assembly.xml b/modules/distribution/src/main/assembly/post-wm-bin-assembly.xml
index 3d46ec6..5ca7cc9 100644
--- a/modules/distribution/src/main/assembly/post-wm-bin-assembly.xml
+++ b/modules/distribution/src/main/assembly/post-wm-bin-assembly.xml
@@ -164,6 +164,10 @@
<include>org.apache.airavata:airavata-security:jar</include>
<include>org.apache.commons:commons-pool2:jar</include>
<include>org.json:json:jar</include>
+
+ <include>org.apache.airavata:platform-monitoring:jar</include>
+ <include>io.prometheus:simpleclient:jar</include>
+ <include>io.prometheus:simpleclient_httpserver:jar</include>
</includes>
<excludes>
<exclude>mysql:mysql-connector-java:jar</exclude>
diff --git a/modules/distribution/src/main/assembly/pre-wm-bin-assembly.xml b/modules/distribution/src/main/assembly/pre-wm-bin-assembly.xml
index 2b26851..c1246d4 100644
--- a/modules/distribution/src/main/assembly/pre-wm-bin-assembly.xml
+++ b/modules/distribution/src/main/assembly/pre-wm-bin-assembly.xml
@@ -164,6 +164,9 @@
<include>org.apache.airavata:airavata-security:jar</include>
<include>org.apache.commons:commons-pool2:jar</include>
<include>org.json:json:jar</include>
+ <include>org.apache.airavata:platform-monitoring:jar</include>
+ <include>io.prometheus:simpleclient:jar</include>
+ <include>io.prometheus:simpleclient_httpserver:jar</include>
</includes>
<excludes>
<exclude>mysql:mysql-connector-java:jar</exclude>
diff --git a/modules/distribution/src/main/assembly/realtime-monitor-bin-assembly.xml b/modules/distribution/src/main/assembly/realtime-monitor-bin-assembly.xml
index e1caef9..9c9832e 100644
--- a/modules/distribution/src/main/assembly/realtime-monitor-bin-assembly.xml
+++ b/modules/distribution/src/main/assembly/realtime-monitor-bin-assembly.xml
@@ -116,6 +116,10 @@
<include>org.apache.commons:commons-pool2:jar</include>
<include>org.json:json:jar</include>
+
+ <include>org.apache.airavata:platform-monitoring:jar</include>
+ <include>io.prometheus:simpleclient:jar</include>
+ <include>io.prometheus:simpleclient_httpserver:jar</include>
</includes>
</dependencySet>
</dependencySets>
diff --git a/modules/distribution/src/main/resources/parser-wm/conf/airavata-server.properties b/modules/distribution/src/main/resources/parser-wm/conf/airavata-server.properties
index 4131aa1..7b2d975 100644
--- a/modules/distribution/src/main/resources/parser-wm/conf/airavata-server.properties
+++ b/modules/distribution/src/main/resources/parser-wm/conf/airavata-server.properties
@@ -59,3 +59,7 @@
kafka.parser.topic=CHANGE_ME
parser.storage.resource.id=CHANGE_ME
kafka.parsing.broker.publisher.id=CHANGE_ME
+
+parser.workflow.manager.monitoring.enabled=true
+parser.workflow.manager.monitoring.host=localhost
+parser.workflow.manager.monitoring.port=9095
\ No newline at end of file
diff --git a/modules/distribution/src/main/resources/participant/conf/airavata-server.properties b/modules/distribution/src/main/resources/participant/conf/airavata-server.properties
index 98fdaba..e034860 100644
--- a/modules/distribution/src/main/resources/participant/conf/airavata-server.properties
+++ b/modules/distribution/src/main/resources/participant/conf/airavata-server.properties
@@ -70,4 +70,8 @@
kafka.parsing.broker.url=CHANGE_ME
kafka.parser.broker.consumer.group=CHANGE_ME
kafka.parser.topic=CHANGE_ME
-parser.storage.resource.id=CHANGE_ME
\ No newline at end of file
+parser.storage.resource.id=CHANGE_ME
+
+participant.monitoring.enabled=true
+participant.monitoring.host=localhost
+participant.monitoring.port=9096
\ No newline at end of file
diff --git a/modules/distribution/src/main/resources/platform-monitor/bin/platform-monitor-daemon.sh b/modules/distribution/src/main/resources/platform-monitor/bin/platform-monitor-daemon.sh
deleted file mode 100644
index dbeb9ef..0000000
--- a/modules/distribution/src/main/resources/platform-monitor/bin/platform-monitor-daemon.sh
+++ /dev/null
@@ -1,113 +0,0 @@
-#!/usr/bin/env bash
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-. `dirname $0`/setenv.sh
-# Capture user's working dir before changing directory
-CWD="$PWD"
-cd ${AIRAVATA_HOME}/bin
-LOGO_FILE="logo.txt"
-
-JAVA_OPTS="-Dairavata.config.dir=${AIRAVATA_HOME}/conf -Dairavata.home=${AIRAVATA_HOME} -Dlogback.configurationFile=file:${AIRAVATA_HOME}/conf/logback.xml"
-AIRAVATA_COMMAND=""
-EXTRA_ARGS=""
-SERVERS=""
-LOGO=true
-IS_SUBSET=false
-SUBSET=""
-DEFAULT_LOG_FILE="${AIRAVATA_HOME}/logs/airavata-daemon.out"
-LOG_FILE=$DEFAULT_LOG_FILE
-
-SERVICE_NAME="Platform Monitor"
-PID_PATH_NAME="${AIRAVATA_HOME}/bin/service-pid"
-
-case $1 in
- start)
- echo "Starting $SERVICE_NAME ..."
- if [ ! -f $PID_PATH_NAME ]; then
- nohup java ${JAVA_OPTS} -classpath "${AIRAVATA_CLASSPATH}" \
- org.apache.airavata.helix.cluster.monitoring.MainMonitor ${AIRAVATA_COMMAND} $* > $LOG_FILE 2>&1 &
- echo $! > $PID_PATH_NAME
- echo "$SERVICE_NAME started ..."
- else
- echo "$SERVICE_NAME is already running ..."
- fi
- ;;
- stop)
- if [ -f $PID_PATH_NAME ]; then
- PID=$(cat $PID_PATH_NAME);
- echo "$SERVICE_NAME stoping ..."
- kill $PID;
- RETRY=0
- while kill -0 $PID 2> /dev/null; do
- echo "Waiting for the process $PID to be stopped"
- RETRY=`expr ${RETRY} + 1`
- if [ "${RETRY}" -gt "20" ]
- then
- echo "Forcefully killing the process as it is not responding ..."
- kill -9 $PID
- fi
- sleep 1
- done
- echo "$SERVICE_NAME stopped ..."
- rm $PID_PATH_NAME
- else
- echo "$SERVICE_NAME is not running ..."
- fi
- ;;
- restart)
- if [ -f $PID_PATH_NAME ]; then
- PID=$(cat $PID_PATH_NAME);
- echo "$SERVICE_NAME stopping ...";
- kill $PID;
- RETRY=0
- while kill -0 $PID 2> /dev/null; do
- echo "Waiting for the process $PID to be stopped"
- RETRY=`expr ${RETRY} + 1`
- if [ "${RETRY}" -gt "20" ]
- then
- echo "Forcefully killing the process as it is not responding ..."
- kill -9 $PID
- fi
- sleep 1
- done
- echo "$SERVICE_NAME stopped ...";
- rm $PID_PATH_NAME
- echo "$SERVICE_NAME starting ..."
- nohup java ${JAVA_OPTS} -classpath "${AIRAVATA_CLASSPATH}" \
- org.apache.airavata.helix.cluster.monitoring.MainMonitor ${AIRAVATA_COMMAND} $* > $LOG_FILE 2>&1 &
- echo $! > $PID_PATH_NAME
- echo "$SERVICE_NAME started ..."
- else
- echo "$SERVICE_NAME is not running ..."
- fi
- ;;
- -h)
- echo "Usage: platform-monitor-daemon.sh"
-
- echo "command options:"
- echo " start Start server in daemon mode"
- echo " stop Stop server running in daemon mode"
- echo " restart Restart server in daemon mode"
- echo " -log <LOG_FILE> Where to redirect stdout/stderr (defaults to $DEFAULT_LOG_FILE)"
- echo " -h Display this help and exit"
- shift
- exit 0
- ;;
-esac
-
diff --git a/modules/distribution/src/main/resources/platform-monitor/bin/platform-monitor.sh b/modules/distribution/src/main/resources/platform-monitor/bin/platform-monitor.sh
deleted file mode 100644
index 263f88e..0000000
--- a/modules/distribution/src/main/resources/platform-monitor/bin/platform-monitor.sh
+++ /dev/null
@@ -1,71 +0,0 @@
-#!/usr/bin/env bash
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-. `dirname $0`/setenv.sh
-# Capture user's working dir before changing directory
-CWD="$PWD"
-cd ${AIRAVATA_HOME}/bin
-LOGO_FILE="logo.txt"
-
-JAVA_OPTS="-Dairavata.config.dir=${AIRAVATA_HOME}/conf -Dairavata.home=${AIRAVATA_HOME} -Dlogback.configurationFile=file:${AIRAVATA_HOME}/conf/logback.xml"
-AIRAVATA_COMMAND=""
-EXTRA_ARGS=""
-SERVERS=""
-IS_SUBSET=false
-SUBSET=""
-DEFAULT_LOG_FILE="${AIRAVATA_HOME}/logs/airavata.out"
-LOG_FILE=$DEFAULT_LOG_FILE
-
-# parse command arguments
-for var in "$@"
-do
- case ${var} in
- -xdebug)
- AIRAVATA_COMMAND="${AIRAVATA_COMMAND}"
- JAVA_OPTS="$JAVA_OPTS -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,address=*:8000"
- shift
- ;;
- -log)
- shift
- LOG_FILE="$1"
- shift
- # If relative path, expand to absolute path using the user's $CWD
- if [ -z "`echo "$LOG_FILE" | egrep "^/"`" ]; then
- LOG_FILE="${CWD}/${LOG_FILE}"
- fi
- ;;
- -h)
- echo "Usage: platform-monitor.sh"
-
- echo "command options:"
- echo " -xdebug Start Platform Monitor JPDA debugger"
- echo " -h Display this help and exit"
- shift
- exit 0
- ;;
- *)
- EXTRA_ARGS="${EXTRA_ARGS} ${var}"
- shift
- ;;
- esac
-done
-
-java ${JAVA_OPTS} -classpath "${AIRAVATA_CLASSPATH}" \
- org.apache.airavata.helix.cluster.monitoring.MainMonitor ${AIRAVATA_COMMAND} $*
-
diff --git a/modules/distribution/src/main/resources/platform-monitor/bin/setenv.sh b/modules/distribution/src/main/resources/platform-monitor/bin/setenv.sh
deleted file mode 100755
index 9e894e1..0000000
--- a/modules/distribution/src/main/resources/platform-monitor/bin/setenv.sh
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/bin/sh
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# resolve links - $0 may be a softlink
-PRG="$0"
-
-while [ -h "$PRG" ]; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '.*/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`/"$link"
- fi
-done
-
-PRGDIR=`dirname "$PRG"`
-
-# Only set AIRAVATA_HOME if not already set
-[ -z "$AIRAVATA_HOME" ] && AIRAVATA_HOME=`cd "$PRGDIR/.." ; pwd`
-
-AIRAVATA_CLASSPATH=""
-
-for f in "$AIRAVATA_HOME"/lib/*.jar
-do
- AIRAVATA_CLASSPATH="$AIRAVATA_CLASSPATH":$f
-done
-
-export AIRAVATA_HOME
-export AIRAVATA_CLASSPATH
diff --git a/modules/distribution/src/main/resources/platform-monitor/conf/airavata-server.properties b/modules/distribution/src/main/resources/platform-monitor/conf/airavata-server.properties
deleted file mode 100644
index 1cd0bd0..0000000
--- a/modules/distribution/src/main/resources/platform-monitor/conf/airavata-server.properties
+++ /dev/null
@@ -1,35 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-###########################################################################
-# Platform Monitor configurations
-###########################################################################
-
-api.server.host=CHANGE_ME
-api.server.port=CHANGE_ME
-database.host=CHANGE_ME
-database.port=CHANGE_ME
-helix.cluster.name=CHANGE_ME
-helix.participant.name=CHANGE_ME
-zookeeper.server.connection=CHANGE_ME
-sender.email.account=CHANGE_ME
-sender.email.password=CHANGE_ME
-target.email.accounts=CHANGE_ME
-platform.name=CHANGE_ME
-platform_monitor_interval_minutes=CHANGE_ME
-platform_mock_workflow_timeout_ms=CHANGE_ME
\ No newline at end of file
diff --git a/modules/distribution/src/main/resources/platform-monitor/conf/logback.xml b/modules/distribution/src/main/resources/platform-monitor/conf/logback.xml
deleted file mode 100644
index ef38b65..0000000
--- a/modules/distribution/src/main/resources/platform-monitor/conf/logback.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-
--->
-<configuration>
-
- <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <pattern>%d [%t] %-5p %c{30} %X - %m%n</pattern>
- </encoder>
- </appender>
-
- <appender name="LOGFILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
- <File>../logs/airavata.log</File>
- <Append>true</Append>
- <encoder>
- <pattern>%d [%t] %-5p %c{30} %X - %m%n</pattern>
- </encoder>
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <fileNamePattern>../logs/airavata.log.%d{yyyy-MM-dd}</fileNamePattern>
- <maxHistory>30</maxHistory>
- <totalSizeCap>1GB</totalSizeCap>
- </rollingPolicy>
- </appender>
-
- <logger name="ch.qos.logback" level="WARN"/>
- <logger name="org.apache.helix" level="WARN"/>
- <logger name="org.apache.zookeeper" level="ERROR"/>
- <logger name="org.apache.airavata" level="INFO"/>
- <logger name="org.hibernate" level="ERROR"/>
- <root level="INFO">
- <appender-ref ref="CONSOLE"/>
- <appender-ref ref="LOGFILE"/>
- </root>
-</configuration>
diff --git a/modules/distribution/src/main/resources/post-wm/conf/airavata-server.properties b/modules/distribution/src/main/resources/post-wm/conf/airavata-server.properties
index fc280ea..849860f 100644
--- a/modules/distribution/src/main/resources/post-wm/conf/airavata-server.properties
+++ b/modules/distribution/src/main/resources/post-wm/conf/airavata-server.properties
@@ -51,4 +51,8 @@
# Zookeeper Server Configuration
###########################################################################
zookeeper.server.connection=192.168.99.103:2181
-zookeeper.timeout=30000
\ No newline at end of file
+zookeeper.timeout=30000
+
+post.workflow.manager.monitoring.enabled=true
+post.workflow.manager.monitoring.host=localhost
+post.workflow.manager.monitoring.port=9094
\ No newline at end of file
diff --git a/modules/distribution/src/main/resources/pre-wm/conf/airavata-server.properties b/modules/distribution/src/main/resources/pre-wm/conf/airavata-server.properties
index e494e6f..2eca988 100644
--- a/modules/distribution/src/main/resources/pre-wm/conf/airavata-server.properties
+++ b/modules/distribution/src/main/resources/pre-wm/conf/airavata-server.properties
@@ -48,4 +48,8 @@
# Zookeeper Server Configuration
###########################################################################
zookeeper.server.connection=192.168.99.103:2181
-zookeeper.timeout=30000
\ No newline at end of file
+zookeeper.timeout=30000
+
+pre.workflow.manager.monitoring.enabled=true
+pre.workflow.manager.monitoring.host=localhost
+pre.workflow.manager.monitoring.port=9093
\ No newline at end of file
diff --git a/modules/platform-monitoring/pom.xml b/modules/platform-monitoring/pom.xml
new file mode 100644
index 0000000..7380088
--- /dev/null
+++ b/modules/platform-monitoring/pom.xml
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+<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/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>airavata</artifactId>
+ <groupId>org.apache.airavata</groupId>
+ <version>0.20-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>platform-monitoring</artifactId>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>log4j-over-slf4j</artifactId>
+ <version>1.7.25</version>
+ </dependency>
+ <!-- The client -->
+ <dependency>
+ <groupId>io.prometheus</groupId>
+ <artifactId>simpleclient</artifactId>
+ <version>0.9.0</version>
+ </dependency>
+ <!-- Hotspot JVM metrics-->
+ <dependency>
+ <groupId>io.prometheus</groupId>
+ <artifactId>simpleclient_hotspot</artifactId>
+ <version>0.9.0</version>
+ </dependency>
+ <!-- Exposition HTTPServer-->
+ <dependency>
+ <groupId>io.prometheus</groupId>
+ <artifactId>simpleclient_httpserver</artifactId>
+ <version>0.9.0</version>
+ </dependency>
+ <!-- Pushgateway exposition-->
+ <dependency>
+ <groupId>io.prometheus</groupId>
+ <artifactId>simpleclient_pushgateway</artifactId>
+ <version>0.9.0</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
diff --git a/modules/platform-monitoring/src/main/java/org/apache/airavata/patform/monitoring/CountMonitor.java b/modules/platform-monitoring/src/main/java/org/apache/airavata/patform/monitoring/CountMonitor.java
new file mode 100644
index 0000000..acadb37
--- /dev/null
+++ b/modules/platform-monitoring/src/main/java/org/apache/airavata/patform/monitoring/CountMonitor.java
@@ -0,0 +1,39 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ package org.apache.airavata.patform.monitoring;
+
+import io.prometheus.client.Counter;
+
+public class CountMonitor {
+
+ private Counter counter;
+
+ public CountMonitor(String monitorName) {
+ counter = Counter.build().name(monitorName).help(monitorName).register();
+ }
+
+ public void inc() {
+ counter.inc();
+ }
+
+ public void inc(double amount) {
+ counter.inc(amount);
+ }
+}
diff --git a/modules/platform-monitoring/src/main/java/org/apache/airavata/patform/monitoring/GaugeMonitor.java b/modules/platform-monitoring/src/main/java/org/apache/airavata/patform/monitoring/GaugeMonitor.java
new file mode 100644
index 0000000..706f5cf
--- /dev/null
+++ b/modules/platform-monitoring/src/main/java/org/apache/airavata/patform/monitoring/GaugeMonitor.java
@@ -0,0 +1,48 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+ package org.apache.airavata.patform.monitoring;
+
+import io.prometheus.client.Gauge;
+
+public class GaugeMonitor {
+
+ private Gauge gauge;
+
+ public GaugeMonitor(String monitorName) {
+ gauge = Gauge.build().name(monitorName).help(monitorName).register();
+ }
+
+ public void inc() {
+ gauge.inc();
+ }
+
+ public void inc(double amount) {
+ gauge.inc(amount);
+ }
+
+ public void dec() {
+ gauge.dec();
+ }
+
+ public void dec(double amount) {
+ gauge.dec(amount);
+ }
+}
diff --git a/modules/platform-monitoring/src/main/java/org/apache/airavata/patform/monitoring/MonitoringServer.java b/modules/platform-monitoring/src/main/java/org/apache/airavata/patform/monitoring/MonitoringServer.java
new file mode 100644
index 0000000..7949a4e
--- /dev/null
+++ b/modules/platform-monitoring/src/main/java/org/apache/airavata/patform/monitoring/MonitoringServer.java
@@ -0,0 +1,57 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+ package org.apache.airavata.patform.monitoring;
+
+import io.prometheus.client.exporter.HTTPServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+
+public class MonitoringServer {
+
+ private final static Logger logger = LoggerFactory.getLogger(MonitoringServer.class);
+
+ private String host;
+ private int port;
+ private HTTPServer httpServer;
+
+ public MonitoringServer(String host, int port) {
+ this.host = host;
+ this.port = port;
+ }
+
+ public void start() throws IOException {
+ try {
+ logger.info("Starting the monitoring server");
+ httpServer = new HTTPServer(host, port, true);
+ } catch (IOException e) {
+ logger.error("Failed to start the monitoring server on host {} na port {}", host, port, e);
+ }
+ }
+
+ public void stop() {
+ if (httpServer != null) {
+ logger.info("Stopping the monitor server");
+ httpServer.stop();
+ }
+ }
+}
diff --git a/pom.xml b/pom.xml
index 2e75767..5666a1f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -782,6 +782,7 @@
<module>modules/airavata-helix</module>
<module>modules/compute-account-provisioning</module>
<module>modules/job-monitor</module>
+ <module>modules/platform-monitoring</module>
<module>modules/distribution</module>
<module>tools</module>
<module>modules/ide-integration</module>