Java Code Examples for org.apache.flink.runtime.execution.Environment#getJobID()

The following examples show how to use org.apache.flink.runtime.execution.Environment#getJobID() . 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: RocksDBStateBackend.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
private void lazyInitializeForJob(
		Environment env,
		@SuppressWarnings("unused") String operatorIdentifier) throws IOException {

	if (isInitialized) {
		return;
	}

	this.jobId = env.getJobID();

	// initialize the paths where the local RocksDB files should be stored
	if (localRocksDbDirectories == null) {
		// initialize from the temp directories
		initializedDbBasePaths = env.getIOManager().getSpillingDirectories();
	}
	else {
		List<File> dirs = new ArrayList<>(localRocksDbDirectories.length);
		StringBuilder errorMessage = new StringBuilder();

		for (File f : localRocksDbDirectories) {
			File testDir = new File(f, UUID.randomUUID().toString());
			if (!testDir.mkdirs()) {
				String msg = "Local DB files directory '" + f
						+ "' does not exist and cannot be created. ";
				LOG.error(msg);
				errorMessage.append(msg);
			} else {
				dirs.add(f);
			}
			//noinspection ResultOfMethodCallIgnored
			testDir.delete();
		}

		if (dirs.isEmpty()) {
			throw new IOException("No local storage directories available. " + errorMessage);
		} else {
			initializedDbBasePaths = dirs.toArray(new File[dirs.size()]);
		}
	}

	nextDirectory = new Random().nextInt(initializedDbBasePaths.length);

	isInitialized = true;
}
 
Example 2
Source File: RocksDBStateBackend.java    From flink with Apache License 2.0 4 votes vote down vote up
private void lazyInitializeForJob(
		Environment env,
		@SuppressWarnings("unused") String operatorIdentifier) throws IOException {

	if (isInitialized) {
		return;
	}

	this.jobId = env.getJobID();

	// initialize the paths where the local RocksDB files should be stored
	if (localRocksDbDirectories == null) {
		// initialize from the temp directories
		initializedDbBasePaths = env.getIOManager().getSpillingDirectories();
	}
	else {
		List<File> dirs = new ArrayList<>(localRocksDbDirectories.length);
		StringBuilder errorMessage = new StringBuilder();

		for (File f : localRocksDbDirectories) {
			File testDir = new File(f, UUID.randomUUID().toString());
			if (!testDir.mkdirs()) {
				String msg = "Local DB files directory '" + f
						+ "' does not exist and cannot be created. ";
				LOG.error(msg);
				errorMessage.append(msg);
			} else {
				dirs.add(f);
			}
			//noinspection ResultOfMethodCallIgnored
			testDir.delete();
		}

		if (dirs.isEmpty()) {
			throw new IOException("No local storage directories available. " + errorMessage);
		} else {
			initializedDbBasePaths = dirs.toArray(new File[dirs.size()]);
		}
	}

	nextDirectory = new Random().nextInt(initializedDbBasePaths.length);

	isInitialized = true;
}
 
Example 3
Source File: RocksDBStateBackend.java    From flink with Apache License 2.0 4 votes vote down vote up
private void lazyInitializeForJob(
		Environment env,
		@SuppressWarnings("unused") String operatorIdentifier) throws IOException {

	if (isInitialized) {
		return;
	}

	this.jobId = env.getJobID();

	// initialize the paths where the local RocksDB files should be stored
	if (localRocksDbDirectories == null) {
		// initialize from the temp directories
		initializedDbBasePaths = env.getIOManager().getSpillingDirectories();
	}
	else {
		List<File> dirs = new ArrayList<>(localRocksDbDirectories.length);
		StringBuilder errorMessage = new StringBuilder();

		for (File f : localRocksDbDirectories) {
			File testDir = new File(f, UUID.randomUUID().toString());
			if (!testDir.mkdirs()) {
				String msg = "Local DB files directory '" + f
						+ "' does not exist and cannot be created. ";
				LOG.error(msg);
				errorMessage.append(msg);
			} else {
				dirs.add(f);
			}
			//noinspection ResultOfMethodCallIgnored
			testDir.delete();
		}

		if (dirs.isEmpty()) {
			throw new IOException("No local storage directories available. " + errorMessage);
		} else {
			initializedDbBasePaths = dirs.toArray(new File[dirs.size()]);
		}
	}

	nextDirectory = new Random().nextInt(initializedDbBasePaths.length);

	isInitialized = true;
}