Java Code Examples for org.apache.flink.table.descriptors.DescriptorProperties#validateString()

The following examples show how to use org.apache.flink.table.descriptors.DescriptorProperties#validateString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DatahubDescriptorValidator.java    From alibaba-flink-connectors with Apache License 2.0 6 votes vote down vote up
@Override
public void validate(DescriptorProperties properties) {
	super.validate(properties);
	properties.validateValue(CONNECTOR_TYPE, getConnectorTypeValue(), false);
	properties.validateString(CONNECTOR_PROJECT, false, 1);
	properties.validateString(CONNECTOR_TOPIC, false, 1);
	properties.validateString(CONNECTOR_ACCESS_ID, false, 1);
	properties.validateString(CONNECTOR_ACCESS_KEY, false, 1);
	properties.validateString(CONNECTOR_ENDPOINT, false, 1);

	properties.validateInt(CONNECTOR_BUFFER_SIZE, true, 1);
	properties.validateInt(CONNECTOR_BATCH_SIZE, true, 1);
	properties.validateLong(CONNECTOR_BATCH_WRITE_TIMEOUT_IN_MILLS, true, 1);
	properties.validateInt(CONNECTOR_RETRY_TIMEOUT_IN_MILLS, true, 1);
	properties.validateInt(CONNECTOR_MAX_RETRY_TIMES, true, 1);
}
 
Example 2
Source File: PravegaValidator.java    From flink-connectors with Apache License 2.0 6 votes vote down vote up
private void validateWriterConfigurations(DescriptorProperties properties) {
    properties.validateString(CONNECTOR_WRITER_SCOPE, true, 1, Integer.MAX_VALUE);
    properties.validateString(CONNECTOR_WRITER_STREAM, false, 1, Integer.MAX_VALUE);
    properties.validateString(CONNECTOR_WRITER_ROUTING_KEY_FILED_NAME, false, 1, Integer.MAX_VALUE);

    // for writers we need default-scope from connection config or scope from writer config
    Optional<String> scope = properties.getOptionalString(CONNECTOR_WRITER_SCOPE);
    Optional<String> connConfigDefaultScope = properties.getOptionalString(CONNECTOR_CONNECTION_CONFIG_DEFAULT_SCOPE);
    if (!scope.isPresent() && !connConfigDefaultScope.isPresent()) {
        throw new ValidationException("Must supply either " + CONNECTOR_WRITER_SCOPE + " or " + CONNECTOR_CONNECTION_CONFIG_DEFAULT_SCOPE);
    }

    // validate writer mode
    final Map<String, Consumer<String>> writerModeValidators = new HashMap<>();
    writerModeValidators.put(CONNECTOR_WRITER_MODE_VALUE_EXACTLY_ONCE, properties.noValidation());
    writerModeValidators.put(CONNECTOR_WRITER_MODE_VALUE_ATLEAST_ONCE, properties.noValidation());
    properties.validateEnum(CONNECTOR_WRITER_MODE, true, writerModeValidators);
}
 
Example 3
Source File: TemporalTableEntry.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
protected void validate(DescriptorProperties properties) {
	properties.validateString(TABLES_HISTORY_TABLE, false, 1);
	properties.validateArray(
		TABLES_PRIMARY_KEY,
		(key) -> properties.validateString(key, false, 1),
		1,
		1); // currently, composite primary keys are not supported
	properties.validateString(TABLES_TIME_ATTRIBUTE, false, 1);
}
 
Example 4
Source File: PulsarCatalogValidator.java    From pulsar-flink with Apache License 2.0 5 votes vote down vote up
@Override
public void validate(DescriptorProperties properties) {
    super.validate(properties);
    properties.validateValue(CATALOG_TYPE, CATALOG_TYPE_VALUE_PULSAR, false);
    properties.validateString(CATALOG_PULSAR_VERSION, true, 1);
    properties.validateString(CATALOG_SERVICE_URL, false, 1);
    properties.validateString(CATALOG_ADMIN_URL, false, 1);
    properties.validateInt(CATALOG_DEFAULT_PARTITIONS, true, 1);
    validateStartingOffsets(properties);
}
 
