Search in sources :

Example 1 with TransferDecoratorManager

use of org.commonjava.maven.galley.io.TransferDecoratorManager in project indy by Commonjava.

the class DefaultGalleyStorageProvider method setupTransferDecoratorPipeline.

/**
 * The order is important. We put the checksum decorator at the last because some decorators may change the content.
 */
private void setupTransferDecoratorPipeline() {
    List<TransferDecorator> decorators = new ArrayList<>();
    decorators.add(new IOLatencyDecorator(timerProviderFunction(), meterProvider(), cumulativeTimer()));
    decorators.add(new NoCacheTransferDecorator(specialPathManager));
    decorators.add(new UploadMetadataGenTransferDecorator(specialPathManager, timerProviderFunction()));
    for (TransferDecorator decorator : transferDecorators) {
        decorators.add(decorator);
    }
    decorators.add(getChecksummingTransferDecorator());
    if (featureConfig.getFileChangeTracking()) {
        decorators.add(new FileChangeTrackingDecorator(config));
    }
    transferDecorator = new TransferDecoratorManager(decorators);
}
Also used : NoCacheTransferDecorator(org.commonjava.maven.galley.io.NoCacheTransferDecorator) TransferDecoratorManager(org.commonjava.maven.galley.io.TransferDecoratorManager) ArrayList(java.util.ArrayList) UploadMetadataGenTransferDecorator(org.commonjava.maven.galley.transport.htcli.UploadMetadataGenTransferDecorator) ChecksummingTransferDecorator(org.commonjava.maven.galley.io.ChecksummingTransferDecorator) NoCacheTransferDecorator(org.commonjava.maven.galley.io.NoCacheTransferDecorator) UploadMetadataGenTransferDecorator(org.commonjava.maven.galley.transport.htcli.UploadMetadataGenTransferDecorator) TransferDecorator(org.commonjava.maven.galley.spi.io.TransferDecorator)

Example 2 with TransferDecoratorManager

use of org.commonjava.maven.galley.io.TransferDecoratorManager in project indy by Commonjava.

the class FileChangeTrackingDecoratorTest method init.

private void init(int logSize) throws IOException {
    config = new DefaultStorageProviderConfiguration();
    config.setStorageRootDirectory(temp.newFolder("storage-root"));
    config.setChangeTrackingRollSize(logSize);
    decorator = new FileChangeTrackingDecorator(config);
    cp = new FileCacheProvider(config.getStorageRootDirectory(), new HashedLocationPathGenerator(), new NoOpFileEventManager(), new TransferDecoratorManager(decorator), false);
}
Also used : FileCacheProvider(org.commonjava.maven.galley.cache.FileCacheProvider) NoOpFileEventManager(org.commonjava.maven.galley.event.NoOpFileEventManager) DefaultStorageProviderConfiguration(org.commonjava.indy.filer.def.conf.DefaultStorageProviderConfiguration) HashedLocationPathGenerator(org.commonjava.maven.galley.io.HashedLocationPathGenerator) TransferDecoratorManager(org.commonjava.maven.galley.io.TransferDecoratorManager)

Example 3 with TransferDecoratorManager

use of org.commonjava.maven.galley.io.TransferDecoratorManager in project indy by Commonjava.

the class TestProvider method setup.

@PostConstruct
public void setup() {
    storeDataManager = new MemoryStoreDataManager(true);
    nfc = new MemoryNotFoundCache();
    objectMapper = new IndyObjectMapper(false);
    fileEventManager = new NoOpFileEventManager();
    transferDecorator = new NoOpTransferDecorator();
    transportManagerConfig = new TransportManagerConfig();
    weftConfig = new DefaultWeftConfig();
    globalHttpConfiguration = new GlobalHttpConfiguration();
    userLifecycleManager = new AlternativeUserLifecycleManager();
    temp = new TemporaryFolder();
    try {
        temp.create();
        cacheProvider = new FileCacheProvider(temp.newFolder("storage"), indyPathGenerator, fileEventManager, new TransferDecoratorManager(transferDecorator));
    } catch (IOException e) {
        fail("Cannot initialize temporary directory structure");
        temp.delete();
    }
}
Also used : FileCacheProvider(org.commonjava.maven.galley.cache.FileCacheProvider) NoOpTransferDecorator(org.commonjava.maven.galley.io.NoOpTransferDecorator) DefaultWeftConfig(org.commonjava.cdi.util.weft.config.DefaultWeftConfig) TransportManagerConfig(org.commonjava.maven.galley.config.TransportManagerConfig) MemoryNotFoundCache(org.commonjava.maven.galley.nfc.MemoryNotFoundCache) IOException(java.io.IOException) NoOpFileEventManager(org.commonjava.maven.galley.event.NoOpFileEventManager) AlternativeUserLifecycleManager(org.commonjava.indy.action.fixture.AlternativeUserLifecycleManager) IndyObjectMapper(org.commonjava.indy.model.core.io.IndyObjectMapper) MemoryStoreDataManager(org.commonjava.indy.mem.data.MemoryStoreDataManager) TransferDecoratorManager(org.commonjava.maven.galley.io.TransferDecoratorManager) GlobalHttpConfiguration(org.commonjava.maven.galley.transport.htcli.conf.GlobalHttpConfiguration) TemporaryFolder(org.junit.rules.TemporaryFolder) PostConstruct(javax.annotation.PostConstruct)

