Search in sources :

Example 1 with CacheableEntity

use of org.gradle.caching.internal.CacheableEntity in project gradle by gradle.

the class DefaultBuildCacheController method loadRemoteAndStoreResultLocally.

private Optional<BuildCacheLoadResult> loadRemoteAndStoreResultLocally(BuildCacheKey key, CacheableEntity entity) {
    if (!remote.canLoad()) {
        return Optional.empty();
    }
    AtomicReference<Optional<BuildCacheLoadResult>> result = new AtomicReference<>(Optional.empty());
    tmp.withTempFile(key, file -> {
        Optional<BuildCacheLoadResult> remoteResult;
        try {
            remoteResult = remote.maybeLoad(key, file, f -> packExecutor.unpack(key, entity, f));
        } catch (Exception e) {
            throw new GradleException("Could not load from remote cache: " + e.getMessage(), e);
        }
        if (remoteResult.isPresent()) {
            local.maybeStore(key, file);
            result.set(remoteResult);
        }
    });
    return result.get();
}
Also used : BuildCacheLoadResult(org.gradle.caching.internal.controller.service.BuildCacheLoadResult) BuildCacheLoadResult(org.gradle.caching.internal.controller.service.BuildCacheLoadResult) UnpackOperationDetails(org.gradle.caching.internal.controller.operations.UnpackOperationDetails) DefaultBuildCacheTempFileStore(org.gradle.caching.local.internal.DefaultBuildCacheTempFileStore) DefaultLocalBuildCacheServiceHandle(org.gradle.caching.internal.controller.service.DefaultLocalBuildCacheServiceHandle) NullLocalBuildCacheServiceHandle(org.gradle.caching.internal.controller.service.NullLocalBuildCacheServiceHandle) BuildCacheTempFileStore(org.gradle.caching.local.internal.BuildCacheTempFileStore) Duration(java.time.Duration) Map(java.util.Map) LocalBuildCacheService(org.gradle.caching.local.internal.LocalBuildCacheService) BuildCacheServiceRole(org.gradle.caching.internal.controller.service.BuildCacheServiceRole) BuildCacheEntryPacker(org.gradle.caching.internal.packaging.BuildCacheEntryPacker) FileSystemLocationSnapshot(org.gradle.internal.snapshot.FileSystemLocationSnapshot) CallableBuildOperation(org.gradle.internal.operations.CallableBuildOperation) BuildCacheService(org.gradle.caching.BuildCacheService) BuildOperationDescriptor(org.gradle.internal.operations.BuildOperationDescriptor) BuildOperationExecutor(org.gradle.internal.operations.BuildOperationExecutor) Optional(java.util.Optional) FileType(org.gradle.internal.file.FileType) OriginMetadata(org.gradle.caching.internal.origin.OriginMetadata) OpFiringRemoteBuildCacheServiceHandle(org.gradle.caching.internal.controller.service.OpFiringRemoteBuildCacheServiceHandle) OriginMetadataFactory(org.gradle.caching.internal.origin.OriginMetadataFactory) FileMetadata(org.gradle.internal.file.FileMetadata) StringInterner(org.gradle.api.internal.cache.StringInterner) AtomicReference(java.util.concurrent.atomic.AtomicReference) RemoteBuildCacheServiceHandle(org.gradle.caching.internal.controller.service.RemoteBuildCacheServiceHandle) TemporaryFileProvider(org.gradle.api.internal.file.temp.TemporaryFileProvider) BuildCacheServicesConfiguration(org.gradle.caching.internal.controller.service.BuildCacheServicesConfiguration) TreeType(org.gradle.internal.file.TreeType) RunnableBuildOperation(org.gradle.internal.operations.RunnableBuildOperation) ImmutableList(com.google.common.collect.ImmutableList) Closer(com.google.common.io.Closer) MissingFileSnapshot(org.gradle.internal.snapshot.MissingFileSnapshot) PackOperationResult(org.gradle.caching.internal.controller.operations.PackOperationResult) FileSystemSnapshot(org.gradle.internal.snapshot.FileSystemSnapshot) ImmutableSortedMap(com.google.common.collect.ImmutableSortedMap) Nullable(javax.annotation.Nullable) PackOperationDetails(org.gradle.caching.internal.controller.operations.PackOperationDetails) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) NullRemoteBuildCacheServiceHandle(org.gradle.caching.internal.controller.service.NullRemoteBuildCacheServiceHandle) FileInputStream(java.io.FileInputStream) FileSystemAccess(org.gradle.internal.vfs.FileSystemAccess) File(java.io.File) BuildCacheKey(org.gradle.caching.BuildCacheKey) CacheableEntity(org.gradle.caching.internal.CacheableEntity) GradleException(org.gradle.api.GradleException) UnpackOperationResult(org.gradle.caching.internal.controller.operations.UnpackOperationResult) LocalBuildCacheServiceHandle(org.gradle.caching.internal.controller.service.LocalBuildCacheServiceHandle) BuildOperationContext(org.gradle.internal.operations.BuildOperationContext) VisibleForTesting(com.google.common.annotations.VisibleForTesting) InputStream(java.io.InputStream) Optional(java.util.Optional) GradleException(org.gradle.api.GradleException) AtomicReference(java.util.concurrent.atomic.AtomicReference) IOException(java.io.IOException) GradleException(org.gradle.api.GradleException)

Aggregations

VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSortedMap (com.google.common.collect.ImmutableSortedMap)1 Closer (com.google.common.io.Closer)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Duration (java.time.Duration)1 Map (java.util.Map)1 Optional (java.util.Optional)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Nullable (javax.annotation.Nullable)1 GradleException (org.gradle.api.GradleException)1 StringInterner (org.gradle.api.internal.cache.StringInterner)1 TemporaryFileProvider (org.gradle.api.internal.file.temp.TemporaryFileProvider)1 BuildCacheKey (org.gradle.caching.BuildCacheKey)1 BuildCacheService (org.gradle.caching.BuildCacheService)1 CacheableEntity (org.gradle.caching.internal.CacheableEntity)1