Search in sources :

Example 6 with CircularStreamBufferTransferer

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);
        }
    }
}
Also used : CircularStreamBufferTransferer(nl.uva.vlet.io.CircularStreamBufferTransferer) FileOutputStream(java.io.FileOutputStream) VlException(nl.uva.vlet.exception.VlException) IOException(java.io.IOException) File(java.io.File) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) VlException(nl.uva.vlet.exception.VlException)

Aggregations

CircularStreamBufferTransferer (nl.uva.vlet.io.CircularStreamBufferTransferer)6 InputStream (java.io.InputStream)4 File (java.io.File)3 FileOutputStream (java.io.FileOutputStream)3 IOException (java.io.IOException)3 DesEncrypter (nl.uva.cs.lobcder.util.DesEncrypter)3 BadRequestException (io.milton.http.exceptions.BadRequestException)2 ConflictException (io.milton.http.exceptions.ConflictException)2 NotAuthorizedException (io.milton.http.exceptions.NotAuthorizedException)2 NotFoundException (io.milton.http.exceptions.NotFoundException)2 FileInputStream (java.io.FileInputStream)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 URISyntaxException (java.net.URISyntaxException)2 URL (java.net.URL)2 UnknownHostException (java.net.UnknownHostException)2 SQLException (java.sql.SQLException)2 PDRI (nl.uva.cs.lobcder.resources.PDRI)2 PDRIDescr (nl.uva.cs.lobcder.resources.PDRIDescr)2 FileNotFoundException (java.io.FileNotFoundException)1 MalformedURLException (java.net.MalformedURLException)1