Package de.fu_berlin.inf.dpp.util

Examples of de.fu_berlin.inf.dpp.util.StopWatch


            // Create a packet collector to listen for a response.
            PacketCollector collector = connection
                .createPacketCollector(new PacketIDFilter(id));

            StopWatch watch = new StopWatch().start();

            try {
                try {
                    progress.subTask("Sending Data");
                    dataTransferManager.sendData(transferData, testData,
                        progress.newChild(40));
                } catch (IOException e) {
                    throw new XMPPException("IOException sending data", e);
                } catch (SarosCancellationException e) {
                    throw new XMPPException(
                        "CancellationException sending data", e);
                }

                progress.subTask("Waiting for reply");
                ConnectionTestResponse response = null;
                for (int i = 0; i < 15; i++) {
                    response = responseProvider.getPayload(collector
                        .nextResult(1000));
                    if (response != null)
                        break;
                    progress.worked(1);
                }

                result.transferTime = watch.stop().getTime();

                if (response == null)
                    throw new XMPPException("Timeout after 15s");

                if (response.errorMessage != null)
View Full Code Here


            FileInputStream fileInputStream = new FileInputStream(file);
            int numRead = 0;
            long sendBytes = 0;
            monitor.worked(1);

            StopWatch watch = new StopWatch();
            watch.start();
            try {
                while ((numRead = fileInputStream.read(buffer)) > 0
                    && streamException == null) {
                    if (monitor.isCanceled())
                        throw new SarosCancellationException();
                    if (Thread.interrupted() || stopped)
                        throw new RemoteCancellationException();

                    out.write(buffer, 0, numRead);
                    sendBytes += numRead;

                    monitor.worked(numRead);
                    monitor.subTask(watch.throughput(sendBytes));
                }

                out.flush();
                sendSuccessfully = sendBytes == file.length();
            } finally {
View Full Code Here

            outgoingTransfers.put(recipient, currentSendingOperations + 1);
        }

        try {

            StopWatch watch = new StopWatch().start();

            long sizeUncompressed = input.length;

            if (transferData.compressInDataTransferManager()) {
                input = Utils.deflate(input, progress.newChild(15));
            }

            connection.send(transferData, input, progress);

            watch.stop();
            transferModeDispatch.transferFinished(recipient,
                connection.getMode(), false, input.length, sizeUncompressed,
                watch.getTime());
        } catch (IOException e) {
            log.error(Utils.prefix(transferData.recipient) + "Failed to send "
                + transferData + " with " + connection.getMode().toString()
                + ":" + e.getMessage() + ":", e.getCause());
            throw e;
View Full Code Here

            long received = 0;
            InputStream in = session.getInputStream(0);
            byte[] buffer = new byte[session.getService().getChunkSize()[0]];

            StopWatch watch = new StopWatch();
            watch.start();
            try {
                int readBytes;
                boolean canceled = false;
                while ((readBytes = in.read(buffer)) > 0) {
                    received += readBytes;
                    fileOutputStream.write(buffer, 0, readBytes);

                    monitor.worked(readBytes);
                    monitor.subTask(watch.throughput(received));

                    if (monitor.isCanceled() && !canceled) {
                        // just stop once
                        getStreamSession().stopSession();
                        canceled = true;
View Full Code Here

TOP

Related Classes of de.fu_berlin.inf.dpp.util.StopWatch

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.