org.apache.flink.shaded.guava18.com.google.common.cache.CacheLoader Java Examples

The following examples show how to use org.apache.flink.shaded.guava18.com.google.common.cache.CacheLoader. 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: AbstractTaskManagerFileHandler.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
protected AbstractTaskManagerFileHandler(
		@Nonnull GatewayRetriever<? extends RestfulGateway> leaderRetriever,
		@Nonnull Time timeout,
		@Nonnull Map<String, String> responseHeaders,
		@Nonnull UntypedResponseMessageHeaders<EmptyRequestBody, M> untypedResponseMessageHeaders,
		@Nonnull GatewayRetriever<ResourceManagerGateway> resourceManagerGatewayRetriever,
		@Nonnull TransientBlobService transientBlobService,
		@Nonnull Time cacheEntryDuration) {
	super(leaderRetriever, timeout, responseHeaders, untypedResponseMessageHeaders);

	this.resourceManagerGatewayRetriever = Preconditions.checkNotNull(resourceManagerGatewayRetriever);

	this.transientBlobService = Preconditions.checkNotNull(transientBlobService);

	this.fileBlobKeys = CacheBuilder
		.newBuilder()
		.expireAfterWrite(cacheEntryDuration.toMilliseconds(), TimeUnit.MILLISECONDS)
		.removalListener(this::removeBlob)
		.build(
			new CacheLoader<ResourceID, CompletableFuture<TransientBlobKey>>() {
				@Override
				public CompletableFuture<TransientBlobKey> load(ResourceID resourceId) throws Exception {
					return loadTaskManagerFile(resourceId);
				}
		});
}
 
Example #2
Source File: AbstractTaskManagerFileHandler.java    From flink with Apache License 2.0 6 votes vote down vote up
protected AbstractTaskManagerFileHandler(
		@Nonnull GatewayRetriever<? extends RestfulGateway> leaderRetriever,
		@Nonnull Time timeout,
		@Nonnull Map<String, String> responseHeaders,
		@Nonnull UntypedResponseMessageHeaders<EmptyRequestBody, M> untypedResponseMessageHeaders,
		@Nonnull GatewayRetriever<ResourceManagerGateway> resourceManagerGatewayRetriever,
		@Nonnull TransientBlobService transientBlobService,
		@Nonnull Time cacheEntryDuration) {
	super(leaderRetriever, timeout, responseHeaders, untypedResponseMessageHeaders);

	this.resourceManagerGatewayRetriever = Preconditions.checkNotNull(resourceManagerGatewayRetriever);

	this.transientBlobService = Preconditions.checkNotNull(transientBlobService);

	this.fileBlobKeys = CacheBuilder
		.newBuilder()
		.expireAfterWrite(cacheEntryDuration.toMilliseconds(), TimeUnit.MILLISECONDS)
		.removalListener(this::removeBlob)
		.build(
			new CacheLoader<ResourceID, CompletableFuture<TransientBlobKey>>() {
				@Override
				public CompletableFuture<TransientBlobKey> load(ResourceID resourceId) throws Exception {
					return loadTaskManagerFile(resourceId);
				}
		});
}
 
Example #3
Source File: AbstractTaskManagerFileHandler.java    From flink with Apache License 2.0 6 votes vote down vote up
protected AbstractTaskManagerFileHandler(
		@Nonnull GatewayRetriever<? extends RestfulGateway> leaderRetriever,
		@Nonnull Time timeout,
		@Nonnull Map<String, String> responseHeaders,
		@Nonnull UntypedResponseMessageHeaders<EmptyRequestBody, M> untypedResponseMessageHeaders,
		@Nonnull GatewayRetriever<ResourceManagerGateway> resourceManagerGatewayRetriever,
		@Nonnull TransientBlobService transientBlobService,
		@Nonnull Time cacheEntryDuration) {
	super(leaderRetriever, timeout, responseHeaders, untypedResponseMessageHeaders);

	this.resourceManagerGatewayRetriever = Preconditions.checkNotNull(resourceManagerGatewayRetriever);

	this.transientBlobService = Preconditions.checkNotNull(transientBlobService);

	this.fileBlobKeys = CacheBuilder
		.newBuilder()
		.expireAfterWrite(cacheEntryDuration.toMilliseconds(), TimeUnit.MILLISECONDS)
		.removalListener(this::removeBlob)
		.build(
			new CacheLoader<Tuple2<ResourceID, String>, CompletableFuture<TransientBlobKey>>() {
				@Override
				public CompletableFuture<TransientBlobKey> load(Tuple2<ResourceID, String> taskManagerIdAndFileName) throws Exception {
					return loadTaskManagerFile(taskManagerIdAndFileName);
				}
		});
}
 
Example #4
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 #5
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 #6
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;
}