Examples of IvyThread


Examples of org.apache.ivy.core.IvyThread

            String srcName = index == -1 ? source : source.substring(index + 1);
            final File to = destDir == null ? Checks.checkAbsolute(srcName, "source") : new File(
                    destDir, srcName);

            final IOException[] ex = new IOException[1];
            Thread get = new IvyThread() {
                public void run() {
                    initContext();
                    try {
                        sendCommand("get " + source, getExpectedDownloadMessage(source, to), 0);
                    } catch (IOException e) {
                        ex[0] = e;
                    }
                }
            };
            get.start();

            long prevLength = 0;
            long lastUpdate = System.currentTimeMillis();
            long timeout = readTimeout;
            while (get.isAlive()) {
                checkInterrupted();
                long length = to.exists() ? to.length() : 0;
                if (length > prevLength) {
                    fireTransferProgress(length - prevLength);
                    lastUpdate = System.currentTimeMillis();
                    prevLength = length;
                } else {
                    if (System.currentTimeMillis() - lastUpdate > timeout) {
                        Message.verbose("download hang for more than " + timeout
                                + "ms. Interrupting.");
                        get.interrupt();
                        if (to.exists()) {
                            to.delete();
                        }
                        throw new IOException(source + " download timeout from " + getHost());
                    }
                }
                try {
                    get.join(GET_JOIN_MAX_TIME);
                } catch (InterruptedException e) {
                    if (to.exists()) {
                        to.delete();
                    }
                    return;
View Full Code Here

Examples of org.apache.ivy.core.IvyThread

        };
        Thread reader = null;
        if (timeout == 0) {
            r.run();
        } else {
            reader = new IvyThread(r);
            reader.start();
            try {
                wait(timeout);
            } catch (InterruptedException e) {
                // nothing to do
View Full Code Here

Examples of org.apache.ivy.core.IvyThread

            try {
                readResponse(false); // waits for first prompt

                if (reuseConnection > 0) {
                    connectionCleaner = new IvyThread() {
                        public void run() {
                            initContext();
                            try {
                                long sleep = REUSE_CONNECTION_SLEEP_TIME;
                                while (in != null && sleep > 0) {
View Full Code Here

Examples of org.apache.ivy.core.IvyThread

        process = Runtime.getRuntime().exec(command);
        in = new InputStreamReader(process.getInputStream());
        err = new InputStreamReader(process.getErrorStream());
        out = new PrintWriter(process.getOutputStream());

        errorsReader = new IvyThread() {
            public void run() {
                initContext();
                int c;
                try {
                    // CheckStyle:InnerAssignment OFF
View Full Code Here

Examples of org.apache.ivy.core.IvyThread

            int index = source.lastIndexOf('/');
            String srcName = index == -1 ? source : source.substring(index + 1);
            final File to = destDir == null ? new File(srcName) : new File(destDir, srcName);

            final IOException[] ex = new IOException[1];
            Thread get = new IvyThread() {
                public void run() {
                    initContext();
                    try {
                        sendCommand("get " + source, getExpectedDownloadMessage(source, to), 0);
                    } catch (IOException e) {
                        ex[0] = e;
                    }
                }
            };
            get.start();

            long prevLength = 0;
            long lastUpdate = System.currentTimeMillis();
            long timeout = readTimeout;
            while (get.isAlive()) {
                checkInterrupted();
                long length = to.exists() ? to.length() : 0;
                if (length > prevLength) {
                    fireTransferProgress(length - prevLength);
                    lastUpdate = System.currentTimeMillis();
                    prevLength = length;
                } else {
                    if (System.currentTimeMillis() - lastUpdate > timeout) {
                        Message.verbose("download hang for more than " + timeout
                                + "ms. Interrupting.");
                        get.interrupt();
                        if (to.exists()) {
                            to.delete();
                        }
                        throw new IOException(source + " download timeout from " + getHost());
                    }
                }
                try {
                    get.join(100);
                } catch (InterruptedException e) {
                    if (to.exists()) {
                        to.delete();
                    }
                    return;
View Full Code Here

Examples of org.apache.ivy.core.IvyThread

        };
        Thread reader = null;
        if (timeout == 0) {
            r.run();
        } else {
            reader = new IvyThread(r);
            reader.start();
            try {
                wait(timeout);
            } catch (InterruptedException e) {
                //nothing to do
View Full Code Here

Examples of org.apache.ivy.core.IvyThread

            try {
                readResponse(false); // waits for first prompt

                if (reuseConnection > 0) {
                    connectionCleaner = new IvyThread() {
                        public void run() {
                            initContext();
                            try {
                                long sleep = 10;
                                while (in != null && sleep > 0) {
View Full Code Here

Examples of org.apache.ivy.core.IvyThread

        process = Runtime.getRuntime().exec(command);
        in = new InputStreamReader(process.getInputStream());
        err = new InputStreamReader(process.getErrorStream());
        out = new PrintWriter(process.getOutputStream());

        errorsReader = new IvyThread() {
            public void run() {
                initContext();
                int c;
                try {
                    while (err != null && (c = err.read()) != -1) {
View Full Code Here

Examples of org.apache.ivy.core.IvyThread

            int index = source.lastIndexOf('/');
            String srcName = index == -1 ? source : source.substring(index + 1);
            final File to = destDir == null ? new File(srcName) : new File(destDir, srcName);

            final IOException ex[] = new IOException[1];
            Thread get = new IvyThread() {
                public void run() {
                    initContext();
                    try {
                        sendCommand("get " + source, getExpectedDownloadMessage(source, to), 0);
                    } catch (IOException e) {
                        ex[0] = e;
                    }
                }
            };
            get.start();

            long prevLength = 0;
            long lastUpdate = System.currentTimeMillis();
            long timeout = _readTimeout;
            while (get.isAlive()) {
                checkInterrupted();
                long length = to.exists() ? to.length() : 0;
                if (length > prevLength) {
                    fireTransferProgress(length - prevLength);
                    lastUpdate = System.currentTimeMillis();
                    prevLength = length;
                } else {
                    if (System.currentTimeMillis() - lastUpdate > timeout) {
                        Message.verbose("download hang for more than " + timeout
                                + "ms. Interrupting.");
                        get.interrupt();
                        if (to.exists())
                            to.delete();
                        throw new IOException(source + " download timeout from " + getHost());
                    }
                }
                try {
                    get.join(100);
                } catch (InterruptedException e) {
                    if (to.exists())
                        to.delete();
                    return;
                }
View Full Code Here

Examples of org.apache.ivy.core.IvyThread

        };
        Thread reader = null;
        if (timeout == 0) {
            r.run();
        } else {
            reader = new IvyThread(r);
            reader.start();
            try {
                wait(timeout);
            } catch (InterruptedException e) {
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.