Java Code Examples for org.apache.flink.util.TernaryBoolean#TRUE

The following examples show how to use org.apache.flink.util.TernaryBoolean#TRUE . 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: CsvTableSinkFactoryTest.java    From flink with Apache License 2.0 6 votes vote down vote up
private DescriptorProperties createDescriptor(TableSchema schema) {
	Map<String, String> properties = new HashMap<>();
	properties.put("connector.type", "filesystem");
	properties.put("connector.property-version", "1");
	properties.put("connector.path", "/path/to/csv");

	// schema
	properties.put("format.type", "csv");
	properties.put("format.property-version", "1");
	properties.put("format.field-delimiter", ";");

	DescriptorProperties descriptor = new DescriptorProperties(true);
	descriptor.putProperties(properties);
	descriptor.putTableSchema(SCHEMA, schema);
	if (deriveSchema == TernaryBoolean.TRUE) {
		descriptor.putBoolean("format.derive-schema", true);
	} else if (deriveSchema == TernaryBoolean.FALSE) {
		descriptor.putTableSchema(FORMAT_FIELDS, testingSchema);
	} // nothing to put for UNDEFINED
	return descriptor;
}
 
Example 2
Source File: StateBackendLoadingTest.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Validates taking the application-defined file system state backend and adding with additional
 * parameters from the cluster configuration, but giving precedence to application-defined
 * parameters over configuration-defined parameters.
 */
@Test
public void testLoadFileSystemStateBackendMixed() throws Exception {
	final String appCheckpointDir = new Path(tmp.newFolder().toURI()).toString();
	final String checkpointDir = new Path(tmp.newFolder().toURI()).toString();
	final String savepointDir = new Path(tmp.newFolder().toURI()).toString();

	final Path expectedCheckpointsPath = new Path(new URI(appCheckpointDir));
	final Path expectedSavepointsPath = new Path(savepointDir);

	final int threshold = 1000000;
	final int writeBufferSize = 4000000;

	final FsStateBackend backend = new FsStateBackend(new URI(appCheckpointDir), null, threshold, writeBufferSize, TernaryBoolean.TRUE);

	final Configuration config = new Configuration();
	config.setString(backendKey, "jobmanager"); // this should not be picked up 
	config.setString(CheckpointingOptions.CHECKPOINTS_DIRECTORY, checkpointDir); // this should not be picked up
	config.setString(CheckpointingOptions.SAVEPOINT_DIRECTORY, savepointDir);
	config.setInteger(CheckpointingOptions.FS_SMALL_FILE_THRESHOLD, 20); // this should not be picked up
	config.setInteger(CheckpointingOptions.FS_WRITE_BUFFER_SIZE, 3000000); // this should not be picked up

	final StateBackend loadedBackend =
			StateBackendLoader.fromApplicationOrConfigOrDefault(backend, config, cl, null);
	assertTrue(loadedBackend instanceof FsStateBackend);

	final FsStateBackend fs = (FsStateBackend) loadedBackend;
	assertEquals(expectedCheckpointsPath, fs.getCheckpointPath());
	assertEquals(expectedSavepointsPath, fs.getSavepointPath());
	assertEquals(threshold, fs.getMinFileSizeThreshold());
	assertEquals(writeBufferSize, fs.getWriteBufferSize());
}
 
Example 3
Source File: StateBackendLoadingTest.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Validates taking the application-defined file system state backend and adding with additional
 * parameters from the cluster configuration, but giving precedence to application-defined
 * parameters over configuration-defined parameters.
 */
@Test
public void testLoadFileSystemStateBackendMixed() throws Exception {
	final String appCheckpointDir = new Path(tmp.newFolder().toURI()).toString();
	final String checkpointDir = new Path(tmp.newFolder().toURI()).toString();
	final String savepointDir = new Path(tmp.newFolder().toURI()).toString();

	final Path expectedCheckpointsPath = new Path(new URI(appCheckpointDir));
	final Path expectedSavepointsPath = new Path(savepointDir);

	final int threshold = 1000000;
	final int writeBufferSize = 4000000;

	final FsStateBackend backend = new FsStateBackend(new URI(appCheckpointDir), null, threshold, writeBufferSize, TernaryBoolean.TRUE);

	final Configuration config = new Configuration();
	config.setString(backendKey, "jobmanager"); // this should not be picked up 
	config.setString(CheckpointingOptions.CHECKPOINTS_DIRECTORY, checkpointDir); // this should not be picked up
	config.setString(CheckpointingOptions.SAVEPOINT_DIRECTORY, savepointDir);
	config.set(CheckpointingOptions.FS_SMALL_FILE_THRESHOLD, MemorySize.parse("20")); // this should not be picked up
	config.setInteger(CheckpointingOptions.FS_WRITE_BUFFER_SIZE, 3000000); // this should not be picked up

	final StateBackend loadedBackend =
			StateBackendLoader.fromApplicationOrConfigOrDefault(backend, config, cl, null);
	assertTrue(loadedBackend instanceof FsStateBackend);

	final FsStateBackend fs = (FsStateBackend) loadedBackend;
	assertEquals(expectedCheckpointsPath, fs.getCheckpointPath());
	assertEquals(expectedSavepointsPath, fs.getSavepointPath());
	assertEquals(threshold, fs.getMinFileSizeThreshold());
	assertEquals(writeBufferSize, fs.getWriteBufferSize());
}
 
Example 4
Source File: CsvTableSinkFactoryTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Parameterized.Parameters(name = "deriveSchema = {0}")
public static TernaryBoolean[] getDeriveSchema() {
	return new TernaryBoolean[]{TernaryBoolean.TRUE, TernaryBoolean.FALSE, TernaryBoolean.UNDEFINED};
}
 
Example 5
Source File: RocksDBStateBackend.java    From Flink-CEPplus with Apache License 2.0 2 votes vote down vote up
/**
 * Enable compaction filter to cleanup state with TTL is enabled.
 *
 * <p>Note: User can still decide in state TTL configuration in state descriptor
 * whether the filter is active for particular state or not.
 */
public void enableTtlCompactionFilter() {
	enableTtlCompactionFilter = TernaryBoolean.TRUE;
}
 
Example 6
Source File: RocksDBStateBackend.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Enable compaction filter to cleanup state with TTL is enabled.
 *
 * <p>Note: User can still decide in state TTL configuration in state descriptor
 * whether the filter is active for particular state or not.
 */
public void enableTtlCompactionFilter() {
	enableTtlCompactionFilter = TernaryBoolean.TRUE;
}