This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"fmt" | |
"os" | |
) | |
func algorithm1(lines []string) int { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FinalizingStep implements AsyncStep<Void>, Callable<Void> { | |
public Void call() throws ExecutionException { | |
// Unwrap the wrapped dependencies. | |
List<ListenableFuture<?>> unwrappedDependencies = new ArrayList<>(); | |
for (AsyncStep<? extends ImmutableList<? extends AsyncStep<?>>> wrappedDependency : | |
futureDependencyLists) { | |
for (AsyncStep<?> unwrappedDependency : NonBlockingSteps.get(wrappedDependency)) { | |
unwrappedDependencies.add(unwrappedDependency.getFuture()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PushContainerConfigurationStep | |
/*(...)*/ | |
@Override | |
public AsyncStep<PushBlobStep> call() throws ExecutionException { | |
ListenableFuture<PushBlobStep> pushBlobStepFuture = | |
Futures.whenAllSucceed( | |
authenticatePushStep.getFuture(), NonBlockingSteps.get(buildImageStep).getFuture()) | |
.call(this::afterBuildConfigurationFutureFuture, listeningExecutorService); | |
return () -> pushBlobStepFuture; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BuildImageStep | |
implements AsyncStep<AsyncStep<Image<CachedLayer>>>, Callable<AsyncStep<Image<CachedLayer>>> { | |
/*(...)*/ | |
private Image<CachedLayer> afterCachedLayersSteps() | |
throws ExecutionException, LayerPropertyNotFoundException { | |
try (Timer ignored = new Timer(buildConfiguration.getBuildLogger(), DESCRIPTION)) { | |
// Constructs the image. | |
Image.Builder<CachedLayer> imageBuilder = Image.builder(); | |
for (PullAndCacheBaseImageLayerStep pullAndCacheBaseImageLayerStep : | |
NonBlockingSteps.get(pullAndCacheBaseImageLayersStep)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BuildImageStep | |
implements AsyncStep<AsyncStep<Image<CachedLayer>>>, Callable<AsyncStep<Image<CachedLayer>>> { | |
/*(...)*/ | |
public AsyncStep<Image<CachedLayer>> call() throws ExecutionException { | |
List<ListenableFuture<?>> dependencies = new ArrayList<>(); | |
for (PullAndCacheBaseImageLayerStep pullAndCacheBaseImageLayerStep : | |
NonBlockingSteps.get(pullAndCacheBaseImageLayersStep)) { | |
dependencies.add(pullAndCacheBaseImageLayerStep.getFuture()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CacheWriter { | |
/*(...)*/ | |
public CachedLayerWithMetadata writeLayer(ReproducibleLayerBuilder reproducibleLayerBuilder) | |
throws IOException { | |
UnwrittenLayer unwrittenLayer = reproducibleLayerBuilder.build(); | |
Path tempLayerFile = Files.createTempFile(cache.getCacheDirectory(), null, null); | |
tempLayerFile.toFile().deleteOnExit(); | |
try (CountingDigestOutputStream compressedDigestOutputStream = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BuildAndCacheApplicationLayerStep | |
implements AsyncStep<CachedLayerWithMetadata>, Callable<CachedLayerWithMetadata> { | |
/*(...)*/ | |
@Override | |
public CachedLayerWithMetadata call() throws IOException, CacheMetadataCorruptedException { | |
/*(...)*/ | |
CachedLayerWithMetadata cachedLayer = | |
new CacheReader(cache) | |
.getUpToDateLayerByLayerEntries(layerConfiguration.getLayerEntries()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BuildAndCacheApplicationLayerStep | |
implements AsyncStep<CachedLayerWithMetadata>, Callable<CachedLayerWithMetadata> { | |
/*(...)*/ | |
static ImmutableList<BuildAndCacheApplicationLayerStep> makeList( | |
ListeningExecutorService listeningExecutorService, | |
BuildConfiguration buildConfiguration, | |
SourceFilesConfiguration sourceFilesConfiguration, | |
Cache cache) { | |
/*(...)*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PushBlobStep implements AsyncStep<BlobDescriptor>, Callable<BlobDescriptor> { | |
/*(...)*/ | |
public BlobDescriptor call() throws IOException, RegistryException, ExecutionException { | |
/*(...)*/ | |
RegistryClient registryClient =/*(...)*/ | |
if (registryClient.checkBlob(blobDescriptor.getDigest()) != null) { | |
/*(...)*/ | |
return blobDescriptor; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PushLayersStep | |
implements AsyncStep<ImmutableList<AsyncStep<PushBlobStep>>>, | |
Callable<ImmutableList<AsyncStep<PushBlobStep>>> { | |
/*(...)*/ | |
private PushBlobStep makePushBlobStep(AsyncStep<? extends CachedLayer> cachedLayerStep) | |
throws ExecutionException { | |
CachedLayer cachedLayer = NonBlockingSteps.get(cachedLayerStep); | |
return new PushBlobStep( | |
listeningExecutorService, | |
buildConfiguration, |
NewerOlder