Search in sources :

Example 1 with RemoteFileCopyProgress

use of com.sun.enterprise.util.cluster.windows.io.RemoteFileCopyProgress in project Payara by payara.

the class InstallNodeDcomCommand method copyToHostsInternal.

private void copyToHostsInternal(File zipFile, ArrayList<String> binDirFiles) throws CommandException, WindowsException {
    final String zipFileName = "glassfish_install.zip";
    final String unpackScriptName = "unpack.bat";
    for (String host : hosts) {
        String remotePassword = getPassword(host);
        WindowsRemoteFileSystem wrfs = new WindowsRemoteFileSystem(host, getRemoteUser(), remotePassword);
        WindowsRemoteFile remoteInstallDir = new WindowsRemoteFile(wrfs, remoteInstallDirString);
        remoteInstallDir.mkdirs(getForce());
        WindowsRemoteFile remoteZip = new WindowsRemoteFile(remoteInstallDir, zipFileName);
        WindowsRemoteFile unpackScript = new WindowsRemoteFile(remoteInstallDir, unpackScriptName);
        // createUnpackScript
        System.out.printf("Copying %d bytes", zipFile.length());
        remoteZip.copyFrom(zipFile, new RemoteFileCopyProgress() {

            @Override
            public void callback(long numcopied, long numtotal) {
                // final int percent = (int)((double)numcopied / (double)numtotal * 100.0);
                System.out.print(".");
            }

            @Override
            public int getChunkSize() {
                return 1048576;
            }
        });
        System.out.println("");
        String fullZipFileName = remoteInstallDirString + "\\" + zipFileName;
        String fullUnpackScriptPath = remoteInstallDirString + "\\" + unpackScriptName;
        unpackScript.copyFrom(makeScriptString(remoteInstallDirString, zipFileName));
        if (logger.isLoggable(Level.FINE))
            logger.fine("WROTE FILE TO REMOTE SYSTEM: " + fullZipFileName + " and " + fullUnpackScriptPath);
        unpackOnHosts(host, remotePassword, fullUnpackScriptPath.replace('/', '\\'));
    }
}
Also used : WindowsRemoteFile(com.sun.enterprise.util.cluster.windows.io.WindowsRemoteFile) WindowsRemoteFileSystem(com.sun.enterprise.util.cluster.windows.io.WindowsRemoteFileSystem) RemoteFileCopyProgress(com.sun.enterprise.util.cluster.windows.io.RemoteFileCopyProgress)

Aggregations

RemoteFileCopyProgress (com.sun.enterprise.util.cluster.windows.io.RemoteFileCopyProgress)1 WindowsRemoteFile (com.sun.enterprise.util.cluster.windows.io.WindowsRemoteFile)1 WindowsRemoteFileSystem (com.sun.enterprise.util.cluster.windows.io.WindowsRemoteFileSystem)1