Example 4 with TransferDecoratorManager

use of org.commonjava.maven.galley.io.TransferDecoratorManager in project indy by Commonjava.

the class NPMPackageMaskingTransferDecoratorTest method testDecorator2.

@Test
public void testDecorator2() throws Exception {
    String path = "package.json";
    KeyedLocation location = new GroupLocation(PKG_TYPE_NPM, "test");
    File file = new File(temp.newFolder(location.getName()), path);
    IOUtils.copy(getResourceAsStream("metadata/package-tar-fs.json"), new FileOutputStream(file));
    ConcreteResource resource = new ConcreteResource(location, path);
    TestCacheProvider provider = new TestCacheProvider(temp.getRoot(), new TestFileEventManager(), new TransferDecoratorManager(new NPMPackageMaskingTransferDecorator()));
    Transfer transfer = provider.getTransfer(resource);
    InputStream stream = transfer.openInputStream(false, new EventMetadata().set(ENTRY_POINT_BASE_URI, "http://localhost/api/content/npm"));
    String ret = IOUtils.toString(stream);
    String expected = IOUtils.toString(getResourceAsStream("metadata/package-tar-fs-decorated.json"));
    assertEquals(expected, ret);
}
Also used : KeyedLocation(org.commonjava.indy.model.galley.KeyedLocation) InputStream(java.io.InputStream) TestFileEventManager(org.commonjava.indy.test.fixture.core.TestFileEventManager) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) GroupLocation(org.commonjava.indy.model.galley.GroupLocation) FileOutputStream(java.io.FileOutputStream) TransferDecoratorManager(org.commonjava.maven.galley.io.TransferDecoratorManager) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) TestCacheProvider(org.commonjava.indy.test.fixture.core.TestCacheProvider) Transfer(org.commonjava.maven.galley.model.Transfer) File(java.io.File) Test(org.junit.Test)

Example 5 with TransferDecoratorManager

use of org.commonjava.maven.galley.io.TransferDecoratorManager in project indy by Commonjava.

the class PackageMetadataMergerTest method setup.

@Before
public void setup() throws Exception {
    cacheProvider = new FileCacheProvider(temp.newFolder("cache"), new IndyPathGenerator(Collections.singleton(new NPMStoragePathCalculator(new SpecialPathManagerImpl()))), new NoOpFileEventManager(), new TransferDecoratorManager(new NoOpTransferDecorator()), false);
    mapper = new IndyObjectMapper(true);
    mapper.registerModule(new PackageSerializerModule());
}
Also used : FileCacheProvider(org.commonjava.maven.galley.cache.FileCacheProvider) NoOpFileEventManager(org.commonjava.maven.galley.event.NoOpFileEventManager) NPMStoragePathCalculator(org.commonjava.indy.pkg.npm.content.NPMStoragePathCalculator) NoOpTransferDecorator(org.commonjava.maven.galley.io.NoOpTransferDecorator) IndyObjectMapper(org.commonjava.indy.model.core.io.IndyObjectMapper) TransferDecoratorManager(org.commonjava.maven.galley.io.TransferDecoratorManager) IndyPathGenerator(org.commonjava.indy.content.IndyPathGenerator) PackageSerializerModule(org.commonjava.indy.pkg.npm.model.io.PackageSerializerModule) SpecialPathManagerImpl(org.commonjava.maven.galley.io.SpecialPathManagerImpl) Before(org.junit.Before)

Aggregations

TransferDecoratorManager (org.commonjava.maven.galley.io.TransferDecoratorManager)6 FileCacheProvider (org.commonjava.maven.galley.cache.FileCacheProvider)3 NoOpFileEventManager (org.commonjava.maven.galley.event.NoOpFileEventManager)3 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 InputStream (java.io.InputStream)2 IndyObjectMapper (org.commonjava.indy.model.core.io.IndyObjectMapper)2 GroupLocation (org.commonjava.indy.model.galley.GroupLocation)2 KeyedLocation (org.commonjava.indy.model.galley.KeyedLocation)2 TestCacheProvider (org.commonjava.indy.test.fixture.core.TestCacheProvider)2 TestFileEventManager (org.commonjava.indy.test.fixture.core.TestFileEventManager)2 EventMetadata (org.commonjava.maven.galley.event.EventMetadata)2 NoOpTransferDecorator (org.commonjava.maven.galley.io.NoOpTransferDecorator)2 ConcreteResource (org.commonjava.maven.galley.model.ConcreteResource)2 Transfer (org.commonjava.maven.galley.model.Transfer)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 PostConstruct (javax.annotation.PostConstruct)1 DefaultWeftConfig (org.commonjava.cdi.util.weft.config.DefaultWeftConfig)1