/** * Returns a new properties instance with the given keys removed. */ public DescriptorProperties withoutKeys(List<String> keys) { final Set<String> keySet = new HashSet<>(keys); final DescriptorProperties copy = new DescriptorProperties(normalizeKeys); properties.entrySet().stream() .filter(e -> !keySet.contains(e.getKey())) .forEach(e -> copy.properties.put(e.getKey(), e.getValue())); return copy; }
/** * Normalizes key-value properties from Yaml in the normalized format of the Table API. */ public static DescriptorProperties normalizeYaml(Map<String, Object> yamlMap) { final Map<String, String> normalized = new HashMap<>(); yamlMap.forEach((k, v) -> normalizeYamlObject(normalized, k, v)); final DescriptorProperties properties = new DescriptorProperties(true); properties.putProperties(normalized); return properties; }
@Override protected Map<String, String> toConnectorProperties() { final DescriptorProperties properties = new DescriptorProperties(); properties.putProperties(internalProperties); final List<List<String>> hostValues = hosts.stream() .map(host -> Arrays.asList(host.hostname, String.valueOf(host.port), host.protocol)) .collect(Collectors.toList()); properties.putIndexedFixedProperties( CONNECTOR_HOSTS, Arrays.asList(CONNECTOR_HOSTS_HOSTNAME, CONNECTOR_HOSTS_PORT, CONNECTOR_HOSTS_PROTOCOL), hostValues); return properties.asMap(); } }
/** * Creates a new execution entry enriched with additional properties that are prefixed with * {@link Environment#EXECUTION_ENTRY}. */ public static ExecutionEntry enrich(ExecutionEntry execution, Map<String, String> prefixedProperties) { final Map<String, String> enrichedProperties = new HashMap<>(execution.asMap()); prefixedProperties.forEach((k, v) -> { final String normalizedKey = k.toLowerCase(); if (k.startsWith(EXECUTION_ENTRY + '.')) { enrichedProperties.put(normalizedKey.substring(EXECUTION_ENTRY.length() + 1), v); } }); final DescriptorProperties properties = new DescriptorProperties(true); properties.putProperties(enrichedProperties); return new ExecutionEntry(properties); } }
/** * Creates a new deployment entry enriched with additional properties that are prefixed with * {@link Environment#DEPLOYMENT_ENTRY}. */ public static DeploymentEntry enrich(DeploymentEntry deployment, Map<String, String> prefixedProperties) { final Map<String, String> enrichedProperties = new HashMap<>(deployment.asMap()); prefixedProperties.forEach((k, v) -> { final String normalizedKey = k.toLowerCase(); if (k.startsWith(DEPLOYMENT_ENTRY + '.')) { enrichedProperties.put(normalizedKey.substring(DEPLOYMENT_ENTRY.length() + 1), v); } }); final DescriptorProperties properties = new DescriptorProperties(true); properties.putProperties(enrichedProperties); return new DeploymentEntry(properties); } }
public static ViewEntry create(String name, String query) { final DescriptorProperties properties = new DescriptorProperties(true); properties.putString(TABLES_QUERY, query); return new ViewEntry(name, properties); } }
/** * Merges two deployments entries. The properties of the first deployment entry might be * overwritten by the second one. */ public static DeploymentEntry merge(DeploymentEntry deployment1, DeploymentEntry deployment2) { final Map<String, String> mergedProperties = new HashMap<>(deployment1.asMap()); mergedProperties.putAll(deployment2.asMap()); final DescriptorProperties properties = new DescriptorProperties(true); properties.putProperties(mergedProperties); return new DeploymentEntry(properties); }
/** * Merges two execution entries. The properties of the first execution entry might be * overwritten by the second one. */ public static ExecutionEntry merge(ExecutionEntry execution1, ExecutionEntry execution2) { final Map<String, String> mergedProperties = new HashMap<>(execution1.asMap()); mergedProperties.putAll(execution2.asMap()); final DescriptorProperties properties = new DescriptorProperties(true); properties.putProperties(mergedProperties); return new ExecutionEntry(properties); }
private static DescriptorProperties getValidatedProperties(Map<String, String> propertiesMap) { final DescriptorProperties descriptorProperties = new DescriptorProperties(); descriptorProperties.putProperties(propertiesMap); // validate new AvroValidator().validate(descriptorProperties); return descriptorProperties; } }
private static DescriptorProperties getValidatedProperties(Map<String, String> propertiesMap) { final DescriptorProperties descriptorProperties = new DescriptorProperties(); descriptorProperties.putProperties(propertiesMap); // validate new JsonValidator().validate(descriptorProperties); return descriptorProperties; } }
@Override protected Map<String, String> toFormatProperties() { final DescriptorProperties properties = new DescriptorProperties(); if (null != recordClass) { properties.putClass(AvroValidator.FORMAT_RECORD_CLASS, recordClass); } if (null != avroSchema) { properties.putString(AvroValidator.FORMAT_AVRO_SCHEMA, avroSchema); } return properties.asMap(); } }
@Override public final Map<String, String> toProperties() { final DescriptorProperties properties = new DescriptorProperties(); properties.putString(FormatDescriptorValidator.FORMAT_TYPE, type); properties.putInt(FormatDescriptorValidator.FORMAT_PROPERTY_VERSION, version); properties.putProperties(toFormatProperties()); return properties.asMap(); }
@Override public final Map<String, String> toProperties() { final DescriptorProperties properties = new DescriptorProperties(); properties.putString(CONNECTOR_TYPE, type); properties.putLong(CONNECTOR_PROPERTY_VERSION, version); properties.putProperties(toConnectorProperties()); return properties.asMap(); }
private DescriptorProperties getValidatedProperties(Map<String, String> properties) { final DescriptorProperties descriptorProperties = new DescriptorProperties(true); descriptorProperties.putProperties(properties); // allow Kafka timestamps to be used, watermarks can not be received from source new SchemaValidator(true, supportsKafkaTimestamps(), false).validate(descriptorProperties); new KafkaValidator().validate(descriptorProperties); return descriptorProperties; }
@Override protected Map<String, String> toFormatProperties() { final DescriptorProperties properties = new DescriptorProperties(); if (deriveSchema != null) { properties.putBoolean(FORMAT_DERIVE_SCHEMA, deriveSchema); } if (jsonSchema != null) { properties.putString(FORMAT_JSON_SCHEMA, jsonSchema); } if (schema != null) { properties.putString(FORMAT_SCHEMA, schema); } if (failOnMissingField != null) { properties.putBoolean(FORMAT_FAIL_ON_MISSING_FIELD, failOnMissingField); } return properties.asMap(); } }
private DescriptorProperties getValidatedProperties(Map<String, String> properties) { final DescriptorProperties descriptorProperties = new DescriptorProperties(true); descriptorProperties.putProperties(properties); new StreamTableDescriptorValidator(true, false, true).validate(descriptorProperties); new SchemaValidator(true, false, false).validate(descriptorProperties); new ElasticsearchValidator().validate(descriptorProperties); return descriptorProperties; }
protected void removePropertyAndVerify(Descriptor descriptor, String property) { final DescriptorProperties properties = new DescriptorProperties(); properties.putProperties(descriptor.toProperties()); final DescriptorProperties copy = properties.withoutKeys(Collections.singletonList(property)); validator().validate(copy); } }
protected void addPropertyAndVerify(Descriptor descriptor, String property, String newValue) { final DescriptorProperties properties = new DescriptorProperties(); properties.putProperties(descriptor.toProperties()); final DescriptorProperties copy = properties.withoutKeys(Collections.singletonList(property)); copy.putString(property, newValue); validator().validate(copy); }
protected void verifyProperties(Descriptor descriptor, Map<String, String> expected) { // test produced properties assertEquals(expected, descriptor.toProperties()); // test validation logic final DescriptorProperties properties = new DescriptorProperties(); properties.putProperties(expected); validator().validate(properties); }
final DescriptorProperties descriptorProperties = new DescriptorProperties(); descriptorProperties.putProperties(properties);