Skip to content

Commit 60f68e3

Browse files
committed
srm: add default port numbers for 3rd party copy
SRM supports third-party copy of files, where the user tells the system to copy data from some third-party server. Currently, if the user doesn't specify the port number (e.g., http://www.example.org/path/to/data) then the system will attempt to use '-1' as the port number. This patch updates this behaviour so well-established default values are used if no port number is specified. FOR RELEASE NOTES: Mention that third-party copies no longer require the port number to be specified. If a port isn't specified in the URI then the well-established default value for that protocol is used. Target: trunk Require-notes: yes Require-book: no Patch: http://rb.dcache.org/r/5206/ Acked-by: Tigran Mkrtchyan
1 parent 4e56932 commit 60f68e3

File tree

1 file changed

+31
-2
lines changed
  • modules/dcache/src/main/java/diskCacheV111/srm/dcache

1 file changed

+31
-2
lines changed

modules/dcache/src/main/java/diskCacheV111/srm/dcache/Storage.java

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,6 +2024,33 @@ public void killRemoteTransfer(String transferId) {
20242024
}
20252025
}
20262026

2027+
private static int portFor(URI target) throws SRMException
2028+
{
2029+
if(target.getPort() != -1) {
2030+
return target.getPort();
2031+
}
2032+
2033+
String scheme = target.getScheme();
2034+
2035+
if(scheme == null) {
2036+
throw new SRMException("No scheme in URI " + target.toString());
2037+
}
2038+
2039+
// REVISIT consider taking default port numbers from /etc/services
2040+
2041+
switch(scheme.toLowerCase()) {
2042+
case "http":
2043+
return 80;
2044+
case "https":
2045+
return 443;
2046+
case "gsiftp":
2047+
return 2811;
2048+
default:
2049+
throw new SRMException("No default port number for " +
2050+
target.toString());
2051+
}
2052+
}
2053+
20272054
private String performRemoteTransfer(SRMUser user,
20282055
URI remoteTURL,
20292056
FsPath actualFilePath,
@@ -2045,6 +2072,8 @@ private String performRemoteTransfer(SRMUser user,
20452072

20462073
IpProtocolInfo protocolInfo;
20472074

2075+
int port = portFor(remoteTURL);
2076+
20482077
if (remoteTURL.getScheme().equals("gsiftp")) {
20492078
RequestCredential credential =
20502079
RequestCredential.getRequestCredential(remoteCredentialId);
@@ -2057,7 +2086,7 @@ private String performRemoteTransfer(SRMUser user,
20572086
RemoteGsiftpTransferProtocolInfo gsiftpProtocolInfo =
20582087
new RemoteGsiftpTransferProtocolInfo("RemoteGsiftpTransfer",
20592088
1, 1,
2060-
new InetSocketAddress(remoteTURL.getHost(), remoteTURL.getPort()),
2089+
new InetSocketAddress(remoteTURL.getHost(), port),
20612090
remoteTURL.toString(),
20622091
getCellName(),
20632092
getCellDomainName(),
@@ -2073,7 +2102,7 @@ private String performRemoteTransfer(SRMUser user,
20732102
protocolInfo =
20742103
new RemoteHttpDataTransferProtocolInfo("RemoteHttpDataTransfer",
20752104
1, 1,
2076-
new InetSocketAddress(remoteTURL.getHost(), remoteTURL.getPort()),
2105+
new InetSocketAddress(remoteTURL.getHost(), port),
20772106
config.getBuffer_size(),
20782107
remoteTURL.toString());
20792108
} else {

0 commit comments

Comments
 (0)