Example 5
Source File: PulsarSchemaValidator.java    From pulsar-flink with Apache License 2.0 5 votes vote down vote up
@Override
public void validate(DescriptorProperties properties) {
    Map<String, String> names = properties.getIndexedProperty(SCHEMA, SCHEMA_NAME);
    Map<String, String> types = properties.getIndexedProperty(SCHEMA, SCHEMA_TYPE);

    boolean proctimeFound = false;

    int fieldsCount = Math.max(names.size(), types.size());

    for (int i = 0; i < fieldsCount; i++) {
        properties.validateString(SCHEMA + "." + i + "." + SCHEMA_NAME, false, 1);
        properties.validateType(SCHEMA + "." + i + "." + SCHEMA_TYPE, false, false);
        properties.validateString(SCHEMA + "." + i + "." + SCHEMA_FROM, true, 1);
        // either proctime or rowtime
        String proctime = SCHEMA + "." + i + "." + SCHEMA_PROCTIME;
        String rowtime = SCHEMA + "." + i + "." + ROWTIME;

        if (properties.containsKey(proctime)) {
            if (!isStreamEnvironment) {
                throw new ValidationException(
                        "Property $proctime is not allowed in a batch environment.");
            } else if (proctimeFound) {
                throw new ValidationException("A proctime attribute must only be defined once.");
            }
            // check proctime
            properties.validateBoolean(proctime, false);
            proctimeFound = properties.getBoolean(proctime);
            // no rowtime
            properties.validatePrefixExclusion(rowtime);
        } else if (properties.hasPrefix(rowtime)) {
            // check rowtime
            RowtimeValidator rowtimeValidator =
                    new RowtimeValidator(
                            supportsSourceTimestamps, supportsSourceWatermarks, SCHEMA + "." + i + ".");
            rowtimeValidator.validate(properties);
            // no proctime
            properties.validateExclusion(proctime);
        }
    }
}
 
Example 6
Source File: TaxiRidesValidator.java    From flink-training-exercises with Apache License 2.0 5 votes vote down vote up
@Override
public void validate(DescriptorProperties properties) {
	super.validate(properties);
	properties.validateValue(CONNECTOR_TYPE, CONNECTOR_TYPE_VALUE_TAXI_RIDES, false);
	properties.validateString(CONNECTOR_PATH, false);
	properties.validateInt(CONNECTOR_MAX_EVENT_DELAY_SECS, true, 0);
	properties.validateInt(CONNECTOR_SERVING_SPEED_FACTOR, true, 1);
}
 
Example 7
Source File: TemporalTableEntry.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected void validate(DescriptorProperties properties) {
	properties.validateString(TABLES_HISTORY_TABLE, false, 1);
	properties.validateArray(
		TABLES_PRIMARY_KEY,
		(key) -> properties.validateString(key, false, 1),
		1,
		1); // currently, composite primary keys are not supported
	properties.validateString(TABLES_TIME_ATTRIBUTE, false, 1);
}
 
Example 8
Source File: DeploymentEntry.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
protected void validate(DescriptorProperties properties) {
	properties.validateLong(DEPLOYMENT_RESPONSE_TIMEOUT, true, 0);
	properties.validateString(DEPLOYMENT_GATEWAY_ADDRESS, true, 0);
	properties.validateInt(DEPLOYMENT_GATEWAY_PORT, true, 0, 65535);
}
 
