private List<String> getLogFilePaths(List<PropertyMap> enabledEventSources) { List<String> logFilePaths = new ArrayList<String>(enabledEventSources.size()); for (PropertyMap logEventSource : enabledEventSources) { String logFilePath = logEventSource.getSimpleValue(LogEventSourcePropertyNames.LOG_FILE_PATH, null); if (logFilePath == null) { throw new IllegalStateException("Required property [" + LogEventSourcePropertyNames.LOG_FILE_PATH + "] is not defined in map."); } logFilePaths.add(logFilePath); } return logFilePaths; } }
private static void applyEnvironmentVars(PropertyList environment, ProcessExecution processExecution) { if (environment != null) { Map<String, String> environmentVariables = processExecution.getEnvironmentVariables(); for (Property prop : environment.getList()) { PropertyMap var = (PropertyMap) prop; environmentVariables.put(var.getSimpleValue("name", null), var.getSimpleValue("value", null)); } processExecution.setEnvironmentVariables(environmentVariables); } }
static Map<String, String> getConnectionPropertiesAsMap(PropertyList listPropertyWrapper, String keyName) { if (listPropertyWrapper == null) { return Collections.emptyMap(); } List<Property> propertyList = listPropertyWrapper.getList(); if (propertyList.size() == 0) { return Collections.emptyMap(); } Map<String, String> result = new HashMap<String, String>(propertyList.size()); for (Property p : propertyList) { PropertyMap map = (PropertyMap) p; String key = map.getSimpleValue(keyName, null); String value = map.getSimpleValue("value", null); if (key == null || value == null) { continue; } result.put(key, value); } return result; } }
private List<Filter> getFilters(String type) { PropertyList filtersListProperty = configuration.getList(type); if (filtersListProperty == null) { return emptyList(); } List<Filter> filters = new ArrayList<Filter>(); for (Property property : filtersListProperty.getList()) { PropertyMap filter = (PropertyMap) property; filters.add(new Filter(filter.getSimpleValue(DriftConfigurationDefinition.PROP_PATH, "."), filter .getSimpleValue(DriftConfigurationDefinition.PROP_PATTERN, ""))); } return filters; } }
public BaseDirectory getBasedir() { PropertyMap map = configuration.getMap(DriftConfigurationDefinition.PROP_BASEDIR); if (map == null) { return null; } String valueContext = map.getSimpleValue(DriftConfigurationDefinition.PROP_BASEDIR_VALUECONTEXT, null); String valueName = map.getSimpleValue(DriftConfigurationDefinition.PROP_BASEDIR_VALUENAME, null); BaseDirValueContext valueContextEnum; if (valueContext == null) { throw new NullPointerException("valueContext is null"); } else { try { valueContextEnum = BaseDirValueContext.valueOf(valueContext); } catch (Exception e) { throw new IllegalArgumentException("Invalid valueContext: " + valueContext); } } if (valueName == null) { throw new NullPointerException("valueName is null"); } return new BaseDirectory(valueContextEnum, valueName); }
PropertySimple findOverrideForMetric(MetricTemplate def, PropertyList overrides) { for (Property p : overrides.getList()) { PropertyMap map = (PropertyMap) p; String metricName = map.getSimpleValue(METRIC_NAME_PROPERTY, null); String resourceTypeName = map.getSimpleValue(RESOURCE_TYPE_NAME_PROPERTY, null); String resourceTypePlugin = map.getSimpleValue(RESOURCE_TYPE_PLUGIN_PROPERTY, null); PropertySimple updateSchedules = map.getSimple(UPDATE_SCHEDULES_PROPERTY); if (metricName == null || resourceTypeName == null || resourceTypePlugin == null || updateSchedules == null) { continue; } if (metricName.equals(def.getMetricName()) && resourceTypeName.equals(def.getResourceTypeName()) && resourceTypePlugin.equals(def.getResourceTypePlugin())) { return updateSchedules; } } return null; } }
@Override boolean isConnectorPropertyDefined() { PropertyMap connector = configuration.getMap(CONNECTOR_PROPERTY); if (connector != null) { return isNotBlank(connector.getSimpleValue("name:0", EMPTY_STRING)); } return false; }
public void stopLogFileEventPollers() { boolean sigarAvailable = this.resourceContext.getSystemInformation().isNative(); if (!sigarAvailable) { return; } for (Iterator<PropertyMap> iterator = this.startedEventSources.iterator(); iterator.hasNext(); ) { PropertyMap logEventSource = iterator.next(); EventContext eventContext = this.resourceContext.getEventContext(); String logFilePath = logEventSource.getSimpleValue(LogEventSourcePropertyNames.LOG_FILE_PATH, null); eventContext.unregisterEventPoller(LOG_ENTRY_EVENT_TYPE, logFilePath); iterator.remove(); } }
private List<String> findAssignedServerGroups() { List<String> groups = new ArrayList<String>(); Configuration config = new Configuration(); loadAssignedServerGroups(config); for (Property prop : config.getList("*1").getList()) { PropertyMap map = (PropertyMap) prop; groups.add(map.getSimpleValue("server-group", null)); } return groups; }
@Nullable private String getListMemberMapKey(PropertyDefinitionList propDefList) { Configuration pluginConfig = this.resourceContext.getPluginConfiguration(); PropertyMap mapKeyNames = pluginConfig.getMap("listMemberMapKeyNames"); if (mapKeyNames == null) { return null; } String listName = propDefList.getName(); return mapKeyNames.getSimpleValue(listName, null); }
String additionalFilesDir = additionalFileMap.getSimpleValue(PROP_ADDITIONAL_FILES_DIRECTORY, ""); String additionalFilesRegex = additionalFileMap.getSimpleValue(PROP_ADDITIONAL_FILES_REGEX, null); String additionalFilesEnabled = additionalFileMap.getSimpleValue(PROP_SNAPSHOT_ADDITIONAL_FILES, "true"); if (!"true".equals(additionalFilesEnabled)) { continue; String recursive = additionalFileMap.getSimpleValue(PROP_ADDITIONAL_FILES_RECURSIVE, "false"); RegexFilenameFilter filter = new RegexFilenameFilter(additionalFilesRegex, recursive); File[] additionalFiles = additionalFilesDirFile.listFiles(filter);
private static <T extends BundleDestinationSpecification> T from(PropertyMap map, Class<T> expectedClass) { String name = map.getSimpleValue(BUNDLE_DEST_NAME_NAME, null); String valueContext = map.getSimpleValue(BUNDLE_DEST_BASE_DIR_VALUE_CONTEXT_NAME, null); String description = map.getSimpleValue(BUNDLE_DEST_DESCRIPTION_NAME, null); String connection = map.getSimpleValue(BUNDLE_DEST_DEFINITION_CONNECTION_NAME, null); PropertyList refs = map.getList(BUNDLE_DEST_DEFINITION_REF_LIST_NAME); PropertyList acceptProps = map.getList(BUNDLE_DEST_ACCEPTS_LIST_NAME); BundleDestinationBaseDirectory.class) || expectedClass.equals(BundleDestinationSpecification.class))) { String valueName = map.getSimpleValue(BUNDLE_DEST_BASE_DIR_VALUE_NAME_NAME, null); PropertyMap ref = (PropertyMap) p; String type = ref.getSimpleValue(BUNDLE_DEST_DEF_REF_TYPE_NAME, null); if (type == null) { continue; BundleDestinationDefinition.ConfigRef.Type.valueOf(type); String context = ref.getSimpleValue(BUNDLE_DEST_DEF_REF_CONTEXT_NAME, null); if (context == null) { continue; String refName = ref.getSimpleValue(BUNDLE_DEST_DEF_REF_NAME_NAME, null); if (name == null) { continue; String refTargetName = ref.getSimpleValue(BUNDLE_DEST_DEF_REF_TARGET_NAME_NAME, refName);
@Override public void updateResourceConfiguration(ConfigurationUpdateReport report) { // We need to filter the path properties that are marked with the read-only flag // This is done by setting the logical removed flag on the map to signal // the write delegate to skip the map Configuration config = report.getConfiguration(); PropertyList propertyList = config.getList("*3"); for (Property property : propertyList.getList()) { PropertyMap map = (PropertyMap) property; String ro = map.getSimpleValue("read-only", "false"); if (Boolean.parseBoolean(ro)) { map.setErrorMessage(ConfigurationWriteDelegate.LOGICAL_REMOVED); } } super.updateResourceConfiguration(report); }
for (Property prop : logEventSources.getList()) { PropertyMap logEventSource = (PropertyMap) prop; String enabled = logEventSource.getSimpleValue(LogEventSourcePropertyNames.ENABLED, null); if (enabled == null) { throw new IllegalStateException("Required property [" + LogEventSourcePropertyNames.ENABLED String logFilePath = logEventSource.getSimpleValue(LogEventSourcePropertyNames.LOG_FILE_PATH, null); if (logFilePath == null) { throw new IllegalStateException("Required property [" + LogEventSourcePropertyNames.LOG_FILE_PATH String dateFormatString = logEventSource.getSimpleValue(LogEventSourcePropertyNames.DATE_FORMAT, null); if (dateFormatString != null) { try { String includesPatternString = logEventSource.getSimpleValue( LogEventSourcePropertyNames.INCLUDES_PATTERN, null); if (includesPatternString != null) { String minimumSeverityString = logEventSource.getSimpleValue( LogEventSourcePropertyNames.MINIMUM_SEVERITY, null); if (minimumSeverityString != null) {
for (Property p : sgConfig.getList("*1").getList()) { PropertyMap map = (PropertyMap) p; assignedCurrent.put(map.getSimpleValue("server-group", null), map); PropertyMap duplicate = assignedNew.put(mapNew.getSimpleValue("server-group", null), mapNew); if (duplicate != null) { report.setStatus(ConfigurationUpdateStatus.FAILURE); report.setErrorMessage("Duplicate assignment to [" + duplicate.getSimpleValue("server-group", null) + "] you cannot assign deployment to server-group more than once"); return; String key = mapNew.getSimpleValue("server-group", null); String runtimeNew = mapNew.getSimpleValue("runtime-name", null); boolean enabledNew = mapNew.getSimple("enabled").getBooleanValue(); PropertyMap mapCurrent = assignedCurrent.remove(key); operation.addStep(createServerGroupAssignmentStep("remove", map.getSimpleValue("server-group", null), null, false));
@Override public Operation getBatchOperation() { CompositeOperation compositeOperation = new CompositeOperation(); if (hasDiscoveryGroupName()) { compositeOperation.addStep(new UndefineAttribute(address, CONNECTOR_ATTRIBUTE)); compositeOperation.addStep(new WriteAttribute(address, DISCOVERY_GROUP_NAME, configuration .getSimpleValue(DISCOVERY_GROUP_NAME))); } else { compositeOperation.addStep(new UndefineAttribute(address, DISCOVERY_GROUP_NAME)); compositeOperation.addStep(new WriteAttribute(address, CONNECTOR_ATTRIBUTE, Collections.singletonMap( configuration.getMap(CONNECTOR_PROPERTY).getSimpleValue("name:0", EMPTY_STRING), null))); } return compositeOperation; } }