Search in sources :

Example 11 with DefaultVaultRegistry

use of ch.cyberduck.core.vault.DefaultVaultRegistry in project cyberduck by iterate-ch.

the class ConcurrentTransferWorkerTest method testAwait.

@Test
public void testAwait() throws Exception {
    final Host host = new Host(new TestProtocol(), "localhost", new Credentials("u", "p"));
    final Transfer transfer = new UploadTransfer(host, new Path("/t", EnumSet.of(Path.Type.directory)), new NullLocal("l"));
    final LoginConnectionService connection = new TestLoginConnectionService();
    final ConcurrentTransferWorker worker = new ConcurrentTransferWorker(new DefaultSessionPool(connection, new DisabledX509TrustManager(), new DefaultX509KeyManager(), new DefaultVaultRegistry(new DisabledPasswordCallback()), new DisabledTranscriptListener(), host), SessionPool.DISCONNECTED, transfer, new TransferOptions(), new TransferSpeedometer(transfer), new DisabledTransferPrompt(), new DisabledTransferErrorCallback(), new DisabledLoginCallback(), new DisabledProgressListener(), new DisabledStreamListener(), new DisabledNotificationService());
    int workers = 1000;
    final CountDownLatch entry = new CountDownLatch(workers);
    for (int i = 0; i < workers; i++) {
        worker.submit(new TransferWorker.TransferCallable() {

            @Override
            public TransferStatus call() {
                entry.countDown();
                return new TransferStatus().complete();
            }
        });
    }
    worker.await();
    assertEquals(0, entry.getCount());
    worker.cleanup(true);
}
Also used : DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) DefaultSessionPool(ch.cyberduck.core.pool.DefaultSessionPool) TransferOptions(ch.cyberduck.core.transfer.TransferOptions) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) DisabledTransferErrorCallback(ch.cyberduck.core.transfer.DisabledTransferErrorCallback) DisabledNotificationService(ch.cyberduck.core.notification.DisabledNotificationService) DisabledStreamListener(ch.cyberduck.core.io.DisabledStreamListener) CountDownLatch(java.util.concurrent.CountDownLatch) DisabledTransferPrompt(ch.cyberduck.core.transfer.DisabledTransferPrompt) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) Transfer(ch.cyberduck.core.transfer.Transfer) DownloadTransfer(ch.cyberduck.core.transfer.DownloadTransfer) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) TransferSpeedometer(ch.cyberduck.core.transfer.TransferSpeedometer) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) Test(org.junit.Test)

Example 12 with DefaultVaultRegistry

use of ch.cyberduck.core.vault.DefaultVaultRegistry in project cyberduck by iterate-ch.

the class ConcurrentTransferWorkerTest method testConcurrentSessions.

