use of nl.uva.vlet.io.CircularStreamBufferTransferer in project lobcder by skoulouzis.
the class GetTask method run.
@Override
public void run() {
double start = System.currentTimeMillis();
FileOutputStream out = null;
File f = null;
try {
f = new File("/tmp/deleteme" + this.hashCode());
// f.deleteOnExit();
out = new FileOutputStream(f);
CircularStreamBufferTransferer cBuff = new CircularStreamBufferTransferer((512 * 1024), cl.getFile(vrl).getInputStream(), out);
cBuff.startTransfer((long) -1);
double elapsed = System.currentTimeMillis() - start;
System.err.println("Speed: " + (f.length() / elapsed));
sleeTime = 5;
} catch (Exception ex) {
try {
//
if (reconnectAttemts < 10) {
sleeTime = sleeTime + 20;
System.err.println("Reconnecting: " + reconnectAttemts + " sleep: " + sleeTime);
Thread.sleep(sleeTime);
reconnect();
run();
} else {
// Logger.getLogger(TestDrivers.class.getName()).log(Level.SEVERE, null, ex);
}
} catch (InterruptedException ex1) {
Logger.getLogger(GetTask.class.getName()).log(Level.SEVERE, null, ex1);
//
} catch (VlException ex1) {
Logger.getLogger(GetTask.class.getName()).log(Level.SEVERE, null, ex1);
}
} finally {
try {
out.close();
} catch (IOException ex) {
Logger.getLogger(TestDrivers.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
Aggregations