org.apache.flink.shaded.guava18.com.google.common.base.Ticker Java Examples

The following examples show how to use org.apache.flink.shaded.guava18.com.google.common.base.Ticker. 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: CompletedOperationCache.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@VisibleForTesting
CompletedOperationCache(final Ticker ticker) {
	completedOperations = CacheBuilder.newBuilder()
		.expireAfterWrite(COMPLETED_OPERATION_RESULT_CACHE_DURATION_SECONDS, TimeUnit.SECONDS)
		.removalListener((RemovalListener<K, ResultAccessTracker<R>>) removalNotification -> {
			if (removalNotification.wasEvicted()) {
				Preconditions.checkState(removalNotification.getKey() != null);
				Preconditions.checkState(removalNotification.getValue() != null);

				// When shutting down the cache, we wait until all results are accessed.
				// When a result gets evicted from the cache, it will not be possible to access
				// it any longer, and we might be in the process of shutting down, so we mark
				// the result as accessed to avoid waiting indefinitely.
				removalNotification.getValue().markAccessed();

				LOGGER.info("Evicted result with trigger id {} because its TTL of {}s has expired.",
					removalNotification.getKey().getTriggerId(),
					COMPLETED_OPERATION_RESULT_CACHE_DURATION_SECONDS);
			}
		})
		.ticker(ticker)
		.build();
}
 
Example #2
Source File: SessionClusterEntrypoint.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
protected ArchivedExecutionGraphStore createSerializableExecutionGraphStore(
		Configuration configuration,
		ScheduledExecutor scheduledExecutor) throws IOException {
	final File tmpDir = new File(ConfigurationUtils.parseTempDirectories(configuration)[0]);

	final Time expirationTime =  Time.seconds(configuration.getLong(JobManagerOptions.JOB_STORE_EXPIRATION_TIME));
	final long maximumCacheSizeBytes = configuration.getLong(JobManagerOptions.JOB_STORE_CACHE_SIZE);

	return new FileArchivedExecutionGraphStore(
		tmpDir,
		expirationTime,
		maximumCacheSizeBytes,
		scheduledExecutor,
		Ticker.systemTicker());
}
 
Example #3
Source File: CompletedOperationCache.java    From flink with Apache License 2.0 6 votes vote down vote up
@VisibleForTesting
CompletedOperationCache(final Ticker ticker) {
	completedOperations = CacheBuilder.newBuilder()
		.expireAfterWrite(COMPLETED_OPERATION_RESULT_CACHE_DURATION_SECONDS, TimeUnit.SECONDS)
		.removalListener((RemovalListener<K, ResultAccessTracker<R>>) removalNotification -> {
			if (removalNotification.wasEvicted()) {
				Preconditions.checkState(removalNotification.getKey() != null);
				Preconditions.checkState(removalNotification.getValue() != null);

				// When shutting down the cache, we wait until all results are accessed.
				// When a result gets evicted from the cache, it will not be possible to access
				// it any longer, and we might be in the process of shutting down, so we mark
				// the result as accessed to avoid waiting indefinitely.
				removalNotification.getValue().markAccessed();

				LOGGER.info("Evicted result with trigger id {} because its TTL of {}s has expired.",
					removalNotification.getKey().getTriggerId(),
					COMPLETED_OPERATION_RESULT_CACHE_DURATION_SECONDS);
			}
		})
		.ticker(ticker)
		.build();
}
 
Example #4
Source File: SessionClusterEntrypoint.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
protected ArchivedExecutionGraphStore createSerializableExecutionGraphStore(
		Configuration configuration,
		ScheduledExecutor scheduledExecutor) throws IOException {
	final File tmpDir = new File(ConfigurationUtils.parseTempDirectories(configuration)[0]);

	final Time expirationTime =  Time.seconds(configuration.getLong(JobManagerOptions.JOB_STORE_EXPIRATION_TIME));
	final long maximumCacheSizeBytes = configuration.getLong(JobManagerOptions.JOB_STORE_CACHE_SIZE);

	return new FileArchivedExecutionGraphStore(
		tmpDir,
		expirationTime,
		maximumCacheSizeBytes,
		scheduledExecutor,
		Ticker.systemTicker());
}
 
Example #5
Source File: CompletedOperationCache.java    From flink with Apache License 2.0 6 votes vote down vote up
@VisibleForTesting
CompletedOperationCache(final Ticker ticker) {
	completedOperations = CacheBuilder.newBuilder()
		.expireAfterWrite(COMPLETED_OPERATION_RESULT_CACHE_DURATION_SECONDS, TimeUnit.SECONDS)
		.removalListener((RemovalListener<K, ResultAccessTracker<R>>) removalNotification -> {
			if (removalNotification.wasEvicted()) {
				Preconditions.checkState(removalNotification.getKey() != null);
				Preconditions.checkState(removalNotification.getValue() != null);

				// When shutting down the cache, we wait until all results are accessed.
				// When a result gets evicted from the cache, it will not be possible to access
				// it any longer, and we might be in the process of shutting down, so we mark
				// the result as accessed to avoid waiting indefinitely.
				removalNotification.getValue().markAccessed();

				LOGGER.info("Evicted result with trigger id {} because its TTL of {}s has expired.",
					removalNotification.getKey().getTriggerId(),
					COMPLETED_OPERATION_RESULT_CACHE_DURATION_SECONDS);
			}
		})
		.ticker(ticker)
		.build();
}
 
