/** * @param atsAgent * @return whether the agent is located on the local host */ public static boolean isLocalAtsAgent( String atsAgent ) { if (!StringUtils.isNullOrEmpty(atsAgent)) { String[] tokens = HostUtils.splitAddressHostAndPort(atsAgent); if (tokens.length > 0) { return HostUtils.isLocalHost(tokens[0]); } } return true; }
@Override public void copyDirectory( String fromDirName, String toDirName, boolean isRecursive, boolean failOnError ) { try { int port = remoteFileSystemOperations.openFileTransferSocket(); localFileSystemOperations.sendDirectoryTo(fromDirName, toDirName, HostUtils.splitAddressHostAndPort(atsAgent)[0], port, isRecursive, failOnError); remoteFileSystemOperations.waitForFileTransferCompletion(port); } catch (Exception e) { String message = new StringBuilder().append("Unable to copy directory ") .append(fromDirName) .append(" to ") .append(toDirName) .append(" on host ") .append(this.atsAgent) .toString(); throw new FileSystemOperationException(message, e); } }
public void copyDirectoryTo( String fromDirName, String toMachine, String toDirName, boolean isRecursive, boolean failOnError ) { try { InternalFileSystemOperations toRemoteFSOperations = new InternalFileSystemOperations(toMachine); int port = toRemoteFSOperations.openFileTransferSocket(); remoteFileSystemOperations.sendDirectoryTo(fromDirName, toDirName, HostUtils.splitAddressHostAndPort(HostUtils.getAtsAgentIpAndPort(toMachine))[0], port, isRecursive, failOnError); toRemoteFSOperations.waitForFileTransferCompletion(port); } catch (Exception e) { String message = new StringBuilder().append("Unable to copy directory ") .append(fromDirName) .append(" from ") .append(this.atsAgent) .append(" to ") .append(toDirName) .append(" on ") .append(toMachine) .toString(); throw new FileSystemOperationException(message, e); } }
/** * Returns the ATS agent address which contains its IP and port. * If a port is not passed, we will append the default one. * * @param atsAgent the agent * @return */ public static String getAtsAgentIpAndPort( String atsAgent ) { if (atsAgent == null) { return null; } String[] tokens = splitAddressHostAndPort(atsAgent); if (tokens.length != 1 // port number detected || StringUtils.isNullOrEmpty(tokens[0])) { // null or empty IP, do not touch return atsAgent; } else { // IP/Hostname provided, but no PORT, so use the default one if (!atsAgent.startsWith("[") && tokens[0].split(":").length > 1) { // assume it is IPv6 return "[" + atsAgent + "]:" + AtsSystemProperties.getAgentDefaultPort(); } return atsAgent + ":" + AtsSystemProperties.getAgentDefaultPort(); } }
String[] atsAgentTokens = splitAddressHostAndPort(remoteAtsAgent); Socket socket = null; try {
HostUtils.splitAddressHostAndPort(atsAgent)[0], port, failOnError); remoteFileSystemOperations.waitForFileTransferCompletion(port);
public void copyFileTo( String fromFile, String toMachine, String toFile, boolean failOnError ) { try { Integer copyFileStartPort = getCopyFilePortProperty(ActionLibraryConfigurator.getInstance() .getCopyFileStartPort()); Integer copyFileEndPort = getCopyFilePortProperty(ActionLibraryConfigurator.getInstance() .getCopyFileEndPort()); InternalFileSystemOperations toRemoteFSOperations = new InternalFileSystemOperations(toMachine); if (copyFileStartPort != null && copyFileStartPort > 0 && copyFileEndPort != null && copyFileEndPort > 0) { toRemoteFSOperations.setCopyFilePortRange(copyFileStartPort, copyFileEndPort); } int port = toRemoteFSOperations.openFileTransferSocket(); this.remoteFileSystemOperations.sendFileTo(fromFile, toFile, HostUtils.splitAddressHostAndPort(HostUtils.getAtsAgentIpAndPort(toMachine) /* append port */ )[0], port, failOnError); toRemoteFSOperations.waitForFileTransferCompletion(port); } catch (Exception e) { String message = new StringBuilder().append("Unable to copy file ") .append(fromFile) .append(" from ") .append(this.atsAgent) .append(" to file ") .append(toFile) .append(" on ") .append(toMachine) .toString(); throw new FileSystemOperationException(message, e); } }
BaseType typePort = null; String[] tokens = HostUtils.splitAddressHostAndPort(this.validatedValue); if (tokens.length == 1 && requirePort) {