|
@@ -24,6 +24,7 @@ public class Configuration {
|
|
|
private final Collection<ExecutableGroup> executableGroups;
|
|
private final Collection<ExecutableGroup> executableGroups;
|
|
|
private final Collection<MessageBrokerConfig> messageBrokerConfigs;
|
|
private final Collection<MessageBrokerConfig> messageBrokerConfigs;
|
|
|
private final Collection<EmailServerConfig> emailServerConfigs;
|
|
private final Collection<EmailServerConfig> emailServerConfigs;
|
|
|
|
|
+ private final Collection<SensLogServerConfig> sensLogServerConfigs;
|
|
|
private final Collection<DataProviderConfig> dataProviderConfigs;
|
|
private final Collection<DataProviderConfig> dataProviderConfigs;
|
|
|
|
|
|
|
|
private Configuration(
|
|
private Configuration(
|
|
@@ -31,12 +32,14 @@ public class Configuration {
|
|
|
Collection<ExecutableGroup> executableGroups,
|
|
Collection<ExecutableGroup> executableGroups,
|
|
|
Collection<EmailServerConfig> emailServerConfigs,
|
|
Collection<EmailServerConfig> emailServerConfigs,
|
|
|
Collection<MessageBrokerConfig> messageBrokerConfigs,
|
|
Collection<MessageBrokerConfig> messageBrokerConfigs,
|
|
|
|
|
+ Collection<SensLogServerConfig> sensLogServerConfigs,
|
|
|
Collection<DataProviderConfig> dataProviderConfigs
|
|
Collection<DataProviderConfig> dataProviderConfigs
|
|
|
){
|
|
){
|
|
|
this.generalConfig = generalConfig;
|
|
this.generalConfig = generalConfig;
|
|
|
this.executableGroups = executableGroups;
|
|
this.executableGroups = executableGroups;
|
|
|
this.messageBrokerConfigs = messageBrokerConfigs;
|
|
this.messageBrokerConfigs = messageBrokerConfigs;
|
|
|
this.emailServerConfigs = emailServerConfigs;
|
|
this.emailServerConfigs = emailServerConfigs;
|
|
|
|
|
+ this.sensLogServerConfigs = sensLogServerConfigs;
|
|
|
this.dataProviderConfigs = dataProviderConfigs;
|
|
this.dataProviderConfigs = dataProviderConfigs;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -45,11 +48,11 @@ public class Configuration {
|
|
|
List<TempUnitConfig> monitoredObjects,
|
|
List<TempUnitConfig> monitoredObjects,
|
|
|
Map<String, EmailServerConfig> emailServers,
|
|
Map<String, EmailServerConfig> emailServers,
|
|
|
Map<String, MessageBrokerConfig> messageBrokers,
|
|
Map<String, MessageBrokerConfig> messageBrokers,
|
|
|
|
|
+ Map<String, SensLogServerConfig> sensLogServers,
|
|
|
Map<String, DataProviderConfig> dataProviders,
|
|
Map<String, DataProviderConfig> dataProviders,
|
|
|
Map<String, GroupConfig> groups,
|
|
Map<String, GroupConfig> groups,
|
|
|
Map<String, SuperGroupConfig> superGroups
|
|
Map<String, SuperGroupConfig> superGroups
|
|
|
) {
|
|
) {
|
|
|
-
|
|
|
|
|
Map<String, ExecutableGroup> executableGroupsMap = new HashMap<>();
|
|
Map<String, ExecutableGroup> executableGroupsMap = new HashMap<>();
|
|
|
for (TempUnitConfig mObject : monitoredObjects) {
|
|
for (TempUnitConfig mObject : monitoredObjects) {
|
|
|
Set<String> unitGroups = mObject.groups;
|
|
Set<String> unitGroups = mObject.groups;
|
|
@@ -138,11 +141,14 @@ public class Configuration {
|
|
|
Collection<ExecutableGroup> execGroups = executableGroupsMap.values();
|
|
Collection<ExecutableGroup> execGroups = executableGroupsMap.values();
|
|
|
Collection<SuperGroup> execSGroups = executableSGroupsMap.values();
|
|
Collection<SuperGroup> execSGroups = executableSGroupsMap.values();
|
|
|
Collection<EmailServerConfig> emailServerConfigs = emailServers.values();
|
|
Collection<EmailServerConfig> emailServerConfigs = emailServers.values();
|
|
|
|
|
+ Collection<SensLogServerConfig> sensLogServerConfigs = sensLogServers.values();
|
|
|
Collection<DataProviderConfig> dataProviderConfigs = dataProviders.values();
|
|
Collection<DataProviderConfig> dataProviderConfigs = dataProviders.values();
|
|
|
Collection<MessageBrokerConfig> messageBrokerConfigs = messageBrokers.values();
|
|
Collection<MessageBrokerConfig> messageBrokerConfigs = messageBrokers.values();
|
|
|
|
|
|
|
|
return new Configuration(generalConfig, execGroups,
|
|
return new Configuration(generalConfig, execGroups,
|
|
|
- emailServerConfigs, messageBrokerConfigs, dataProviderConfigs);
|
|
|
|
|
|
|
+ emailServerConfigs, messageBrokerConfigs,
|
|
|
|
|
+ sensLogServerConfigs, dataProviderConfigs
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public static Configuration load(String fileName) throws IOException {
|
|
public static Configuration load(String fileName) throws IOException {
|
|
@@ -179,6 +185,7 @@ public class Configuration {
|
|
|
parseMonitoredObjects(createPropertyConfig(properties, "monitoredObjects")),
|
|
parseMonitoredObjects(createPropertyConfig(properties, "monitoredObjects")),
|
|
|
parseEmailServers(createPropertyConfig(properties, "emailServers")),
|
|
parseEmailServers(createPropertyConfig(properties, "emailServers")),
|
|
|
parseMessageBrokers(createPropertyConfig(properties, "messageBrokers")),
|
|
parseMessageBrokers(createPropertyConfig(properties, "messageBrokers")),
|
|
|
|
|
+ parseSensLogServers(createPropertyConfig(properties, "senslogServers")),
|
|
|
parseDataProviders(createPropertyConfig(properties, "dataProviders")),
|
|
parseDataProviders(createPropertyConfig(properties, "dataProviders")),
|
|
|
parseGroups(createPropertyConfig(properties, "groups")),
|
|
parseGroups(createPropertyConfig(properties, "groups")),
|
|
|
parseSuperGroups(createPropertyConfig(properties, "superGroups"))
|
|
parseSuperGroups(createPropertyConfig(properties, "superGroups"))
|
|
@@ -199,12 +206,7 @@ public class Configuration {
|
|
|
Map<String, EmailServerConfig> emailServers = new HashMap<>();
|
|
Map<String, EmailServerConfig> emailServers = new HashMap<>();
|
|
|
for (String id : serverIds) {
|
|
for (String id : serverIds) {
|
|
|
PropertyConfig serverConfig = config.getPropertyConfig(id);
|
|
PropertyConfig serverConfig = config.getPropertyConfig(id);
|
|
|
- emailServers.put(id, new EmailServerConfig(id,
|
|
|
|
|
- serverConfig.getStringProperty("smtpHost"),
|
|
|
|
|
- serverConfig.getIntegerProperty("smtpPort"),
|
|
|
|
|
- serverConfig.getStringProperty("authUsername"),
|
|
|
|
|
- serverConfig.getStringProperty("authPassword")
|
|
|
|
|
- ));
|
|
|
|
|
|
|
+ emailServers.put(id, EmailServerConfig.create(serverConfig));
|
|
|
}
|
|
}
|
|
|
return emailServers;
|
|
return emailServers;
|
|
|
}
|
|
}
|
|
@@ -221,6 +223,16 @@ public class Configuration {
|
|
|
return messageBrokers;
|
|
return messageBrokers;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private static Map<String, SensLogServerConfig> parseSensLogServers(PropertyConfig config) {
|
|
|
|
|
+ Set<String> serverIds = config.getAttributes();
|
|
|
|
|
+ Map<String, SensLogServerConfig> serverConfigs = new HashMap<>(serverIds.size());
|
|
|
|
|
+ for (String id : serverIds) {
|
|
|
|
|
+ PropertyConfig serverConfig = config.getPropertyConfig(id);
|
|
|
|
|
+ serverConfigs.put(id, SensLogServerConfig.create(serverConfig));
|
|
|
|
|
+ }
|
|
|
|
|
+ return serverConfigs;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private static Map<String, DataProviderConfig> parseDataProviders(PropertyConfig config) {
|
|
private static Map<String, DataProviderConfig> parseDataProviders(PropertyConfig config) {
|
|
|
Set<String> providerIds = config.getAttributes();
|
|
Set<String> providerIds = config.getAttributes();
|
|
|
Map<String, DataProviderConfig> dataProviders = new HashMap<>(providerIds.size());
|
|
Map<String, DataProviderConfig> dataProviders = new HashMap<>(providerIds.size());
|
|
@@ -237,13 +249,7 @@ public class Configuration {
|
|
|
Map<String, GroupConfig> groups = new HashMap<>(groupIds.size());
|
|
Map<String, GroupConfig> groups = new HashMap<>(groupIds.size());
|
|
|
for (String id : groupIds) {
|
|
for (String id : groupIds) {
|
|
|
PropertyConfig groupConfig = config.getPropertyConfig(id);
|
|
PropertyConfig groupConfig = config.getPropertyConfig(id);
|
|
|
- groups.put(id, new GroupConfig(id,
|
|
|
|
|
- groupConfig.getStringProperty("name"),
|
|
|
|
|
- groupConfig.getStringProperty("dataProvider"),
|
|
|
|
|
- groupConfig.getStringProperty("messageBroker"),
|
|
|
|
|
- ResultType.of(groupConfig.getStringProperty("resultType")),
|
|
|
|
|
- groupConfig.getOptionalProperty("period", Integer.class).orElse(null)
|
|
|
|
|
- ));
|
|
|
|
|
|
|
+ groups.put(id, GroupConfig.create(groupConfig));
|
|
|
}
|
|
}
|
|
|
return groups;
|
|
return groups;
|
|
|
}
|
|
}
|
|
@@ -302,14 +308,14 @@ public class Configuration {
|
|
|
private static PropertyConfig createPropertyConfig(Map<Object, Object> properties, String propertyName) throws IOException {
|
|
private static PropertyConfig createPropertyConfig(Map<Object, Object> properties, String propertyName) throws IOException {
|
|
|
Object generalConfig = properties.get(propertyName);
|
|
Object generalConfig = properties.get(propertyName);
|
|
|
if (generalConfig == null) {
|
|
if (generalConfig == null) {
|
|
|
- return new PropertyConfig(propertyName);
|
|
|
|
|
|
|
+ return new PropertyConfig(propertyName, propertyName);
|
|
|
}
|
|
}
|
|
|
if (!(generalConfig instanceof Map)) {
|
|
if (!(generalConfig instanceof Map)) {
|
|
|
throw new IOException(propertyName);
|
|
throw new IOException(propertyName);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
Map<?, ?> generalConfigMap = (Map<?, ?>) generalConfig;
|
|
Map<?, ?> generalConfigMap = (Map<?, ?>) generalConfig;
|
|
|
- PropertyConfig propertyConfig = new PropertyConfig(propertyName);
|
|
|
|
|
|
|
+ PropertyConfig propertyConfig = new PropertyConfig(propertyName, propertyName);
|
|
|
|
|
|
|
|
for (Map.Entry<?, ?> entry : generalConfigMap.entrySet()) {
|
|
for (Map.Entry<?, ?> entry : generalConfigMap.entrySet()) {
|
|
|
String keyName = entry.getKey().toString();
|
|
String keyName = entry.getKey().toString();
|
|
@@ -326,6 +332,10 @@ public class Configuration {
|
|
|
return emailServerConfigs;
|
|
return emailServerConfigs;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public Collection<SensLogServerConfig> getSensLogServerConfigs() {
|
|
|
|
|
+ return sensLogServerConfigs;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public Collection<DataProviderConfig> getDataProviderConfigs() {
|
|
public Collection<DataProviderConfig> getDataProviderConfigs() {
|
|
|
return dataProviderConfigs;
|
|
return dataProviderConfigs;
|
|
|
}
|
|
}
|