Example #6
Source File: SessionClusterEntrypoint.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
protected ArchivedExecutionGraphStore createSerializableExecutionGraphStore(
		Configuration configuration,
		ScheduledExecutor scheduledExecutor) throws IOException {
	final File tmpDir = new File(ConfigurationUtils.parseTempDirectories(configuration)[0]);

	final Time expirationTime =  Time.seconds(configuration.getLong(JobManagerOptions.JOB_STORE_EXPIRATION_TIME));
	final int maximumCapacity = configuration.getInteger(JobManagerOptions.JOB_STORE_MAX_CAPACITY);
	final long maximumCacheSizeBytes = configuration.getLong(JobManagerOptions.JOB_STORE_CACHE_SIZE);

	return new FileArchivedExecutionGraphStore(
		tmpDir,
		expirationTime,
		maximumCapacity,
		maximumCacheSizeBytes,
		scheduledExecutor,
		Ticker.systemTicker());
}
 
Example #7
Source File: FileArchivedExecutionGraphStoreTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private FileArchivedExecutionGraphStore createDefaultExecutionGraphStore(File storageDirectory) throws IOException {
	return new FileArchivedExecutionGraphStore(
		storageDirectory,
		Time.hours(1L),
		10000L,
		TestingUtils.defaultScheduledExecutor(),
		Ticker.systemTicker());
}
 
Example #8
Source File: FileArchivedExecutionGraphStoreTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private FileArchivedExecutionGraphStore createDefaultExecutionGraphStore(File storageDirectory) throws IOException {
	return new FileArchivedExecutionGraphStore(
		storageDirectory,
		Time.hours(1L),
		10000L,
		TestingUtils.defaultScheduledExecutor(),
		Ticker.systemTicker());
}
 
Example #9
Source File: FileArchivedExecutionGraphStoreTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private FileArchivedExecutionGraphStore createDefaultExecutionGraphStore(File storageDirectory) throws IOException {
	return new FileArchivedExecutionGraphStore(
		storageDirectory,
		Time.hours(1L),
		Integer.MAX_VALUE,
		10000L,
		TestingUtils.defaultScheduledExecutor(),
		Ticker.systemTicker());
}
 
Example #10
Source File: FileArchivedExecutionGraphStore.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
public FileArchivedExecutionGraphStore(
		File rootDir,
		Time expirationTime,
		long maximumCacheSizeBytes,
		ScheduledExecutor scheduledExecutor,
		Ticker ticker) throws IOException {

	final File storageDirectory = initExecutionGraphStorageDirectory(rootDir);

	LOG.info(
		"Initializing {}: Storage directory {}, expiration time {}, maximum cache size {} bytes.",
		FileArchivedExecutionGraphStore.class.getSimpleName(),
		storageDirectory,
		expirationTime.toMilliseconds(),
		maximumCacheSizeBytes);

	this.storageDir = Preconditions.checkNotNull(storageDirectory);
	Preconditions.checkArgument(
		storageDirectory.exists() && storageDirectory.isDirectory(),
		"The storage directory must exist and be a directory.");
	this.jobDetailsCache = CacheBuilder.newBuilder()
		.expireAfterWrite(expirationTime.toMilliseconds(), TimeUnit.MILLISECONDS)
		.removalListener(
			(RemovalListener<JobID, JobDetails>) notification -> deleteExecutionGraphFile(notification.getKey()))
		.ticker(ticker)
		.build();

	this.archivedExecutionGraphCache = CacheBuilder.newBuilder()
		.maximumWeight(maximumCacheSizeBytes)
		.weigher(this::calculateSize)
		.build(new CacheLoader<JobID, ArchivedExecutionGraph>() {
			@Override
			public ArchivedExecutionGraph load(JobID jobId) throws Exception {
				return loadExecutionGraph(jobId);
			}});

	this.cleanupFuture = scheduledExecutor.scheduleWithFixedDelay(
		jobDetailsCache::cleanUp,
		expirationTime.toMilliseconds(),
		expirationTime.toMilliseconds(),
		TimeUnit.MILLISECONDS);

	this.shutdownHook = ShutdownHookUtil.addShutdownHook(this, getClass().getSimpleName(), LOG);

	this.numFinishedJobs = 0;
	this.numFailedJobs = 0;
	this.numCanceledJobs = 0;
}
 