Example 9
Source File: ExecutionEntry.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected void validate(DescriptorProperties properties) {
	properties.validateEnumValues(
		EXECUTION_PLANNER,
		true,
		Arrays.asList(
			EXECUTION_PLANNER_VALUE_OLD,
			EXECUTION_PLANNER_VALUE_BLINK));
	properties.validateEnumValues(
		EXECUTION_TYPE,
		true,
		Arrays.asList(
			EXECUTION_TYPE_VALUE_BATCH,
			EXECUTION_TYPE_VALUE_STREAMING));
	properties.validateEnumValues(
		EXECUTION_TIME_CHARACTERISTIC,
		true,
		Arrays.asList(
			EXECUTION_TIME_CHARACTERISTIC_VALUE_EVENT_TIME,
			EXECUTION_TIME_CHARACTERISTIC_VALUE_PROCESSING_TIME));
	properties.validateLong(EXECUTION_PERIODIC_WATERMARKS_INTERVAL, true, 1);
	properties.validateLong(EXECUTION_MIN_STATE_RETENTION, true, 0);
	properties.validateLong(EXECUTION_MAX_STATE_RETENTION, true, 0);
	properties.validateInt(EXECUTION_PARALLELISM, true, 1);
	properties.validateInt(EXECUTION_MAX_PARALLELISM, true, 1);
	properties.validateInt(EXECUTION_MAX_TABLE_RESULT_ROWS, true, 1);
	properties.validateEnumValues(
		EXECUTION_RESTART_STRATEGY_TYPE,
		true,
		Arrays.asList(
			EXECUTION_RESTART_STRATEGY_TYPE_VALUE_FALLBACK,
			EXECUTION_RESTART_STRATEGY_TYPE_VALUE_NONE,
			EXECUTION_RESTART_STRATEGY_TYPE_VALUE_FIXED_DELAY,
			EXECUTION_RESTART_STRATEGY_TYPE_VALUE_FAILURE_RATE));
	properties.validateInt(EXECUTION_RESTART_STRATEGY_ATTEMPTS, true, 1);
	properties.validateLong(EXECUTION_RESTART_STRATEGY_DELAY, true, 0);
	properties.validateLong(EXECUTION_RESTART_STRATEGY_FAILURE_RATE_INTERVAL, true, 1);
	properties.validateInt(EXECUTION_RESTART_STRATEGY_MAX_FAILURES_PER_INTERVAL, true, 1);
	properties.validateString(EXECUTION_CURRENT_CATALOG, true, 1);
	properties.validateString(EXECUTION_CURRENT_DATABASE, true, 1);
}
 
Example 10
Source File: PravegaValidator.java    From flink-connectors with Apache License 2.0 4 votes vote down vote up
private void validateConnectionConfig(DescriptorProperties properties) {
    properties.validateString(CONNECTOR_CONNECTION_CONFIG_CONTROLLER_URI, false, 1, Integer.MAX_VALUE);
}
 
Example 11
Source File: ViewEntry.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected void validate(DescriptorProperties properties) {
	properties.validateString(TABLES_QUERY, false, 1);
}
 
Example 12
Source File: ExecutionEntry.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected void validate(DescriptorProperties properties) {
	properties.validateEnumValues(
		EXECUTION_PLANNER,
		true,
		Arrays.asList(
			EXECUTION_PLANNER_VALUE_OLD,
			EXECUTION_PLANNER_VALUE_BLINK));
	properties.validateEnumValues(
		EXECUTION_TYPE,
		true,
		Arrays.asList(
			EXECUTION_TYPE_VALUE_BATCH,
			EXECUTION_TYPE_VALUE_STREAMING));
	properties.validateEnumValues(
		EXECUTION_TIME_CHARACTERISTIC,
		true,
		Arrays.asList(
			EXECUTION_TIME_CHARACTERISTIC_VALUE_EVENT_TIME,
			EXECUTION_TIME_CHARACTERISTIC_VALUE_PROCESSING_TIME));
	properties.validateLong(EXECUTION_PERIODIC_WATERMARKS_INTERVAL, true, 1);
	properties.validateLong(EXECUTION_MIN_STATE_RETENTION, true, 0);
	properties.validateLong(EXECUTION_MAX_STATE_RETENTION, true, 0);
	properties.validateInt(EXECUTION_PARALLELISM, true, 1);
	properties.validateInt(EXECUTION_MAX_PARALLELISM, true, 1);
	properties.validateInt(EXECUTION_MAX_TABLE_RESULT_ROWS, true, 1);
	properties.validateEnumValues(
		EXECUTION_RESTART_STRATEGY_TYPE,
		true,
		Arrays.asList(
			EXECUTION_RESTART_STRATEGY_TYPE_VALUE_FALLBACK,
			EXECUTION_RESTART_STRATEGY_TYPE_VALUE_NONE,
			EXECUTION_RESTART_STRATEGY_TYPE_VALUE_FIXED_DELAY,
			EXECUTION_RESTART_STRATEGY_TYPE_VALUE_FAILURE_RATE));
	properties.validateInt(EXECUTION_RESTART_STRATEGY_ATTEMPTS, true, 1);
	properties.validateLong(EXECUTION_RESTART_STRATEGY_DELAY, true, 0);
	properties.validateLong(EXECUTION_RESTART_STRATEGY_FAILURE_RATE_INTERVAL, true, 1);
	properties.validateInt(EXECUTION_RESTART_STRATEGY_MAX_FAILURES_PER_INTERVAL, true, 1);
	properties.validateString(EXECUTION_CURRENT_CATALOG, true, 1);
	properties.validateString(EXECUTION_CURRENT_DATABASE, true, 1);
}
 