@Test
public void testConcurrentSessions() throws Exception {
    final int files = 20;
    final int connections = 3;
    final Set<Path> transferred = ConcurrentHashMap.newKeySet();
    final List<TransferItem> list = new ArrayList<TransferItem>();
    for (int i = 1; i <= files; i++) {
        list.add(new TransferItem(new Path("/t" + i, EnumSet.of(Path.Type.file)), new NullLocal("/t" + i)));
    }
    final Host host = new Host(new TestProtocol(), "test.cyberduck.ch");
    final Transfer t = new DownloadTransfer(host, list) {

        @Override
        public void transfer(final Session<?> source, final Session<?> destination, final Path file, final Local local, final TransferOptions options, final TransferStatus overall, final TransferStatus segment, final ConnectionCallback connectionCallback, final ProgressListener listener, final StreamListener streamListener) {
            assertNotNull(source);
            transferred.add(file);
        }

        @Override
        public AbstractDownloadFilter filter(final Session<?> source, final Session<?> destination, final TransferAction action, final ProgressListener listener) {
            return new AbstractDownloadFilter(new DisabledDownloadSymlinkResolver(), source, null) {

                @Override
                public boolean accept(final Path file, final Local local, final TransferStatus parent) {
                    assertFalse(transferred.contains(file));
                    return true;
                }

                @Override
                public TransferStatus prepare(final Path file, final Local local, final TransferStatus parent, final ProgressListener progress) {
                    assertFalse(transferred.contains(file));
                    return new TransferStatus();
                }

                @Override
                public void apply(final Path file, final Local local, final TransferStatus status, final ProgressListener listener) {
                    assertFalse(transferred.contains(file));
                }

                @Override
                public void complete(final Path file, final Local local, final TransferOptions options, final TransferStatus status, final ProgressListener listener) {
                    assertTrue(transferred.contains(file));
                }
            };
        }
    };
    final LoginConnectionService connection = new TestLoginConnectionService();
    final DefaultSessionPool pool = new DefaultSessionPool(connection, new DisabledX509TrustManager(), new DefaultX509KeyManager(), new DefaultVaultRegistry(new DisabledPasswordCallback()), new DisabledTranscriptListener(), host);
    final ConcurrentTransferWorker worker = new ConcurrentTransferWorker(pool, SessionPool.DISCONNECTED, t, new TransferOptions(), new TransferSpeedometer(t), new DisabledTransferPrompt() {

        @Override
        public TransferAction prompt(final TransferItem file) {
            return TransferAction.overwrite;
        }
    }, new DisabledTransferErrorCallback(), new DisabledLoginCallback(), new DisabledProgressListener(), new DisabledStreamListener(), new DisabledNotificationService());
    pool.withMaxTotal(connections);
    final Session<?> session = worker.borrow(ConcurrentTransferWorker.Connection.source);
    assertTrue(worker.run(session));
    worker.release(session, ConcurrentTransferWorker.Connection.source, null);
    for (int i = 1; i <= files; i++) {
        assertTrue(transferred.contains(new Path("/t" + i, EnumSet.of(Path.Type.file))));
    }
    worker.cleanup(true);
}
Also used : DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) TransferAction(ch.cyberduck.core.transfer.TransferAction) ArrayList(java.util.ArrayList) DefaultSessionPool(ch.cyberduck.core.pool.DefaultSessionPool) DisabledDownloadSymlinkResolver(ch.cyberduck.core.transfer.symlink.DisabledDownloadSymlinkResolver) TransferOptions(ch.cyberduck.core.transfer.TransferOptions) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) DownloadTransfer(ch.cyberduck.core.transfer.DownloadTransfer) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) StreamListener(ch.cyberduck.core.io.StreamListener) DisabledStreamListener(ch.cyberduck.core.io.DisabledStreamListener) DisabledTransferErrorCallback(ch.cyberduck.core.transfer.DisabledTransferErrorCallback) DisabledNotificationService(ch.cyberduck.core.notification.DisabledNotificationService) DisabledStreamListener(ch.cyberduck.core.io.DisabledStreamListener) DisabledTransferPrompt(ch.cyberduck.core.transfer.DisabledTransferPrompt) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) Transfer(ch.cyberduck.core.transfer.Transfer) DownloadTransfer(ch.cyberduck.core.transfer.DownloadTransfer) AbstractDownloadFilter(ch.cyberduck.core.transfer.download.AbstractDownloadFilter) TransferSpeedometer(ch.cyberduck.core.transfer.TransferSpeedometer) TransferItem(ch.cyberduck.core.transfer.TransferItem) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) Test(org.junit.Test)

Example 13 with DefaultVaultRegistry

use of ch.cyberduck.core.vault.DefaultVaultRegistry in project cyberduck by iterate-ch.

the class ConcurrentTransferWorkerTest method testDoubleRelease.

@Test
public void testDoubleRelease() throws Exception {
    final Host host = new Host(new TestProtocol(), "test.cyberduck.ch");
    final Transfer t = new UploadTransfer(host, new Path("/t", EnumSet.of(Path.Type.directory)), new NullLocal("l"));
    final LoginConnectionService connection = new TestLoginConnectionService();
    final DefaultSessionPool pool = new DefaultSessionPool(connection, new DisabledX509TrustManager(), new DefaultX509KeyManager(), new DefaultVaultRegistry(new DisabledPasswordCallback()), new DisabledTranscriptListener(), host);
    final ConcurrentTransferWorker worker = new ConcurrentTransferWorker(pool, SessionPool.DISCONNECTED, t, new TransferOptions(), new TransferSpeedometer(t), new DisabledTransferPrompt(), new DisabledTransferErrorCallback(), new DisabledConnectionCallback(), new DisabledProgressListener(), new DisabledStreamListener(), new DisabledNotificationService());
    final Session<?> session = worker.borrow(ConcurrentTransferWorker.Connection.source);
    worker.release(session, ConcurrentTransferWorker.Connection.source, null);
    worker.release(session, ConcurrentTransferWorker.Connection.source, null);
}
Also used : DisabledNotificationService(ch.cyberduck.core.notification.DisabledNotificationService) DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) DisabledStreamListener(ch.cyberduck.core.io.DisabledStreamListener) DefaultSessionPool(ch.cyberduck.core.pool.DefaultSessionPool) TransferOptions(ch.cyberduck.core.transfer.TransferOptions) DisabledTransferPrompt(ch.cyberduck.core.transfer.DisabledTransferPrompt) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) Transfer(ch.cyberduck.core.transfer.Transfer) DownloadTransfer(ch.cyberduck.core.transfer.DownloadTransfer) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) TransferSpeedometer(ch.cyberduck.core.transfer.TransferSpeedometer) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) DisabledTransferErrorCallback(ch.cyberduck.core.transfer.DisabledTransferErrorCallback) Test(org.junit.Test)

Example 14 with DefaultVaultRegistry

use of ch.cyberduck.core.vault.DefaultVaultRegistry in project cyberduck by iterate-ch.

the class ConcurrentTransferWorkerTest method testBorrowTimeoutNoSessionAvailable.

@Test
public void testBorrowTimeoutNoSessionAvailable() throws Exception {
    final Host host = new Host(new TestProtocol(), "localhost", new Credentials("u", "p"));
    final Transfer t = new UploadTransfer(host, new Path("/t", EnumSet.of(Path.Type.directory)), new NullLocal("l"));
    final LoginConnectionService connection = new TestLoginConnectionService();
    final ConcurrentTransferWorker worker = new ConcurrentTransferWorker(new DefaultSessionPool(connection, new DisabledX509TrustManager(), new DefaultX509KeyManager(), new DefaultVaultRegistry(new DisabledPasswordCallback()), new DisabledTranscriptListener(), host), SessionPool.DISCONNECTED, t, new TransferOptions(), new TransferSpeedometer(t), new DisabledTransferPrompt(), new DisabledTransferErrorCallback(), new DisabledLoginCallback(), new DisabledProgressListener(), new DisabledStreamListener(), new DisabledNotificationService());
    final Session<?> session = worker.borrow(ConcurrentTransferWorker.Connection.source);
    assertNotNull(session);
    final CyclicBarrier lock = new CyclicBarrier(2);
    new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                lock.await(1, TimeUnit.MINUTES);
            } catch (InterruptedException | BrokenBarrierException | TimeoutException e) {
                fail();
            }
        }
    }).start();
    Thread.sleep(2000L);
    worker.release(session, ConcurrentTransferWorker.Connection.source, null);
}
Also used : DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) BrokenBarrierException(java.util.concurrent.BrokenBarrierException) DefaultSessionPool(ch.cyberduck.core.pool.DefaultSessionPool) TransferOptions(ch.cyberduck.core.transfer.TransferOptions) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) DisabledTransferErrorCallback(ch.cyberduck.core.transfer.DisabledTransferErrorCallback) TimeoutException(java.util.concurrent.TimeoutException) DisabledNotificationService(ch.cyberduck.core.notification.DisabledNotificationService) DisabledStreamListener(ch.cyberduck.core.io.DisabledStreamListener) CyclicBarrier(java.util.concurrent.CyclicBarrier) DisabledTransferPrompt(ch.cyberduck.core.transfer.DisabledTransferPrompt) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) Transfer(ch.cyberduck.core.transfer.Transfer) DownloadTransfer(ch.cyberduck.core.transfer.DownloadTransfer) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) TransferSpeedometer(ch.cyberduck.core.transfer.TransferSpeedometer) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) Test(org.junit.Test)

Example 15 with DefaultVaultRegistry

use of ch.cyberduck.core.vault.DefaultVaultRegistry in project cyberduck by iterate-ch.

the class EueThresholdUploadServiceTest method testUploadVaultWithBulkFeature.

@Test
public void testUploadVaultWithBulkFeature() throws Exception {
    final EueResourceIdProvider fileid = new EueResourceIdProvider(session);
    final Path container = new EueDirectoryFeature(session, fileid).mkdir(new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus().withLength(0L));
    final Path vault = new Path(container, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    final Path test = new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final CryptoVault cryptomator = new CryptoVault(vault);
    cryptomator.create(session, new VaultCredentials("test"), new DisabledPasswordStore(), vaultVersion);
    final DefaultVaultRegistry registry = new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator);
    session.withRegistry(registry);
    final Local local = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString());
    final byte[] content = RandomUtils.nextBytes(50240000);
    IOUtils.write(content, local.getOutputStream(false));
    final TransferStatus writeStatus = new TransferStatus();
    final FileHeader header = cryptomator.getFileHeaderCryptor().create();
    writeStatus.setHeader(cryptomator.getFileHeaderCryptor().encryptHeader(header));
    writeStatus.setLength(content.length);
    final CryptoBulkFeature<Map<TransferItem, TransferStatus>> bulk = new CryptoBulkFeature<>(session, new DisabledBulkFeature(), new EueDeleteFeature(session, fileid), cryptomator);
    bulk.pre(Transfer.Type.upload, Collections.singletonMap(new TransferItem(test), writeStatus), new DisabledConnectionCallback());
    final BytecountStreamListener count = new BytecountStreamListener();
    final CryptoUploadFeature feature = new CryptoUploadFeature<>(session, new EueThresholdUploadService(session, fileid, registry), new EueWriteFeature(session, fileid), cryptomator);
    feature.upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), count, writeStatus, new DisabledConnectionCallback());
    assertEquals(content.length, count.getSent());
    assertTrue(writeStatus.isComplete());
    assertTrue(new CryptoFindFeature(session, new EueFindFeature(session, fileid), cryptomator).find(test));
    assertEquals(content.length, new CryptoAttributesFeature(session, new EueAttributesFinderFeature(session, fileid), cryptomator).find(test).getSize());
    final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length);
    final TransferStatus readStatus = new TransferStatus().withLength(content.length);
    final InputStream in = new CryptoReadFeature(session, new EueReadFeature(session, fileid), cryptomator).read(test, readStatus, new DisabledConnectionCallback());
    new StreamCopier(readStatus, readStatus).transfer(in, buffer);
    assertArrayEquals(content, buffer.toByteArray());
    cryptomator.getFeature(session, Delete.class, new EueDeleteFeature(session, fileid)).delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
    local.delete();
}
Also used : EueDirectoryFeature(ch.cyberduck.core.eue.EueDirectoryFeature) Delete(ch.cyberduck.core.features.Delete) EueAttributesFinderFeature(ch.cyberduck.core.eue.EueAttributesFinderFeature) CryptoBulkFeature(ch.cyberduck.core.cryptomator.features.CryptoBulkFeature) EueFindFeature(ch.cyberduck.core.eue.EueFindFeature) EueReadFeature(ch.cyberduck.core.eue.EueReadFeature) EueDeleteFeature(ch.cyberduck.core.eue.EueDeleteFeature) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) CryptoReadFeature(ch.cyberduck.core.cryptomator.features.CryptoReadFeature) FileHeader(org.cryptomator.cryptolib.api.FileHeader) CryptoUploadFeature(ch.cyberduck.core.cryptomator.features.CryptoUploadFeature) Path(ch.cyberduck.core.Path) VaultCredentials(ch.cyberduck.core.vault.VaultCredentials) InputStream(java.io.InputStream) DisabledBulkFeature(ch.cyberduck.core.shared.DisabledBulkFeature) Local(ch.cyberduck.core.Local) ByteArrayOutputStream(java.io.ByteArrayOutputStream) EueResourceIdProvider(ch.cyberduck.core.eue.EueResourceIdProvider) BytecountStreamListener(ch.cyberduck.core.BytecountStreamListener) EueWriteFeature(ch.cyberduck.core.eue.EueWriteFeature) CryptoFindFeature(ch.cyberduck.core.cryptomator.features.CryptoFindFeature) CryptoAttributesFeature(ch.cyberduck.core.cryptomator.features.CryptoAttributesFeature) BandwidthThrottle(ch.cyberduck.core.io.BandwidthThrottle) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) EueThresholdUploadService(ch.cyberduck.core.eue.EueThresholdUploadService) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) Map(java.util.Map) TransferItem(ch.cyberduck.core.transfer.TransferItem) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) StreamCopier(ch.cyberduck.core.io.StreamCopier) AbstractEueSessionTest(ch.cyberduck.core.eue.AbstractEueSessionTest) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Aggregations

DefaultVaultRegistry (ch.cyberduck.core.vault.DefaultVaultRegistry)169 Test (org.junit.Test)169 DisabledPasswordCallback (ch.cyberduck.core.DisabledPasswordCallback)157 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)148 Path (ch.cyberduck.core.Path)146 VaultCredentials (ch.cyberduck.core.vault.VaultCredentials)145 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)143 DisabledPasswordStore (ch.cyberduck.core.DisabledPasswordStore)143 IntegrationTest (ch.cyberduck.test.IntegrationTest)143 Delete (ch.cyberduck.core.features.Delete)136 AlphanumericRandomStringService (ch.cyberduck.core.AlphanumericRandomStringService)135 CryptoFindFeature (ch.cyberduck.core.cryptomator.features.CryptoFindFeature)123 DefaultFindFeature (ch.cyberduck.core.shared.DefaultFindFeature)72 DisabledConnectionCallback (ch.cyberduck.core.DisabledConnectionCallback)70 CryptoAttributesFeature (ch.cyberduck.core.cryptomator.features.CryptoAttributesFeature)62 CryptoReadFeature (ch.cyberduck.core.cryptomator.features.CryptoReadFeature)50 StreamCopier (ch.cyberduck.core.io.StreamCopier)50 Directory (ch.cyberduck.core.features.Directory)49 InputStream (java.io.InputStream)47 DefaultTouchFeature (ch.cyberduck.core.shared.DefaultTouchFeature)44