Example #11
Source File: CompletedOperationCache.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
CompletedOperationCache() {
	this(Ticker.systemTicker());
}
 
Example #12
Source File: FileArchivedExecutionGraphStore.java    From flink with Apache License 2.0 4 votes vote down vote up
public FileArchivedExecutionGraphStore(
		File rootDir,
		Time expirationTime,
		long maximumCacheSizeBytes,
		ScheduledExecutor scheduledExecutor,
		Ticker ticker) throws IOException {

	final File storageDirectory = initExecutionGraphStorageDirectory(rootDir);

	LOG.info(
		"Initializing {}: Storage directory {}, expiration time {}, maximum cache size {} bytes.",
		FileArchivedExecutionGraphStore.class.getSimpleName(),
		storageDirectory,
		expirationTime.toMilliseconds(),
		maximumCacheSizeBytes);

	this.storageDir = Preconditions.checkNotNull(storageDirectory);
	Preconditions.checkArgument(
		storageDirectory.exists() && storageDirectory.isDirectory(),
		"The storage directory must exist and be a directory.");
	this.jobDetailsCache = CacheBuilder.newBuilder()
		.expireAfterWrite(expirationTime.toMilliseconds(), TimeUnit.MILLISECONDS)
		.removalListener(
			(RemovalListener<JobID, JobDetails>) notification -> deleteExecutionGraphFile(notification.getKey()))
		.ticker(ticker)
		.build();

	this.archivedExecutionGraphCache = CacheBuilder.newBuilder()
		.maximumWeight(maximumCacheSizeBytes)
		.weigher(this::calculateSize)
		.build(new CacheLoader<JobID, ArchivedExecutionGraph>() {
			@Override
			public ArchivedExecutionGraph load(JobID jobId) throws Exception {
				return loadExecutionGraph(jobId);
			}});

	this.cleanupFuture = scheduledExecutor.scheduleWithFixedDelay(
		jobDetailsCache::cleanUp,
		expirationTime.toMilliseconds(),
		expirationTime.toMilliseconds(),
		TimeUnit.MILLISECONDS);

	this.shutdownHook = ShutdownHookUtil.addShutdownHook(this, getClass().getSimpleName(), LOG);

	this.numFinishedJobs = 0;
	this.numFailedJobs = 0;
	this.numCanceledJobs = 0;
}
 
Example #13
Source File: CompletedOperationCache.java    From flink with Apache License 2.0 4 votes vote down vote up
CompletedOperationCache() {
	this(Ticker.systemTicker());
}
 
Example #14
Source File: FileArchivedExecutionGraphStore.java    From flink with Apache License 2.0 4 votes vote down vote up
public FileArchivedExecutionGraphStore(
		File rootDir,
		Time expirationTime,
		int maximumCapacity,
		long maximumCacheSizeBytes,
		ScheduledExecutor scheduledExecutor,
		Ticker ticker) throws IOException {

	final File storageDirectory = initExecutionGraphStorageDirectory(rootDir);

	LOG.info(
		"Initializing {}: Storage directory {}, expiration time {}, maximum cache size {} bytes.",
		FileArchivedExecutionGraphStore.class.getSimpleName(),
		storageDirectory,
		expirationTime.toMilliseconds(),
		maximumCacheSizeBytes);

	this.storageDir = Preconditions.checkNotNull(storageDirectory);
	Preconditions.checkArgument(
		storageDirectory.exists() && storageDirectory.isDirectory(),
		"The storage directory must exist and be a directory.");
	this.jobDetailsCache = CacheBuilder.newBuilder()
		.expireAfterWrite(expirationTime.toMilliseconds(), TimeUnit.MILLISECONDS)
		.maximumSize(maximumCapacity)
		.removalListener(
			(RemovalListener<JobID, JobDetails>) notification -> deleteExecutionGraphFile(notification.getKey()))
		.ticker(ticker)
		.build();

	this.archivedExecutionGraphCache = CacheBuilder.newBuilder()
		.maximumWeight(maximumCacheSizeBytes)
		.weigher(this::calculateSize)
		.build(new CacheLoader<JobID, ArchivedExecutionGraph>() {
			@Override
			public ArchivedExecutionGraph load(JobID jobId) throws Exception {
				return loadExecutionGraph(jobId);
			}});

	this.cleanupFuture = scheduledExecutor.scheduleWithFixedDelay(
		jobDetailsCache::cleanUp,
		expirationTime.toMilliseconds(),
		expirationTime.toMilliseconds(),
		TimeUnit.MILLISECONDS);

	this.shutdownHook = ShutdownHookUtil.addShutdownHook(this, getClass().getSimpleName(), LOG);

	this.numFinishedJobs = 0;
	this.numFailedJobs = 0;
	this.numCanceledJobs = 0;
}
 
Example #15
Source File: CompletedOperationCache.java    From flink with Apache License 2.0 4 votes vote down vote up
CompletedOperationCache() {
	this(Ticker.systemTicker());
}