/** * 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); } }
/** * 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 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(); }
@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(); }
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; }
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); }
descriptorProperties.putProperties(properties);
@Override public StreamTableSource<Row> create(Map<String, String> properties) { DescriptorProperties params = new DescriptorProperties(true); params.putProperties(properties); TableSchema schema = params.getTableSchema(TOPIC_SCHEMA_KEY); String topic = params.getString(TOPIC_NAME_KEY); Properties conf = new Properties(); conf.putAll(params.getPrefix(KAFKA_CONFIG_PREFIX)); return new JsonTableSource(topic, conf, schema); } }
@Override public TableSource<Row> create(Map<String, String> properties) { DescriptorProperties params = new DescriptorProperties(true); params.putProperties(properties); TableSchema schema = params.getTableSchema(TABLE_SCHEMA_CONNECTOR_PROPERTY); List<Row> rows = deserializeRows(params.getString(TABLE_DATA_CONNECTOR_PROPERTY)); return new MockTableSource(rows, new RowTypeInfo(schema.getTypes(), schema.getColumnNames())); }
private static DescriptorProperties getValidatedProperties(Map<String, String> propertiesMap) { final DescriptorProperties descriptorProperties = new DescriptorProperties(); descriptorProperties.putProperties(propertiesMap); // validate new JsonValidator().validate(descriptorProperties); return descriptorProperties; } }
@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(); }