
com.centurylink.mdw.monitor.MonitorRegistry Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mdw-common Show documentation
Show all versions of mdw-common Show documentation
MDW is a microservices based workflow framework
/*
* Copyright (C) 2017 CenturyLink, Inc.
*
* Licensed 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 com.centurylink.mdw.monitor;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import com.centurylink.mdw.common.service.RegisteredService;
import com.centurylink.mdw.common.service.ServiceRegistry;
import com.centurylink.mdw.model.workflow.RuntimeContext;
/**
* Registry for MDW monitoring services.
*/
public class MonitorRegistry extends ServiceRegistry {
public static final List monitorServices = new ArrayList(Arrays.asList(new String[] {ProcessMonitor.class.getName(), ActivityMonitor.class.getName(),
AdapterMonitor.class.getName(), ServiceMonitor.class.getName()}));
protected MonitorRegistry(List> serviceInterfaces) {
super(serviceInterfaces);
}
private static MonitorRegistry instance;
public static MonitorRegistry getInstance() {
if (instance == null) {
List> services = new ArrayList>();
services.add(ProcessMonitor.class);
services.add(ActivityMonitor.class);
services.add(AdapterMonitor.class);
services.add(ServiceMonitor.class);
instance = new MonitorRegistry(services);
}
return instance;
}
/**
* Returns all process monitors.
*/
public List getProcessMonitors() {
return getDynamicServices(ProcessMonitor.class);
}
/**
* Returns only enabled monitors.
*/
public List getProcessMonitors(RuntimeContext context) {
return getProcessMonitors().stream().filter(monitor ->
monitor.isEnabled(context)
).collect(Collectors.toList());
}
/**
* Returns all activity monitors.
*/
public List getActivityMonitors() {
return getDynamicServices(ActivityMonitor.class);
}
/**
* Returns only enabled monitors.
*/
public List getActivityMonitors(RuntimeContext context) {
return getActivityMonitors().stream().filter(monitor ->
monitor.isEnabled(context)
).collect(Collectors.toList());
}
/**
* Returns all adapter monitors.
*/
public List getAdapterMonitors() {
return getDynamicServices(AdapterMonitor.class);
}
/**
* Returns only enabled monitors.
*/
public List getAdapterMonitors(RuntimeContext context) {
return getAdapterMonitors().stream().filter(monitor ->
monitor.isEnabled(context)
).collect(Collectors.toList());
}
/**
* Returns all task monitors.
*/
public List getTaskMonitors() {
return getDynamicServices(TaskMonitor.class);
}
/**
* Returns only enabled monitors.
*/
public List getTaskMonitors(RuntimeContext context) {
return getTaskMonitors().stream().filter(monitor ->
monitor.isEnabled(context)
).collect(Collectors.toList());
}
/**
* Returns all service monitors.
*/
public List getServiceMonitors() {
List serviceMonitors = new ArrayList<>();
serviceMonitors.addAll(getDynamicServices(ServiceMonitor.class));
return serviceMonitors;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy