IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
Browse Source

Downloading all blocks in parallel for better performance.

master
parent
commit
b9795a4802
2 changed files with 25 additions and 18 deletions
  1. +1
    -1
      frontend/src/js/component/wb-collection-content.js
  2. +24
    -17
      frontend/src/js/misc/wb-download-file.js

+ 1
- 1
frontend/src/js/component/wb-collection-content.js View File

@@ -67,7 +67,7 @@ class WBCollectionContent extends Component {
null, null,
(<div></div>) (<div></div>)
] : [ ] : [
(<a href={ this.getUrl({ 'collectionPath': collectionPath + '/' + item[1], 'page': 0 }) }>{ item[1] }</a>),
item[1],
'File', 'File',
filesize(item[2]), filesize(item[2]),
(<div> (<div>


+ 24
- 17
frontend/src/js/misc/wb-download-file.js View File

@@ -6,7 +6,6 @@ function wbDownloadFile(arvHost, arvToken,
const file = manifestReader.getFile(path); const file = manifestReader.getFile(path);
const name = path.split('/').reverse()[0]; const name = path.split('/').reverse()[0];
const blockRefs = file[0]; const blockRefs = file[0];
let proxy;
let prom = makeArvadosRequest(arvHost, arvToken, let prom = makeArvadosRequest(arvHost, arvToken,
'/arvados/v1/keep_services'); '/arvados/v1/keep_services');
@@ -14,26 +13,34 @@ function wbDownloadFile(arvHost, arvToken,
const services = xhr.response['items']; const services = xhr.response['items'];
const proxies = services.filter(svc => (svc.service_type === 'proxy')); const proxies = services.filter(svc => (svc.service_type === 'proxy'));
const n = Math.floor(Math.random() * proxies.length); const n = Math.floor(Math.random() * proxies.length);
proxy = proxies[n];
});
const proxy = proxies[n];
const blocks = [];
let prom_2 = new Promise(accept => accept());
for (let i = 0; i < blockRefs.length; i++) {
const [ locator, position, size ] = blockRefs[i];
const prom_1 = makeArvadosRequest(
proxy.service_host + ':' + proxy.service_port,
arvToken,
'/' + locator,
{ 'useSsl': proxy.service_ssl_flag,
'responseType': 'arraybuffer' }
);
const blocks = [];
for (let i = 0; i < blockRefs.length; i++) {
const [ locator, position, size ] = blockRefs[i];
prom_2 = prom_2.then(() => prom_1);
prom = prom.then(() => makeArvadosRequest(
proxy.service_host + ':' + proxy.service_port,
arvToken,
'/' + locator,
{ 'useSsl': proxy.service_ssl_flag,
'responseType': 'arraybuffer' }
));
prom_2 = prom_2.then(xhr => (blocks.push(xhr.response.slice(position,
position + size))));
}
prom_2 = prom_2.then(() => blocks);
return prom_2;
});
prom = prom.then(xhr => (blocks.push(xhr.response.slice(position,
position + size))));
}
prom = prom.then(() => blocks);
/* prom = prom.then(() => { /* prom = prom.then(() => {
const blob = new Blob(blocks); const blob = new Blob(blocks);


Loading…
Cancel
Save