@Override public void onPropertyModified(PropertyDescriptor descriptor, String oldValue, String newValue) { logger.info("property {} value changed from {} to {}", descriptor.getName(), oldValue, newValue); }
/** * Hook method allowing subclasses to eagerly react to a configuration * change for the given property descriptor. As an alternative to using this * method a processor may simply getField the latest value whenever it needs it * and if necessary lazily evaluate it. * * @param descriptor of the modified property * @param oldValue non-null property value (previous) * @param newValue the new property value or if null indicates the property * was removed */ @Override public void onPropertyModified(PropertyDescriptor descriptor, String oldValue, String newValue) { logger.info("property {} value changed from {} to {}", descriptor.getName(), oldValue, newValue); }
@Override public void onPropertyModified(PropertyDescriptor descriptor, String oldValue, String newValue) { logger.debug("property {} value changed from {} to {}", descriptor.getName(), oldValue, newValue); /** * Handle the debug property */ if (descriptor.getName().equals(KEY_DEBUG)) { if (newValue != null) { if (newValue.equalsIgnoreCase("true")) { debug = true; } } else { debug = false; } } } }
@Override public void onPropertyModified(PropertyDescriptor descriptor, String oldValue, String newValue) { logger.debug("property {} value changed from {} to {}", descriptor.getName(), oldValue, newValue); /** * Handle the debug property */ if (descriptor.getName().equals(KEY_DEBUG)) { if (newValue != null) { if (newValue.equalsIgnoreCase("true")) { debug = true; } } else { debug = false; } } } }
@Override public void onPropertyModified(PropertyDescriptor descriptor, String oldValue, String newValue) { logger.debug("property {} value changed from {} to {}", descriptor.getName(), oldValue, newValue); /** * Handle the debug property */ if (descriptor.getName().equals(KEY_DEBUG)) { if (newValue != null) { if (newValue.equalsIgnoreCase("true")) { debug = true; } } else { debug = false; } } } }
@Override public void onPropertyModified(PropertyDescriptor descriptor, String oldValue, String newValue) { logger.debug("property {} value changed from {} to {}", descriptor.getName(), oldValue, newValue); /** * Handle the debug property */ if (descriptor.getName().equals(KEY_DEBUG)) { if (newValue != null) { if (newValue.equalsIgnoreCase("true")) { debug = true; } } else { debug = false; } } }
@Override public void onPropertyModified(PropertyDescriptor descriptor, String oldValue, String newValue) { logger.debug("property {} value changed from {} to {}", descriptor.getName(), oldValue, newValue); /** * Handle the debug property */ if (descriptor.getName().equals(KEY_DEBUG)) { if (newValue != null) { if (newValue.equalsIgnoreCase("true")) { debug = true; } } else { debug = false; } } } }
@Override public PropertyValue getPropertyValue(final PropertyDescriptor descriptor) { return getPropertyValue(descriptor.getName()); }
public StandardValidationContext(final Map<PropertyDescriptor, String> properties) { this.properties = new HashMap<>(properties); expressionLanguageSupported = new HashMap<>(properties.size()); for (final PropertyDescriptor descriptor : properties.keySet()) { expressionLanguageSupported.put(descriptor.getName(), descriptor.isExpressionLanguageSupported()); } }
@Override public PropertyValue getPropertyValue(final PropertyDescriptor descriptor) { return getPropertyValue(descriptor.getName()); }
@Override public void onPropertyModified(PropertyDescriptor descriptor, String oldValue, String newValue) { logger.debug("property {} value changed from {} to {}", new Object[]{descriptor.getName(), oldValue, newValue}); }
@Override public PropertyValue getPropertyValue(final PropertyDescriptor descriptor) { return getPropertyValue(descriptor.getName()); }
@Override public PropertyValue getPropertyValue(final PropertyDescriptor descriptor) { return getPropertyValue(descriptor.getName()); }
private Map<String, String> getFieldsNameMapping(ProcessContext context) { /** * list alternative regex */ Map<String, String> fieldsNameMappings = new HashMap<>(); // loop over dynamic properties to add alternative regex for (final Map.Entry<PropertyDescriptor, String> entry : context.getProperties().entrySet()) { if (!entry.getKey().isDynamic()) { continue; } final String fieldName = entry.getKey().getName(); final String mapping = entry.getValue(); fieldsNameMappings.put(fieldName, mapping); } return fieldsNameMappings; } }
private Map<String, String[]> getFieldsNameMapping(ProcessContext context) { /** * list alternative regex */ Map<String, String[]> fieldsNameMappings = new HashMap<>(); // loop over dynamic properties to add alternative regex for (final Map.Entry<PropertyDescriptor, String> entry : context.getProperties().entrySet()) { if (!entry.getKey().isDynamic()) { continue; } final String fieldName = entry.getKey().getName(); final String[] mapping = entry.getValue().split(","); fieldsNameMappings.put(fieldName, mapping); } return fieldsNameMappings; }
@Override protected void setupDynamicProperties(ProcessContext context) { for (final Map.Entry<PropertyDescriptor, String> entry : context.getProperties().entrySet()) { if (!entry.getKey().isDynamic()) { continue; } String key = entry.getKey().getName(); String value = entry.getValue() .replaceAll("cache\\((\\S*\\))", "cache.get(\"test\", new com.hurence.logisland.record.StandardRecord().setId($1)") .replaceAll("\\.value", ".getField(com.hurence.logisland.record.FieldDictionary.RECORD_VALUE).asDouble()"); StringBuilder sb = new StringBuilder(); sb.append("var match=false;\n") .append("try {\n") .append("if( ") .append(value) .append(" ) { match=true; }\n") .append("} catch(error) {}"); dynamicTagValuesMap.put(entry.getKey().getName(), sb.toString()); // System.out.println(sb.toString()); // logger.debug(sb.toString()); } defaultCollection = context.getPropertyValue(DATASTORE_CACHE_COLLECTION).asString(); recordTTL = context.getPropertyValue(RECORD_TTL).asInteger(); }
@Override public void onPropertyModified(PropertyDescriptor descriptor, String oldValue, String newValue) { logger.info("property {} value changed from {} to {}", descriptor.getName(), oldValue, newValue); /** * In java, onPropertyModified for config properties is called before the init method is called so before our * init method is called our python interpreter is not initialized and we cannot call it before */ if (initDone) { if (useScriptFile) { /** * pyProcessor.onPropertyModified(context, oldValue, newValue) */ pythonInterpreter.set("descriptor", descriptor); pythonInterpreter.set("oldValue", oldValue); pythonInterpreter.set("newValue", newValue); pythonInterpreter.exec("pyProcessor.onPropertyModified(context, oldValue, newValue)"); } else { // TODO logger.warn("Dynamic update of configuration properties is not supported when not using python" + " script file"); } } }
@Override protected Collection<ValidationResult> customValidate(ValidationContext context) { final List<ValidationResult> validationResults = new ArrayList<>(super.customValidate(context)); if (context.getPropertyValue(STRATEGY).isSet()) { if (context.getPropertyValue(STRATEGY).getRawValue().equals(JAVA_FORMAT_STRING_WITH_FIELDS_STRATEGY.getValue())) { if (!context.getPropertyValue(JAVA_FORMAT_STRING).isSet()) { validationResults.add( new ValidationResult.Builder() .input(JAVA_FORMAT_STRING.getName()) .explanation(String.format("%s must be set when strategy is %s", JAVA_FORMAT_STRING.getName(), context.getPropertyValue(STRATEGY).getRawValue())) .valid(false) .build()); } } } return validationResults; }
private PropertyDescriptor getPropertyDescriptor(final PropertyDescriptor specDescriptor) { PropertyDescriptor descriptor = null; //check if property supported final List<PropertyDescriptor> supportedDescriptors = getSupportedPropertyDescriptors(); if (supportedDescriptors != null) { for (final PropertyDescriptor desc : supportedDescriptors) { //find actual descriptor if (specDescriptor.equals(desc)) { return desc; } } } descriptor = getSupportedDynamicPropertyDescriptor(specDescriptor.getName()); if (descriptor != null && !descriptor.isDynamic()) { descriptor = new PropertyDescriptor.Builder().fromPropertyDescriptor(descriptor).dynamic(true).build(); } if (descriptor == null) { descriptor = new PropertyDescriptor.Builder().fromPropertyDescriptor(specDescriptor).addValidator(Validator.INVALID).dynamic(true).build(); } return descriptor; }