Package com.sun.faban.harness.agent

Examples of com.sun.faban.harness.agent.FileService


    @Deprecated public synchronized boolean copy(String srcmachine, String destmachine,
            String srcfile, String destfile,
            boolean append) {

        FileAgent srcf, destf = null;
        FileService srcfilep = null, destfilep = null;
        int sidx = machinesList.indexOf(srcmachine);
        int didx = machinesList.indexOf(destmachine);
        byte[] buf;
        if (sidx == didx && srcfile.equals(destfile)) {
            return (true);
        }

        if (srcfile.equals(destfile)) {
            try {
                String dest = cmdp.get(didx).getHostName();
                String src = cmdp.get(sidx).getHostName();
                if (dest == src) {
                    return true;
                }
            } catch (Exception e) {
                logger.severe("CmdService: Copying - CmdAgent getHostName exception");
                logger.log(Level.FINE, "Exception", e);
            }
        }
        logger.fine("CmdService: Copying " + srcfile + " from " + srcmachine + " to " + destfile + " in " + destmachine);

        srcf = filep.get(sidx);
        destf = filep.get(didx);
        try {
            srcfilep = srcf.open(srcfile, FileAgent.READ);
            if (append) {
                destfilep = destf.open(destfile, FileAgent.APPEND);
            } else {
                destfilep = destf.open(destfile, FileAgent.WRITE);
            }

            // Read from src and write to dest.
            buf = srcfilep.read();
            destfilep.write(buf);

            srcfilep.close();
            destfilep.close();
        } catch (Exception ie) {
            logger.log(Level.WARNING, "CmdService: Could not copy " +
                    srcmachine + ":" + srcfile + " to " + destmachine + ":" +
                    destfile, ie);
View Full Code Here


     * @param stream The stream to copy the content to
     * @return true/false if copy was successful/failed
     */
    public synchronized boolean copyToStream(String srcmachine, String srcfile,
            OutputStream stream) {
        FileService srcfilep = null;
        byte[] buf = null;

        FileAgent srcf = findFileAgent(srcmachine);
        try {
            srcfilep = srcf.open(srcfile, FileAgent.READ);

            // Now loop, reading from src and writing to dest
            while (true) {
                buf = srcfilep.readBytes(1000000);
                //  logger.info("           Read " + buf);
                //  logger.info(buf);
                //    logger.info(buf.length);
                stream.write(buf);
                if (buf.length < 1000000) {
                    break;
                }
            }

            srcfilep.close();
        } catch (Exception ie) {
            logger.log(Level.WARNING, "CmdService: Could not copy " +
                    srcmachine + ":" + srcfile, ie);
            return (false);
        }
View Full Code Here

            BufferedInputStream in = new BufferedInputStream(new FileInputStream(f));
            byte[] buf = new byte[8192];
            int i = in.read(buf);

            if(i > 0) {
                FileService outfp = fa.open(outFile, FileAgent.WRITE);
                while (i > 0) {
                    outfp.writeBytes(buf, 0, i);
                    i = in.read(buf);
                }
                outfp.close();
            }
            in.close();
        } catch (FileServiceException fe) {
            logger.severe("Error in creating file " + outFile);
            logger.log(Level.FINE, "Exception", fe);
View Full Code Here

TOP

Related Classes of com.sun.faban.harness.agent.FileService

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.