Example 13
Source File: ViewEntry.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected void validate(DescriptorProperties properties) {
	properties.validateString(TABLES_QUERY, false, 1);
}
 
Example 14
Source File: DeploymentEntry.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected void validate(DescriptorProperties properties) {
	properties.validateLong(DEPLOYMENT_RESPONSE_TIMEOUT, true, 0);
	properties.validateString(DEPLOYMENT_GATEWAY_ADDRESS, true, 0);
	properties.validateInt(DEPLOYMENT_GATEWAY_PORT, true, 0, 65535);
}
 
Example 15
Source File: ViewEntry.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
protected void validate(DescriptorProperties properties) {
	properties.validateString(TABLES_QUERY, false, 1);
}
 
Example 16
Source File: ModuleEntry.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected void validate(DescriptorProperties properties) {
	properties.validateString(MODULE_TYPE, false, 1);

	// further validation is performed by the discovered factory
}
 
Example 17
Source File: FunctionEntry.java    From flink with Apache License 2.0 3 votes vote down vote up
private static FunctionEntry create(DescriptorProperties properties) {
	properties.validateString(FUNCTIONS_NAME, false, 1);

	final String name = properties.getString(FUNCTIONS_NAME);

	final DescriptorProperties cleanedProperties =
		properties.withoutKeys(Collections.singletonList(FUNCTIONS_NAME));

	return new FunctionEntry(name, cleanedProperties);
}
 
Example 18
Source File: CatalogEntry.java    From flink with Apache License 2.0 3 votes vote down vote up
private static CatalogEntry create(DescriptorProperties properties) {
	properties.validateString(CATALOG_NAME, false, 1);

	final String name = properties.getString(CATALOG_NAME);

	final DescriptorProperties cleanedProperties =
		properties.withoutKeys(Collections.singletonList(CATALOG_NAME));

	return new CatalogEntry(name, cleanedProperties);
}
 
Example 19
Source File: FunctionEntry.java    From flink with Apache License 2.0 3 votes vote down vote up
private static FunctionEntry create(DescriptorProperties properties) {
	properties.validateString(FUNCTIONS_NAME, false, 1);

	final String name = properties.getString(FUNCTIONS_NAME);

	final DescriptorProperties cleanedProperties =
		properties.withoutKeys(Collections.singletonList(FUNCTIONS_NAME));

	return new FunctionEntry(name, cleanedProperties);
}
 
Example 20
Source File: FunctionEntry.java    From Flink-CEPplus with Apache License 2.0 3 votes vote down vote up
private static FunctionEntry create(DescriptorProperties properties) {
	properties.validateString(FUNCTIONS_NAME, false, 1);

	final String name = properties.getString(FUNCTIONS_NAME);

	final DescriptorProperties cleanedProperties =
		properties.withoutKeys(Collections.singletonList(FUNCTIONS_NAME));

	return new FunctionEntry(name, cleanedProperties);
}