From 7e2a3ed7460ea45ddd7e4cd75e5f82236f1feb47 Mon Sep 17 00:00:00 2001
From: Andrea Ceccanti
Date: Tue, 14 Jan 2014 16:48:30 +0100
Subject: [PATCH 01/45] Fix for STOR-501
---
pom.xml | 2 +-
src/main/java/it/grid/storm/namespace/Namespace.java | 5 ++++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 8ec40ec4..7eb7dd23 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
StoRM Backend server
org.italiangrid.storm
storm-backend-server
- 1.11.3
+ 1.11.4-SNAPSHOT
diff --git a/src/main/java/it/grid/storm/namespace/Namespace.java b/src/main/java/it/grid/storm/namespace/Namespace.java
index 03347043..e9d147e0 100644
--- a/src/main/java/it/grid/storm/namespace/Namespace.java
+++ b/src/main/java/it/grid/storm/namespace/Namespace.java
@@ -227,8 +227,11 @@ private StoRI resolveStoRIbySURL(TSURL surl,
"Unable to perform getWinnerRule, invalid arguments");
}
String stfnStr = surl.sfn().stfn().toString();
- MappingRule winnerRule = getWinnerRule(NamespaceUtil.getStFNPath(stfnStr),
+
+ // Fix for STOR-501
+ MappingRule winnerRule = getWinnerRule(stfnStr,
vfsApproachable, withVFSList);
+
if (winnerRule == null) {
/* attempt using complete file path */
winnerRule = getWinnerRule(stfnStr, vfsApproachable, withVFSList);
From 35e0363b744e4155838249c118408858b6452716 Mon Sep 17 00:00:00 2001
From: Andrea Ceccanti
Date: Tue, 14 Jan 2014 16:49:31 +0100
Subject: [PATCH 02/45] 1.11.4 version
---
pom.xml | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/pom.xml b/pom.xml
index 7eb7dd23..2e731901 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
StoRM Backend server
org.italiangrid.storm
storm-backend-server
- 1.11.4-SNAPSHOT
+ 1.11.4
@@ -66,7 +66,7 @@
maven-surefire-plugin
2.13
-
true
@@ -93,12 +93,12 @@
-
-
+
org.apache.maven.plugins
maven-dependency-plugin
@@ -116,7 +116,7 @@
-
+
org.codehaus.mojo
wagon-maven-plugin
@@ -132,7 +132,7 @@
${remoteDeployment.url}/
${remoteDeployment.serverId}
etc
-
logging.xml, namespace.xml, path-authz.db,
@@ -180,7 +180,7 @@
/etc/logrotate.d
-
+
upload-deps
deploy
@@ -195,7 +195,7 @@
/usr/share/java/storm-backend-server
-
+
upload-jar
deploy
@@ -210,10 +210,10 @@
/usr/share/java/storm-backend-server
-
+
-
+
@@ -351,10 +351,10 @@
${jsonVersion}
-
org.globus
@@ -402,7 +402,7 @@
${cogGlobusVersion}
-
srm22client
@@ -473,7 +473,7 @@
runtime
-
org.apache.oro
From 02dde9602fde4576bf70d9f2ab1ffda1a84fba19 Mon Sep 17 00:00:00 2001
From: enricovianello
Date: Wed, 15 Jan 2014 16:59:02 +0100
Subject: [PATCH 03/45] little adjustments to Namespace.java
---
.../it/grid/storm/namespace/Namespace.java | 119 +++++++-----------
1 file changed, 47 insertions(+), 72 deletions(-)
diff --git a/src/main/java/it/grid/storm/namespace/Namespace.java b/src/main/java/it/grid/storm/namespace/Namespace.java
index e9d147e0..961a4f32 100644
--- a/src/main/java/it/grid/storm/namespace/Namespace.java
+++ b/src/main/java/it/grid/storm/namespace/Namespace.java
@@ -96,8 +96,7 @@ public String getNamespaceVersion() throws NamespaceException {
return parser.getNamespaceVersion();
}
- public Collection getAllDefinedVFS()
- throws NamespaceException {
+ public Collection getAllDefinedVFS() {
return parser.getVFSs().values();
}
@@ -161,12 +160,15 @@ public StoRI resolveStoRIbySURL(TSURL surl, GridUserInterface user)
log.error("Received null parameters: surl= " + surl + " user=" + user);
throw new IllegalArgumentException("Received null parameters");
}
+
List vfsApproachable = getApproachableVFS(user);
-
- StoRI stori = resolveStoRIbySURL(surl, vfsApproachable);
- if (stori == null)
+ StoRI stori = resolveStoRIbySURL(surl);
+
+ if (stori == null
+ || !vfsApproachable.contains(stori.getVirtualFileSystem())) {
throw new UnapprochableSurlException("Surl " + surl
+ " is not approchable by user " + user);
+ }
return stori;
}
@@ -183,31 +185,17 @@ public StoRI resolveStoRIbySURL(TSURL surl, GridUserInterface user)
* @return StoRI
* @throws NamespaceException
*/
- private StoRI resolveStoRIbySURL(TSURL surl,
- List vfsApproachable) throws UnapprochableSurlException {
-
- log.debug("Resolving StoRI from surl " + surl + " on " + vfsApproachable
- + " VFS");
- return resolveStoRIbySURL(surl, vfsApproachable, true);
- }
-
- /**
- *
- * The resolution is based on the retrieving of the Winner Rule 1) First
- * attempt is based on StFN-Path 2) Second attempt is based on all StFN. That
- * because is possible that SURL is expressed without File Name so StFN is a
- * directory. ( Special case is when the SFN does not contain the File Name
- * and ALL the StFN is considerable as StFN-Path. )
- *
- * @param surl
- * TSURL
- * @return StoRI
- * @throws NamespaceException
- */
- public StoRI resolveStoRIbySURL(TSURL surl) throws UnapprochableSurlException {
+ public StoRI resolveStoRIbySURL(TSURL surl) throws IllegalArgumentException,
+ UnapprochableSurlException {
+
+ if (surl == null) {
+ log.error("Unable to perform resolveStoRIbySURL, invalid arguments: surl=" + surl);
+ throw new IllegalArgumentException("Unable to perform getWinnerRule, invalid arguments");
+ }
log.debug("Resolving StoRI from surl " + surl + " on any VFS");
- StoRI stori = resolveStoRIbySURL(surl, null, false);
+ StoRI stori = resolveStoRIbySURL(surl,
+ new ArrayList(getAllDefinedVFS()));
if (stori == null) {
throw new UnapprochableSurlException("Surl " + surl
+ " is not managed by this StoRM instance");
@@ -216,51 +204,35 @@ public StoRI resolveStoRIbySURL(TSURL surl) throws UnapprochableSurlException {
}
private StoRI resolveStoRIbySURL(TSURL surl,
- List vfsApproachable, boolean withVFSList) {
+ List vfsApproachable) throws UnapprochableSurlException {
- if (surl == null || withVFSList && vfsApproachable == null) {
- log
- .error("Unable to perform resolveStoRIbySURL, invalid arguments: surl="
- + surl + " withVFSList=" + withVFSList + " vfsApproachable="
- + vfsApproachable);
- throw new IllegalArgumentException(
- "Unable to perform getWinnerRule, invalid arguments");
- }
String stfnStr = surl.sfn().stfn().toString();
-
- // Fix for STOR-501
- MappingRule winnerRule = getWinnerRule(stfnStr,
- vfsApproachable, withVFSList);
-
+ MappingRule winnerRule = getWinnerRule(stfnStr, vfsApproachable);
if (winnerRule == null) {
- /* attempt using complete file path */
- winnerRule = getWinnerRule(stfnStr, vfsApproachable, withVFSList);
+ log.debug("Unable to perform resolveStoRIbySURL, no MappingRule matches SURL " + surl);
+ return null;
}
StoRI stori = null;
- if (winnerRule != null) {
- log.debug("For StFN " + stfnStr + " the winner Rule is "
- + winnerRule.getRuleName());
- stori = winnerRule.getMappedFS().createFile(
- NamespaceUtil.extractRelativePath(winnerRule.getStFNRoot(),
- stfnStr), StoRIType.FILE);
- stori.setStFNRoot(winnerRule.getStFNRoot());
- stori.setMappingRule(winnerRule);
- try {
- if (!stori.getLocalFile().getCanonicalPath().startsWith(winnerRule.getMappedFS().getRootPath())) {
- log.debug("Unable to perform resolveStoRIbySURL, '"
- + stori.getLocalFile().getCanonicalPath() + "' doesn't belong to '"
- + winnerRule.getMappedFS().getAliasName() + "'");
- return null;
- } else {
- log.debug("'" + stori.getLocalFile().getCanonicalPath() + "' belongs to '"
- + winnerRule.getMappedFS().getAliasName() + "'");
- }
- } catch (IOException e) {
- log.debug("Unable to perform resolveStoRIbySURL, " + e.getMessage());
+ log.debug("For StFN " + stfnStr + " the winner Rule is "
+ + winnerRule.getRuleName());
+ stori = winnerRule.getMappedFS().createFile(
+ NamespaceUtil.extractRelativePath(winnerRule.getStFNRoot(), stfnStr),
+ StoRIType.FILE);
+ stori.setStFNRoot(winnerRule.getStFNRoot());
+ stori.setMappingRule(winnerRule);
+ try {
+ if (!stori.getLocalFile().getCanonicalPath()
+ .startsWith(winnerRule.getMappedFS().getRootPath())) {
+ log.debug("Unable to perform resolveStoRIbySURL, '"
+ + stori.getLocalFile().getCanonicalPath() + "' doesn't belong to '"
+ + winnerRule.getMappedFS().getAliasName() + "'");
return null;
+ } else {
+ log.debug("'" + stori.getLocalFile().getCanonicalPath()
+ + "' belongs to '" + winnerRule.getMappedFS().getAliasName() + "'");
}
- } else {
- log.debug("Unable to perform resolveStoRIbySURL, no MappingRule matches SURL " + surl);
+ } catch (IOException e) {
+ log.debug("Unable to perform resolveStoRIbySURL, " + e.getMessage());
return null;
}
return stori;
@@ -280,12 +252,15 @@ public VirtualFSInterface resolveVFSbySURL(TSURL surl, GridUserInterface user)
private VirtualFSInterface resolveVFSbySURL(TSURL surl,
List vfsApproachable) {
-
- MappingRule winnerRule = getWinnerRule(
- NamespaceUtil.getStFNPath(surl.sfn().stfn().toString()), vfsApproachable);
- log.debug("For surl " + surl + " the winner Rule is "
- + winnerRule.getRuleName());
- return parser.getVFS(winnerRule.getMappedFS().getAliasName());
+
+ String stfnStr = surl.sfn().stfn().toString();
+ MappingRule winnerRule = getWinnerRule(stfnStr, vfsApproachable);
+ if (winnerRule == null) {
+ log.debug("Unable to perform resolveStoRIbySURL, no MappingRule matches SURL " + surl);
+ return null;
+ }
+ log.debug("For surl " + surl + " the winner Rule is " + winnerRule.getRuleName());
+ return winnerRule.getMappedFS();
}
public StoRI resolveStoRIbyAbsolutePath(String absolutePath,
From a81d3de3ac31300b2030e98eb437ce587212282a Mon Sep 17 00:00:00 2001
From: Andrea Ceccanti
Date: Wed, 15 Jan 2014 19:07:03 +0100
Subject: [PATCH 04/45] Fix for STOR-505
Now the StFN are correctly computed from the
winning mapping rule for a given ls request.
---
.../it/grid/storm/namespace/Namespace.java | 72 +++++++++++--------
.../java/it/grid/storm/namespace/StoRI.java | 2 +
.../it/grid/storm/namespace/StoRIImpl.java | 69 ++++++++++--------
.../command/directory/LsCommand.java | 8 +--
4 files changed, 88 insertions(+), 63 deletions(-)
diff --git a/src/main/java/it/grid/storm/namespace/Namespace.java b/src/main/java/it/grid/storm/namespace/Namespace.java
index e9d147e0..6a8cfbe9 100644
--- a/src/main/java/it/grid/storm/namespace/Namespace.java
+++ b/src/main/java/it/grid/storm/namespace/Namespace.java
@@ -226,44 +226,54 @@ private StoRI resolveStoRIbySURL(TSURL surl,
throw new IllegalArgumentException(
"Unable to perform getWinnerRule, invalid arguments");
}
+
String stfnStr = surl.sfn().stfn().toString();
- // Fix for STOR-501
MappingRule winnerRule = getWinnerRule(stfnStr,
vfsApproachable, withVFSList);
- if (winnerRule == null) {
- /* attempt using complete file path */
- winnerRule = getWinnerRule(stfnStr, vfsApproachable, withVFSList);
- }
- StoRI stori = null;
- if (winnerRule != null) {
- log.debug("For StFN " + stfnStr + " the winner Rule is "
- + winnerRule.getRuleName());
- stori = winnerRule.getMappedFS().createFile(
- NamespaceUtil.extractRelativePath(winnerRule.getStFNRoot(),
- stfnStr), StoRIType.FILE);
- stori.setStFNRoot(winnerRule.getStFNRoot());
- stori.setMappingRule(winnerRule);
- try {
- if (!stori.getLocalFile().getCanonicalPath().startsWith(winnerRule.getMappedFS().getRootPath())) {
- log.debug("Unable to perform resolveStoRIbySURL, '"
- + stori.getLocalFile().getCanonicalPath() + "' doesn't belong to '"
- + winnerRule.getMappedFS().getAliasName() + "'");
- return null;
- } else {
- log.debug("'" + stori.getLocalFile().getCanonicalPath() + "' belongs to '"
- + winnerRule.getMappedFS().getAliasName() + "'");
- }
- } catch (IOException e) {
- log.debug("Unable to perform resolveStoRIbySURL, " + e.getMessage());
- return null;
- }
- } else {
- log.debug("Unable to perform resolveStoRIbySURL, no MappingRule matches SURL " + surl);
+ if (winnerRule == null){
+ log.debug("Unable to perform resolveStoRIbySURL, " +
+ "no MappingRule matches SURL " + surl);
return null;
}
- return stori;
+
+ log.debug("For StFN " + stfnStr + " the winner Rule is "
+ + winnerRule.getRuleName());
+
+ StoRI stori = winnerRule.getMappedFS().createFile(
+ NamespaceUtil.extractRelativePath(winnerRule.getStFNRoot(),
+ stfnStr), StoRIType.FILE);
+
+ stori.setStFNRoot(winnerRule.getStFNRoot());
+ stori.setMappingRule(winnerRule);
+
+ try {
+
+ if (stori
+ .getLocalFile()
+ .getCanonicalPath()
+ .startsWith(winnerRule.getMappedFS().getRootPath())){
+
+ log.debug("'" + stori.getLocalFile().getCanonicalPath() + "' belongs to '"
+ + winnerRule.getMappedFS().getAliasName() + "'");
+ return stori;
+
+ } else {
+
+ log.debug("Unable to perform resolveStoRIbySURL, '"
+ + stori.getLocalFile().getCanonicalPath() + "' doesn't belong to '"
+ + winnerRule.getMappedFS().getAliasName() + "'");
+ return null;
+ }
+ } catch (IOException e) {
+
+ log.error("Error resolving stori for surl {}: {}.",
+ surl, e.getMessage(), e);
+
+ return null;
+ }
+
}
public VirtualFSInterface resolveVFSbySURL(TSURL surl, GridUserInterface user)
diff --git a/src/main/java/it/grid/storm/namespace/StoRI.java b/src/main/java/it/grid/storm/namespace/StoRI.java
index 685c8b50..6d06c961 100644
--- a/src/main/java/it/grid/storm/namespace/StoRI.java
+++ b/src/main/java/it/grid/storm/namespace/StoRI.java
@@ -60,6 +60,8 @@ public TTURL getTURL(TURLPrefix prefixOfAcceptedTransferProtocols)
public PFN getPFN();
public StFN getStFN();
+
+ public StFN getStFNFromMappingRule();
public String getRelativePath();
diff --git a/src/main/java/it/grid/storm/namespace/StoRIImpl.java b/src/main/java/it/grid/storm/namespace/StoRIImpl.java
index 5aac23db..9c3b50c5 100644
--- a/src/main/java/it/grid/storm/namespace/StoRIImpl.java
+++ b/src/main/java/it/grid/storm/namespace/StoRIImpl.java
@@ -22,6 +22,7 @@
import it.grid.storm.balancer.Node;
import it.grid.storm.catalogs.VolatileAndJiTCatalog;
import it.grid.storm.common.types.InvalidPFNAttributeException;
+import it.grid.storm.common.types.InvalidStFNAttributeException;
import it.grid.storm.common.types.PFN;
import it.grid.storm.common.types.StFN;
import it.grid.storm.common.types.TURLPrefix;
@@ -362,7 +363,11 @@ public ArrayList getChildren(TDirOption dirOption)
log.debug(":Creation of new StoRI with path : "
+ childPath);
try {
- stoRIList.add(namespace.resolveStoRIbyAbsolutePath(childPath));
+
+ StoRI childStorI = namespace.resolveStoRIbyAbsolutePath(childPath);
+ childStorI.setMappingRule(getMappingRule());
+
+ stoRIList.add(childStorI);
} catch (NamespaceException ex) {
log.error("Error occurred while resolving StoRI by absolute path",
ex);
@@ -566,7 +571,7 @@ public TTURL getTURL(TURLPrefix desiredProtocols)
transProt = protList.get(0);
authority = transProt.getAuthority();
}
- // TODO HTTPS TURL
+
resultTURL = buildTURL(choosen, authority);
turlBuilt = true;
}
@@ -659,14 +664,11 @@ public void setStoRIType(StoRIType type) {
this.type = type;
}
- /***********************************************
- * UTILITY METHODS
- **********************************************/
-
@Override
public String toString() {
StringBuffer sb = new StringBuffer();
+
sb.append("\n");
sb.append(" stori.stfn : " + this.getStFN().toString() + "\n");
sb.append(" stori.vfs-root :" + this.vfsRoot + "\n");
@@ -680,6 +682,7 @@ public String toString() {
sb.append(" story.type : " + this.type + "\n");
sb.append(" stori.SURL : " + this.getSURL() + "\n");
sb.append(" stori.localFile : " + this.getLocalFile() + "\n");
+ sb.append(" stori.mappingRule : " + this.getMappingRule() + "\n");
return sb.toString();
}
@@ -691,29 +694,11 @@ private String buildSURLString() throws NamespaceException {
return surl.toString();
}
- // TODO MICHELE HTTPS here we can add a case to build https TURL...what really
- // matter is that probably because it is an URL we cannot build it
- // just using the infomation available actually from the parameters
- // I can make an hypothesis on web server url construction, maybe it is
- // https://server_name.server_domain:web_server_https_port/file_server_service_identifier/file_relative_url
- // in such a case we need: web_server_https_port -> can be retrieved from
- // Protocol object : we can associate a default port to protocol the effective
- // value
- // has to be demanded to the connector
- // file_server_service_identifier -> also from Protocol object ... not so
- // true... hummm : it has to be demanded to the connector
- // file_relative_url -> here start real problems... : we have to hope that
- // from the physicalFN we are able to build this value
- // - it has to be demanded to the connector
- // TODO HTTPS TURL
- // private TTURL buildTURL(Protocol protocol, Authority authority, PFN
- // physicalFN) throws InvalidProtocolForTURLException {
private TTURL buildTURL(Protocol protocol, Authority authority)
throws InvalidProtocolForTURLException {
TTURL result = null;
- // TODO MICHELE HTTPS NOTE: this is the only access point to TURLBuilder
- // class (good sign)
+
switch (protocol.getProtocolIndex()) {
case 0: // EMPTY Protocol
throw new InvalidProtocolForTURLException(protocol.getSchema());
@@ -731,7 +716,6 @@ private TTURL buildTURL(Protocol protocol, Authority authority)
case 5:
result = TURLBuilder.buildROOTTURL(authority, this.getPFN());
break; // ROOT Protocol
- // TODO HTTPS TURL
case 6:
try {
result = TURLBuilder.buildHTTPTURL(authority, this.getLocalFile());
@@ -756,8 +740,9 @@ private TTURL buildTURL(Protocol protocol, Authority authority)
break; // HTTPS Protocol
default:
- throw new InvalidProtocolForTURLException(protocol.getSchema()); // UNKNOWN
- // Protocol
+ // Unknown protocol
+ throw new InvalidProtocolForTURLException(protocol.getSchema());
+
}
return result;
}
@@ -813,4 +798,32 @@ private void setVolatileInformation() {
volatileInformationAreSet = true;
}
+ @Override
+ public StFN getStFNFromMappingRule() {
+ try {
+
+ if (getMappingRule() == null){
+ log.warn("Mapping rule is null for this StorI. " +
+ "Falling back to VFS StFN.");
+ return getStFN();
+ }
+
+ String mappingRuleRoot = getMappingRule().getStFNRoot();
+ String mappedStfn = mappingRuleRoot + NamingConst.SEPARATOR
+ + relativeStFN;
+
+ return StFN.make(mappedStfn);
+
+ } catch (InvalidStFNAttributeException e) {
+
+ log.error("Error building StFN from mapping rule. Reason: {}",
+ e.getMessage(),e);
+
+ log.error("Falling back to VFS StFN.");
+
+ return getStFN();
+
+ }
+ }
+
}
diff --git a/src/main/java/it/grid/storm/synchcall/command/directory/LsCommand.java b/src/main/java/it/grid/storm/synchcall/command/directory/LsCommand.java
index 2ae7b4fa..d81342b1 100644
--- a/src/main/java/it/grid/storm/synchcall/command/directory/LsCommand.java
+++ b/src/main/java/it/grid/storm/synchcall/command/directory/LsCommand.java
@@ -343,7 +343,7 @@ public OutputData execute(InputData data) {
elementDetail.setStatus(status);
elementDetail.setSurl(surl);
if (stori != null) {
- elementDetail.setStFN(stori.getStFN());
+ elementDetail.setStFN(stori.getStFNFromMappingRule());
} else {
elementDetail.setStFN(surl.sfn().stfn());
}
@@ -505,7 +505,7 @@ private int manageAuthorizedLS(LSInputData inputData, StoRI stori,
}
}
// In Any case set SURL value into TMetaDataPathDetail
- currentElementDetail.setStFN(stori.getStFN());
+ currentElementDetail.setStFN(stori.getStFNFromMappingRule());
numberOfResults.increment();
rootArray.addTMetaDataPathDetail(currentElementDetail);
@@ -565,7 +565,7 @@ private int manageAuthorizedLS(LSInputData inputData, StoRI stori,
}
// In Any case set SURL value into TMetaDataPathDetail
- currentElementDetail.setStFN(stori.getStFN());
+ currentElementDetail.setStFN(stori.getStFNFromMappingRule());
numberOfResults.increment();
rootArray.addTMetaDataPathDetail(currentElementDetail);
}
@@ -577,7 +577,7 @@ private int manageAuthorizedLS(LSInputData inputData, StoRI stori,
if (numberOfIterations.intValue() >= offset) {
errorCount++;
// In Any case set SURL value into TMetaDataPathDetail
- currentElementDetail.setStFN(stori.getStFN());
+ currentElementDetail.setStFN(stori.getStFNFromMappingRule());
// Set Error Status Code and Explanation
populateDetailFromFS(stori, currentElementDetail);
// Add the information into details structure
From 50090e8b1265d25e3394af365302c84c0326de88 Mon Sep 17 00:00:00 2001
From: enricovianello
Date: Fri, 17 Jan 2014 10:54:44 +0100
Subject: [PATCH 05/45] Explanation string is truncated if too long
---
.../grid/storm/srm/types/TReturnStatus.java | 25 ++++++++++++++++---
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/src/main/java/it/grid/storm/srm/types/TReturnStatus.java b/src/main/java/it/grid/storm/srm/types/TReturnStatus.java
index 01915f9b..5e9529ce 100644
--- a/src/main/java/it/grid/storm/srm/types/TReturnStatus.java
+++ b/src/main/java/it/grid/storm/srm/types/TReturnStatus.java
@@ -31,15 +31,23 @@
import java.util.HashMap;
import java.util.Map;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
public class TReturnStatus implements Serializable {
private static final long serialVersionUID = -4550845540710062810L;
+ private static final Logger log = LoggerFactory
+ .getLogger(TReturnStatus.class);
+
protected TStatusCode statusCode = null;
protected String explanation = null;
private Long lastUpdateTIme = null;
private static final String UNDEFINED_EXPLANATION = "undefined";
+ private static final String EMPTY_EXPLANATION = "";
+ private static final int MAX_EXPLANATION_LENGTH = 255;
public static final String PNAME_RETURNSTATUS = "returnStatus";
public static final String PNAME_STATUS = "status";
@@ -62,7 +70,7 @@ public TReturnStatus(TReturnStatus original)
throw new InvalidTReturnStatusAttributeException(statusCode);
}
this.statusCode = original.statusCode;
- this.explanation = original.explanation;
+ this.setExplanation(original.getExplanation());
updated();
}
@@ -82,7 +90,7 @@ public TReturnStatus(TStatusCode statusCode, String explanation)
throw new InvalidTReturnStatusAttributeException(statusCode);
}
this.statusCode = statusCode;
- this.explanation = explanation;
+ this.setExplanation(explanation);
updated();
}
@@ -143,7 +151,16 @@ protected void setStatusCode(TStatusCode statusCode) {
*/
protected void setExplanation(String explanationString) {
- explanation = (explanationString == null ? "" : explanationString);
+ if (explanationString == null) {
+ this.explanation = EMPTY_EXPLANATION;
+ } else if (explanationString.length() <= MAX_EXPLANATION_LENGTH) {
+ this.explanation = explanationString;
+ } else {
+ this.explanation = explanationString.substring(0, MAX_EXPLANATION_LENGTH);
+ log.warn(String.format(
+ "Explanation string truncated at %d characters: '%s'",
+ MAX_EXPLANATION_LENGTH, this.explanation));
+ }
updated();
}
@@ -201,7 +218,7 @@ public boolean isSRM_SUCCESS() {
public void extendExplaination(String string) {
- this.explanation += " [ " + string + " ]";
+ this.setExplanation(this.getExplanation() + " [ " + string + " ]");
}
/*
From 2cbbfd7893c916e9f8a8e69beabc46a62a8ab665 Mon Sep 17 00:00:00 2001
From: enricovianello
Date: Fri, 17 Jan 2014 18:13:40 +0100
Subject: [PATCH 06/45] Fixed sym link management
---
.../it/grid/storm/namespace/Namespace.java | 37 +++++++++++--------
1 file changed, 22 insertions(+), 15 deletions(-)
diff --git a/src/main/java/it/grid/storm/namespace/Namespace.java b/src/main/java/it/grid/storm/namespace/Namespace.java
index 0500334a..8267e861 100644
--- a/src/main/java/it/grid/storm/namespace/Namespace.java
+++ b/src/main/java/it/grid/storm/namespace/Namespace.java
@@ -205,14 +205,6 @@ private StoRI resolveStoRIbySURL(TSURL surl,
MappingRule winnerRule = getWinnerRule(surl);
log.debug(String.format("For SURL %s the winner Rule is %s", surl,
winnerRule.getRuleName()));
-
- if (!vfsApproachable.contains(winnerRule.getMappedFS())) {
- String msg = String.format(
- "VFS '%s' is not on the approachable VFS list!", winnerRule
- .getMappedFS().getAliasName());
- log.debug(msg);
- throw new UnapprochableSurlException(msg);
- }
StoRI stori = winnerRule.getMappedFS().createFile(
NamespaceUtil.extractRelativePath(winnerRule.getStFNRoot(), surl.sfn()
@@ -231,18 +223,33 @@ private StoRI resolveStoRIbySURL(TSURL surl,
}
if (realPath.startsWith(winnerRule.getMappedFS().getRootPath())) {
- log.debug(String.format("Resource '%s' belongs to '%s'", realPath,
- winnerRule.getMappedFS().getAliasName()));
- return stori;
+ if (vfsApproachable.contains(winnerRule.getMappedFS())) {
+ log.debug(String.format("Resource '%s' belongs to '%s'", realPath,
+ winnerRule.getMappedFS().getAliasName()));
+ return stori;
+ }
+ String msg = String.format(
+ "VFS '%s' is not on the approachable VFS list!", winnerRule
+ .getMappedFS().getAliasName());
+ log.debug(msg);
+ throw new UnapprochableSurlException(msg);
}
-
+
String msg = String.format("Resource '%s' doesn't belong to %s", realPath,
winnerRule.getMappedFS().getAliasName());
log.debug(msg);
VirtualFSInterface redirectedVFS = getWinnerVFS(realPath);
- log.debug(String.format("Surl %s is a symbolic link to %s", surl, redirectedVFS.getAliasName()));
- if (vfsApproachable.contains(winnerRule.getMappedFS())) {
- log.debug(String.format("%s is approachable", redirectedVFS.getAliasName()));
+ log.debug(String.format("Surl %s is a symbolic link to %s", surl,
+ redirectedVFS.getAliasName()));
+ if (vfsApproachable.contains(redirectedVFS)) {
+ log.debug(String.format("%s is approachable",
+ redirectedVFS.getAliasName()));
+ MappingRule rule = redirectedVFS.getMappingRules().get(0);
+ stori = redirectedVFS.createFile(NamespaceUtil.extractRelativePath(
+ redirectedVFS.getRootPath(), realPath), StoRIType.FILE);
+
+ stori.setStFNRoot(rule.getStFNRoot());
+ stori.setMappingRule(rule);
return stori;
}
throw new UnapprochableSurlException(String.format(
From 5df1971b7455f62dcd8171778997b65d590c3b91 Mon Sep 17 00:00:00 2001
From: Andrea Ceccanti
Date: Wed, 22 Jan 2014 14:05:03 +0100
Subject: [PATCH 07/45] Improved error reporting for SpaceHelper.
---
.gitignore | 1 +
.../java/it/grid/storm/space/SpaceHelper.java | 217 +++++++++---------
2 files changed, 114 insertions(+), 104 deletions(-)
diff --git a/.gitignore b/.gitignore
index 4c28d9d8..306f8b0d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,4 @@
.checkstyle
target
src/main/java/rebel*.xml
+/bin
diff --git a/src/main/java/it/grid/storm/space/SpaceHelper.java b/src/main/java/it/grid/storm/space/SpaceHelper.java
index 8a6ba2a7..fa43188f 100644
--- a/src/main/java/it/grid/storm/space/SpaceHelper.java
+++ b/src/main/java/it/grid/storm/space/SpaceHelper.java
@@ -66,8 +66,8 @@
public class SpaceHelper {
- private static final int ADD = 0;
- private static final int REMOVE = 1;
+ private static final int ADD_FREE_SPACE = 0;
+ private static final int REMOVE_FREE_SPACE = 1;
private Configuration config;
private static final Logger log = LoggerFactory.getLogger(SpaceHelper.class);
public static GridUserInterface storageAreaOwner = GridUserManager
@@ -77,119 +77,128 @@ public SpaceHelper() {
config = Configuration.getInstance();
}
+
- /**
- * @param log
- * @param funcName
- * @param user
- * @param surl
- */
private void updateSpaceUsageForSA(Logger log, String funcName,
GridUserInterface user, TSURL surl, int operation, long filesize) {
- log.debug(funcName + " Updating Storage Area free size on db");
+ log.debug("{}: Updating Storage Area free size on db", funcName);
+
ReservedSpaceCatalog catalog = new ReservedSpaceCatalog();
StoRI stori = null;
- // Retrieve the StoRI associate to the SURL
- if (user == null) {
- // implicit put done by TimerTask
- try {
- stori = NamespaceDirector.getNamespace().resolveStoRIbySURL(surl);
- } catch (UnapprochableSurlException e) {
- log.warn("Unable to build a stori for requested surl " + surl
- + " UnapprochableSurlException: " + e.getMessage());
- return;
- }
- } else {
- try {
- stori = NamespaceDirector.getNamespace().resolveStoRIbySURL(surl, user);
- } catch (IllegalArgumentException e) {
- log.error(
- funcName + " Unable to build StoRI by SURL and user: " + surl, e);
- return;
- } catch (UnapprochableSurlException e) {
- log.warn("Unable to build a stori for surl " + surl + " for user "
- + user + " UnapprochableSurlException: " + e.getMessage());
- return;
+
+ try {
+ // FIXME: should be fixed in NamespaceDirector to avoid having
+ // two distinct calls if user is null or not.
+ // The resolveStoRIBySURL(surl, user) should handle this.
+ if (user == null){
+
+ stori = NamespaceDirector.getNamespace().resolveStoRIbySURL(surl);
+
+ } else {
+
+ stori = NamespaceDirector
+ .getNamespace()
+ .resolveStoRIbySURL(surl, user);
}
- }
- // Get Virtual FileSystem for DB information
- VirtualFSInterface fs = stori.getVirtualFileSystem();
-
- // Get StorageSpaceData from the database
- StorageSpaceData spaceData = null;
-
- spaceData = catalog.getStorageSpaceByAlias(fs.getSpaceTokenDescription());
+
+ } catch(UnapprochableSurlException e){
+
+ log.warn("Unable to build stori for surl {} and user {}: {}",
+ new Object[]{surl,user,e.getMessage()},e);
+ return;
+
+ } catch( IllegalArgumentException e) {
+
+ log.error(e.getMessage(),e);
+ return;
+ }
- // Get the localELement to know the real file size, if exists
+ VirtualFSInterface fs = stori.getVirtualFileSystem();
+ StorageSpaceData spaceData = catalog.getStorageSpaceByAlias(fs.getSpaceTokenDescription());
LocalFile localElement = stori.getLocalFile();
-
- if (spaceData != null
- && (localElement.exists() || operation == SpaceHelper.ADD)) {
-
- // IF PutDone, calculate the real fileSize
- if (operation == SpaceHelper.REMOVE) {
- // increase used size by localElement size
- filesize = localElement.getExactSize();
- // else in case of RM the filesize is passed from the client
- }
-
- TSizeInBytes availableSize = spaceData.getAvailableSpaceSize();
- long usedSize = -1;
- if (operation == SpaceHelper.REMOVE) {
- // remainingSize = availableSize.value() - filesize;
- usedSize = spaceData.getUsedSpaceSize().value() + filesize;
- } else if (operation == SpaceHelper.ADD) {
- // The new remaining size cannot be greater than the total size
- long newAvailableSize = availableSize.value() + filesize;
- // Use Storage Area Total Size as upper limit for the new Unused Size
- long totalSize = spaceData.getTotalSpaceSize().value();
- newAvailableSize = (newAvailableSize > totalSize) ? totalSize
- : newAvailableSize;
- long reservedSize = spaceData.getReservedSpaceSize().isEmpty() ? 0
- : spaceData.getReservedSpaceSize().value();
- long unavailableSize = spaceData.getUnavailableSpaceSize().isEmpty() ? 0
- : spaceData.getUnavailableSpaceSize().value();
- usedSize = totalSize - newAvailableSize - reservedSize
- - unavailableSize;
- }
-
- // Prevent negative value
- if (usedSize < 0) {
- usedSize = 0;
- }
-
- // Update the unused space size with new value
- TSizeInBytes newUsedSize = spaceData.getTotalSpaceSize();
- try {
- newUsedSize = TSizeInBytes.make(usedSize, SizeUnit.BYTES);
- } catch (InvalidTSizeAttributesException ex) {
- // never thrown
- log
- .error(
- funcName
- + " Unexpected InvalidTSizeAttributesException , Unable to create new used size, so the previous one is used",
- ex);
- }
-
- spaceData.setUsedSpaceSize(newUsedSize);
-
- try {
- fs.storeSpaceByToken(spaceData);
- } catch (NamespaceException e) {
- log.error(funcName + " Unable to update the new free size.", e);
+
+ if (spaceData == null){
+ log.error("{}: StorageSpace not found from space token description: {}",
+ funcName,
+ fs.getSpaceTokenDescription());
+ return;
+ }
+
+ TSizeInBytes availableSize = spaceData.getAvailableSpaceSize();
+ long usedSize = -1;
+
+ if (operation == SpaceHelper.ADD_FREE_SPACE){
+
+ log.debug("Adding {} bytes of free space to Storage Area {}",
+ filesize, fs.getAliasName());
+
+ long totalSize = spaceData.getTotalSpaceSize().value();
+ long newAvailableSize = availableSize.value() + filesize;
+
+ // The new remaining size cannot be greater than the total size
+ if (newAvailableSize > totalSize) {
+ newAvailableSize = totalSize;
}
+
+ long reservedSize = spaceData.getReservedSpaceSize().isEmpty() ? 0
+ : spaceData.getReservedSpaceSize().value();
+
+ long unavailableSize = spaceData.getUnavailableSpaceSize().isEmpty() ? 0
+ : spaceData.getUnavailableSpaceSize().value();
+
+ usedSize = totalSize - newAvailableSize - reservedSize
+ - unavailableSize;
+
+ } else if (operation == SpaceHelper.REMOVE_FREE_SPACE){
+
+ if (!localElement.exists()){
+ log.error("{}: Local file not found to compute space size change: {}",
+ funcName,
+ localElement);
+ return;
+ }
+
+ log.debug("Removing {} bytes of free space from Storage Area {}",
+ filesize, fs.getAliasName());
+
+ usedSize = spaceData.getUsedSpaceSize().value() + localElement.getSize();
+
+ }
+
+ // Prevent used size negative values.
+ if (usedSize < 0){
+ usedSize = 0;
+ }
+
+ TSizeInBytes oldUsedSize = null, newUsedSize = null;
+
+ // Update used size
+ try{
+
+ oldUsedSize = spaceData.getTotalSpaceSize();
+ newUsedSize = TSizeInBytes.make(usedSize, SizeUnit.BYTES);
+ spaceData.setUsedSpaceSize(newUsedSize);
+
+ }catch(InvalidTSizeAttributesException e){
+
+ log.error("Error creating new used size: {}.",e.getMessage(),e);
+ log.info("Falling back to old used size value: {}", oldUsedSize.value());
+ spaceData.setUsedSpaceSize(oldUsedSize);
+ }
+
+
+ try {
- log.debug(funcName + " Storage Area used size updated to: "
- + newUsedSize.value());
+ fs.storeSpaceByToken(spaceData);
- } else {
- // Nothing to do. Problem with DB?
- log.error(funcName + " Unable to update the DB used size!");
+ } catch (NamespaceException e) {
+ log.error("Error storing updated space data: {}. {}", spaceData, e.getMessage(), e);
return;
}
-
+
+ log.debug("{}: Starage Area used size updated to {}", spaceData.getUsedSpaceSize().value());
}
/**
@@ -217,7 +226,7 @@ public void consumeSpaceForSA(Logger log, String funcName,
.get(i);
TSURL surl = chunkData.toSURL();
- updateSpaceUsageForSA(log, funcName, user, surl, SpaceHelper.REMOVE, 0);
+ updateSpaceUsageForSA(log, funcName, user, surl, SpaceHelper.REMOVE_FREE_SPACE, 0);
}
@@ -232,7 +241,7 @@ public void consumeSpaceForSA(Logger log, String funcName,
public void decreaseFreeSpaceForSA(Logger log, String funcName,
GridUserInterface user, TSURL surl) {
- updateSpaceUsageForSA(log, funcName, user, surl, SpaceHelper.REMOVE, 0);
+ updateSpaceUsageForSA(log, funcName, user, surl, SpaceHelper.REMOVE_FREE_SPACE, 0);
}
@@ -249,13 +258,13 @@ public void decreaseFreeSpaceForSA(Logger log, String funcName,
public void increaseFreeSpaceForSA(Logger log, String funcName,
GridUserInterface user, TSURL surl, long fileSize) {
- updateSpaceUsageForSA(log, funcName, user, surl, SpaceHelper.ADD, fileSize);
+ updateSpaceUsageForSA(log, funcName, user, surl, SpaceHelper.ADD_FREE_SPACE, fileSize);
}
public void increaseFreeSpaceForSA(Logger log, String funcName, TSURL surl,
long fileSize) {
- updateSpaceUsageForSA(log, funcName, null, surl, SpaceHelper.ADD, fileSize);
+ updateSpaceUsageForSA(log, funcName, null, surl, SpaceHelper.ADD_FREE_SPACE, fileSize);
}
public boolean isSAFull(Logger log, StoRI stori) {
From 4b3b40733e8f62b42875e8bcbcfb62355a78d74e Mon Sep 17 00:00:00 2001
From: enricovianello
Date: Wed, 22 Jan 2014 16:54:54 +0100
Subject: [PATCH 08/45] Fixed StoRI resolving
---
.../it/grid/storm/namespace/Namespace.java | 213 ++++++++++--------
1 file changed, 115 insertions(+), 98 deletions(-)
diff --git a/src/main/java/it/grid/storm/namespace/Namespace.java b/src/main/java/it/grid/storm/namespace/Namespace.java
index 8267e861..673b7c85 100644
--- a/src/main/java/it/grid/storm/namespace/Namespace.java
+++ b/src/main/java/it/grid/storm/namespace/Namespace.java
@@ -152,7 +152,7 @@ public boolean isApproachable(StoRI storageResource,
GridUserInterface gridUser) throws NamespaceException {
return getApproachableVFS(gridUser).contains(storageResource.getVirtualFileSystem());
}
-
+
/**
*
* The resolution is based on the retrieving of the Winner Rule 1) First
@@ -170,92 +170,114 @@ public boolean isApproachable(StoRI storageResource,
public StoRI resolveStoRIbySURL(TSURL surl) throws IllegalArgumentException,
UnapprochableSurlException, NamespaceException, InvalidSURLException {
- if (surl == null) {
- String errorMsg = String.format("Received null parameter: surl=%s", surl);
- log.error(errorMsg);
- throw new IllegalArgumentException(errorMsg);
- }
-
- List allVFSs = new ArrayList(this.getAllDefinedVFS());
-
- return resolveStoRIbySURL(surl, allVFSs);
+ return resolveStoRI(surl, null);
}
-
+
public StoRI resolveStoRIbySURL(TSURL surl, GridUserInterface user)
- throws IllegalArgumentException, UnapprochableSurlException, NamespaceException, InvalidSURLException {
-
- if (surl == null || user == null) {
- log.error("Received null parameters: surl= " + surl + " user=" + user);
- throw new IllegalArgumentException("Received null parameters");
- }
-
- List vfsApproachable = getApproachableVFS(user);
- if (vfsApproachable.isEmpty()) {
- String errorMsg = String.format("Surl %s is not approachable by user %s", surl, user);
- log.debug(errorMsg);
- throw new UnapprochableSurlException(errorMsg);
- }
+ throws IllegalArgumentException, UnapprochableSurlException,
+ NamespaceException, InvalidSURLException {
- return resolveStoRIbySURL(surl, vfsApproachable);
+ return resolveStoRI(surl, user);
}
- private StoRI resolveStoRIbySURL(TSURL surl,
- List vfsApproachable) throws UnapprochableSurlException, InvalidSURLException, NamespaceException {
+ private StoRI resolveStoRI(TSURL surl, GridUserInterface user)
+ throws IllegalArgumentException, UnapprochableSurlException,
+ NamespaceException, InvalidSURLException {
- MappingRule winnerRule = getWinnerRule(surl);
- log.debug(String.format("For SURL %s the winner Rule is %s", surl,
- winnerRule.getRuleName()));
-
- StoRI stori = winnerRule.getMappedFS().createFile(
- NamespaceUtil.extractRelativePath(winnerRule.getStFNRoot(), surl.sfn()
- .stfn().toString()), StoRIType.FILE);
+ if (surl == null) {
+ log.error("resolveStoRIbySURL: invalid null surl");
+ throw new IllegalArgumentException(
+ "resolveStoRIbySURL: invalid null surl");
+ }
- stori.setStFNRoot(winnerRule.getStFNRoot());
- stori.setMappingRule(winnerRule);
+ List vfsApproachable = null;
+ if (user != null) {
+ // get the user approachable VFSs
+ vfsApproachable = getApproachableVFS(user);
+ if (vfsApproachable.isEmpty()) {
+ String errorMsg = String
+ .format("User %s can't approach any VFS!", user);
+ log.debug(errorMsg);
+ throw new UnapprochableSurlException(errorMsg);
+ }
+ } else {
+ // get all the approachable VFSs
+ vfsApproachable = new ArrayList(getAllDefinedVFS());
+ }
+ // get the winner rule for SURL
+ MappingRule winnerRule = getWinnerRule(surl, vfsApproachable);
+ if (winnerRule == null) {
+ if (user == null) {
+ // there's no VFS where the surl can be mapped
+ String msg = String.format("No mapping rule found for surl='%s'", surl);
+ log.debug(msg);
+ throw new InvalidSURLException(surl, msg);
+ }
+ // user's VFSs can't map the surl
+ String msg = String.format(
+ "No mapping rule found for surl='%s' and user ='%s'", surl, user);
+ log.debug(msg);
+ if (getWinnerRule(surl) == null) {
+ // invalid surl
+ throw new InvalidSURLException(surl, msg);
+ }
+ throw new UnapprochableSurlException(msg);
+ }
+ log.debug(String.format(
+ "For surl='%s' and vfsApproachable=[%s] the winner Rule is %s", surl,
+ vfsApproachable, winnerRule.getRuleName()));
+ // create StoRI
+ String stfnPath = surl.sfn().stfn().toString();
+ String relativePath = NamespaceUtil.extractRelativePath(
+ winnerRule.getStFNRoot(), stfnPath);
+ StoRI stori = winnerRule.getMappedFS().createFile(relativePath,
+ StoRIType.FILE);
+ stori.setStFNRoot(winnerRule.getStFNRoot());
+ stori.setMappingRule(winnerRule);
+ // check if StoRI real path is enclosed into the mapped VFS
String realPath = null;
try {
realPath = stori.getLocalFile().getCanonicalPath();
} catch (IOException e) {
- log.error("Error resolving stori for surl {}: {}.", surl, e.getMessage(),
- e);
+ log.error("Error on reading the canonical path: " + e.getMessage());
throw new NamespaceException(e.getMessage());
}
-
if (realPath.startsWith(winnerRule.getMappedFS().getRootPath())) {
- if (vfsApproachable.contains(winnerRule.getMappedFS())) {
- log.debug(String.format("Resource '%s' belongs to '%s'", realPath,
- winnerRule.getMappedFS().getAliasName()));
- return stori;
- }
- String msg = String.format(
- "VFS '%s' is not on the approachable VFS list!", winnerRule
- .getMappedFS().getAliasName());
- log.debug(msg);
- throw new UnapprochableSurlException(msg);
+ log.debug(String.format("Resource '%s' belongs to '%s'", realPath,
+ winnerRule.getMappedFS().getAliasName()));
+ return stori;
}
-
- String msg = String.format("Resource '%s' doesn't belong to %s", realPath,
- winnerRule.getMappedFS().getAliasName());
- log.debug(msg);
+ log.debug(String.format("Resource '%s' doesn't belong to %s", realPath,
+ winnerRule.getMappedFS().getAliasName()));
+ /* get the VFS where the resource is phisically located, if exists */
VirtualFSInterface redirectedVFS = getWinnerVFS(realPath);
- log.debug(String.format("Surl %s is a symbolic link to %s", surl,
+ if (redirectedVFS == null) {
+ log.debug(String.format("Unable to find a valid VFS from path '%s'",
+ realPath));
+ throw new InvalidSURLException(surl,
+ "The requested SURL is not managed by this instance of StoRM");
+ }
+ log.debug(String.format("%s belongs to %s", realPath,
redirectedVFS.getAliasName()));
- if (vfsApproachable.contains(redirectedVFS)) {
- log.debug(String.format("%s is approachable",
- redirectedVFS.getAliasName()));
- MappingRule rule = redirectedVFS.getMappingRules().get(0);
- stori = redirectedVFS.createFile(NamespaceUtil.extractRelativePath(
- redirectedVFS.getRootPath(), realPath), StoRIType.FILE);
-
- stori.setStFNRoot(rule.getStFNRoot());
- stori.setMappingRule(rule);
- return stori;
+ if (user != null && !vfsApproachable.contains(redirectedVFS)) {
+ String msg = String.format("%s is not approachable by the user",
+ redirectedVFS.getAliasName());
+ log.debug(msg);
+ throw new UnapprochableSurlException(msg);
}
- throw new UnapprochableSurlException(String.format(
- "%s is not approachable", redirectedVFS.getAliasName()));
- }
+ log.debug(String.format("%s is approachable by the user",
+ redirectedVFS.getAliasName()));
+ MappingRule rule = redirectedVFS.getMappingRules().get(0);
+ relativePath = NamespaceUtil.extractRelativePath(rule.getStFNRoot(),
+ stfnPath);
+ stori = rule.getMappedFS().createFile(relativePath, StoRIType.FILE);
+ stori.setStFNRoot(rule.getStFNRoot());
+ stori.setMappingRule(rule);
+ return stori;
+ }
+
public VirtualFSInterface resolveVFSbySURL(TSURL surl, GridUserInterface user)
throws UnapprochableSurlException, IllegalArgumentException,
InvalidSURLException, NamespaceException {
@@ -459,13 +481,26 @@ public Space retrieveSpaceByToken(TSizeInBytes totSize, TSpaceToken token) {
/***********************************************
* UTILITY METHODS
**********************************************/
+
+ /**
+ *
+ * @param surl
+ * @param vfsApproachable
+ * @return the mapped rule or null if not found
+ * @throws IllegalArgumentException
+ * @throws InvalidSURLException
+ * @throws UnapprochableSurlException
+ * @throws NamespaceException
+ */
+ private MappingRule getWinnerRule(TSURL surl,
+ List vfsApproachable) throws IllegalArgumentException,
+ InvalidSURLException, UnapprochableSurlException, NamespaceException {
- private MappingRule getWinnerRule(TSURL surl)
- throws IllegalArgumentException, InvalidSURLException,
- UnapprochableSurlException, NamespaceException {
-
- if (surl == null) {
- String errorMsg = "Unable to perform getWinnerRule, invalid argument stfnPath";
+ if (surl == null || vfsApproachable == null || vfsApproachable.isEmpty()) {
+ String errorMsg = String
+ .format(
+ "Unable to perform getWinnerRule, invalid argument(s): surl=%s, vfs=%s",
+ surl, vfsApproachable);
log.error(errorMsg);
throw new IllegalArgumentException(errorMsg);
}
@@ -484,7 +519,8 @@ private MappingRule getWinnerRule(TSURL surl)
MappingRule winnerRule = null;
int minDistance = Integer.MAX_VALUE;
for (MappingRule rule : rules) {
- if (NamespaceUtil.isEnclosed(rule.getStFNRoot(), stfnPath)) {
+ if (NamespaceUtil.isEnclosed(rule.getStFNRoot(), stfnPath)
+ && vfsApproachable.contains(rule.getMappedFS())) {
int distance = NamespaceUtil.computeDistanceFromPath(rule.getStFNRoot(), stfnPath);
if (distance < minDistance) {
minDistance = distance;
@@ -492,35 +528,16 @@ private MappingRule getWinnerRule(TSURL surl)
}
}
}
- if (winnerRule == null) {
- String errorMsg = "No mapping rules defined for stfnPath=" + stfnPath;
- log.error(errorMsg);
- throw new InvalidSURLException(surl, errorMsg);
- }
return winnerRule;
}
-
- private MappingRule getWinnerRule(TSURL surl,
- List vfsApproachable) throws IllegalArgumentException,
- InvalidSURLException, UnapprochableSurlException, NamespaceException {
- if (vfsApproachable == null || vfsApproachable.isEmpty()) {
- String errorMsg = "Unable to perform getWinnerRule, invalid argument vfsApproachable";
- log.error(errorMsg);
- throw new IllegalArgumentException(errorMsg);
- }
-
- MappingRule winnerRule = getWinnerRule(surl);
-
- if (vfsApproachable.contains(winnerRule.getMappedFS())) {
- return winnerRule;
- }
+ private MappingRule getWinnerRule(TSURL surl) throws IllegalArgumentException,
+ InvalidSURLException, UnapprochableSurlException, NamespaceException {
- String errorMsg = String.format("Surl %s is not approachable by the user", surl);
- log.error(errorMsg);
- throw new UnapprochableSurlException(errorMsg);
+ List allVFSs = new ArrayList(getAllDefinedVFS());
+ return getWinnerRule(surl, allVFSs);
}
-
+
@SuppressWarnings("unchecked")
public VirtualFSInterface getWinnerVFS(String absolutePath)
throws NamespaceException {
From 902a4187afd56e5c8403e3b47d403bd48b2a9536 Mon Sep 17 00:00:00 2001
From: enricovianello
Date: Thu, 23 Jan 2014 18:26:47 +0100
Subject: [PATCH 09/45] Fixed Namespace StoRI resolution alghoritm
---
.../it/grid/storm/namespace/Namespace.java | 159 ++++++++++++------
.../storm/namespace/NamespaceInterface.java | 27 +++
2 files changed, 133 insertions(+), 53 deletions(-)
diff --git a/src/main/java/it/grid/storm/namespace/Namespace.java b/src/main/java/it/grid/storm/namespace/Namespace.java
index 673b7c85..69ae8d77 100644
--- a/src/main/java/it/grid/storm/namespace/Namespace.java
+++ b/src/main/java/it/grid/storm/namespace/Namespace.java
@@ -114,6 +114,57 @@ public List getApproachableVFS(GridUserInterface user) {
return approachVFS;
}
+ @Override
+ public List getApproachableByAnonymousVFS()
+ throws NamespaceException {
+
+ LinkedList anonymousVFS = new LinkedList();
+ LinkedList allVFS = new LinkedList(
+ getAllDefinedVFS());
+
+ for (VirtualFSInterface vfs : allVFS) {
+ if (vfs.isApproachableByAnonymous()) {
+ anonymousVFS.add(vfs);
+ }
+ }
+
+ return anonymousVFS;
+ }
+
+ @Override
+ public List getReadableByAnonymousVFS()
+ throws NamespaceException {
+
+ LinkedList readableVFS = new LinkedList();
+ LinkedList allVFS = new LinkedList(
+ getAllDefinedVFS());
+
+ for (VirtualFSInterface vfs : allVFS) {
+ if (vfs.isHttpWorldReadable()) {
+ readableVFS.add(vfs);
+ }
+ }
+
+ return readableVFS;
+ }
+
+ @Override
+ public List getReadableOrApproachableByAnonymousVFS()
+ throws NamespaceException {
+
+ LinkedList rowVFS = new LinkedList();
+ LinkedList allVFS = new LinkedList(
+ getAllDefinedVFS());
+
+ for (VirtualFSInterface vfs : allVFS) {
+ if (vfs.isHttpWorldReadable() || vfs.isApproachableByAnonymous()) {
+ rowVFS.add(vfs);
+ }
+ }
+
+ return rowVFS;
+ }
+
public VirtualFSInterface getDefaultVFS(GridUserInterface user)
throws NamespaceException {
@@ -184,58 +235,65 @@ private StoRI resolveStoRI(TSURL surl, GridUserInterface user)
throws IllegalArgumentException, UnapprochableSurlException,
NamespaceException, InvalidSURLException {
+ StoRI stori = null;
+
+ /* check surl */
if (surl == null) {
- log.error("resolveStoRIbySURL: invalid null surl");
- throw new IllegalArgumentException(
- "resolveStoRIbySURL: invalid null surl");
+ String msg = "resolveStoRIbySURL: invalid null surl";
+ log.error(msg);
+ throw new IllegalArgumentException(msg);
}
List vfsApproachable = null;
if (user != null) {
- // get the user approachable VFSs
+ // get the grid user approachable VFSs
vfsApproachable = getApproachableVFS(user);
- if (vfsApproachable.isEmpty()) {
- String errorMsg = String
- .format("User %s can't approach any VFS!", user);
- log.debug(errorMsg);
- throw new UnapprochableSurlException(errorMsg);
- }
} else {
- // get all the approachable VFSs
- vfsApproachable = new ArrayList(getAllDefinedVFS());
+ // get all the R or RW by anonymous VFSs
+ vfsApproachable = getReadableOrApproachableByAnonymousVFS();
+ }
+
+ //check vfsApproachable
+ if (vfsApproachable.isEmpty()) {
+ String errorMsg = "No approachable VFS found for user!";
+ log.debug(errorMsg);
+ throw new UnapprochableSurlException(errorMsg);
}
// get the winner rule for SURL
MappingRule winnerRule = getWinnerRule(surl, vfsApproachable);
+
if (winnerRule == null) {
- if (user == null) {
- // there's no VFS where the surl can be mapped
- String msg = String.format("No mapping rule found for surl='%s'", surl);
+ /* is this surl invalid for this instance of StoRM? */
+ if (getWinnerRule(surl, new ArrayList(getAllDefinedVFS())) == null) {
+ String msg = "The requested SURL is not managed by this instance of StoRM";
log.debug(msg);
throw new InvalidSURLException(surl, msg);
}
- // user's VFSs can't map the surl
- String msg = String.format(
- "No mapping rule found for surl='%s' and user ='%s'", surl, user);
- log.debug(msg);
- if (getWinnerRule(surl) == null) {
- // invalid surl
- throw new InvalidSURLException(surl, msg);
+
+ String msg = null;
+ if (user != null) {
+ msg = String.format("No mapping rule found for surl='%s' and user '%s'", surl, user);
+ } else {
+ msg = String.format("No mapping rule found for surl='%s'", surl);
}
+ log.debug(msg);
throw new UnapprochableSurlException(msg);
}
- log.debug(String.format(
- "For surl='%s' and vfsApproachable=[%s] the winner Rule is %s", surl,
- vfsApproachable, winnerRule.getRuleName()));
+
+ log.debug("The winner Rule is %s", winnerRule.getRuleName());
+
// create StoRI
String stfnPath = surl.sfn().stfn().toString();
- String relativePath = NamespaceUtil.extractRelativePath(
+
+ String relPath = NamespaceUtil.extractRelativePath(
winnerRule.getStFNRoot(), stfnPath);
- StoRI stori = winnerRule.getMappedFS().createFile(relativePath,
- StoRIType.FILE);
+
+ stori = winnerRule.getMappedFS().createFile(relPath, StoRIType.FILE);
stori.setStFNRoot(winnerRule.getStFNRoot());
stori.setMappingRule(winnerRule);
- // check if StoRI real path is enclosed into the mapped VFS
+
+ // verify if StoRI real resource is enclosed into the winner VFS
String realPath = null;
try {
realPath = stori.getLocalFile().getCanonicalPath();
@@ -243,38 +301,40 @@ private StoRI resolveStoRI(TSURL surl, GridUserInterface user)
log.error("Error on reading the canonical path: " + e.getMessage());
throw new NamespaceException(e.getMessage());
}
+
if (realPath.startsWith(winnerRule.getMappedFS().getRootPath())) {
log.debug(String.format("Resource '%s' belongs to '%s'", realPath,
winnerRule.getMappedFS().getAliasName()));
return stori;
}
- log.debug(String.format("Resource '%s' doesn't belong to %s", realPath,
- winnerRule.getMappedFS().getAliasName()));
+
+ log.debug("Resource '{}' doesn't belong to {}", realPath, winnerRule
+ .getMappedFS().getAliasName());
+
/* get the VFS where the resource is phisically located, if exists */
- VirtualFSInterface redirectedVFS = getWinnerVFS(realPath);
- if (redirectedVFS == null) {
- log.debug(String.format("Unable to find a valid VFS from path '%s'",
- realPath));
+ VirtualFSInterface targetVFS = getWinnerVFS(realPath);
+
+ if (targetVFS == null) {
+ log.debug("Unable to find a valid VFS from path '{}'", realPath);
throw new InvalidSURLException(surl,
"The requested SURL is not managed by this instance of StoRM");
}
- log.debug(String.format("%s belongs to %s", realPath,
- redirectedVFS.getAliasName()));
- if (user != null && !vfsApproachable.contains(redirectedVFS)) {
+
+ log.debug("{} belongs to {}", realPath, targetVFS.getAliasName());
+
+ if (!vfsApproachable.contains(targetVFS)) {
String msg = String.format("%s is not approachable by the user",
- redirectedVFS.getAliasName());
+ targetVFS.getAliasName());
log.debug(msg);
throw new UnapprochableSurlException(msg);
}
- log.debug(String.format("%s is approachable by the user",
- redirectedVFS.getAliasName()));
- MappingRule rule = redirectedVFS.getMappingRules().get(0);
- relativePath = NamespaceUtil.extractRelativePath(rule.getStFNRoot(),
+ log.debug("{} is approachable by the user", targetVFS.getAliasName());
+ relPath = NamespaceUtil.extractRelativePath(winnerRule.getStFNRoot(),
stfnPath);
- stori = rule.getMappedFS().createFile(relativePath, StoRIType.FILE);
- stori.setStFNRoot(rule.getStFNRoot());
- stori.setMappingRule(rule);
+ stori = targetVFS.createFile(relPath, StoRIType.FILE);
+ stori.setStFNRoot(winnerRule.getStFNRoot());
+ stori.setMappingRule(winnerRule);
return stori;
}
@@ -531,13 +591,6 @@ private MappingRule getWinnerRule(TSURL surl,
return winnerRule;
}
- private MappingRule getWinnerRule(TSURL surl) throws IllegalArgumentException,
- InvalidSURLException, UnapprochableSurlException, NamespaceException {
-
- List allVFSs = new ArrayList(getAllDefinedVFS());
- return getWinnerRule(surl, allVFSs);
- }
-
@SuppressWarnings("unchecked")
public VirtualFSInterface getWinnerVFS(String absolutePath)
throws NamespaceException {
diff --git a/src/main/java/it/grid/storm/namespace/NamespaceInterface.java b/src/main/java/it/grid/storm/namespace/NamespaceInterface.java
index 4e0ea168..1869a85e 100644
--- a/src/main/java/it/grid/storm/namespace/NamespaceInterface.java
+++ b/src/main/java/it/grid/storm/namespace/NamespaceInterface.java
@@ -99,6 +99,33 @@ public Collection getAllDefinedVFS()
public List getApproachableVFS(GridUserInterface user)
throws NamespaceException;
+ /**
+ *
+ * @return List : Return a List of readable and writable by anonymous users
+ * VirtualFS instances
+ * @throws NamespaceException
+ */
+ public List getApproachableByAnonymousVFS()
+ throws NamespaceException;
+
+ /**
+ *
+ * @return List : Return a List of readable by anonymous users
+ * VirtualFS instances
+ * @throws NamespaceException
+ */
+ public List getReadableByAnonymousVFS()
+ throws NamespaceException;
+
+ /**
+ *
+ * @return List : Return a List of readable or writable by anonymous users
+ * VirtualFS instances
+ * @throws NamespaceException
+ */
+ public List getReadableOrApproachableByAnonymousVFS()
+ throws NamespaceException;
+
/**
*
* @param user
From 65157818217d732da4121f1e550c88ba9cd01982 Mon Sep 17 00:00:00 2001
From: enricovianello
Date: Thu, 23 Jan 2014 18:26:59 +0100
Subject: [PATCH 10/45] Fixed typo
---
.../grid/storm/authz/remote/resource/PermissionEvaluator.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/main/java/it/grid/storm/authz/remote/resource/PermissionEvaluator.java b/src/main/java/it/grid/storm/authz/remote/resource/PermissionEvaluator.java
index 80fff4f1..f08a3cfa 100644
--- a/src/main/java/it/grid/storm/authz/remote/resource/PermissionEvaluator.java
+++ b/src/main/java/it/grid/storm/authz/remote/resource/PermissionEvaluator.java
@@ -161,7 +161,7 @@ static Boolean evaluateAnonymousPermission(String filePathDecoded,
if (!fileVFS.getCapabilities().getAllManagedProtocols()
.contains(Protocol.HTTP)) {
log.debug("The requeste Storage Area \'" + fileVFS.getAliasName()
- + "\' is not appoachable via HTTPS");
+ + "\' is not approachable via HTTPS");
return Boolean.FALSE;
}
log.info("Authorization decision for Anonymous user requesting " + request
@@ -189,7 +189,7 @@ static Boolean evaluateAnonymousPermission(String filePathDecoded,
if (!fileVFS.isApproachableByAnonymous()
&& !(request.isReadOnly() && fileVFS.isHttpWorldReadable())) {
log.debug("The requeste Storage Area \'" + fileVFS.getAliasName()
- + "\' is not appoachable by anonymous users");
+ + "\' is not approachable by anonymous users");
return new Boolean(false);
}
StFN fileStFN = buildStFN(filePathDecoded, fileVFS);
From 57e3f4ff54bb1e0c8621c196da4869a11656615a Mon Sep 17 00:00:00 2001
From: enricovianello
Date: Fri, 24 Jan 2014 14:14:40 +0100
Subject: [PATCH 11/45] Fixed SRM_INVALID_PATH returned if surl is unsolvable
---
.../it/grid/storm/namespace/Namespace.java | 210 ++++++++++--------
.../config/xml/XMLNamespaceParser.java | 1 -
2 files changed, 120 insertions(+), 91 deletions(-)
diff --git a/src/main/java/it/grid/storm/namespace/Namespace.java b/src/main/java/it/grid/storm/namespace/Namespace.java
index 69ae8d77..e8831485 100644
--- a/src/main/java/it/grid/storm/namespace/Namespace.java
+++ b/src/main/java/it/grid/storm/namespace/Namespace.java
@@ -172,36 +172,31 @@ public VirtualFSInterface getDefaultVFS(GridUserInterface user)
getApproachableRules(user));
if (appRules.isEmpty()) {
if (user instanceof AbstractGridUser) {
- log.error("No approachable rules found for user with DN='"
- + user.getDn() + "' and VO = '" + ((AbstractGridUser) user).getVO()
- + "'");
- throw new NamespaceException(
- "No approachable rules found for user with DN='" + user.getDn()
- + "' and VO = '" + ((AbstractGridUser) user).getVO() + "'");
+ String msg = String.format(
+ "No approachable rules found for user with DN='%s' and VO = '%s'",
+ user.getDn(), ((AbstractGridUser) user).getVO());
+ log.error(msg);
+ throw new NamespaceException(msg);
} else {
- log.error("No approachable rules found for user with DN='"
- + user.getDn() + "' User certificate has not VOMS extension");
- throw new NamespaceException(
- "No approachable rules found for user with DN='" + user.getDn()
- + "' User certificate has not VOMS extension");
+ String msg = String.format("No approachable rules found for user with "
+ + "DN='%s' User certificate has not VOMS extension", user.getDn());
+ log.error(msg);
+ throw new NamespaceException(msg);
}
}
- log.debug("Compatible Approachable rules : " + appRules);
+ log.debug("Compatible Approachable rules : {}", appRules);
ApproachableRule firstAppRule = appRules.first();
- log.debug("Default APP_RULE is the first (in respsect of name): "
- + firstAppRule);
+ log.debug("Default APP_RULE is the first: {}", firstAppRule);
- // Retrieve default VFS for the first Approachable Rule compatible for the
- // user.
VirtualFSInterface vfs = getApproachableDefaultVFS(firstAppRule);
- log.debug("Default VFS for Space Files : " + vfs);
+ log.debug("Default VFS for Space Files : {}", vfs);
return vfs;
-
}
- public boolean isApproachable(StoRI storageResource,
- GridUserInterface gridUser) throws NamespaceException {
- return getApproachableVFS(gridUser).contains(storageResource.getVirtualFileSystem());
+ public boolean isApproachable(StoRI stori, GridUserInterface user)
+ throws NamespaceException {
+
+ return getApproachableVFS(user).contains(stori.getVirtualFileSystem());
}
/**
@@ -221,6 +216,13 @@ public boolean isApproachable(StoRI storageResource,
public StoRI resolveStoRIbySURL(TSURL surl) throws IllegalArgumentException,
UnapprochableSurlException, NamespaceException, InvalidSURLException {
+ /* check surl */
+ if (surl == null) {
+ String msg = "resolveStoRIbySURL: invalid null surl";
+ log.error(msg);
+ throw new IllegalArgumentException(msg);
+ }
+
return resolveStoRI(surl, null);
}
@@ -228,100 +230,79 @@ public StoRI resolveStoRIbySURL(TSURL surl, GridUserInterface user)
throws IllegalArgumentException, UnapprochableSurlException,
NamespaceException, InvalidSURLException {
- return resolveStoRI(surl, user);
- }
-
- private StoRI resolveStoRI(TSURL surl, GridUserInterface user)
- throws IllegalArgumentException, UnapprochableSurlException,
- NamespaceException, InvalidSURLException {
-
- StoRI stori = null;
-
/* check surl */
if (surl == null) {
String msg = "resolveStoRIbySURL: invalid null surl";
log.error(msg);
throw new IllegalArgumentException(msg);
}
+
+ return resolveStoRI(surl, user);
+ }
+
+ private StoRI resolveStoRI(TSURL surl, GridUserInterface user)
+ throws IllegalArgumentException, UnapprochableSurlException,
+ NamespaceException, InvalidSURLException {
+ StoRI stori = null;
List vfsApproachable = null;
- if (user != null) {
- // get the grid user approachable VFSs
- vfsApproachable = getApproachableVFS(user);
+
+ /* 1. compute user's approachable VFS: */
+ if (isAnonymous(user)) {
+ vfsApproachable = new ArrayList(getAllDefinedVFS());
} else {
- // get all the R or RW by anonymous VFSs
- vfsApproachable = getReadableOrApproachableByAnonymousVFS();
+ vfsApproachable = getApproachableVFS(user);
}
- //check vfsApproachable
if (vfsApproachable.isEmpty()) {
String errorMsg = "No approachable VFS found for user!";
log.debug(errorMsg);
throw new UnapprochableSurlException(errorMsg);
}
- // get the winner rule for SURL
+ /* get the winner rule for SURL */
MappingRule winnerRule = getWinnerRule(surl, vfsApproachable);
if (winnerRule == null) {
- /* is this surl invalid for this instance of StoRM? */
- if (getWinnerRule(surl, new ArrayList(getAllDefinedVFS())) == null) {
- String msg = "The requested SURL is not managed by this instance of StoRM";
- log.debug(msg);
- throw new InvalidSURLException(surl, msg);
- }
-
- String msg = null;
- if (user != null) {
- msg = String.format("No mapping rule found for surl='%s' and user '%s'", surl, user);
- } else {
- msg = String.format("No mapping rule found for surl='%s'", surl);
+ /* check if surl can be resolved by this instance of StoRM */
+ if (!isAnonymous(user) && isSolvable(surl)) {
+ log.debug("No mapping rule found for surl='{}' and user '{}'", surl,
+ user);
+ throw new UnapprochableSurlException("User '" + user + "' is not "
+ + "authorized to access '" + surl + "'");
}
+ /* this surl is invalid for this instance of StoRM? */
+ String msg = "The requested SURL is not managed by this instance of StoRM";
log.debug(msg);
- throw new UnapprochableSurlException(msg);
+ throw new InvalidSURLException(surl, msg);
}
- log.debug("The winner Rule is %s", winnerRule.getRuleName());
+ log.debug("The winner rule is {}", winnerRule.getRuleName());
// create StoRI
- String stfnPath = surl.sfn().stfn().toString();
-
- String relPath = NamespaceUtil.extractRelativePath(
- winnerRule.getStFNRoot(), stfnPath);
-
- stori = winnerRule.getMappedFS().createFile(relPath, StoRIType.FILE);
- stori.setStFNRoot(winnerRule.getStFNRoot());
- stori.setMappingRule(winnerRule);
+ stori = buildStoRI(winnerRule.getMappedFS(), winnerRule, surl);
- // verify if StoRI real resource is enclosed into the winner VFS
- String realPath = null;
- try {
- realPath = stori.getLocalFile().getCanonicalPath();
- } catch (IOException e) {
- log.error("Error on reading the canonical path: " + e.getMessage());
- throw new NamespaceException(e.getMessage());
- }
-
- if (realPath.startsWith(winnerRule.getMappedFS().getRootPath())) {
- log.debug(String.format("Resource '%s' belongs to '%s'", realPath,
- winnerRule.getMappedFS().getAliasName()));
+ // verify if StoRI canonical path is enclosed into the winner VFS
+ if (isStoRIEnclosed(stori, winnerRule.getMappedFS())) {
+ log.debug("Resource '{}' belongs to '{}'", stori.getLocalFile(),
+ winnerRule.getMappedFS().getAliasName());
return stori;
}
- log.debug("Resource '{}' doesn't belong to {}", realPath, winnerRule
- .getMappedFS().getAliasName());
+ log.debug("Resource '{}' doesn't belong to {}", stori.getLocalFile(),
+ winnerRule.getMappedFS().getAliasName());
/* get the VFS where the resource is phisically located, if exists */
+ String realPath = getStoRICanonicalPath(stori);
VirtualFSInterface targetVFS = getWinnerVFS(realPath);
-
if (targetVFS == null) {
log.debug("Unable to find a valid VFS from path '{}'", realPath);
throw new InvalidSURLException(surl,
"The requested SURL is not managed by this instance of StoRM");
}
-
log.debug("{} belongs to {}", realPath, targetVFS.getAliasName());
+ /* check if target VFS is approachable */
if (!vfsApproachable.contains(targetVFS)) {
String msg = String.format("%s is not approachable by the user",
targetVFS.getAliasName());
@@ -330,14 +311,51 @@ private StoRI resolveStoRI(TSURL surl, GridUserInterface user)
}
log.debug("{} is approachable by the user", targetVFS.getAliasName());
- relPath = NamespaceUtil.extractRelativePath(winnerRule.getStFNRoot(),
- stfnPath);
- stori = targetVFS.createFile(relPath, StoRIType.FILE);
- stori.setStFNRoot(winnerRule.getStFNRoot());
- stori.setMappingRule(winnerRule);
- return stori;
+ return buildStoRI(targetVFS, winnerRule, surl);
}
-
+
+ private boolean isSolvable(TSURL surl) throws IllegalArgumentException,
+ InvalidSURLException, UnapprochableSurlException, NamespaceException {
+
+ return getWinnerRule(surl) != null;
+ }
+
+ private String getStoRICanonicalPath(StoRI stori)
+ throws NamespaceException {
+
+ String realPath = null;
+ try {
+ realPath = stori.getLocalFile().getCanonicalPath();
+ } catch (IOException e) {
+ log.error("Error on reading the canonical path: " + e.getMessage());
+ throw new NamespaceException(e.getMessage());
+ }
+ return realPath;
+ }
+
+ private boolean isStoRIEnclosed(StoRI stori, VirtualFSInterface vfs)
+ throws NamespaceException {
+
+ return getStoRICanonicalPath(stori).startsWith(vfs.getRootPath());
+ }
+
+ private StoRI buildStoRI(VirtualFSInterface vfs, MappingRule mappingRule,
+ TSURL surl) {
+
+ String stfnPath = surl.sfn().stfn().toString();
+ String relativePath = NamespaceUtil.extractRelativePath(
+ mappingRule.getStFNRoot(), stfnPath);
+ StoRI stori = vfs.createFile(relativePath, StoRIType.FILE);
+ stori.setStFNRoot(mappingRule.getStFNRoot());
+ stori.setMappingRule(mappingRule);
+ return stori;
+ }
+
+ private boolean isAnonymous(GridUserInterface user) {
+
+ return user == null;
+ }
+
public VirtualFSInterface resolveVFSbySURL(TSURL surl, GridUserInterface user)
throws UnapprochableSurlException, IllegalArgumentException,
InvalidSURLException, NamespaceException {
@@ -371,8 +389,8 @@ public StoRI resolveStoRIbyAbsolutePath(String absolutePath)
throws NamespaceException {
VirtualFSInterface vfs = resolveVFSbyAbsolutePath(absolutePath);
- log.debug("VFS retrivied is " + vfs.getAliasName());
- log.debug("VFS instance is " + vfs.hashCode());
+ log.debug("VFS retrivied is {}", vfs.getAliasName());
+ log.debug("VFS instance is {}", vfs.hashCode());
String relativePath = NamespaceUtil.extractRelativePath(vfs.getRootPath(),
absolutePath);
StoRI stori = vfs.createFile(relativePath);
@@ -556,15 +574,18 @@ private MappingRule getWinnerRule(TSURL surl,
List vfsApproachable) throws IllegalArgumentException,
InvalidSURLException, UnapprochableSurlException, NamespaceException {
- if (surl == null || vfsApproachable == null || vfsApproachable.isEmpty()) {
- String errorMsg = String
- .format(
- "Unable to perform getWinnerRule, invalid argument(s): surl=%s, vfs=%s",
- surl, vfsApproachable);
+ if (surl == null || vfsApproachable == null) {
+ String errorMsg = String.format("Unable to perform getWinnerRule, "
+ + "invalid argument(s): surl=%s, vfs=%s", surl, vfsApproachable);
log.error(errorMsg);
throw new IllegalArgumentException(errorMsg);
}
+ if (vfsApproachable.isEmpty()) {
+ log.debug("Empty VFS list!");
+ return null;
+ }
+
Vector rules = new Vector(parser
.getMappingRules().values());
@@ -581,7 +602,8 @@ private MappingRule getWinnerRule(TSURL surl,
for (MappingRule rule : rules) {
if (NamespaceUtil.isEnclosed(rule.getStFNRoot(), stfnPath)
&& vfsApproachable.contains(rule.getMappedFS())) {
- int distance = NamespaceUtil.computeDistanceFromPath(rule.getStFNRoot(), stfnPath);
+ int distance = NamespaceUtil.computeDistanceFromPath(
+ rule.getStFNRoot(), stfnPath);
if (distance < minDistance) {
minDistance = distance;
winnerRule = rule;
@@ -590,6 +612,14 @@ private MappingRule getWinnerRule(TSURL surl,
}
return winnerRule;
}
+
+ private MappingRule getWinnerRule(TSURL surl)
+ throws IllegalArgumentException, InvalidSURLException,
+ UnapprochableSurlException, NamespaceException {
+
+ return getWinnerRule(surl, new ArrayList(
+ getAllDefinedVFS()));
+ }
@SuppressWarnings("unchecked")
public VirtualFSInterface getWinnerVFS(String absolutePath)
diff --git a/src/main/java/it/grid/storm/namespace/config/xml/XMLNamespaceParser.java b/src/main/java/it/grid/storm/namespace/config/xml/XMLNamespaceParser.java
index aaabf07c..be4ddf66 100644
--- a/src/main/java/it/grid/storm/namespace/config/xml/XMLNamespaceParser.java
+++ b/src/main/java/it/grid/storm/namespace/config/xml/XMLNamespaceParser.java
@@ -49,7 +49,6 @@
import it.grid.storm.namespace.model.VirtualFS;
import it.grid.storm.space.SpaceHelper;
import it.grid.storm.space.gpfsquota.GPFSFilesetQuotaInfo;
-import it.grid.storm.space.gpfsquota.GPFSQuotaInfo;
import it.grid.storm.space.gpfsquota.GetGPFSFilesetQuotaInfoCommand;
import it.grid.storm.srm.types.TSizeInBytes;
import it.grid.storm.srm.types.TSpaceToken;
From 2bbdd859710fc0dea442c433a88cd0e116db3930 Mon Sep 17 00:00:00 2001
From: enricovianello
Date: Wed, 29 Jan 2014 16:35:31 +0100
Subject: [PATCH 12/45] Improved log verbosity in case of a malformed log
configuration file
---
src/main/java/it/grid/storm/startup/Bootstrap.java | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/main/java/it/grid/storm/startup/Bootstrap.java b/src/main/java/it/grid/storm/startup/Bootstrap.java
index a2728d26..a03319c4 100644
--- a/src/main/java/it/grid/storm/startup/Bootstrap.java
+++ b/src/main/java/it/grid/storm/startup/Bootstrap.java
@@ -55,8 +55,11 @@ public static void configureLogging(String loggingConfigFilePath) {
String message = String.format("Error loading logging configuration: "
+ "'%s' does not exist or is not readable.",loggingConfigFilePath);
+
+ log.error(message);
+
throw new RuntimeException(message);
- }
+ }
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
JoranConfigurator configurator = new JoranConfigurator();
@@ -69,11 +72,15 @@ public static void configureLogging(String loggingConfigFilePath) {
} catch (JoranException e) {
+ System.err.println(e + "\n" + e.getCause());
+
throw new RuntimeException(e);
- }
+ } finally {
+
+ StatusPrinter.printInCaseOfErrorsOrWarnings(lc);
- StatusPrinter.printInCaseOfErrorsOrWarnings(lc);
+ }
}
public static void initializePathAuthz(String pathAuthzDBFileName)
From 9bdc41bc85136c76f0bcccd8eb4a820b0dc58128 Mon Sep 17 00:00:00 2001
From: enricovianello
Date: Wed, 29 Jan 2014 16:40:20 +0100
Subject: [PATCH 13/45] Removed useless log message
---
src/main/java/it/grid/storm/startup/Bootstrap.java | 2 --
1 file changed, 2 deletions(-)
diff --git a/src/main/java/it/grid/storm/startup/Bootstrap.java b/src/main/java/it/grid/storm/startup/Bootstrap.java
index a03319c4..2b0bc982 100644
--- a/src/main/java/it/grid/storm/startup/Bootstrap.java
+++ b/src/main/java/it/grid/storm/startup/Bootstrap.java
@@ -72,8 +72,6 @@ public static void configureLogging(String loggingConfigFilePath) {
} catch (JoranException e) {
- System.err.println(e + "\n" + e.getCause());
-
throw new RuntimeException(e);
} finally {
From e0bdebd067af9c5c8bd6775e83465d5f8a9a3729 Mon Sep 17 00:00:00 2001
From: enricovianello
Date: Thu, 30 Jan 2014 16:14:51 +0100
Subject: [PATCH 14/45] Fixed symbolic-link case in StoRI resolution algorithm
- anonymous users = not allowed sym links
- auth users = verify target vfs permissions (source vfs must be
approachable)
---
src/main/java/it/grid/storm/namespace/Namespace.java | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/main/java/it/grid/storm/namespace/Namespace.java b/src/main/java/it/grid/storm/namespace/Namespace.java
index e8831485..274a3be8 100644
--- a/src/main/java/it/grid/storm/namespace/Namespace.java
+++ b/src/main/java/it/grid/storm/namespace/Namespace.java
@@ -265,7 +265,7 @@ private StoRI resolveStoRI(TSURL surl, GridUserInterface user)
if (winnerRule == null) {
/* check if surl can be resolved by this instance of StoRM */
- if (!isAnonymous(user) && isSolvable(surl)) {
+ if (isSolvable(surl)) {
log.debug("No mapping rule found for surl='{}' and user '{}'", surl,
user);
throw new UnapprochableSurlException("User '" + user + "' is not "
@@ -292,6 +292,11 @@ private StoRI resolveStoRI(TSURL surl, GridUserInterface user)
log.debug("Resource '{}' doesn't belong to {}", stori.getLocalFile(),
winnerRule.getMappedFS().getAliasName());
+ if (isAnonymous(user)) {
+ throw new UnapprochableSurlException(stori.getLocalFile()
+ + " is not approachable by anonymous users!");
+ }
+
/* get the VFS where the resource is phisically located, if exists */
String realPath = getStoRICanonicalPath(stori);
VirtualFSInterface targetVFS = getWinnerVFS(realPath);
@@ -311,7 +316,7 @@ private StoRI resolveStoRI(TSURL surl, GridUserInterface user)
}
log.debug("{} is approachable by the user", targetVFS.getAliasName());
- return buildStoRI(targetVFS, winnerRule, surl);
+ return stori;
}
private boolean isSolvable(TSURL surl) throws IllegalArgumentException,
From 34aa813d4fe9d1b9eec1ca4c12c7d17c834a6168 Mon Sep 17 00:00:00 2001
From: enricovianello
Date: Mon, 3 Feb 2014 11:39:13 +0100
Subject: [PATCH 15/45] Proper use of string formatting in log calls - package
it.grid.storm
---
src/main/java/it/grid/storm/Constants.java | 14 ++--
src/main/java/it/grid/storm/StoRM.java | 20 +++---
.../it/grid/storm/StoRMCommandServer.java | 70 ++++++++++++-------
3 files changed, 59 insertions(+), 45 deletions(-)
diff --git a/src/main/java/it/grid/storm/Constants.java b/src/main/java/it/grid/storm/Constants.java
index 8f80a82c..6f013641 100644
--- a/src/main/java/it/grid/storm/Constants.java
+++ b/src/main/java/it/grid/storm/Constants.java
@@ -61,24 +61,22 @@ private static String getDistribution() {
+ "issue";
File issueFile = new File(issuePath);
if (!issueFile.exists() || !issueFile.isFile() || !issueFile.canRead()) {
- log.warn("Unable to read " + issueFile.getAbsolutePath() + " file!!");
+ log.warn("Unable to read {} file!!", issueFile.getAbsolutePath());
} else {
try {
BufferedReader issueReader = new BufferedReader(new FileReader(
issueFile));
String output = issueReader.readLine();
if (output == null) {
- log.warn("The file " + issueFile.getAbsolutePath() + " is empty!");
+ log.warn("The file {} is empty!", issueFile.getAbsolutePath());
} else {
distribution = output;
}
issueReader.close();
} catch (FileNotFoundException e) {
- log.error("Unable to read file '" + issueFile.getAbsolutePath() + "'. "
- + e);
+ log.error("Unable to read file '{}'. {}", issueFile.getAbsolutePath(), e);
} catch (IOException e) {
- log.error("Unable to read file '" + issueFile.getAbsolutePath() + "'."
- + e);
+ log.error("Unable to read file '{}'. {}", issueFile.getAbsolutePath(), e);
}
}
return distribution;
@@ -105,14 +103,14 @@ private static HashMap getPlatformKernel() {
while (error != null) {
error += stdError.readLine();
}
- log.error("Unable to invoke \'uname -ri\' . Standard error : " + error);
+ log.error("Unable to invoke \'uname -ri\' . Standard error : {}", error);
} else {
String[] fields = output.trim().split(" ");
map.put("kernelRelease", fields[0]);
map.put("platform", fields[1]);
}
} catch (IOException e) {
- log.error("Unable to invoke \'uname -ri\' . IOException " + e);
+ log.error("Unable to invoke \'uname -ri\' . IOException {}", e);
}
return map;
}
diff --git a/src/main/java/it/grid/storm/StoRM.java b/src/main/java/it/grid/storm/StoRM.java
index 0d6c187c..281d7bec 100644
--- a/src/main/java/it/grid/storm/StoRM.java
+++ b/src/main/java/it/grid/storm/StoRM.java
@@ -145,10 +145,9 @@ private void configureXMLRPCService(){
} catch (StoRMXmlRpcException e) {
- log.error("Unable to create the XML-RPC Server. StoRMXmlRpcException: "
- + e.getMessage());
+ log.error(e.getMessage(), e);
- throw new RuntimeException("Unable to create the XML-RPC Server", e);
+ throw new RuntimeException(e.getMessage(), e);
}
}
@@ -281,11 +280,11 @@ synchronized public void startRestServer() throws Exception {
try {
RestService.startServer();
} catch (IOException e) {
- log.error("Unable to start internal HTTP Server listening for RESTFul services. IOException : "
- + e.getMessage());
- throw new Exception(
- "Unable to start internal HTTP Server listening for RESTFul services. IOException : "
- + e.getMessage());
+
+ String emsg = String.format("Unable to start internal HTTP Server "
+ + "listening for RESTFul services. IOException : %s", e.getMessage());
+ log.error(emsg, e);
+ throw new Exception(emsg);
}
this.isRestServerRunning = true;
}
@@ -301,8 +300,9 @@ synchronized public void stopRestServer() {
} catch (Exception e) {
- log.error("Unable to stop internal HTTP Server listening for RESTFul services: "
- + e.getMessage());
+ String emsg = String.format("Unable to stop internal HTTP Server "
+ + "listening for RESTFul services: %s", e.getMessage());
+ log.error(emsg, e);
}
this.isRestServerRunning = false;
diff --git a/src/main/java/it/grid/storm/StoRMCommandServer.java b/src/main/java/it/grid/storm/StoRMCommandServer.java
index b0c7cb2a..03f7f910 100644
--- a/src/main/java/it/grid/storm/StoRMCommandServer.java
+++ b/src/main/java/it/grid/storm/StoRMCommandServer.java
@@ -144,9 +144,9 @@ private void startCommandServer() {
} catch (IOException e) {
- log.error("Could not bind to port {}: {}",
- new Object[]{listeningPort,e.getMessage()},
- e);
+ String emsg = String.format("Could not bind to port %d: %s",
+ listeningPort, e.getMessage());
+ log.error(emsg, e);
System.exit(1);
}
@@ -164,9 +164,11 @@ public void run() {
}
} catch (IOException e) {
- log
- .error("UNEXPECTED ERROR! Something went wrong " +
- "with server.accept(): {}", e.getMessage(), e);
+ String emsg = String.format(
+ "UNEXPECTED ERROR! Something went wrong with server.accept(): %s",
+ e.getMessage());
+ log.error(emsg, e);
+
System.exit(1);
}
}
@@ -294,7 +296,7 @@ public void run() {
// sequence of commands completed
break;
case UNKNOW:
- log.warn("Received an unknown command: " + inputLine);
+ log.warn("Received an unknown command: {}", inputLine);
acceptCommands = false;
// any other command breaks the connection, but the command server
// remains on!
@@ -303,15 +305,16 @@ public void run() {
// any other command breaks the connection, but the command server
// remains on!
acceptCommands = false;
- log.warn("Received an unknown command: " + inputLine);
+ log.warn("Received an unknown command: {}", inputLine);
break;
}
try {
inputLine = in.readLine();
} catch (IOException e) {
- log
- .error("UNEXPECTED ERROR! Unable to read from the client socket. IOException : "
- + e.getMessage());
+
+ String emsg = String.format("UNEXPECTED ERROR! Unable to read from "
+ + "the client socket. IOException : %s", e.getMessage());
+ log.error(emsg, e);
return;
}
} while (inputLine != null && acceptCommands);
@@ -333,8 +336,11 @@ private boolean startServices() {
storm.startXmlRpcServer();
}
} catch (Exception e) {
- log.error("Unable to start the xmlrpc server. Exception: "
- + e.getMessage(),e);
+
+ String emsg = String.format("Unable to start the xmlrpc server. "
+ + "Exception: %s", e.getMessage());
+ log.error(emsg, e);
+
stopServices();
return false;
}
@@ -343,8 +349,11 @@ private boolean startServices() {
storm.startRestServer();
}
} catch (Exception e) {
- log.error("Unable to start the Rest server. Exception: "
- + e.getMessage(),e);
+
+ String emsg = String.format("Unable to start the Rest server. "
+ + "Exception: %s", e.getMessage());
+ log.error(emsg, e);
+
stopServices();
return false;
}
@@ -384,25 +393,31 @@ private void sendOutputAndClose(String response, BufferedWriter out,
out.write(response, 0, response.length());
out.newLine();
} catch (IOException e) {
- log
- .error("UNEXPECTED ERROR! Unable to write on the client socket. IOException : "
- + e.getMessage(),e);
+
+ String emsg = String.format("UNEXPECTED ERROR! Unable to write on "
+ + "the client socket. IOException : %s", e.getMessage());
+ log.error(emsg, e);
+
}
try {
out.close();
in.close();
} catch (IOException e) {
- log
- .error("UNEXPECTED ERROR! Unable to close client socket streams. IOException : "
- + e.getMessage(),e);
+
+ String emsg = String.format("UNEXPECTED ERROR! Unable to close client "
+ + "socket streams. IOException : %s", e.getMessage());
+ log.error(emsg, e);
+
}
} finally {
try {
socket.close();
} catch (IOException e) {
- log
- .error("UNEXPECTED ERROR! Unable to close client socket. IOException : "
- + e.getMessage(),e);
+
+ String emsg = String.format("UNEXPECTED ERROR! Unable to close client "
+ + "socket. IOException : %s", e.getMessage());
+ log.error(emsg, e);
+
}
}
}
@@ -507,16 +522,17 @@ public static void main(String[] args) {
configurationPathname = args[0];
log.info("StoRMCommandServer invoked with two parameters.");
- log.info("Configuration file: " + configurationPathname);
+ log.info("Configuration file: {}", configurationPathname);
try {
refresh = Integer.parseInt(args[1]);
- log.info("Configuration file refresh rate: " + refresh + " seconds");
+ log.info("Configuration file refresh rate: {} seconds", refresh);
} catch (NumberFormatException e) {
- log.error("Configuration file refresh rate: NOT an integer! Disabling refresh by default!");
+ log.error("Configuration file refresh rate: NOT an integer! "
+ + "Disabling refresh by default!", e);
}
} else {
From 05f77180d619e4e0256cec3b7df4bb4dba1db1b0 Mon Sep 17 00:00:00 2001
From: enricovianello
Date: Tue, 4 Feb 2014 16:48:40 +0100
Subject: [PATCH 16/45] Fix log calls in storm backend - package
it.grid.storm.asynch
---
.../it/grid/storm/asynch/AdvancedPicker.java | 58 +-
src/main/java/it/grid/storm/asynch/BoL.java | 293 ++++----
.../java/it/grid/storm/asynch/BoLFeeder.java | 216 +++---
.../grid/storm/asynch/BoLPersistentChunk.java | 31 +-
src/main/java/it/grid/storm/asynch/Copy.java | 86 +--
.../java/it/grid/storm/asynch/CopyFeeder.java | 56 +-
.../storm/asynch/GlobalStatusManager.java | 630 ++++++++++--------
.../InvalidBoLChunkAttributesException.java | 7 +-
.../InvalidBoLFeederAttributesException.java | 6 +-
.../InvalidCopyAttributesException.java | 12 +-
.../InvalidCopyFeederAttributesException.java | 6 +-
...opyPersistentChunkAttributesException.java | 16 +-
...dPersistentRequestAttributesException.java | 6 +-
.../asynch/InvalidPtGAttributesException.java | 4 +-
.../InvalidPtGChunkAttributesException.java | 7 +-
.../InvalidPtGFeederAttributesException.java | 6 +-
.../InvalidPtPFeederAttributesException.java | 6 +-
.../InvalidPutStatusAttributesException.java | 4 +-
.../InvalidRequestAttributesException.java | 4 +-
.../asynch/NaiveGridFTPTransferClient.java | 2 +-
.../it/grid/storm/asynch/NaiveSRMClient.java | 115 +---
...NoGridFTPTransferClientFoundException.java | 3 +-
.../asynch/NoSRMClientFoundException.java | 3 +-
src/main/java/it/grid/storm/asynch/PtG.java | 482 +++++++-------
.../java/it/grid/storm/asynch/PtGBuilder.java | 23 +-
.../java/it/grid/storm/asynch/PtGFeeder.java | 290 ++++----
.../grid/storm/asynch/PtGPersistentChunk.java | 21 +-
src/main/java/it/grid/storm/asynch/PtP.java | 591 +++++++---------
.../java/it/grid/storm/asynch/PtPBuilder.java | 24 +-
.../java/it/grid/storm/asynch/PtPFeeder.java | 36 +-
.../grid/storm/asynch/PtPPersistentChunk.java | 8 +-
.../grid/storm/asynch/PushCopyGetVisitor.java | 5 +-
.../grid/storm/asynch/PushCopyPutVisitor.java | 42 +-
.../storm/asynch/PushCopyTransferVisitor.java | 29 +-
.../it/grid/storm/asynch/SRM22Client.java | 38 +-
.../ThirdPartGridFTPTransferClient.java | 24 +-
.../storm/asynch/WSRequestTokenConverter.java | 5 +-
.../it/grid/storm/asynch/WSTurlConverter.java | 5 +-
38 files changed, 1513 insertions(+), 1687 deletions(-)
diff --git a/src/main/java/it/grid/storm/asynch/AdvancedPicker.java b/src/main/java/it/grid/storm/asynch/AdvancedPicker.java
index 46df50d1..884727f3 100644
--- a/src/main/java/it/grid/storm/asynch/AdvancedPicker.java
+++ b/src/main/java/it/grid/storm/asynch/AdvancedPicker.java
@@ -155,7 +155,7 @@ public void retrieve() {
} else {
- log.info("ADVANCED PICKER: dispatching " + requests.size() + " requests.");
+ log.info("ADVANCED PICKER: dispatching {} requests.", requests.size());
}
@@ -207,12 +207,12 @@ public void retrieve() {
} else {
- log.warn("ADVANCED PICKER received request " + rt + " of type "
- + rtype + " which is NOT currently supported. Dropping request... ");
+ log.warn("ADVANCED PICKER received request {} of type which is NOT "
+ + "currently supported. Dropping request... ", rt, rtype);
- log.warn("ADVANCED PICKER: Beware that the global status of request "
- + rt + " will transit to SRM_FAILURE, but each chunk in the request " +
- "will remain in SRM_REQUEST_QUEUED!");
+ log.warn("ADVANCED PICKER: Beware that the global status of "
+ + "request {} will transit to SRM_FAILURE, but each chunk in the "
+ + "request will remain in SRM_REQUEST_QUEUED!", rt);
try {
@@ -222,57 +222,59 @@ public void retrieve() {
} catch (InvalidTReturnStatusAttributeException ex) {
- log.error("ADVANCED PICKER! Unable to change global status in DB: " + ex
- , ex);
+ log.error("ADVANCED PICKER! Unable to change global status in "
+ + "DB: {}", ex.getMessage(), ex);
}
}
} catch (InvalidPtGFeederAttributesException e) {
+
+ log.error("ADVANCED PICKER ERROR! PtGFeeder could not be created "
+ + "because of invalid attributes: {}", e.getMessage(), e);
- log.error("ADVANCED PICKER ERROR! PtGFeeder could not be created because of invalid attributes:\n"
- + e,e);
-
- log.error("PtG Request is being dropped: " + rsd.requestToken());
+ log.error("PtG Request is being dropped: {}", rsd.requestToken());
RequestSummaryCatalog.getInstance().failRequest(rsd,
"Internal error does not allow request to be fed to scheduler.");
} catch (InvalidPtPFeederAttributesException e) {
- log.error("ADVANCED PICKER ERROR! PtPFeeder could not be created" +
- " because of invalid attributes:\n" + e,e);
+ log.error("ADVANCED PICKER ERROR! PtPFeeder could not be created "
+ + "because of invalid attributes: {}", e.getMessage(),e);
- log.error("PtP Request is being dropped: " + rsd.requestToken());
+ log.error("PtP Request is being dropped: {}", rsd.requestToken());
RequestSummaryCatalog.getInstance().failRequest(rsd,
"Internal error does not allow request to be fed to scheduler.");
} catch (InvalidCopyFeederAttributesException e) {
- log.error("ADVANCED PICKER ERROR! CopyFeeder could not be created" +
- " because of invalid attributes:\n" + e, e);
-
- log.error("Copy Request is being dropped: " + rsd.requestToken());
+
+ log.error("ADVANCED PICKER ERROR! CopyFeeder could not be created "
+ + "because of invalid attributes: {}", e.getMessage(),e);
+
+ log.error("Copy Request is being dropped: {}", rsd.requestToken());
RequestSummaryCatalog.getInstance().failRequest(rsd,
"Internal error does not allow request to be fed to scheduler.");
} catch (InvalidBoLFeederAttributesException e) {
-
- log.error("ADVANCED PICKER ERROR! BoLFeeder could not be created " +
- "because of invalid attributes:\n" + e, e);
- log.error("BoL Request is being dropped: " + rsd.requestToken());
-
+
+ log.error("ADVANCED PICKER ERROR! BoLFeeder could not be created "
+ + "because of invalid attributes: {}", e.getMessage(), e);
+
+ log.error("BoL Request is being dropped: {}", rsd.requestToken());
+
RequestSummaryCatalog.getInstance().failRequest(rsd,
"Internal error does not allow request to be fed to scheduler.");
} catch (SchedulerException e) {
- log.error("ADVANCED PICKER ERROR! The request could not be scheduled" +
- " because of scheduler errors!\n" + e, e);
- log.error("ADVANCED PICKER ERROR! Request " + rsd.requestToken()
- + " of type " + rsd.requestType() + " dropped.");
+ log.error("ADVANCED PICKER ERROR! The request could not be scheduled"
+ + "because of scheduler errors: {}", e.getMessage(), e);
+ log.error("ADVANCED PICKER ERROR! Request {} of type {} dropped.",
+ rsd.requestToken(), rsd.requestType());
RequestSummaryCatalog.getInstance().failRequest(rsd,
"Internal scheduler has problems accepting request feed.");
diff --git a/src/main/java/it/grid/storm/asynch/BoL.java b/src/main/java/it/grid/storm/asynch/BoL.java
index d15aa8ce..d6a3d141 100644
--- a/src/main/java/it/grid/storm/asynch/BoL.java
+++ b/src/main/java/it/grid/storm/asynch/BoL.java
@@ -45,7 +45,6 @@
import it.grid.storm.srm.types.TSizeInBytes;
import it.grid.storm.srm.types.TSpaceToken;
import it.grid.storm.srm.types.TStatusCode;
-import it.grid.storm.synchcall.data.DataHelper;
import it.grid.storm.synchcall.surl.SurlStatusManager;
import it.grid.storm.tape.recalltable.TapeRecallCatalog;
import it.grid.storm.tape.recalltable.model.TapeRecallStatus;
@@ -165,34 +164,32 @@ public void choose(Streets s) {
*/
public Boolean completeRequest(TapeRecallStatus recallStatus) {
- boolean requestSuccessfull = false;
- if (recallStatus == TapeRecallStatus.SUCCESS) {
- try {
- if (bupLocalFile.isOnDisk()) {
- requestData.changeStatusSRM_SUCCESS("File recalled from tape");
- requestSuccessfull = true;
- } else {
- log
- .error("File "
- + bupLocalFile.getAbsolutePath()
- + " not found on the disk, but it was reported to be successfully recalled from tape");
- requestData.changeStatusSRM_FAILURE("Error recalling file from tape");
- }
- } catch (FSException e) {
- log.error("Unable to determine if file "
- + bupLocalFile.getAbsolutePath() + " is on disk . FSException : "
- + e.getMessage(),e);
- requestData
- .changeStatusSRM_FAILURE("Internal error: unable to determine if the file is on disk");
- }
- } else {
- if (recallStatus == TapeRecallStatus.ABORTED) {
- requestData.changeStatusSRM_ABORTED("Recalling file from tape aborted");
- } else {
- requestData.changeStatusSRM_FAILURE("Error recalling file from tape");
+ if (TapeRecallStatus.ABORTED.equals(recallStatus)) {
+ requestData.changeStatusSRM_ABORTED("Recalling file from tape aborted");
+ return false;
+ }
+
+ if (!TapeRecallStatus.SUCCESS.equals(recallStatus)) {
+ requestData.changeStatusSRM_FAILURE("Error recalling file from tape");
+ return false;
+ }
+
+ try {
+ if (bupLocalFile.isOnDisk()) {
+ requestData.changeStatusSRM_SUCCESS("File recalled from tape");
+ return true;
}
+ } catch (FSException e) {
+ log.error("Unable to determine if file {} is on disk. FSException: {}",
+ bupLocalFile.getAbsolutePath(), e.getMessage(), e);
+ requestData.changeStatusSRM_FAILURE("Unable to determine if file is on disk");
+ return false;
}
- return requestSuccessfull;
+
+ log.error("File {} not found on the disk, but it was reported to be "
+ + "successfully recalled from tape", bupLocalFile.getAbsolutePath());
+ requestData.changeStatusSRM_FAILURE("Error recalling file from tape");
+ return false;
}
/**
@@ -201,67 +198,67 @@ public Boolean completeRequest(TapeRecallStatus recallStatus) {
*/
public void doIt() {
- log.debug("Handling BoL chunk for user DN: " + gu.getDn() + "; for SURL: "
- + requestData.getSURL());
+ TSURL surl = requestData.getSURL();
+ TRequestToken rToken = requestData.getRequestToken();
+ String user = gu.getDn();
+
+ log.debug("Handling BoL chunk for user DN: {}; for SURL: {}", user, surl);
- if (!verifySurlStatusTransition(requestData.getSURL(),
- requestData.getRequestToken())) {
+ if (!verifySurlStatusTransition(surl, rToken)) {
failure = true;
+ log.info("Unable to perform the BOL request, surl busy");
requestData.changeStatusSRM_FILE_BUSY("Requested file is"
+ " busy (in an incompatible state with BOL)");
- log.info("Unable to perform the BOL request, surl busy");
- printOutcome(gu.getDn(), requestData.getSURL(), requestData.getStatus());
+ printOutcome(user, surl, requestData.getStatus());
return;
}
- else {
- StoRI fileStoRI = null;
- try {
- fileStoRI = NamespaceDirector.getNamespace().resolveStoRIbySURL(
- requestData.getSURL(), gu);
- } catch (IllegalArgumentException e) {
- failure = true;
- requestData
- .changeStatusSRM_INTERNAL_ERROR("Unable to get StoRI for surl "
- + requestData.getSURL());
- log.error("Unable to get StoRI for surl " + requestData.getSURL()
- + " IllegalArgumentException: " + e.getMessage());
- } catch (UnapprochableSurlException e) {
- requestData.changeStatusSRM_AUTHORIZATION_FAILURE(e.getMessage());
- failure = true;
- log.info("Unable to build a stori for surl " + requestData.getSURL()
- + " for user " + DataHelper.getRequestor(requestData)
- + " UnapprochableSurlException: " + e.getMessage());
- } catch (NamespaceException e) {
- requestData.changeStatusSRM_INTERNAL_ERROR(e.getMessage());
- failure = true;
- log.info("Unable to build a stori for surl " + requestData.getSURL()
- + " for user " + DataHelper.getRequestor(requestData)
- + " NamespaceException: " + e.getMessage());
- } catch (InvalidSURLException e) {
- requestData.changeStatusSRM_INVALID_PATH(e.getMessage());
- failure = true;
- log.info("Unable to build a stori for surl " + requestData.getSURL()
- + " for user " + DataHelper.getRequestor(requestData)
- + " InvalidSURLException: " + e.getMessage());
- }
- if (!failure) {
- SpaceHelper sp = new SpaceHelper();
- TSpaceToken token = sp.getTokenFromStoRI(log, fileStoRI);
- SpaceAuthzInterface spaceAuth = AuthzDirector.getSpaceAuthz(token);
-
- if (spaceAuth.authorize(gu, SRMSpaceRequest.BOL)) {
- manageIsPermit(fileStoRI);
- } else {
- failure = true;
- requestData
- .changeStatusSRM_AUTHORIZATION_FAILURE("Space authoritazion denied "
- + requestData.getSURL() + " in Storage Area: " + token);
- log.debug("Read access to " + requestData.getSURL()
- + " in Storage Area: " + token + " denied!");
- }
+
+ StoRI fileStoRI = null;
+ try {
+ fileStoRI = NamespaceDirector.getNamespace().resolveStoRIbySURL(surl, gu);
+ } catch (IllegalArgumentException e) {
+ log.error("Unable to build a stori for surl '{}' and user '{}'. "
+ + "IllegalArgumentException: {}", surl, user, e.getMessage(), e);
+ requestData.changeStatusSRM_INTERNAL_ERROR(e.getMessage());
+ failure = true;
+ } catch (UnapprochableSurlException e) {
+ log.info("Unable to build a stori for surl '{}' and user '{}'. "
+ + "UnapprochableSurlException: {}", surl, user, e.getMessage());
+ requestData.changeStatusSRM_AUTHORIZATION_FAILURE(e.getMessage());
+ failure = true;
+ } catch (NamespaceException e) {
+ log.error("Unable to build a stori for surl '{}' and user '{}'. "
+ + "NamespaceException: {}", surl, user, e.getMessage(), e);
+ requestData.changeStatusSRM_INTERNAL_ERROR(e.getMessage());
+ failure = true;
+ } catch (InvalidSURLException e) {
+ log.info("Unable to build a stori for surl '{}' and user '{}'. "
+ + "InvalidSURLException: {}", surl, user, e.getMessage());
+ requestData.changeStatusSRM_INVALID_PATH(e.getMessage());
+ failure = true;
+ } finally {
+ if (failure) {
+ printOutcome(user, surl, requestData.getStatus());
+ return;
}
}
- printOutcome(gu.getDn(), requestData.getSURL(), requestData.getStatus());
+
+ SpaceHelper sp = new SpaceHelper();
+ TSpaceToken token = sp.getTokenFromStoRI(log, fileStoRI);
+ SpaceAuthzInterface spaceAuth = AuthzDirector.getSpaceAuthz(token);
+
+ if (!spaceAuth.authorize(gu, SRMSpaceRequest.BOL)) {
+ String emsg = String.format("Space authorization denied %s"
+ + " in Storage Area: %s", surl, token);
+ log.debug(emsg);
+ requestData.changeStatusSRM_AUTHORIZATION_FAILURE(emsg);
+ failure = true;
+ printOutcome(user, surl, requestData.getStatus());
+ return;
+ }
+
+ manageIsPermit(fileStoRI);
+ printOutcome(user, surl, requestData.getStatus());
}
@Override
@@ -291,13 +288,9 @@ public String getUserDN() {
public boolean isResultSuccess() {
- boolean result = false;
TStatusCode statusCode = requestData.getStatus().getStatusCode();
- if ((statusCode.getValue().equals(TStatusCode.SRM_FILE_PINNED.getValue()))
- || requestData.getStatus().isSRM_SUCCESS()) {
- result = true;
- }
- return result;
+ return ((statusCode.equals(TStatusCode.SRM_FILE_PINNED))
+ || requestData.getStatus().isSRM_SUCCESS());
}
private void backupData(LocalFile localFile) {
@@ -313,74 +306,77 @@ private void manageIsPermit(StoRI fileStoRI) {
LocalFile localFile = fileStoRI.getLocalFile();
try {
+
if ((!localFile.exists()) || (localFile.isDirectory())) {
- // File does not exist, or it is a directory! Fail request with
- // SRM_INVALID_PATH!
- requestData
- .changeStatusSRM_INVALID_PATH("The requested file either does not exist, or it is a directory!");
+
+ String emsg = "The requested file either does not exist, or it is a directory!";
+ requestData.changeStatusSRM_INVALID_PATH(emsg);
failure = true;
- log
- .debug("BoLChunk: the requested file either does not exist, or it is a directory!");
-
- } else { // File exists and it is not a directory
-
- if (fileStoRI.getVirtualFileSystem().getStorageClassType()
- .isTapeEnabled()) {
-
- // Compute the Expiration Time in seconds
- // Add the deferred start time to the expiration date
- long expDate = (System.currentTimeMillis() / 1000 + (requestData
- .getLifeTime().value() + requestData.getDeferredStartTime()));
- StormEA.setPinned(localFile.getAbsolutePath(), expDate);
-
- // set group permission for tape quota management
- fileStoRI.setGroupTapeRead();
- requestData.setFileSize(TSizeInBytes.make(localFile.length(),
- SizeUnit.BYTES));
-
- if (isStoriOndisk(fileStoRI)) {
-
- requestData
- .changeStatusSRM_SUCCESS("srmBringOnLine successfully handled!");
-
- } else {
-
- requestData
- .changeStatusSRM_REQUEST_INPROGRESS("Recalling file from tape");
-
- String voName = null;
- if (gu instanceof AbstractGridUser) {
- voName = ((AbstractGridUser) gu).getVO().getValue();
- }
- new TapeRecallCatalog().insertTask(this, voName,
- localFile.getAbsolutePath());
- backupData(localFile);
- }
- } else {
- requestData
- .changeStatusSRM_NOT_SUPPORTED("Tape not supported for this filesystem");
- }
+ log.debug("BoLChunk: {}", emsg);
+ return;
+ }
+
+ if (!fileStoRI.getVirtualFileSystem().getStorageClassType()
+ .isTapeEnabled()) {
+
+ String emsg = "Tape not supported for this filesystem";
+ log.debug(emsg);
+ requestData.changeStatusSRM_NOT_SUPPORTED(emsg);
+ return;
+ }
+
+ // Compute the Expiration Time in seconds
+ // Add the deferred start time to the expiration date
+ long expDate = (System.currentTimeMillis() / 1000 + (requestData
+ .getLifeTime().value() + requestData.getDeferredStartTime()));
+ StormEA.setPinned(localFile.getAbsolutePath(), expDate);
+
+ // set group permission for tape quota management
+ fileStoRI.setGroupTapeRead();
+ requestData.setFileSize(TSizeInBytes.make(localFile.length(),
+ SizeUnit.BYTES));
+
+ if (isStoriOndisk(fileStoRI)) {
+ requestData
+ .changeStatusSRM_SUCCESS("srmBringOnLine successfully handled!");
+
+ } else {
+
+ requestData
+ .changeStatusSRM_REQUEST_INPROGRESS("Recalling file from tape");
+ String voName = null;
+ if (gu instanceof AbstractGridUser) {
+ voName = ((AbstractGridUser) gu).getVO().getValue();
+ }
+ new TapeRecallCatalog().insertTask(this, voName,
+ localFile.getAbsolutePath());
+ backupData(localFile);
}
+
} catch (SecurityException e) {
- // The check for existence of the File failed because there is a
- // SecurityManager installed that
- // denies read privileges for that File! Perhaps the local system
- // administrator of StoRM set
- // up Java policies that contrast policies described by the
- // PolicyCollector! There is a conflict here!
+ /*
+ * The check for existence of the File failed because there is a
+ * SecurityManager installed that denies read privileges for that File!
+ * Perhaps the local system administrator of StoRM set up Java policies
+ * that contrast policies described by the PolicyCollector! There is a
+ * conflict here!
+ */
requestData
- .changeStatusSRM_FAILURE("StoRM is not allowed to work on requested file!");
+ .changeStatusSRM_FAILURE("StoRM is not allowed to work on requested file!");
failure = true;
- log
- .error("ATTENTION in BoLChunk! BoLChunk received a SecurityException from Java SecurityManager; StoRM cannot check-existence or check-if-directory for: "
- + localFile.toString() + "; exception: " + e);
+ log.error("ATTENTION in BoLChunk! BoLChunk received a SecurityException "
+ + "from Java SecurityManager; StoRM cannot check-existence or "
+ + "check-if-directory for: {}; exception: {}", localFile.toString(),
+ e.getMessage(), e);
+ return;
+
} catch (Exception e) {
- requestData
- .changeStatusSRM_FAILURE("StoRM encountered an unexpected error!");
+ requestData.changeStatusSRM_FAILURE("StoRM encountered an unexpected error!");
failure = true;
- log.error("ERROR in BoLChunk! StoRM process got an unexpected error! "
- + e);
+ log.error("ERROR in BoLChunk! StoRM process got an unexpected error! {}",
+ e.getMessage(), e);
+ return;
}
}
@@ -388,9 +384,8 @@ private boolean isStoriOndisk(StoRI storiFile) throws FSException {
if (!storiFile.getVirtualFileSystem().getStorageClassType().isTapeEnabled()) {
return true;
- } else {
- return storiFile.getLocalFile().isOnDisk();
}
+ return storiFile.getLocalFile().isOnDisk();
}
private boolean verifySurlStatusTransition(TSURL surl,
@@ -404,7 +399,7 @@ private boolean verifySurlStatusTransition(TSURL surl,
private void printOutcome(String dn, TSURL surl, TReturnStatus status) {
- log.info("Finished handling BoL chunk for user DN: " + dn + "; for SURL: "
- + surl + "; result is: " + status);
+ log.info("Finished handling BoL chunk for user DN: {}; for SURL: {}; "
+ + "result is: {}", dn, surl, status);
}
}
diff --git a/src/main/java/it/grid/storm/asynch/BoLFeeder.java b/src/main/java/it/grid/storm/asynch/BoLFeeder.java
index fa1c21df..cbb759b4 100644
--- a/src/main/java/it/grid/storm/asynch/BoLFeeder.java
+++ b/src/main/java/it/grid/storm/asynch/BoLFeeder.java
@@ -123,14 +123,16 @@ public BoLFeeder(RequestSummaryData rsd)
throw new InvalidBoLFeederAttributesException(rsd, null, null);
}
try {
+
gu = rsd.gridUser();
this.rsd = rsd;
gsm = new GlobalStatusManager(rsd.requestToken());
+
} catch (InvalidOverallRequestAttributeException e) {
- log
- .error("ATTENTION in BoLFeeder! Programming bug when creating GlobalStatusManager! "
- + e);
+
+ log.error(e.getMessage(), e);
throw new InvalidBoLFeederAttributesException(rsd, gu, null);
+
}
}
@@ -141,7 +143,7 @@ public BoLFeeder(RequestSummaryData rsd)
*/
public void doIt() {
- log.debug("BoLFeeder: pre-processing " + rsd.requestToken());
+ log.debug("BoLFeeder: pre-processing {}", rsd.requestToken());
// Get all parts in request
Collection chunks = BoLChunkCatalog.getInstance()
.lookup(rsd.requestToken());
@@ -153,7 +155,7 @@ public void doIt() {
"This SRM Get request contained nothing to process!");
} else {
manageChunks(chunks);
- log.debug("BoLFeeder: finished pre-processing " + rsd.requestToken());
+ log.debug("BoLFeeder: finished pre-processing {}", rsd.requestToken());
}
}
@@ -163,7 +165,7 @@ public void doIt() {
*/
private void manageChunks(Collection chunks) {
- log.debug("BoLFeeder - number of chunks in request: " + chunks.size());
+ log.debug("BoLFeeder - number of chunks in request: {}", chunks.size());
for (BoLPersistentChunkData chunkData : chunks) {
/* add chunk for global status consideration */
gsm.addChunk(chunkData);
@@ -184,9 +186,9 @@ private void manageChunks(Collection chunks) {
* fromSURL does _not_ correspond to this installation of StoRM: fail
* chunk!
*/
- log.warn("BoLFeeder: srmBoL contract violation! fromSURL"
- + " does not correspond to this machine!\n Request: "
- + rsd.requestToken() + "\n Chunk: " + chunkData);
+ log.warn("BoLFeeder: srmBoL contract violation! fromSURL does not "
+ + "correspond to this machine!\n Request: {}\n Chunk: {}",
+ rsd.requestToken(), chunkData);
chunkData.changeStatusSRM_FAILURE("SRM protocol violation! "
+ "Cannot do an srmBoL of a SURL that is not local!");
@@ -221,10 +223,10 @@ private void manageNotDirectory(BoLPersistentChunkData auxChunkData) {
* for some reason gu, rsd or auxChunkData may be null! This should not be
* so!
*/
- log.error("UNEXPECTED ERROR in BoLFeeder! Chunk could not be created!\n"
- + e);
- log.error("Request: " + rsd.requestToken());
- log.error("Chunk: " + auxChunkData);
+ log.error("UNEXPECTED ERROR in BoLFeeder! Chunk could not be "
+ + "created!\n{}", e.getMessage(), e);
+ log.error("Request: {}" + rsd.requestToken());
+ log.error("Chunk: {}" + auxChunkData);
auxChunkData.changeStatusSRM_FAILURE("StoRM internal error does"
+ " not allow this chunk to be processed!");
@@ -233,11 +235,10 @@ private void manageNotDirectory(BoLPersistentChunkData auxChunkData) {
gsm.failedChunk(auxChunkData);
} catch (SchedulerException e) {
/* Internal error of scheduler! */
- log
- .error("UNEXPECTED ERROR in ChunkScheduler! Chunk could not be scheduled!\n"
- + e);
- log.error("Request: " + rsd.requestToken());
- log.error("Chunk: " + auxChunkData);
+ log.error("UNEXPECTED ERROR in ChunkScheduler! Chunk could not be "
+ + "scheduled!\n{}", e.getMessage(), e);
+ log.error("Request: {}", rsd.requestToken());
+ log.error("Chunk: {}", auxChunkData);
auxChunkData.changeStatusSRM_FAILURE("StoRM internal scheduler "
+ "error prevented this chunk from being processed!");
@@ -254,105 +255,104 @@ private void manageNotDirectory(BoLPersistentChunkData auxChunkData) {
private void manageIsDirectory(BoLPersistentChunkData chunkData) {
log.debug("BoLFeeder - pre-processing Directory chunk...");
- chunkData
- .changeStatusSRM_REQUEST_INPROGRESS("srmBringOnLine chunk is being processed!");
+ chunkData.changeStatusSRM_REQUEST_INPROGRESS("srmBringOnLine chunk "
+ + "is being processed!");
BoLChunkCatalog.getInstance().update(chunkData);
- try {
- StoRI stori = null;
- try {
- stori = NamespaceDirector.getNamespace().resolveStoRIbySURL(
- chunkData.getSURL(), gu);
- } catch (IllegalArgumentException e) {
- log.error("Unable to build StoRI by SURL and user", e);
- chunkData
- .changeStatusSRM_INTERNAL_ERROR("Unable to build StoRI by SURL and user");
- BoLChunkCatalog.getInstance().update(chunkData);
+ TSURL surl = chunkData.getSURL();
+ String user = DataHelper.getRequestor(chunkData);
- log.debug("ATTENTION in BoLFeeder! BoLFeeder received request"
- + " for a SURL and user not recognised by StoRI!");
- gsm.failedChunk(chunkData);
- } catch (UnapprochableSurlException e) {
- chunkData.changeStatusSRM_AUTHORIZATION_FAILURE(e.getMessage());
- BoLChunkCatalog.getInstance().update(chunkData);
- log.info("Unable to build a stori for surl " + chunkData.getSURL()
- + " for user " + DataHelper.getRequestor(chunkData)
- + " UnapprochableSurlException: " + e.getMessage());
- gsm.failedChunk(chunkData);
- } catch (NamespaceException e) {
- chunkData.changeStatusSRM_INTERNAL_ERROR(e.getMessage());
- BoLChunkCatalog.getInstance().update(chunkData);
- log.info("Unable to build a stori for surl " + chunkData.getSURL()
- + " for user " + DataHelper.getRequestor(chunkData)
- + " NamespaceException: " + e.getMessage());
- gsm.failedChunk(chunkData);
- } catch (InvalidSURLException e) {
- chunkData.changeStatusSRM_INVALID_PATH(e.getMessage());
+ StoRI stori = null;
+ try {
+ stori = NamespaceDirector.getNamespace().resolveStoRIbySURL(surl, gu);
+ } catch (IllegalArgumentException e) {
+ log.error("Unable to build a stori for surl {} for user {}. "
+ + "IllegalArgumentException: {}", surl, user, e.getMessage(), e);
+ chunkData.changeStatusSRM_INTERNAL_ERROR(e.getMessage());
+ } catch (UnapprochableSurlException e) {
+ log.info("Unable to build a stori for surl {} for user {}. "
+ + "UnapprochableSurlException: {}", surl, user, e.getMessage());
+ chunkData.changeStatusSRM_AUTHORIZATION_FAILURE(e.getMessage());
+ } catch (NamespaceException e) {
+ log.error("Unable to build a stori for surl {} for user {}. "
+ + "NamespaceException: {}", surl, user, e.getMessage(), e);
+ chunkData.changeStatusSRM_INTERNAL_ERROR(e.getMessage());
+ } catch (InvalidSURLException e) {
+ log.info("Unable to build a stori for surl {} for user {}. "
+ + "InvalidSURLException: {}", surl, user, e.getMessage());
+ chunkData.changeStatusSRM_INVALID_PATH(e.getMessage());
+ } finally {
+ if (stori == null) {
+ // failed:
BoLChunkCatalog.getInstance().update(chunkData);
- log.info("Unable to build a stori for surl " + chunkData.getSURL()
- + " for user " + DataHelper.getRequestor(chunkData)
- + " InvalidSURLException: " + e.getMessage());
gsm.failedChunk(chunkData);
+ return;
}
- if (stori != null) {
- /* Collection of children! */
- Collection storiChildren = stori.getChildren(chunkData
- .getDirOption());
- log.debug("BoLFeeder - Number of children in parent: "
- + storiChildren.size());
-
- TDirOption notDir = new TDirOption(false, false, 0);
- BoLPersistentChunkData childData;
- for (StoRI storiChild : storiChildren) {
- try {
- childData = new BoLPersistentChunkData(chunkData.getRequestToken(),
- storiChild.getSURL(), chunkData.getLifeTime(), notDir,
- chunkData.getTransferProtocols(), chunkData.getFileSize(),
- chunkData.getStatus(), chunkData.getTransferURL(),
- chunkData.getDeferredStartTime());
-
- /* fill in new db row and set the PrimaryKey of ChildData! */
- BoLChunkCatalog.getInstance().addChild(childData);
-
- log.debug("BoLFeeder - added child data: " + childData);
- /* add chunk for global status consideration */
- gsm.addChunk(childData);
-
- manageNotDirectory(childData);
- } catch (InvalidSurlRequestDataAttributesException e) {
- /*
- * For some reason it was not possible to create a BoLChunkData: it
- * is a programme bug!!! It should not occur!!! Log it and skip to
- * the next one!
- */
- log.error("ERROR in BoLFeeder! While expanding recursive request"
- + ", it was not possible to create a new BoLChunkData! " + e);
+ }
+
+ try {
+
+ /* Collection of children! */
+ Collection storiChildren = stori.getChildren(chunkData
+ .getDirOption());
+ log.debug("BoLFeeder - Number of children in parent: {}",
+ storiChildren.size());
+
+ TDirOption notDir = new TDirOption(false, false, 0);
+ BoLPersistentChunkData childData;
+
+ for (StoRI storiChild : storiChildren) {
+ try {
+ childData = new BoLPersistentChunkData(chunkData.getRequestToken(),
+ storiChild.getSURL(), chunkData.getLifeTime(), notDir,
+ chunkData.getTransferProtocols(), chunkData.getFileSize(),
+ chunkData.getStatus(), chunkData.getTransferURL(),
+ chunkData.getDeferredStartTime());
+
+ /* fill in new db row and set the PrimaryKey of ChildData! */
+ BoLChunkCatalog.getInstance().addChild(childData);
+
+ log.debug("BoLFeeder - added child data: {}", childData);
+ /* add chunk for global status consideration */
+ gsm.addChunk(childData);
+
+ manageNotDirectory(childData);
+ } catch (InvalidSurlRequestDataAttributesException e) {
+ /*
+ * For some reason it was not possible to create a BoLChunkData: it
+ * is a programme bug!!! It should not occur!!! Log it and skip to
+ * the next one!
+ */
+ log.error("ERROR in BoLFeeder! While expanding recursive request, "
+ + "it was not possible to create a new BoLChunkData! {}",
+ e.getMessage(), e);
}
}
- log.debug("BoLFeeder - expansion completed."); // info
+ log.debug("BoLFeeder - expansion completed.");
chunkData.changeStatusSRM_SUCCESS("srmBringOnLine with dirOption"
+ " set: request successfully expanded!");
BoLChunkCatalog.getInstance().update(chunkData);
gsm.successfulChunk(chunkData);
- }
+
} catch (InvalidTDirOptionAttributesException e) {
+
/* Could not create TDirOption that specifies no-expansion! */
chunkData.changeStatusSRM_FAILURE("srmBringOnLine with dirOption set:"
+ " expansion failure due to internal error!");
BoLChunkCatalog.getInstance().update(chunkData);
- log.error("UNEXPECTED ERROR in BoLFeeder! Could"
- + " not create TDirOption specifying non-expansion!\n" + e);
- log.error("Request: " + rsd.requestToken());
- log.error("Chunk: " + chunkData);
+ log.error("UNEXPECTED ERROR in BoLFeeder! Could not create TDirOption "
+ + "specifying non-expansion!\n{}", e.getMessage(), e);
+ log.error("Request: {}", rsd.requestToken());
+ log.error("Chunk: {}", chunkData);
gsm.failedChunk(chunkData);
+
} catch (InvalidDescendantsEmptyRequestException e) {
- chunkData
- .changeStatusSRM_SUCCESS("BEWARE! srmBringOnLine with dirOption set:"
- + " it referred to a directory that was empty!");
+ chunkData.changeStatusSRM_SUCCESS("BEWARE! srmBringOnLine with "
+ + "dirOption set: it referred to a directory that was empty!");
BoLChunkCatalog.getInstance().update(chunkData);
@@ -361,32 +361,34 @@ private void manageIsDirectory(BoLPersistentChunkData chunkData) {
gsm.successfulChunk(chunkData);
} catch (InvalidDescendantsPathRequestException e) {
+
/* Attempting to expand non existent directory! */
- chunkData
- .changeStatusSRM_INVALID_PATH("srmBringOnLine with dirOption set:"
- + " it referred to a non-existent directory!");
+ chunkData.changeStatusSRM_INVALID_PATH("srmBringOnLine with dirOption "
+ + "set: it referred to a non-existent directory!");
BoLChunkCatalog.getInstance().update(chunkData);
- log.debug("ATTENTION in BoLFeeder! BoLFeeder received request"
- + " to expand non-existing directory.");
+ log.debug("ATTENTION in BoLFeeder! BoLFeeder received request to expand "
+ + "non-existing directory.");
gsm.failedChunk(chunkData);
+
} catch (InvalidDescendantsFileRequestException e) {
+
/* Attempting to expand a file! */
- chunkData
- .changeStatusSRM_INVALID_PATH("srmBringOnLine with dirOption set: "
- + "a file was asked to be expanded!");
+ chunkData.changeStatusSRM_INVALID_PATH("srmBringOnLine with dirOption "
+ + "set: a file was asked to be expanded!");
BoLChunkCatalog.getInstance().update(chunkData);
- log
- .debug("ATTENTION in BoLFeeder! BoLFeeder received request to expand a file.");
+ log.debug("ATTENTION in BoLFeeder! BoLFeeder received request to expand "
+ + "a file.");
gsm.failedChunk(chunkData);
+
} catch (InvalidDescendantsAuthRequestException e) {
+
/* No rights to directory! */
- chunkData
- .changeStatusSRM_AUTHORIZATION_FAILURE("srmBringOnLine with dirOption set:"
- + " user has no right to access directory!");
+ chunkData.changeStatusSRM_AUTHORIZATION_FAILURE("srmBringOnLine with "
+ + "dirOption set: user has no right to access directory!");
BoLChunkCatalog.getInstance().update(chunkData);
diff --git a/src/main/java/it/grid/storm/asynch/BoLPersistentChunk.java b/src/main/java/it/grid/storm/asynch/BoLPersistentChunk.java
index dfd56be2..b45643fc 100644
--- a/src/main/java/it/grid/storm/asynch/BoLPersistentChunk.java
+++ b/src/main/java/it/grid/storm/asynch/BoLPersistentChunk.java
@@ -128,15 +128,13 @@ public Boolean completeRequest(TapeRecallStatus recallStatus) {
persistStatus();
if (requestSuccessfull) {
gsm.successfulChunk((BoLPersistentChunkData) requestData);
- log.info("Completed BoL request (" + rsd.requestToken()
- + "), file successfully recalled from tape: "
- + requestData.getSURL().toString());
+ log.info(
+ "Completed BoL request ({}), file successfully recalled from tape: {}",
+ rsd.requestToken(), requestData.getSURL().toString());
} else {
gsm.failedChunk((BoLPersistentChunkData) requestData);
- log
- .error("BoL request (" + requestData.getRequestToken()
- + "), file not recalled from tape: "
- + requestData.getSURL().toString());
+ log.error("BoL request ({}), file not recalled from tape: {}",
+ requestData.getRequestToken(), requestData.getSURL().toString());
}
return requestSuccessfull;
}
@@ -148,8 +146,8 @@ public Boolean completeRequest(TapeRecallStatus recallStatus) {
@Override
public String getName() {
- return "BoLChunk of request " + rsd.requestToken() + " for SURL "
- + requestData.getSURL();
+ return String.format("BoLChunk of request %s for SURL %s",
+ rsd.requestToken(), requestData.getSURL());
}
public String getRequestToken() {
@@ -167,12 +165,15 @@ public void updateGlobalStatus() {
* a SUCCESS in the corresponding row (and the file will have been
* recalled).
*/
- if (requestData.getStatus().getStatusCode() != TStatusCode.SRM_REQUEST_INPROGRESS) {
- if (failure) {
- gsm.failedChunk((BoLPersistentChunkData) requestData);
- } else {
- gsm.successfulChunk((BoLPersistentChunkData) requestData);
- }
+ if (TStatusCode.SRM_REQUEST_INPROGRESS.equals(requestData.getStatus()
+ .getStatusCode())) {
+
+ return;
+ }
+ if (failure) {
+ gsm.failedChunk((BoLPersistentChunkData) requestData);
+ } else {
+ gsm.successfulChunk((BoLPersistentChunkData) requestData);
}
}
diff --git a/src/main/java/it/grid/storm/asynch/Copy.java b/src/main/java/it/grid/storm/asynch/Copy.java
index a1891bb4..85387b57 100644
--- a/src/main/java/it/grid/storm/asynch/Copy.java
+++ b/src/main/java/it/grid/storm/asynch/Copy.java
@@ -100,8 +100,8 @@ public Copy(GridUserInterface gu, CopyData requestData, int n)
.getTime());
} catch (InvalidTRequestTokenAttributesException e) {
// never thrown
- log.error("Unexpected InvalidTRequestTokenAttributesException: "
- + e.getMessage());
+ log.error("Unexpected InvalidTRequestTokenAttributesException: {}",
+ e.getMessage(), e);
throw new IllegalStateException(
"Unexpected InvalidTRequestTokenAttributesException");
}
@@ -141,16 +141,18 @@ public void choose(Streets s) {
*/
public void doIt() {
- log.debug("Handling Copy chunk for user DN: " + this.gu.getDn()
- + "; fromSURL: " + this.requestData.getSURL() + "; toSURL: "
- + this.requestData.getDestinationSURL());
- log.debug("RequestToken used for local operation: " + localrt);
+ log.debug("Handling Copy chunk for user DN: {}; fromSURL: {}; toSURL: {}",
+ gu.getDn(), requestData.getSURL(), requestData.getDestinationSURL());
+
+ log.debug("RequestToken used for local operation: {}", localrt);
GetOperationResult getResult = executeGetOperation();
- log.debug("Result from get: " + getResult);
+ log.debug("Result from get: {}", getResult);
+
if (getResult.successful()
- && getResult.status().getStatusCode() == TStatusCode.SRM_FILE_PINNED) {
+ && TStatusCode.SRM_FILE_PINNED.equals(getResult.status().getStatusCode())) {
+
PutOperationResult putResult = executePutOperation(getResult.filesize());
- log.debug("Result from put: " + putResult);
+ log.debug("Result from put: {}", putResult);
/*
* ATTENTION! the following check for SRM_SUCCESS is done to keep
* compatibility between StoRM servers which use a hack thereby switching
@@ -162,15 +164,16 @@ public void doIt() {
&& ((putResult.status().getStatusCode()
.equals(TStatusCode.SRM_SPACE_AVAILABLE)) || (putResult.status()
.getStatusCode().equals(TStatusCode.SRM_SUCCESS)))) {
+
TransferResult transferResult = executeTransfer(getResult, putResult);
- log.debug("Result from transfer: " + transferResult);
+ log.debug("Result from transfer: {}", transferResult);
if (transferResult.successful()) {
requestData.changeStatusSRM_SUCCESS("srmCopy successfully handled!");
log.debug("SRM Copy successful!");
this.failure = false; // gsm.successfulChunk(chunkData);
} else {
- String message = "GSIFTP transfer failed! "
- + transferResult.failureExplanation();
+ String message = String.format("GSIFTP transfer failed! %s",
+ transferResult.failureExplanation());
log.error(message);
requestData.changeStatusSRM_FAILURE(message);
this.failure = true; // gsm.failedChunk(chunkData);
@@ -178,28 +181,20 @@ public void doIt() {
} else {
// The put operation was problematic!
String message = "PUT part of srmCopy failed! ";
- if (putResult.successful()) {
- message = message + putResult.status().toString();
- }
log.error(message);
- requestData.changeStatusSRM_FAILURE("PUT part of srmCopy failed! "
- + message);
+ requestData.changeStatusSRM_FAILURE(message);
this.failure = true;
}
} else {
// the get operation was problematic!
String message = "GET part of srmCopy failed! ";
- if (getResult.successful()) {
- message = message + getResult.status().toString();
- }
log.error(message);
requestData.changeStatusSRM_FAILURE(message);
- this.failure = true; // gsm.failedChunk(chunkData);
+ this.failure = true;
}
- log.info("Finished handling Copy chunk for user DN: " + this.gu.getDn()
- + "; fromSURL: " + this.requestData.getSURL() + "; toSURL: "
- + this.requestData.getDestinationSURL() + " result is: "
- + this.requestData.getStatus());
+ log.info("Finished handling Copy chunk for user DN: {}; fromSURL: {}; "
+ + "toSURL: {} result is: {}", gu.getDn(), requestData.getSURL(),
+ requestData.getDestinationSURL(), requestData.getStatus());
}
/**
@@ -208,8 +203,8 @@ public void doIt() {
*/
public String getName() {
- return "Copy for SURL " + requestData.getSURL() + " to SURL "
- + requestData.getDestinationSURL();
+ return String.format("Copy for SURL %s to SURL %s", requestData.getSURL(),
+ requestData.getDestinationSURL());
}
@Override
@@ -271,8 +266,6 @@ protected class TransferResult implements Result {
private boolean successful = false;
private String failureExplanation = "";
- private final Copy.ResultType type = Copy.ResultType.TRANSFER;
-
/**
* Constructor used to indicate a failed transfer: it requires a String
* explaining the failure.
@@ -325,7 +318,6 @@ public String failureExplanation() {
*/
protected class GetOperationResult implements Result {
- private final Copy.ResultType type = Copy.ResultType.GET;
/**
* boolean indicating if the operation was successful
*/
@@ -377,7 +369,7 @@ public GetOperationResult(TReturnStatus status, TTURL getTURL,
try {
this.status = new TReturnStatus();
} catch (InvalidTReturnStatusAttributeException e) {
- log.warn("Unexpected InvalidTReturnStatusAttributeException: " + e);
+ log.warn("Unexpected InvalidTReturnStatusAttributeException: {}", e);
}
}
}
@@ -397,7 +389,7 @@ public GetOperationResult(String failureExplanation) {
try {
this.status = new TReturnStatus();
} catch (InvalidTReturnStatusAttributeException e) {
- log.warn("Unexpected InvalidTReturnStatusAttributeException: " + e);
+ log.warn("Unexpected InvalidTReturnStatusAttributeException: {}", e);
}
}
@@ -452,9 +444,9 @@ public TRequestToken requetToken() {
@Override
public String toString() {
- return "GetOperationResult: successful=" + successful + "; status="
- + status + "; getTURL=" + getTURL + "; filesize=" + filesize
- + "; requestToken=" + rt;
+ return String.format("GetOperationResult: successful=%b; status=%s; "
+ + "getTURL=%s; filesize=%s; requestToken=%s", successful, status,
+ getTURL, filesize, rt);
}
}
@@ -471,15 +463,11 @@ public String toString() {
*/
protected class PutOperationResult implements Result {
- private final Copy.ResultType type = Copy.ResultType.PUT;
-
- private boolean successful = false; // boolean indicating if the operation
- // was successful
- private TReturnStatus status; // TReturnStatus from srmPrepareToGet
- private TTURL putTURL = TTURL.makeEmpty(); // TURL from srmPrepareToGet
- private String failureExplanation = ""; // String containing an explanation
- // of failure
- private TRequestToken rt = null; // TRequestToken associated to PtP
+ private boolean successful = false;
+ private TReturnStatus status;
+ private TTURL putTURL = TTURL.makeEmpty();
+ private String failureExplanation = "";
+ private TRequestToken rt = null;
/**
* Constructor to make a successful PutOperationResult containing the
@@ -500,7 +488,7 @@ public PutOperationResult(TReturnStatus status, TTURL putTURL,
try {
this.status = new TReturnStatus();
} catch (InvalidTReturnStatusAttributeException e) {
- log.warn("Unexpected InvalidTReturnStatusAttributeException: " + e);
+ log.warn("Unexpected InvalidTReturnStatusAttributeException: {}", e);
}
}
}
@@ -520,7 +508,7 @@ public PutOperationResult(String failureExplanation) {
try {
this.status = new TReturnStatus();
} catch (InvalidTReturnStatusAttributeException e) {
- log.warn("Unexpected InvalidTReturnStatusAttributeException: " + e);
+ log.warn("Unexpected InvalidTReturnStatusAttributeException: {}", e);
}
}
@@ -568,9 +556,9 @@ public TRequestToken requestToken() {
@Override
public String toString() {
- return "PutOperationResult: successful=" + successful + "; status="
- + status + "; putTURL=" + putTURL + "; failureExplanation="
- + failureExplanation;
+ return String.format("PutOperationResult: successful=%b; status=%s; "
+ + "putTURL=%s; failureExplanation=%s", successful, status, putTURL,
+ failureExplanation);
}
}
}
diff --git a/src/main/java/it/grid/storm/asynch/CopyFeeder.java b/src/main/java/it/grid/storm/asynch/CopyFeeder.java
index 9d428d95..ac29379f 100644
--- a/src/main/java/it/grid/storm/asynch/CopyFeeder.java
+++ b/src/main/java/it/grid/storm/asynch/CopyFeeder.java
@@ -86,7 +86,7 @@ public CopyFeeder(RequestSummaryData rsd)
gsm = new GlobalStatusManager(rsd.requestToken());
} catch (InvalidOverallRequestAttributeException e) {
log.error("ATTENTION in CopyFeeder! "
- + "Programming bug when creating GlobalStatusManager! " + e);
+ + "Programming bug when creating GlobalStatusManager! {}", e);
throw new InvalidCopyFeederAttributesException(rsd, gu, gsm);
}
}
@@ -102,14 +102,13 @@ public void doIt() {
Collection chunks = CopyChunkCatalog.getInstance()
.lookup(rsd.requestToken());
if (chunks.isEmpty()) {
- log.warn("ATTENTION in CopyFeeder! "
- + "This SRM Copy request contained nothing to process! "
- + rsd.requestToken());
+ log.warn("ATTENTION in CopyFeeder! This SRM Copy request contained "
+ + "nothing to process! {}", rsd.requestToken());
RequestSummaryCatalog.getInstance().failRequest(rsd,
"This SRM Copy request contained nothing to process!");
} else {
manageChunks(chunks);
- log.debug("CopyFeeder: finished pre-processing " + rsd.requestToken());
+ log.debug("CopyFeeder: finished pre-processing {}", rsd.requestToken());
}
}
@@ -119,7 +118,7 @@ public void doIt() {
*/
private void manageChunks(Collection chunksData) {
- log.debug("CopyFeeder: number of chunks in request " + chunksData.size());
+ log.debug("CopyFeeder: number of chunks in request {}", chunksData.size());
int counter = 0; // counter of the number of chunk retrieved
for (CopyPersistentChunkData chunkData : chunksData) {
/* Add chunk for global status consideration */
@@ -156,8 +155,8 @@ private void manage(CopyPersistentChunkData chunkData, int counter) {
* CHANGED SOON!!! ONLY FOR DEBUG PURPOSES!!!
*/
log.info("CopyFeeder: chunk is localCopy.");
- log.debug("Request: " + rsd.requestToken());
- log.debug("Chunk: " + chunkData);
+ log.debug("Request: {}", rsd.requestToken());
+ log.debug("Chunk: {]", chunkData);
SchedulerFacade
.getInstance()
@@ -173,8 +172,8 @@ private void manage(CopyPersistentChunkData chunkData, int counter) {
* copy to destination!
*/
log.info("CopyFeeder: chunk is pushCopy.");
- log.debug("Request: " + rsd.requestToken());
- log.debug("Chunk: " + chunkData);
+ log.debug("Request: {}", rsd.requestToken());
+ log.debug("Chunk: {}", chunkData);
SchedulerFacade
.getInstance()
@@ -194,11 +193,11 @@ private void manage(CopyPersistentChunkData chunkData, int counter) {
* WARNING!!! OPERATION NOT SUPPORTED!!! MUST BE CHANGED SOON!!!
*/
log.warn("CopyFeeder: srmCopy in pull mode NOT supported yet!");
- log.debug("Request: " + rsd.requestToken());
- log.debug("Chunk: " + chunkData);
+ log.debug("Request: {}", rsd.requestToken());
+ log.debug("Chunk: {}", chunkData);
- chunkData.changeStatusSRM_NOT_SUPPORTED("srmCopy in pull "
- + "mode NOT supported yet!");
+ chunkData
+ .changeStatusSRM_NOT_SUPPORTED("srmCopy in pull mode NOT supported yet!");
CopyChunkCatalog.getInstance().update(chunkData);
/*
@@ -213,11 +212,11 @@ private void manage(CopyPersistentChunkData chunkData, int counter) {
log.warn("CopyFeeder: srmCopy contract violation! Neither fromSURL"
+ " nor toSURL are this machine! Cannot do a third party SRM"
+ " transfer as per protocol!");
- log.warn("Request: " + rsd.requestToken());
- log.warn("Chunk: " + chunkData);
+ log.warn("Request: {}", rsd.requestToken());
+ log.warn("Chunk: {}", chunkData);
- chunkData.changeStatusSRM_FAILURE("SRM protocol violation"
- + "! Cannot do an srmCopy between third parties!");
+ chunkData
+ .changeStatusSRM_FAILURE("SRM protocol violation! Cannot do an srmCopy between third parties!");
CopyChunkCatalog.getInstance().update(chunkData);
/*
@@ -233,25 +232,24 @@ private void manage(CopyPersistentChunkData chunkData, int counter) {
*/
log.error("UNEXPECTED ERROR in CopyFeeder! Chunk could not be created!\n"
+ e);
- log.error("Request: " + rsd.requestToken());
- log.error("Chunk: " + chunkData);
+ log.error("Request: {}", rsd.requestToken());
+ log.error("Chunk: {}", chunkData);
- chunkData.changeStatusSRM_FAILURE("StoRM internal error does not"
- + " allow this chunk to be processed!");
+ chunkData
+ .changeStatusSRM_FAILURE("StoRM internal error does not allow this chunk to be processed!");
CopyChunkCatalog.getInstance().update(chunkData);
/* inform global status computation of the chunk s failure */
gsm.failedChunk(chunkData);
} catch (SchedulerException e) {
/* Internal error of scheduler! */
- log
- .error("UNEXPECTED ERROR in ChunkScheduler! Chunk could not be scheduled!\n"
- + e);
- log.error("Request: " + rsd.requestToken());
- log.error("Chunk: " + chunkData);
+ log.error("UNEXPECTED ERROR in ChunkScheduler! Chunk could not be "
+ + "scheduled!\n{}", e);
+ log.error("Request: {}", rsd.requestToken());
+ log.error("Chunk: {}", chunkData);
- chunkData.changeStatusSRM_FAILURE("StoRM internal scheduler "
- + "error prevented this chunk from being processed!");
+ chunkData
+ .changeStatusSRM_FAILURE("StoRM internal scheduler error prevented this chunk from being processed!");
CopyChunkCatalog.getInstance().update(chunkData);
/* inform global status computation of the chunk s failure */
diff --git a/src/main/java/it/grid/storm/asynch/GlobalStatusManager.java b/src/main/java/it/grid/storm/asynch/GlobalStatusManager.java
index cb860c8b..19871a5b 100644
--- a/src/main/java/it/grid/storm/asynch/GlobalStatusManager.java
+++ b/src/main/java/it/grid/storm/asynch/GlobalStatusManager.java
@@ -78,20 +78,28 @@ public GlobalStatusManager(TRequestToken rt)
*/
synchronized public void addChunk(ChunkData c) {
- log.debug("GlobalStatusManager: asked to add chunkData "
- + c.getIdentifier());
- if ((!finished) && (c != null)) {
- if (chunks.contains(new Long(c.getIdentifier()))) {
- log
- .warn("GlobalStatusManager: chunkData NOT added because of another chunkData already added with the same identifier");
- } else {
- chunks.add(new Long(c.getIdentifier()));
- log.debug("GlobalStatusManager: chunkData added.");
- }
- } else {
- log
- .warn("GlobalStatusManager: chunkData NOT added because either it is null or finishedAdding has already been invoked!");
+ if (c == null) {
+ log.warn("GlobalStatusManager: chunkData NOT added because it is null!");
+ return;
+ }
+
+ log.debug("GlobalStatusManager: asked to add chunkData {}",
+ c.getIdentifier());
+
+ if (finished) {
+ log.warn("GlobalStatusManager: chunkData NOT added because finishedAdding "
+ + "has already been invoked!");
+ return;
+ }
+
+ if (chunks.contains(new Long(c.getIdentifier()))) {
+ log.warn("GlobalStatusManager: chunkData NOT added because of another "
+ + "chunkData already added with the same identifier");
+ return;
}
+
+ chunks.add(new Long(c.getIdentifier()));
+ log.debug("GlobalStatusManager: chunkData added.");
}
/**
@@ -103,20 +111,23 @@ synchronized public void finishedAdding() {
log.debug("GlobalStatusManager: received finishedAdding signal.");
this.finished = true;
- if (chunks.isEmpty()) {
- // finishedAdding invoked after _all_ ChunkData were processed!
- // make final state transition
- if (internal == InternalState.INTERMEDIATE_SUCCESS) {
- internal = InternalState.SUCCESS;
- } else if (internal == InternalState.INTERMEDIATE_FAIL) {
- internal = InternalState.FAIL;
- }
- // save state in persistence
- log
- .debug("GlobalStatusManager: since all chunks have been processed, saving final state "
- + internal);
- saveRequestState();
+
+ if (!chunks.isEmpty()) {
+ log.debug("Empty chunks!");
+ return;
+ }
+
+ // finishedAdding invoked after _all_ ChunkData were processed!
+ // do final state transition:
+ if (internal.equals(InternalState.INTERMEDIATE_SUCCESS)) {
+ internal = InternalState.SUCCESS;
+ } else if (internal.equals(InternalState.INTERMEDIATE_FAIL)) {
+ internal = InternalState.FAIL;
}
+ // save state in persistence
+ log.debug("GlobalStatusManager: since all chunks have been processed, "
+ + "saving final state {}", internal);
+ saveRequestState();
}
/**
@@ -127,99 +138,115 @@ synchronized public void finishedAdding() {
*/
synchronized public void successfulChunk(ChunkData c) {
- log.debug("GlobalStatusManager: received successfulChunk signal for " + c);
-
- if (c != null && !chunks.isEmpty()
- && chunks.remove(new Long(c.getIdentifier()))) {
-
- // manage state transition: c was indeed there
- if (finished && (chunks.isEmpty())) {
- // no other chunk will be added to request, and none is left: this was
- // the last one to be processed!
- log.debug("GlobalStatusManager: finished and no more chunks left... ");
- if (internal == InternalState.IN_PROGRESS) {
- internal = InternalState.SUCCESS;
- } else if (internal == InternalState.INTERMEDIATE_SUCCESS) {
- internal = InternalState.SUCCESS;
- } else if (internal == InternalState.INTERMEDIATE_FAIL) {
- internal = InternalState.PARTIAL;
- } else if (internal == InternalState.PARTIAL) {
- internal = InternalState.PARTIAL; // stays the same!
- } else if (internal == InternalState.ERROR) {
- internal = InternalState.ERROR; // stays the same!
- } else {
- log
- .error("ERROR in GlobalStatusManager: programming bug! Unexpected InternalState: "
- + internal);
- }
-
- log.debug("GlobalStatusManager: saving final global state " + internal);
- saveRequestState();
-
- } else if (finished && (!chunks.isEmpty())) {
-
- // no chunk will be added to request, but there are _more_ left to be
- // processed!
- log
- .debug("GlobalStatusManager: finished but there are more chunks to be processed... ");
- if (internal == InternalState.IN_PROGRESS) {
- internal = InternalState.INTERMEDIATE_SUCCESS;
- } else if (internal == InternalState.INTERMEDIATE_SUCCESS) {
- internal = InternalState.INTERMEDIATE_SUCCESS; // stays the same!
- } else if (internal == InternalState.INTERMEDIATE_FAIL) {
- internal = InternalState.PARTIAL;
- } else if (internal == InternalState.PARTIAL) {
- internal = InternalState.PARTIAL; // stays the same!
- } else if (internal == InternalState.ERROR) {
- internal = InternalState.ERROR; // stays the same!
- } else {
- log
- .error("ERROR in GlobalStatusManager: programming bug! Unexpected InternalState: "
- + internal);
- }
- log.debug("GlobalStatusManager: transited to " + internal);
-
- } else if (!finished) {
-
- // more chunks may be added to request, and it is all the same if there
- // are or aren't any left to be
- // processed!
- log
- .debug("GlobalStatusManager: still not finished adding chunks for consideration, but it is the same whether there are more to be processed or not...");
- if (internal == InternalState.IN_PROGRESS) {
- internal = InternalState.INTERMEDIATE_SUCCESS;
- } else if (internal == InternalState.INTERMEDIATE_SUCCESS) {
- internal = InternalState.INTERMEDIATE_SUCCESS; // stays the same!
- } else if (internal == InternalState.INTERMEDIATE_FAIL) {
- internal = InternalState.PARTIAL;
- } else if (internal == InternalState.PARTIAL) {
- internal = InternalState.PARTIAL; // stays the same!
- } else if (internal == InternalState.ERROR) {
- internal = InternalState.ERROR; // stays the same!
- } else {
- log
- .error("ERROR in GlobalStatusManager: programming bug! Unexpected InternalState: "
- + internal);
- }
- log.debug("GlobalStatusManager: transited to " + internal);
+ log.debug("GlobalStatusManager: received successfulChunk signal for {}", c);
+ if (c == null) {
+ log.error("ERROR IN GLOBAL STATUS EVALUATION! There was an attempt to "
+ + "signal a successful Chunk, but it is null!");
+ log.error("Request: {}", rt);
+ log.error("Chunk: {}", c);
+ internal = InternalState.ERROR;
+ return;
+ }
+
+ if (chunks.isEmpty()) {
+ log.error("ERROR IN GLOBAL STATUS EVALUATION! There was an attempt to "
+ + "signal a successful Chunk, but there are actually no Chunks left to "
+ + "be considered!");
+ log.error("Request: {}", rt);
+ log.error("Chunk: {}", c);
+ internal = InternalState.ERROR;
+ return;
+ }
+
+ boolean removed = chunks.remove(new Long(c.getIdentifier()));
+
+ if (!removed) {
+ log.error("ERROR IN GLOBAL STATUS EVALUATION! There was an attempt to "
+ + "signal a successful Chunk, but it was not originally asked to be "
+ + "considered in the evaluation!");
+ log.error("Request: {}", rt);
+ log.error("Chunk: {}", c);
+ internal = InternalState.ERROR;
+ return;
+ }
+
+ // manage state transition: c was indeed there
+ if (finished && (chunks.isEmpty())) {
+ // no other chunk will be added to request, and none is left: this was
+ // the last one to be processed!
+ log.debug("GlobalStatusManager: finished and no more chunks left... ");
+ if (internal.equals(InternalState.IN_PROGRESS)) {
+ internal = InternalState.SUCCESS;
+ } else if (internal.equals(InternalState.INTERMEDIATE_SUCCESS)) {
+ internal = InternalState.SUCCESS;
+ } else if (internal.equals(InternalState.INTERMEDIATE_FAIL)) {
+ internal = InternalState.PARTIAL;
+ } else if (internal.equals(InternalState.PARTIAL)) {
+ internal = InternalState.PARTIAL; // stays the same!
+ } else if (internal.equals(InternalState.ERROR)) {
+ internal = InternalState.ERROR; // stays the same!
} else {
- // This cannot possibly occur by logic! But there could be
- // multithreading issues in case of bugs!
- log
- .error("ERROR IN GLOBAL STATUS EVALUATION! An impossible logic codition has materialised: it may be due to multithreading issues! Request is "
- + rt);
- internal = InternalState.ERROR;
+ log.error("ERROR in GlobalStatusManager: programming bug! Unexpected InternalState: {}", internal);
+ return;
}
+ log.debug("GlobalStatusManager: saving final global state {}", internal);
+ saveRequestState();
+ } else if (finished && (!chunks.isEmpty())) {
+
+ // no chunk will be added to request, but there are _more_ left to be
+ // processed!
+ log.debug("GlobalStatusManager: finished but there are more chunks to be processed... ");
+ if (internal.equals(InternalState.IN_PROGRESS)) {
+ internal = InternalState.INTERMEDIATE_SUCCESS;
+ } else if (internal.equals(InternalState.INTERMEDIATE_SUCCESS)) {
+ internal = InternalState.INTERMEDIATE_SUCCESS; // stays the same!
+ } else if (internal.equals(InternalState.INTERMEDIATE_FAIL)) {
+ internal = InternalState.PARTIAL;
+ } else if (internal.equals(InternalState.PARTIAL)) {
+ internal = InternalState.PARTIAL; // stays the same!
+ } else if (internal.equals(InternalState.ERROR)) {
+ internal = InternalState.ERROR; // stays the same!
+ } else {
+ log.error("ERROR in GlobalStatusManager: programming bug! Unexpected InternalState: {}", internal);
+ return;
+ }
+ log.debug("GlobalStatusManager: transited to {}", internal);
+
+ } else if (!finished) {
+
+ // more chunks may be added to request, and it is all the same if there
+ // are or aren't any left to be processed!
+ log.debug("GlobalStatusManager: still not finished adding chunks for "
+ + "consideration, but it is the same whether there are more to be "
+ + "processed or not...");
+
+ if (internal.equals(InternalState.IN_PROGRESS)) {
+ internal = InternalState.INTERMEDIATE_SUCCESS;
+ } else if (internal.equals(InternalState.INTERMEDIATE_SUCCESS)) {
+ internal = InternalState.INTERMEDIATE_SUCCESS; // stays the same!
+ } else if (internal.equals(InternalState.INTERMEDIATE_FAIL)) {
+ internal = InternalState.PARTIAL;
+ } else if (internal.equals(InternalState.PARTIAL)) {
+ internal = InternalState.PARTIAL; // stays the same!
+ } else if (internal.equals(InternalState.ERROR)) {
+ internal = InternalState.ERROR; // stays the same!
+ } else {
+ log.error("ERROR in GlobalStatusManager: programming bug! Unexpected InternalState: {}", internal);
+ return;
+ }
+
+ log.debug("GlobalStatusManager: transited to {}", internal);
} else {
- // error situation!
- log
- .error("ERROR IN GLOBAL STATUS EVALUATION! There was an attempt to signal a successful Chunk, but it is either null, or there are actually no Chunks left to be considered, or it was not originally asked to be considered in the evaluation!");
- log.error("Request: " + rt);
- log.error("Chunk: " + c);
- internal = InternalState.ERROR;
+ // This cannot possibly occur by logic! But there could be
+ // multithreading issues in case of bugs!
+ log.error("ERROR IN GLOBAL STATUS EVALUATION! An impossible logic "
+ + "condition has materialised: it may be due to multithreading issues! "
+ + "Request is {}", rt);
+ internal = InternalState.ERROR;
}
+
}
/**
@@ -230,88 +257,113 @@ synchronized public void successfulChunk(ChunkData c) {
*/
synchronized public void failedChunk(ChunkData c) {
- log.debug("GlobalStatusManager: received failedChunk signal for " + c);
- if ((c != null) && (!chunks.isEmpty())
- && chunks.remove(new Long(c.getIdentifier()))) {
- // manage state transition: c was indeed there
- if (finished && (chunks.isEmpty())) {
- // no other chunk will be added to request, and none is left: this was
- // the last one to be processed!
- log.debug("GlobalStatusManager: finished and no more chunks left... ");
- if (internal == InternalState.IN_PROGRESS) {
- internal = InternalState.FAIL;
- } else if (internal == InternalState.INTERMEDIATE_SUCCESS) {
- internal = InternalState.PARTIAL;
- } else if (internal == InternalState.INTERMEDIATE_FAIL) {
- internal = InternalState.FAIL;
- } else if (internal == InternalState.PARTIAL) {
- internal = InternalState.PARTIAL; // stays the same!
- } else if (internal == InternalState.ERROR) {
- internal = InternalState.ERROR; // stays the same!
- } else {
- log
- .error("ERROR in GlobalStatusManager: programming bug! Unexpected InternalState: "
- + internal);
- }
- log.debug("GlobalStatusManager: saving final global state " + internal);
- saveRequestState();
- } else if (finished && (!chunks.isEmpty())) {
- // no chunk will be added to request, but there are _more_ left to be
- // processed!
- log
- .debug("GlobalStatusManager: finished but there are more chunks to be processed... ");
- if (internal == InternalState.IN_PROGRESS) {
- internal = InternalState.INTERMEDIATE_FAIL;
- } else if (internal == InternalState.INTERMEDIATE_SUCCESS) {
- internal = InternalState.PARTIAL;
- } else if (internal == InternalState.INTERMEDIATE_FAIL) {
- internal = InternalState.INTERMEDIATE_FAIL; // stays the same!
- } else if (internal == InternalState.PARTIAL) {
- internal = InternalState.PARTIAL; // stays the same!
- } else if (internal == InternalState.ERROR) {
- internal = InternalState.ERROR; // stays the same!
- } else {
- log
- .error("ERROR in GlobalStatusManager: programming bug! Unexpected InternalState: "
- + internal);
- }
- log.debug("GlobalStatusManager: transited to " + internal);
- } else if (!finished) {
- // more chunks may be added to request, and it is all the same if there
- // are or arent any left to be
- // processed!
- log
- .debug("GlobalStatusManager: still not finished adding chunks for consideration, but it is the same whether there are more to be processed or not...");
- if (internal == InternalState.IN_PROGRESS) {
- internal = InternalState.INTERMEDIATE_FAIL;
- } else if (internal == InternalState.INTERMEDIATE_SUCCESS) {
- internal = InternalState.PARTIAL;
- } else if (internal == InternalState.INTERMEDIATE_FAIL) {
- internal = InternalState.INTERMEDIATE_FAIL; // stays the same!
- } else if (internal == InternalState.PARTIAL) {
- internal = InternalState.PARTIAL; // stays the same!
- } else if (internal == InternalState.ERROR) {
- internal = InternalState.ERROR; // stays the same!
- } else {
- log
- .error("ERROR in GlobalStatusManager: programming bug! Unexpected InternalState: "
- + internal);
- }
- log.debug("GlobalStatusManager: transited to " + internal);
+ log.debug("GlobalStatusManager: received failedChunk signal for {}", c);
+
+ if (c == null) {
+ log.error("ERROR IN GLOBAL STATUS EVALUATION! There was an attempt to "
+ + "signal a failed Chunk, but it is null!");
+ log.error("Request: {}", rt);
+ log.error("ChunkData: {}", c);
+ internal = InternalState.ERROR;
+ return;
+ }
+
+ if (chunks.isEmpty()) {
+ log.error("ERROR IN GLOBAL STATUS EVALUATION! There was an attempt to "
+ + "signal a failed Chunk, but there are actually no Chunks left to be "
+ + "considered!");
+ log.error("Request: {}", rt);
+ log.error("ChunkData: {}", c);
+ internal = InternalState.ERROR;
+ return;
+ }
+
+ boolean removed = chunks.remove(new Long(c.getIdentifier()));
+
+ if (!removed) {
+ log.error("ERROR IN GLOBAL STATUS EVALUATION! There was an attempt to "
+ + "signal a successful Chunk, but it was not originally asked to be "
+ + "considered in the evaluation!");
+ log.error("Request: {}", rt);
+ log.error("ChunkData: {}", c);
+ internal = InternalState.ERROR;
+ return;
+ }
+
+ // manage state transition: c was indeed there
+ if (finished && (chunks.isEmpty())) {
+ // no other chunk will be added to request, and none is left: this was
+ // the last one to be processed!
+ log.debug("GlobalStatusManager: finished and no more chunks left... ");
+ if (internal.equals(InternalState.IN_PROGRESS)) {
+ internal = InternalState.FAIL;
+ } else if (internal.equals(InternalState.INTERMEDIATE_SUCCESS)) {
+ internal = InternalState.PARTIAL;
+ } else if (internal.equals(InternalState.INTERMEDIATE_FAIL)) {
+ internal = InternalState.FAIL;
+ } else if (internal.equals(InternalState.PARTIAL)) {
+ internal = InternalState.PARTIAL; // stays the same!
+ } else if (internal.equals(InternalState.ERROR)) {
+ internal = InternalState.ERROR; // stays the same!
} else {
- // This cannot possibly occur by logic! But there could be
- // multithreading issues in case of bugs!
- log
- .error("ERROR IN GLOBAL STATUS EVALUATION! An impossible logic codition has materialised: it may be due to multithreading issues! Request is "
- + rt);
- internal = InternalState.ERROR;
+ log.error("ERROR in GlobalStatusManager: programming bug! "
+ + "Unexpected InternalState: {}", internal);
+ return;
+ }
+ log.debug("GlobalStatusManager: saving final global state {}", internal);
+ saveRequestState();
+ } else if (finished && (!chunks.isEmpty())) {
+ // no chunk will be added to request, but there are _more_ left to be
+ // processed!
+ log.debug("GlobalStatusManager: finished but there are more chunks to be "
+ + "processed... ");
+ if (internal.equals(InternalState.IN_PROGRESS)) {
+ internal = InternalState.INTERMEDIATE_FAIL;
+ } else if (internal.equals(InternalState.INTERMEDIATE_SUCCESS)) {
+ internal = InternalState.PARTIAL;
+ } else if (internal.equals(InternalState.INTERMEDIATE_FAIL)) {
+ internal = InternalState.INTERMEDIATE_FAIL; // stays the same!
+ } else if (internal.equals(InternalState.PARTIAL)) {
+ internal = InternalState.PARTIAL; // stays the same!
+ } else if (internal.equals(InternalState.ERROR)) {
+ internal = InternalState.ERROR; // stays the same!
+ } else {
+ log.error("ERROR in GlobalStatusManager: programming bug! Unexpected "
+ + "InternalState: {}", internal);
+ return;
+ }
+ log.debug("GlobalStatusManager: transited to {}", internal);
+
+ } else if (!finished) {
+ // more chunks may be added to request, and it is all the same if there
+ // are or arent any left to be processed!
+ log.debug("GlobalStatusManager: still not finished adding chunks for "
+ + "consideration, but it is the same whether there are more to be "
+ + "processed or not...");
+
+ if (internal.equals(InternalState.IN_PROGRESS)) {
+ internal = InternalState.INTERMEDIATE_FAIL;
+ } else if (internal.equals(InternalState.INTERMEDIATE_SUCCESS)) {
+ internal = InternalState.PARTIAL;
+ } else if (internal.equals(InternalState.INTERMEDIATE_FAIL)) {
+ internal = InternalState.INTERMEDIATE_FAIL; // stays the same!
+ } else if (internal.equals(InternalState.PARTIAL)) {
+ internal = InternalState.PARTIAL; // stays the same!
+ } else if (internal.equals(InternalState.ERROR)) {
+ internal = InternalState.ERROR; // stays the same!
+ } else {
+ log.error("ERROR in GlobalStatusManager: programming bug! Unexpected "
+ + "InternalState: {}", internal);
+ return;
}
+ log.debug("GlobalStatusManager: transited to " + internal);
+
} else {
- // error situation!
- log
- .error("ERROR IN GLOBAL STATUS EVALUATION! There was an attempt to signal a failed Chunk, but it is either null, or there are actually no Chunks left to be considered, or it was not originally asked to be considered in the evaluation!");
- log.error("Request: " + rt);
- log.error("ChunkData: " + c);
+ // This cannot possibly occur by logic! But there could be
+ // multithreading issues in case of bugs!
+ log.error("ERROR IN GLOBAL STATUS EVALUATION! An impossible logic "
+ + "condition has materialised: it may be due to multithreading issues! "
+ + "Request is {}", rt);
internal = InternalState.ERROR;
}
}
@@ -325,78 +377,107 @@ synchronized public void failedChunk(ChunkData c) {
*/
synchronized public void expiredSpaceLifetimeChunk(ChunkData c) {
- log
- .debug("GlobalStatusManager: received expiredSpaceLifetimeChunk signal for "
- + c);
- if ((c != null) && (!chunks.isEmpty())
- && chunks.remove(new Long(c.getIdentifier()))) {
- // manage state transition: c was indeed there
- if (finished && (chunks.isEmpty())) {
- // no other chunk will be added to request, and none is left: this was
- // the last one to be processed!
- log.debug("GlobalStatusManager: finished and no more chunks left... ");
- if (internal == InternalState.IN_PROGRESS) {
- internal = InternalState.SPACEFAIL;
- } else if (internal == InternalState.SPACEFAIL) {
- internal = InternalState.SPACEFAIL; // stays the same!
- } else if (internal == InternalState.ERROR) {
- internal = InternalState.ERROR; // stays the same!
- } else {
- log
- .error("ERROR in GlobalStatusManager: programming bug! Unexpected InternalState: "
- + internal);
- }
- log.debug("GlobalStatusManager: saving final global state " + internal);
- saveRequestState();
- } else if (finished && (!chunks.isEmpty())) {
- // no chunk will be added to request, but there are _more_ left to be
- // processed!
- log
- .debug("GlobalStatusManager: finished but there are more chunks to be processed... ");
- if (internal == InternalState.IN_PROGRESS) {
- internal = InternalState.SPACEFAIL;
- } else if (internal == InternalState.SPACEFAIL) {
- internal = InternalState.SPACEFAIL; // stays the same!
- } else if (internal == InternalState.ERROR) {
- internal = InternalState.ERROR; // stays the same!
- } else {
- log
- .error("ERROR in GlobalStatusManager: programming bug! Unexpected InternalState: "
- + internal);
- }
- log.debug("GlobalStatusManager: transited to " + internal);
- } else if (!finished) {
- // more chunks may be added to request, and it is all the same if there
- // are or arent any left to be
- // processed!
- log
- .debug("GlobalStatusManager: still not finished adding chunks for consideration, but it is the same whether there are more to be processed or not...");
- if (internal == InternalState.IN_PROGRESS) {
- internal = InternalState.SPACEFAIL;
- } else if (internal == InternalState.SPACEFAIL) {
- internal = InternalState.SPACEFAIL; // stays the same!
- } else if (internal == InternalState.ERROR) {
- internal = InternalState.ERROR; // stays the same!
- } else {
- log
- .error("ERROR in GlobalStatusManager: programming bug! Unexpected InternalState: "
- + internal);
- }
- log.debug("GlobalStatusManager: transited to " + internal);
+ log.debug("GlobalStatusManager: received expiredSpaceLifetimeChunk signal for {}", c);
+
+ if (c == null) {
+ log.error("ERROR IN GLOBAL STATUS EVALUATION! There was an attempt to "
+ + "signal a failed Chunk, but it is null!");
+ log.error("Request: {}", rt);
+ log.error("ChunkData: {}", c);
+ internal = InternalState.ERROR;
+ return;
+ }
+
+ if (chunks.isEmpty()) {
+ log.error("ERROR IN GLOBAL STATUS EVALUATION! There was an attempt to "
+ + "signal a failed Chunk, but there are actually no Chunks left to be "
+ + "considered!");
+ log.error("Request: {}", rt);
+ log.error("ChunkData: {}", c);
+ internal = InternalState.ERROR;
+ return;
+ }
+
+ boolean removed = chunks.remove(new Long(c.getIdentifier()));
+
+ if (!removed) {
+ log.error("ERROR IN GLOBAL STATUS EVALUATION! There was an attempt to "
+ + "signal a successful Chunk, but it was not originally asked to be "
+ + "considered in the evaluation!");
+ log.error("Request: {}", rt);
+ log.error("ChunkData: {}", c);
+ internal = InternalState.ERROR;
+ return;
+ }
+
+ // manage state transition: c was indeed there
+ if (finished && (chunks.isEmpty())) {
+
+ // no other chunk will be added to request, and none is left: this was
+ // the last one to be processed!
+ log.debug("GlobalStatusManager: finished and no more chunks left... ");
+ if (internal.equals(InternalState.IN_PROGRESS)) {
+ internal = InternalState.SPACEFAIL;
+ } else if (internal.equals(InternalState.SPACEFAIL)) {
+ internal = InternalState.SPACEFAIL; // stays the same!
+ } else if (internal.equals(InternalState.ERROR)) {
+ internal = InternalState.ERROR; // stays the same!
} else {
- // This cannot possibly occur by logic! But there could be
- // multithreading issues in case of bugs!
- log
- .error("ERROR IN GLOBAL STATUS EVALUATION! An impossible logic codition has materialised: it may be due to multithreading issues! Request is "
- + rt);
- internal = InternalState.ERROR;
+ log.error("ERROR in GlobalStatusManager: programming bug! Unexpected "
+ + "InternalState: {}", internal);
+ return;
}
+ log.debug("GlobalStatusManager: saving final global state {}", internal);
+ saveRequestState();
+
+ } else if (finished && (!chunks.isEmpty())) {
+
+ // no chunk will be added to request, but there are _more_ left to be
+ // processed!
+ log.debug("GlobalStatusManager: finished but there are more chunks to be "
+ + "processed... ");
+ if (internal.equals(InternalState.IN_PROGRESS)) {
+ internal = InternalState.SPACEFAIL;
+ } else if (internal.equals(InternalState.SPACEFAIL)) {
+ internal = InternalState.SPACEFAIL; // stays the same!
+ } else if (internal.equals(InternalState.ERROR)) {
+ internal = InternalState.ERROR; // stays the same!
+ } else {
+ log.error("ERROR in GlobalStatusManager: programming bug! Unexpected "
+ + "InternalState: {}", internal);
+ return;
+ }
+ log.debug("GlobalStatusManager: transited to {}", internal);
+
+ } else if (!finished) {
+
+ // more chunks may be added to request, and it is all the same if there
+ // are or arent any left to be processed!
+ log.debug("GlobalStatusManager: still not finished adding chunks for "
+ + "consideration, but it is the same whether there are more to be "
+ + "processed or not...");
+
+ if (internal.equals(InternalState.IN_PROGRESS)) {
+ internal = InternalState.SPACEFAIL;
+ } else if (internal.equals(InternalState.SPACEFAIL)) {
+ internal = InternalState.SPACEFAIL; // stays the same!
+ } else if (internal.equals(InternalState.ERROR)) {
+ internal = InternalState.ERROR; // stays the same!
+ } else {
+ log.error("ERROR in GlobalStatusManager: programming bug! Unexpected "
+ + "InternalState: {}", internal);
+ return;
+ }
+
+ log.debug("GlobalStatusManager: transited to {}", internal);
+
} else {
- // error situation!
- log
- .error("ERROR IN GLOBAL STATUS EVALUATION! There was an attempt to signal a space failed Chunk, but it is either null, or there are actually no Chunks left to be considered, or it was not originally asked to be considered in the evaluation!");
- log.error("Request: " + rt);
- log.error("ChunkData: " + c);
+
+ // This cannot possibly occur by logic! But there could be
+ // multithreading issues in case of bugs!
+ log.error("ERROR IN GLOBAL STATUS EVALUATION! An impossible logic "
+ + "condition has materialised: it may be due to multithreading issues! "
+ + "Request is {}", rt);
internal = InternalState.ERROR;
}
}
@@ -414,48 +495,48 @@ private void saveRequestState() {
TReturnStatus retstat = null;
- if (internal == InternalState.ERROR) {
+ if (internal.equals(InternalState.ERROR)) {
updatePinFileLifetime = true;
retstat = new TReturnStatus(TStatusCode.SRM_PARTIAL_SUCCESS,
"Global status cannot be evaluated: single file status must be checked.");
- } else if (internal == InternalState.FAIL) {
+ } else if (internal.equals(InternalState.FAIL)) {
updatePinFileLifetime = false;
retstat = new TReturnStatus(TStatusCode.SRM_FAILURE,
"All chunks failed!");
- } else if (internal == InternalState.SUCCESS) {
+ } else if (internal.equals(InternalState.SUCCESS)) {
updatePinFileLifetime = true;
retstat = new TReturnStatus(TStatusCode.SRM_SUCCESS,
"All chunks successfully handled!");
- } else if (internal == InternalState.PARTIAL) {
+ } else if (internal.equals(InternalState.PARTIAL)) {
updatePinFileLifetime = true;
retstat = new TReturnStatus(TStatusCode.SRM_PARTIAL_SUCCESS,
"Some chunks were successful while others failed!");
- } else if (internal == InternalState.SPACEFAIL) {
+ } else if (internal.equals(InternalState.SPACEFAIL)) {
updatePinFileLifetime = false;
retstat = new TReturnStatus(TStatusCode.SRM_SPACE_LIFETIME_EXPIRED,
"Supplied SpaceToken has expired lifetime!");
+
} else {
updatePinFileLifetime = true;
retstat = new TReturnStatus(TStatusCode.SRM_PARTIAL_SUCCESS,
"Global status cannot be evaluated: single file status must be checked.");
- log
- .error("ERROR IN GLOBAL STATUS EVALUATION! "
- + internal
- + " was attempted to be written into persistence, but it is not a final state!");
- log.error("Request: " + rt);
+ log.error("ERROR IN GLOBAL STATUS EVALUATION! {} was attempted to be "
+ + "written into persistence, but it is not a final state!", internal);
+ log.error("Request: {}", rt);
+
}
- log.debug("GlobalStatusManager: saving into persistence " + retstat);
+ log.debug("GlobalStatusManager: saving into persistence {}", retstat);
if (updatePinFileLifetime) {
RequestSummaryCatalog.getInstance().updateGlobalStatusPinFileLifetime(
@@ -466,9 +547,8 @@ private void saveRequestState() {
}
} catch (InvalidTReturnStatusAttributeException e) {
- log
- .error("ERROR IN GLOBAL STATUS EVALUATION! Could not create a valid TReturnStatus: this is a programming bug! "
- + e);
+ log.error("ERROR IN GLOBAL STATUS EVALUATION! Could not create a valid "
+ + "TReturnStatus: this is a programming bug! {}", e);
}
}
diff --git a/src/main/java/it/grid/storm/asynch/InvalidBoLChunkAttributesException.java b/src/main/java/it/grid/storm/asynch/InvalidBoLChunkAttributesException.java
index 392e0f61..d6cea5db 100644
--- a/src/main/java/it/grid/storm/asynch/InvalidBoLChunkAttributesException.java
+++ b/src/main/java/it/grid/storm/asynch/InvalidBoLChunkAttributesException.java
@@ -55,8 +55,9 @@ public InvalidBoLChunkAttributesException(GridUserInterface gu,
public String toString() {
- return "Invalid attributes when creating BoLChunk: nullGridUser=" + nullGu
- + ", nullRequestSumamryData=" + nullRsd + "nullBoLChunkData="
- + nullChunkData + "nullGlobalStatusManager=" + nullGlobalStatusManager;
+ return String.format("Invalid attributes when creating BoLChunk: "
+ + "nullGridUser=%b; nullRequestSumamryData=%b; nullBoLChunkData=%b; "
+ + "nullGlobalStatusManager=%b" ,nullGu, nullRsd, nullChunkData,
+ nullGlobalStatusManager);
}
}
diff --git a/src/main/java/it/grid/storm/asynch/InvalidBoLFeederAttributesException.java b/src/main/java/it/grid/storm/asynch/InvalidBoLFeederAttributesException.java
index 33c09c72..41c71da8 100644
--- a/src/main/java/it/grid/storm/asynch/InvalidBoLFeederAttributesException.java
+++ b/src/main/java/it/grid/storm/asynch/InvalidBoLFeederAttributesException.java
@@ -51,8 +51,8 @@ public InvalidBoLFeederAttributesException(RequestSummaryData rsd,
public String toString() {
- return "null-RequestSummaryData=" + nullRequestSummaryData
- + "; null-GridUser=" + nullGridUser + "; null-GlobalStatusManagerr="
- + nullGlobalStatusManager;
+ return String.format("null-RequestSummaryData=%b; null-GridUser=%b; "
+ + "null-GlobalStatusManager=%b", nullRequestSummaryData, nullGridUser,
+ nullGlobalStatusManager);
}
}
diff --git a/src/main/java/it/grid/storm/asynch/InvalidCopyAttributesException.java b/src/main/java/it/grid/storm/asynch/InvalidCopyAttributesException.java
index a1b115c2..03b4d43b 100644
--- a/src/main/java/it/grid/storm/asynch/InvalidCopyAttributesException.java
+++ b/src/main/java/it/grid/storm/asynch/InvalidCopyAttributesException.java
@@ -55,14 +55,8 @@ public InvalidCopyAttributesException(GridUserInterface gu,
@Override
public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append("InvalidCopyAttributesException [negativeN=");
- builder.append(negativeN);
- builder.append(", nullGu=");
- builder.append(nullGu);
- builder.append(", nullChunkData=");
- builder.append(nullChunkData);
- builder.append("]");
- return builder.toString();
+ return String.format("InvalidCopyAttributesException [negativeN=%b, "
+ + "nullGu=%b, nullChunkData=%b]", negativeN, nullGu, nullChunkData);
+
}
}
diff --git a/src/main/java/it/grid/storm/asynch/InvalidCopyFeederAttributesException.java b/src/main/java/it/grid/storm/asynch/InvalidCopyFeederAttributesException.java
index 5821810c..71982752 100644
--- a/src/main/java/it/grid/storm/asynch/InvalidCopyFeederAttributesException.java
+++ b/src/main/java/it/grid/storm/asynch/InvalidCopyFeederAttributesException.java
@@ -49,8 +49,8 @@ public InvalidCopyFeederAttributesException(RequestSummaryData rsd,
public String toString() {
- return "null-RequestSummaryData=" + nullRequestSummaryData
- + "; null-GridUser=" + nullGridUser + "; null-GlobalStatusManager="
- + nullGlobalStatusManager;
+ return String.format("null-RequestSummaryData=%b; null-GridUser=%b; "
+ + "null-GlobalStatusManager=%b", nullRequestSummaryData, nullGridUser,
+ nullGlobalStatusManager);
}
}
diff --git a/src/main/java/it/grid/storm/asynch/InvalidCopyPersistentChunkAttributesException.java b/src/main/java/it/grid/storm/asynch/InvalidCopyPersistentChunkAttributesException.java
index fb915957..46131f6f 100644
--- a/src/main/java/it/grid/storm/asynch/InvalidCopyPersistentChunkAttributesException.java
+++ b/src/main/java/it/grid/storm/asynch/InvalidCopyPersistentChunkAttributesException.java
@@ -48,18 +48,8 @@ public InvalidCopyPersistentChunkAttributesException(GridUserInterface gu,
@Override
public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append("InvalidCopyPersistentChunkAttributesException [nullrsd=");
- builder.append(nullrsd);
- builder.append(", nullgsm=");
- builder.append(nullgsm);
- builder.append(", negativeN=");
- builder.append(negativeN);
- builder.append(", nullGu=");
- builder.append(nullGu);
- builder.append(", nullChunkData=");
- builder.append(nullChunkData);
- builder.append("]");
- return builder.toString();
+ return String.format("InvalidCopyPersistentChunkAttributesException "
+ + "[nullrsd=%b, nullgsm=%b, negativeN=%b, nullGu=%b, nullChunkData=%b]",
+ nullrsd, nullgsm, negativeN, nullGu, nullChunkData);
}
}
diff --git a/src/main/java/it/grid/storm/asynch/InvalidPersistentRequestAttributesException.java b/src/main/java/it/grid/storm/asynch/InvalidPersistentRequestAttributesException.java
index 99391c7d..b958b5dd 100644
--- a/src/main/java/it/grid/storm/asynch/InvalidPersistentRequestAttributesException.java
+++ b/src/main/java/it/grid/storm/asynch/InvalidPersistentRequestAttributesException.java
@@ -56,8 +56,8 @@ public InvalidPersistentRequestAttributesException(GridUserInterface gu,
public String toString() {
- return "Invalid attributes when creating Chunk: nullGridUser=" + nullGu
- + ", nullRequestSumamryData=" + nullRsd + " , nullChunkData="
- + nullChunkData + " , nullGsm=" + nullGsm;
+ return String.format("Invalid attributes when creating Chunk: "
+ + "nullGridUser=%b, nullRequestSumamryData=%b, nullChunkData=%b, "
+ + "nullGsm=%b", nullGu, nullRsd, nullChunkData, nullGsm);
}
}
diff --git a/src/main/java/it/grid/storm/asynch/InvalidPtGAttributesException.java b/src/main/java/it/grid/storm/asynch/InvalidPtGAttributesException.java
index f9623dea..66b73b52 100644
--- a/src/main/java/it/grid/storm/asynch/InvalidPtGAttributesException.java
+++ b/src/main/java/it/grid/storm/asynch/InvalidPtGAttributesException.java
@@ -28,7 +28,7 @@ public InvalidPtGAttributesException(GridUserInterface gu, PtGData chunkData) {
public String toString() {
- return "Invalid attributes when creating PtG: null-GridUser=" + nullGu
- + " null-PtGChunkData=" + nullChunkData;
+ return String.format("Invalid attributes when creating PtG: "
+ + "null-GridUser=%b, null-PtGChunkData=%b", nullGu, nullChunkData);
}
}
diff --git a/src/main/java/it/grid/storm/asynch/InvalidPtGChunkAttributesException.java b/src/main/java/it/grid/storm/asynch/InvalidPtGChunkAttributesException.java
index c23d27fe..7cdc1467 100644
--- a/src/main/java/it/grid/storm/asynch/InvalidPtGChunkAttributesException.java
+++ b/src/main/java/it/grid/storm/asynch/InvalidPtGChunkAttributesException.java
@@ -61,8 +61,9 @@ public InvalidPtGChunkAttributesException(GridUserInterface gu,
public String toString() {
- return "Invalid attributes when creating PtGChunk: null-GridUser=" + nullGu
- + ", null-RequestSumamryData=" + nullRsd + " null-PtGChunkData="
- + nullChunkData + " null-GlobalStatusManager=" + nullGlobalStatusManager;
+ return String.format("Invalid attributes when creating PtGChunk: "
+ + "null-GridUser=%b, null-RequestSumamryData=%b, null-PtGChunkData=%b, "
+ + "null-GlobalStatusManager=%b", nullGu, nullRsd, nullChunkData,
+ nullGlobalStatusManager);
}
}
diff --git a/src/main/java/it/grid/storm/asynch/InvalidPtGFeederAttributesException.java b/src/main/java/it/grid/storm/asynch/InvalidPtGFeederAttributesException.java
index feef7e84..d6e02eb5 100644
--- a/src/main/java/it/grid/storm/asynch/InvalidPtGFeederAttributesException.java
+++ b/src/main/java/it/grid/storm/asynch/InvalidPtGFeederAttributesException.java
@@ -49,8 +49,8 @@ public InvalidPtGFeederAttributesException(RequestSummaryData rsd,
public String toString() {
- return "null-RequestSummaryData=" + nullRequestSummaryData
- + "; null-GridUser=" + nullGridUser + "; null-GlobalStatusManagerr="
- + nullGlobalStatusManager;
+ return String.format("null-RequestSummaryData=%b; null-GridUser=%b; "
+ + "null-GlobalStatusManager=%b", nullRequestSummaryData, nullGridUser,
+ nullGlobalStatusManager);
}
}
diff --git a/src/main/java/it/grid/storm/asynch/InvalidPtPFeederAttributesException.java b/src/main/java/it/grid/storm/asynch/InvalidPtPFeederAttributesException.java
index 32430b42..bc56b8c8 100644
--- a/src/main/java/it/grid/storm/asynch/InvalidPtPFeederAttributesException.java
+++ b/src/main/java/it/grid/storm/asynch/InvalidPtPFeederAttributesException.java
@@ -48,8 +48,8 @@ public InvalidPtPFeederAttributesException(RequestSummaryData rsd,
public String toString() {
- return "null-RequestSummaryData=" + nullRequestSummaryData
- + "; null-GridUser=" + nullGridUser + "; null-GlobalStatusManager="
- + nullGlobalStatusManager;
+ return String.format("null-RequestSummaryData=%b; null-GridUser=%b; "
+ + "null-GlobalStatusManager=%b", nullRequestSummaryData, nullGridUser,
+ nullGlobalStatusManager);
}
}
diff --git a/src/main/java/it/grid/storm/asynch/InvalidPutStatusAttributesException.java b/src/main/java/it/grid/storm/asynch/InvalidPutStatusAttributesException.java
index 348de870..1a65e3bc 100644
--- a/src/main/java/it/grid/storm/asynch/InvalidPutStatusAttributesException.java
+++ b/src/main/java/it/grid/storm/asynch/InvalidPutStatusAttributesException.java
@@ -48,7 +48,7 @@ public InvalidPutStatusAttributesException(TTURL toTURL,
public String toString() {
- return "nullToTURL=" + nullToTURL + "; nullReturnStatus="
- + nullReturnStatus;
+ return String.format("nullToTURL=%b; nullReturnStatus=%b", nullToTURL,
+ nullReturnStatus);
}
}
diff --git a/src/main/java/it/grid/storm/asynch/InvalidRequestAttributesException.java b/src/main/java/it/grid/storm/asynch/InvalidRequestAttributesException.java
index 59b89836..6c96f4cc 100644
--- a/src/main/java/it/grid/storm/asynch/InvalidRequestAttributesException.java
+++ b/src/main/java/it/grid/storm/asynch/InvalidRequestAttributesException.java
@@ -45,7 +45,7 @@ public InvalidRequestAttributesException(GridUserInterface gu,
public String toString() {
- return "Invalid attributes when creating Request: nullGridUser=" + nullGu
- + " , nullChunkData=" + nullChunkData;
+ return String.format("Invalid attributes when creating Request: "
+ + "nullGridUser=%b, nullChunkData=%b", nullGu, nullChunkData);
}
}
diff --git a/src/main/java/it/grid/storm/asynch/NaiveGridFTPTransferClient.java b/src/main/java/it/grid/storm/asynch/NaiveGridFTPTransferClient.java
index f2261f93..7a45faef 100644
--- a/src/main/java/it/grid/storm/asynch/NaiveGridFTPTransferClient.java
+++ b/src/main/java/it/grid/storm/asynch/NaiveGridFTPTransferClient.java
@@ -95,7 +95,7 @@ public void putFile(GridUserInterface gu, TTURL local, TTURL remote)
proxy), GSSCredential.INITIATE_AND_ACCEPT));
client.setType(Session.TYPE_IMAGE);
FeatureList fl = client.getFeatureList();
- log.debug("NAIVE GSIFTP CLIENT: Remote server supports " + fl.toString());
+ log.debug("NAIVE GSIFTP CLIENT: Remote server supports {}", fl.toString());
if (!fl.contains(FeatureList.DCAU)) {
log.debug("NAIVE GSIFTP CLIENT: disabling DCAU");
client.setLocalNoDataChannelAuthentication(); // compatibility with old
diff --git a/src/main/java/it/grid/storm/asynch/NaiveSRMClient.java b/src/main/java/it/grid/storm/asynch/NaiveSRMClient.java
index 6d6d55b1..9466c6b6 100644
--- a/src/main/java/it/grid/storm/asynch/NaiveSRMClient.java
+++ b/src/main/java/it/grid/storm/asynch/NaiveSRMClient.java
@@ -90,8 +90,7 @@ public SRMPrepareToPutReply prepareToPut(GridUserInterface gu, TSURL toSURL,
srmClientStubs.ISRM _srm = setUpGSI(gu, toSURL);
// prepare srm request and execute it
- srmClientStubs.SrmPrepareToPutRequest req = new srmClientStubs.SrmPrepareToPutRequest(); // srm
- // request
+ srmClientStubs.SrmPrepareToPutRequest req = new srmClientStubs.SrmPrepareToPutRequest();
// set authorization ID
String stubuid = gu.getDn();
req.setAuthorizationID(stubuid);
@@ -123,10 +122,8 @@ public SRMPrepareToPutReply prepareToPut(GridUserInterface gu, TSURL toSURL,
.intValue()));
// set request specific info
- srmClientStubs.TPutFileRequest stubpfr = new srmClientStubs.TPutFileRequest(); // ws
- // put
- // file
- // request!
+ // ws put file request!
+ srmClientStubs.TPutFileRequest stubpfr = new srmClientStubs.TPutFileRequest();
// set file size
org.apache.axis.types.UnsignedLong ulFileSize = new org.apache.axis.types.UnsignedLong(
filesize.value());
@@ -134,23 +131,18 @@ public SRMPrepareToPutReply prepareToPut(GridUserInterface gu, TSURL toSURL,
// set target SURL
stubpfr.setTargetSURL(new org.apache.axis.types.URI(toSURL.toString()));
- // set array of requests
- srmClientStubs.TPutFileRequest[] stubpfrArray = new srmClientStubs.TPutFileRequest[1]; // ws
- // array
- // of
- // put
- // file
- // request!
+ // set array of requests ws array of put file request!
+ srmClientStubs.TPutFileRequest[] stubpfrArray = new srmClientStubs.TPutFileRequest[1];
stubpfrArray[0] = stubpfr;
srmClientStubs.ArrayOfTPutFileRequest arrayOfPut = new srmClientStubs.ArrayOfTPutFileRequest(
stubpfrArray);
req.setArrayOfFileRequests(arrayOfPut);
// execute request!
- log.debug("NAIVE SRM CLIENT: sending request " + arrayOfPut);
+ log.debug("NAIVE SRM CLIENT: sending request {}", arrayOfPut);
srmClientStubs.SrmPrepareToPutResponse response = _srm
.srmPrepareToPut(req);
- log.debug("NAIVE SRM CLIENT: received reply " + response);
+ log.debug("NAIVE SRM CLIENT: received reply {}", response);
// get TRequestToken
it.grid.storm.srm.types.TRequestToken requestToken = new WSRequestTokenConverter()
@@ -256,10 +248,10 @@ public SRMStatusOfPutRequestReply statusOfPutRequest(
stubSurlArray);
req.setArrayOfTargetSURLs(arrayOfTSURL);
- log.debug("NAIVE SRM CLIENT: invoking status of put with " + req);
+ log.debug("NAIVE SRM CLIENT: invoking status of put with {}", req);
srmClientStubs.SrmStatusOfPutRequestResponse response = _srm
.srmStatusOfPutRequest(req);
- log.debug("NAIVE SRM CLIENT: received response " + response);
+ log.debug("NAIVE SRM CLIENT: received response {}", response);
// process response
srmClientStubs.ArrayOfTPutRequestFileStatus arrayOfPutStatuses = response
@@ -333,12 +325,6 @@ public SRMPutDoneReply srmPutDone(TRequestToken rt, GridUserInterface gu,
TSURL toSURL) throws SRMClientException {
return null;
- /*
- * try { return new SRMPutDoneReply(new
- * it.grid.storm.srm.types.TReturnStatus
- * (it.grid.storm.srm.types.TStatusCode.SRM_SUCCESS,"DUMMY SUCCESS")); }
- * catch (Exception e) { throw new SRMClientException(); }
- */
}
/**
@@ -364,86 +350,31 @@ private srmClientStubs.ISRM setUpGSI(GridUserInterface gu,
// set proxy in stub
if (((AbstractGridUser) gu).getUserCredentials() == null) {
- log.error("ERROR in NaiveSRMClient! No proxy present for " + gu.getDn());
+ log.error("ERROR in NaiveSRMClient! No proxy present for {}", gu.getDn());
}
+ // String containing the proxy seen as an input stream!
InputStream proxy = new ByteArrayInputStream(((AbstractGridUser) gu)
- .getUserCredentials().getBytes()); // String containing the proxy seen as
- // an input stream!
+ .getUserCredentials().getBytes());
+ // GSSCredential containing the proxy!
GSSCredential globusProxy = new GlobusGSSCredentialImpl(
- new GlobusCredential(proxy), GSSCredential.INITIATE_AND_ACCEPT); // GSSCredential
- // containing
- // the
- // proxy!
- ((Stub) _srm)._setProperty(GSIHTTPTransport.GSI_CREDENTIALS, globusProxy); // set
- // the
- // proxy
- // to
- // be
- // used
- // during
- // GSI
- // connection!
+ new GlobusCredential(proxy), GSSCredential.INITIATE_AND_ACCEPT);
+ // set the proxy to be used during GSI connection!
+ ((Stub) _srm)._setProperty(GSIHTTPTransport.GSI_CREDENTIALS, globusProxy);
+ // set the authorization that will be performed by the web service for the
+ // supplied credentails!
((Stub) _srm)._setProperty(GSIHTTPTransport.GSI_AUTHORIZATION,
- NoAuthorization.getInstance()); // set the authorization that will be
- // performed by the web service for the
- // supplied credentails!
+ NoAuthorization.getInstance());
+ // set the supply of both private and public key of credentials
((Stub) _srm)._setProperty(GSIHTTPTransport.GSI_MODE,
- GSIHTTPTransport.GSI_MODE_NO_DELEG); // set the supply of both private and
- // public key of credentials
+ GSIHTTPTransport.GSI_MODE_NO_DELEG);
// set service endpoint address
- String sea = "httpg://" + toSURL.sfn().machine() + ":"
- + toSURL.sfn().port() + "/";
+ String sea = String.format("httpg://%s:%s/", toSURL.sfn().machine(), toSURL
+ .sfn().port());
((Stub) _srm)._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, sea);
// return the interface
return _srm;
}
- /**
- * Private method that returns a String representation of
- * srmClientStubs.SrmPrepareToPutResponse
- */
- /*
- * private String
- * srmPtPResponseToString(srmClientStubs.SrmPrepareToPutResponse response) {
- * StringBuffer sb = new StringBuffer(); if (response==null) {
- * sb.append("srmClientStubs.SrmPrepareToPutResponse is null!"); } else {
- * sb.append("srmClientStubs.SrmPrepareToPutResponse:\n");
- * srmClientStubs.TRequestToken stubrt = response.getRequestToken(); if
- * (stubrt==null) { sb.append("srmClientStubs.TRequestToken is null!\n"); }
- * else { sb.append("srmClientStubs.TRequestToken is ");
- * sb.append(stubrt.getValue()); sb.append("\n"); }
- * srmClientStubs.TReturnStatus stubretstat = response.getReturnStatus(); if
- * (stubretstat==null) { sb.append("srmClientStubs.TReturnStatus is null!\n");
- * } else { sb.append("srmClientStubs.TReturnStatus has ");
- * srmClientStubs.TStatusCode stubstatcode = stubretstat.getStatusCode(); if
- * (stubstatcode==null) { sb.append("TStatusCode=null and "); } else {
- * sb.append("TStatusCode="); sb.append(stubstatcode.getValue());
- * sb.append(" and "); } String aux = stubretstat.getExplanation(); if
- * (aux==null) { sb.append("explanationString=null"); } else {
- * sb.append("explanationString="); sb.append(aux); } sb.append("\n"); }
- * srmClientStubs.ArrayOfTPutRequestFileStatus stubaprfs =
- * response.getArrayOfFileStatuses(); if (stubaprfs==null) {
- * sb.append("srmClientStubs.ArrayOfTPutRequestFileStatus is null!\n"); } else
- * { srmClientStubs.TPutRequestFileStatus[] stubprfs =
- * stubaprfs.getPutStatusArray(); int arraysize = stubprfs.length;
- * sb.append("srmClientStubs.ArrayOfTPutRequestFileStatus has ");
- * sb.append(arraysize); sb.append(" elements\n");
- * srmClientStubs.TPutRequestFileStatus stubaux; srmClientStubs.TReturnStatus
- * stubauxretstat; srmClientStubs.TStatusCode stubauxstatcode; String
- * auxString; for (int i=0; i aclList = acl.getACL();
- for (ACLEntry ace : aclList) {
- /* Re-Check if the ACE is yet valid */
- if (ace.isValid()) {
- log.debug("Adding DefaultACL for the gid: " + ace.getGroupID()
- + " with permission: " + ace.getFilePermissionString());
- LocalUser u = new LocalUser(ace.getGroupID(), ace.getGroupID());
- if (ace.getFilesystemPermission() == null) {
- log
- .warn("Unable to setting up the ACL. ACl entry permission is null!");
- } else {
- try {
- AclManagerFSAndHTTPS.getInstance().grantGroupPermission(
- localFile, u, ace.getFilesystemPermission());
-
- } catch (IllegalArgumentException e) {
- log
- .error("Unable to grant group permissions on the file. IllegalArgumentException: "
- + e.getMessage());
- }
- }
- }
+
+ if ((acl == null) || (acl.isEmpty())) {
+ log.debug("{} acl null or empty!", vfs.getAliasName());
+ return;
+ }
+
+ /* There are ACLs to set n file */
+ List aclList = acl.getACL();
+ for (ACLEntry ace : aclList) {
+ /* Re-Check if the ACE is yet valid */
+ if (!ace.isValid()) {
+ log.debug("ACE {} is not valid!", ace.toString());
+ continue;
+ }
+ log.debug("Adding DefaultACL for the gid: {} with permission: {}",
+ ace.getGroupID(), ace.getFilePermissionString());
+ LocalUser u = new LocalUser(ace.getGroupID(), ace.getGroupID());
+ if (ace.getFilesystemPermission() == null) {
+ log.warn("Unable to setting up the ACL. ACl entry permission is null!");
+ continue;
}
+ try {
+ AclManagerFSAndHTTPS.getInstance().grantGroupPermission(localFile, u,
+ ace.getFilesystemPermission());
+ } catch (IllegalArgumentException e) {
+ log.error("Unable to grant group permissions on the file. "
+ + "IllegalArgumentException: {}", e.getMessage(), e);
+ }
}
}
@@ -824,9 +807,8 @@ private boolean isStoriOndisk(StoRI storiFile) throws FSException {
if (!storiFile.getVirtualFileSystem().getStorageClassType().isTapeEnabled()) {
return true;
- } else {
- return storiFile.getLocalFile().isOnDisk();
}
+ return storiFile.getLocalFile().isOnDisk();
}
/**
@@ -852,47 +834,47 @@ public void choose(Streets s) {
@Override
public Boolean completeRequest(TapeRecallStatus recallStatus) {
- Boolean success = false;
- if (recallStatus == TapeRecallStatus.SUCCESS) {
- try {
- if (bupLocalFile.isOnDisk()) {
- success = managePermitReadFileStep(bupFileStori, bupLocalFile,
- bupLocalUser, bupTURL);
- if (bupLocalUser != null) {
- success = managePermitReadFileStep(bupFileStori, bupLocalFile,
- bupLocalUser, bupTURL);
- } else {
- success = true;
- setDefaultAcl(bupFileStori, bupLocalFile);
- }
- if (success) {
- requestData.setTransferURL(bupTURL);
- requestData
- .changeStatusSRM_FILE_PINNED("srmPrepareToGet successfully handled!");
- } else {
- requestData
- .changeStatusSRM_FAILURE("Local filesystem mask does not allow"
- + " setting up correct ACLs for PtG!");
- }
- } else {
- log.error("File " + bupLocalFile.getAbsolutePath()
- + " not found on the disk, but it was reported to"
- + " be successfully recalled from tape");
- requestData.changeStatusSRM_FAILURE("Error recalling file from tape");
- }
- } catch (FSException e) {
- log.error("Unable to determine if file "
- + bupLocalFile.getAbsolutePath() + " is on disk . FSException : "
- + e.getMessage());
- requestData
- .changeStatusSRM_FAILURE("Internal error: unable to determine if the file is on disk");
- }
+ if (recallStatus.equals(TapeRecallStatus.ABORTED)) {
+ requestData.changeStatusSRM_ABORTED("Recalling file from tape aborted");
+ return false;
+ }
+ if (!recallStatus.equals(TapeRecallStatus.SUCCESS)) {
+ requestData.changeStatusSRM_FAILURE("Error recalling file from tape");
+ return false;
+ }
+
+ Boolean isOnDisk = false;
+ try {
+ isOnDisk = bupLocalFile.isOnDisk();
+ } catch (FSException e) {
+ log.error("Unable to determine if file {} is on disk. FSException: ",
+ bupLocalFile.getAbsolutePath(), e.getMessage(), e);
+ requestData.changeStatusSRM_FAILURE("Internal error: unable to determine "
+ + "if the file is on disk");
+ return false;
+ }
+ if (!isOnDisk) {
+ log.error("File {} not found on the disk, but it was reported to be "
+ + "successfully recalled from tape", bupLocalFile.getAbsolutePath());
+ requestData.changeStatusSRM_FAILURE("Error recalling file from tape");
+ return false;
+ }
+ Boolean success = managePermitReadFileStep(bupFileStori, bupLocalFile,
+ bupLocalUser, bupTURL);
+ if (bupLocalUser != null) {
+ success = managePermitReadFileStep(bupFileStori, bupLocalFile,
+ bupLocalUser, bupTURL);
} else {
- if (recallStatus == TapeRecallStatus.ABORTED) {
- requestData.changeStatusSRM_ABORTED("Recalling file from tape aborted");
- } else {
- requestData.changeStatusSRM_FAILURE("Error recalling file from tape");
- }
+ success = true;
+ setDefaultAcl(bupFileStori, bupLocalFile);
+ }
+ if (success) {
+ requestData.setTransferURL(bupTURL);
+ requestData.changeStatusSRM_FILE_PINNED("srmPrepareToGet successfully "
+ + "handled!");
+ } else {
+ requestData.changeStatusSRM_FAILURE("Local filesystem mask does not "
+ + "allow setting up correct ACLs for PtG!");
}
return success;
}
@@ -926,13 +908,9 @@ public String getUserDN() {
@Override
public boolean isResultSuccess() {
- boolean result = false;
TStatusCode statusCode = requestData.getStatus().getStatusCode();
- if ((statusCode.getValue().equals(TStatusCode.SRM_FILE_PINNED.getValue()))
- || requestData.getStatus().isSRM_SUCCESS()) {
- result = true;
- }
- return result;
+ return ((statusCode.equals(TStatusCode.SRM_FILE_PINNED))
+ || requestData.getStatus().isSRM_SUCCESS());
}
/**
@@ -940,10 +918,11 @@ public boolean isResultSuccess() {
*/
private void manageIsDeny() {
- requestData.changeStatusSRM_AUTHORIZATION_FAILURE("Read access to "
- + requestData.getSURL() + " denied!");
+ String emsg = String.format("Read access to %s denied!",
+ requestData.getSURL());
+ log.debug(emsg);
+ requestData.changeStatusSRM_AUTHORIZATION_FAILURE(emsg);
failure = true;
- log.debug("Read access to " + requestData.getSURL() + " denied!");
}
/**
@@ -956,10 +935,10 @@ private void manageIsIndeterminate(AuthzDecision ad) {
requestData.changeStatusSRM_FAILURE("Failure in PolicySource prevented"
+ " PolicyCollector from establishing access rights! Processing failed!");
failure = true;
- log
- .error("ERROR in PtGChunk! PolicyCollector received an error from PolicySource!");
- log.error("Received state: " + ad);
- log.error("Requested SURL: " + requestData.getSURL());
+ log.error("ERROR in PtGChunk! PolicyCollector received an error from "
+ + "PolicySource!");
+ log.error("Received state: {}", ad);
+ log.error("Requested SURL: {}", requestData.getSURL());
}
/**
@@ -969,14 +948,13 @@ private void manageIsIndeterminate(AuthzDecision ad) {
*/
private void manageIsNotApplicabale(AuthzDecision ad) {
- requestData
- .changeStatusSRM_FAILURE("No policies found for the requested SURL! "
- + "Therefore access rights cannot be established! Processing cannot continue!");
+ requestData.changeStatusSRM_FAILURE("No policies found for the requested "
+ + "SURL! Therefore access rights cannot be established! Processing cannot "
+ + "continue!");
failure = true;
- log
- .warn("PtGChunk: PolicyCollector found no policy for the supplied SURL!");
- log.warn("Received state: " + ad);
- log.warn("Requested SURL: " + requestData.getSURL());
+ log.warn("PtGChunk: PolicyCollector found no policy for the supplied SURL!");
+ log.warn("Received state: {}", ad);
+ log.warn("Requested SURL: {}", requestData.getSURL());
}
protected void printRequestOutcome(PtGData inputData) {
diff --git a/src/main/java/it/grid/storm/asynch/PtGBuilder.java b/src/main/java/it/grid/storm/asynch/PtGBuilder.java
index d5d9bd61..0e998847 100644
--- a/src/main/java/it/grid/storm/asynch/PtGBuilder.java
+++ b/src/main/java/it/grid/storm/asynch/PtGBuilder.java
@@ -60,13 +60,12 @@ public static PtG build(FileTransferInputData inputData)
status = new TReturnStatus(TStatusCode.SRM_REQUEST_INPROGRESS,
"Synchronous request created");
} catch (InvalidTReturnStatusAttributeException e) {
- log
- .error("Unable to build TReturnStatus. InvalidTReturnStatusAttributeException: "
- + e.getMessage());
+ log.error("Unable to build TReturnStatus. "
+ + "InvalidTReturnStatusAttributeException: {}", e.getMessage(), e);
throw new BuilderException(
"Error building PtG TReturnStatus. Building failed");
}
- ;
+
TTURL transferURL = TTURL.makeEmpty();
PtGData data;
try {
@@ -80,21 +79,19 @@ public static PtG build(FileTransferInputData inputData)
}
data.store();
} catch (InvalidPtGDataAttributesException e) {
- log
- .error("Unable to build PtGChunkData. InvalidPtGChunkDataAttributesException: "
- + e.getMessage());
+ log.error("Unable to build PtGChunkData. "
+ + "InvalidPtGChunkDataAttributesException: {}", e.getMessage(), e);
throw new BuilderException(
"Error building PtG PtGChunkData. Building failed");
} catch (InvalidFileTransferDataAttributesException e) {
- log
- .error("Unable to build PtGChunkData. InvalidFileTransferChunkDataAttributesException: "
- + e.getMessage());
+ log.error("Unable to build PtGChunkData. "
+ + "InvalidFileTransferChunkDataAttributesException: {}",
+ e.getMessage(), e);
throw new BuilderException(
"Error building PtG PtGChunkData. Building failed");
} catch (InvalidSurlRequestDataAttributesException e) {
- log
- .error("Unable to build PtGChunkData. InvalidSurlRequestDataAttributesException: "
- + e.getMessage());
+ log.error("Unable to build PtGChunkData. "
+ + "InvalidSurlRequestDataAttributesException: {}", e.getMessage(), e);
throw new BuilderException(
"Error building PtG PtGChunkData. Building failed");
}
diff --git a/src/main/java/it/grid/storm/asynch/PtGFeeder.java b/src/main/java/it/grid/storm/asynch/PtGFeeder.java
index bdb97fcb..202c7463 100644
--- a/src/main/java/it/grid/storm/asynch/PtGFeeder.java
+++ b/src/main/java/it/grid/storm/asynch/PtGFeeder.java
@@ -127,9 +127,8 @@ public PtGFeeder(RequestSummaryData rsd)
this.rsd = rsd;
gsm = new GlobalStatusManager(rsd.requestToken());
} catch (InvalidOverallRequestAttributeException e) {
- log
- .error("ATTENTION in PtGFeeder! Programming bug when creating GlobalStatusManager! "
- + e);
+ log.error("ATTENTION in PtGFeeder! Programming bug when creating "
+ + "GlobalStatusManager! {}", e.getMessage(), e);
throw new InvalidPtGFeederAttributesException(rsd, null, null);
}
}
@@ -141,19 +140,18 @@ public PtGFeeder(RequestSummaryData rsd)
*/
public void doIt() {
- log.debug("PtGFeeder: pre-processing " + rsd.requestToken());
+ log.debug("PtGFeeder: pre-processing {}", rsd.requestToken());
// Get all parts in request
Collection chunks = PtGChunkCatalog.getInstance()
.lookup(rsd.requestToken());
if (chunks.isEmpty()) {
- log
- .warn("ATTENTION in PtGFeeder! This SRM PtG request contained nothing to process! "
- + rsd.requestToken());
+ log.warn("ATTENTION in PtGFeeder! This SRM PtG request contained nothing "
+ + "to process! {}", rsd.requestToken());
RequestSummaryCatalog.getInstance().failRequest(rsd,
"This SRM Get request contained nothing to process!");
} else {
manageChunks(chunks);
- log.debug("PtGFeeder: finished pre-processing " + rsd.requestToken());
+ log.debug("PtGFeeder: finished pre-processing {}", rsd.requestToken());
}
}
@@ -163,7 +161,7 @@ public void doIt() {
*/
private void manageChunks(Collection chunks) {
- log.debug("PtGFeeder - number of chunks in request: " + chunks.size());
+ log.debug("PtGFeeder - number of chunks in request: {}", chunks.size());
for (PtGPersistentChunkData chunkData : chunks) {
gsm.addChunk(chunkData); // add chunk for global status
// consideration
@@ -184,10 +182,10 @@ private void manageChunks(Collection chunks) {
* fromSURL does _not_ correspond to this installation of StoRM: fail
* chunk!
*/
- log.warn("PtGFeeder: srmPtG contract violation!"
- + " fromSURL does not correspond to this machine!");
- log.warn("Request: " + rsd.requestToken());
- log.warn("Chunk: " + chunkData);
+ log.warn("PtGFeeder: srmPtG contract violation! fromSURL does not"
+ + "correspond to this machine!");
+ log.warn("Request: {}", rsd.requestToken());
+ log.warn("Chunk: {}", chunkData);
chunkData.changeStatusSRM_FAILURE("SRM protocol violation!"
+ " Cannot do an srmPtG of a SURL that is not local!");
@@ -222,10 +220,10 @@ private void manageNotDirectory(PtGPersistentChunkData auxChunkData) {
.schedule(new PtGPersistentChunk(rsd, auxChunkData, gsm));
log.debug("PtGFeeder - chunk scheduled.");
} catch (InvalidPersistentRequestAttributesException e) {
- log.error("UNEXPECTED ERROR in PtGFeeder! Chunk could not be created!\n"
- + e);
- log.error("Request: " + rsd.requestToken());
- log.error("Chunk: " + auxChunkData);
+ log.error("UNEXPECTED ERROR in PtGFeeder! Chunk could not be created!");
+ log.error(e.getMessage(), e);
+ log.error("Request: {}", rsd.requestToken());
+ log.error("Chunk: {}", auxChunkData);
auxChunkData.changeStatusSRM_FAILURE("StoRM internal error does"
+ " not allow this chunk to be processed!");
@@ -233,10 +231,10 @@ private void manageNotDirectory(PtGPersistentChunkData auxChunkData) {
PtGChunkCatalog.getInstance().update(auxChunkData);
gsm.failedChunk(auxChunkData);
} catch (InvalidRequestAttributesException e) {
- log.error("UNEXPECTED ERROR in PtGFeeder! Chunk could not be created!\n"
- + e);
- log.error("Request: " + rsd.requestToken());
- log.error("Chunk: " + auxChunkData);
+ log.error("UNEXPECTED ERROR in PtGFeeder! Chunk could not be created!");
+ log.error(e.getMessage(), e);
+ log.error("Request: {}", rsd.requestToken());
+ log.error("Chunk: {}", auxChunkData);
auxChunkData.changeStatusSRM_FAILURE("StoRM internal error does"
+ " not allow this chunk to be processed!");
@@ -245,10 +243,10 @@ private void manageNotDirectory(PtGPersistentChunkData auxChunkData) {
gsm.failedChunk(auxChunkData);
} catch (SchedulerException e) {
/* Internal error of scheduler! */
- log.error("UNEXPECTED ERROR in ChunkScheduler! "
- + "Chunk could not be scheduled!\n" + e);
- log.error("Request: " + rsd.requestToken());
- log.error("Chunk: " + auxChunkData);
+ log.error("UNEXPECTED ERROR in ChunkScheduler! Chunk could not be scheduled!");
+ log.error(e.getMessage(), e);
+ log.error("Request: {}", rsd.requestToken());
+ log.error("Chunk: {}", auxChunkData);
auxChunkData.changeStatusSRM_FAILURE("StoRM internal scheduler "
+ "error prevented this chunk from being processed!");
@@ -270,157 +268,149 @@ private void manageIsDirectory(PtGPersistentChunkData chunkData) {
/* Change status of this chunk to being processed! */
chunkData.changeStatusSRM_REQUEST_INPROGRESS("srmPrepareToGet "
+ "chunk is being processed!");
+
+ TSURL surl = chunkData.getSURL();
+ String user = DataHelper.getRequestor(chunkData);
+
/* update persistence!!! */
PtGChunkCatalog.getInstance().update(chunkData);
+
+ /* Build StoRI for current chunk */
+ StoRI stori = null;
try {
- /* Build StoRI for current chunk */
- StoRI stori = null;
- try {
- stori = NamespaceDirector.getNamespace().resolveStoRIbySURL(
- chunkData.getSURL(), chunkData.getUser());
- } catch (IllegalArgumentException e) {
- log.error("Unable to build StoRI by SURL and user", e);
- chunkData.changeStatusSRM_INTERNAL_ERROR(e.getMessage());
- PtGChunkCatalog.getInstance().update(chunkData);
- log.error("ATTENTION in PtGFeeder! PtGFeeder received "
- + "request for a SURL and user not recognised by StoRI!"); // info
- gsm.failedChunk(chunkData);
- } catch (UnapprochableSurlException e) {
- chunkData.changeStatusSRM_AUTHORIZATION_FAILURE(e.getMessage());
- PtGChunkCatalog.getInstance().update(chunkData);
- log.info(String.format(
- "Unable to build a stori for surl %s for user %s %s: %s", chunkData
- .getSURL(), DataHelper.getRequestor(chunkData), e.getClass()
- .getCanonicalName(), e.getMessage()));
- gsm.failedChunk(chunkData);
- } catch (NamespaceException e) {
- chunkData.changeStatusSRM_INTERNAL_ERROR(e.getMessage());
+ stori = NamespaceDirector.getNamespace().resolveStoRIbySURL(surl,
+ chunkData.getUser());
+ } catch (IllegalArgumentException e) {
+ log.error("Unable to build a stori for surl {} for user {}. "
+ + "IllegalArgumentException: {}", surl, user, e.getMessage(), e);
+ chunkData.changeStatusSRM_INTERNAL_ERROR(e.getMessage());
+ } catch (UnapprochableSurlException e) {
+ log.info("Unable to build a stori for surl {} for user {}. "
+ + "UnapprochableSurlException: {}", surl, user, e.getMessage());
+ chunkData.changeStatusSRM_AUTHORIZATION_FAILURE(e.getMessage());
+ } catch (NamespaceException e) {
+ log.error("Unable to build a stori for surl {} for user {}. "
+ + "NamespaceException: {}", surl, user, e.getMessage(), e);
+ chunkData.changeStatusSRM_INTERNAL_ERROR(e.getMessage());
+ } catch (InvalidSURLException e) {
+ log.info("Unable to build a stori for surl {} for user {}. "
+ + "InvalidSURLException: {}", surl, user, e.getMessage());
+ chunkData.changeStatusSRM_INVALID_PATH(e.getMessage());
+ } finally {
+ if (stori == null) {
+ // failed!
PtGChunkCatalog.getInstance().update(chunkData);
- log.info(String.format(
- "Unable to build a stori for surl %s for user %s %s: %s", chunkData
- .getSURL(), DataHelper.getRequestor(chunkData), e.getClass()
- .getCanonicalName(), e.getMessage()));
- gsm.failedChunk(chunkData);
- } catch (InvalidSURLException e) {
- chunkData.changeStatusSRM_INVALID_PATH(e.getMessage());
- PtGChunkCatalog.getInstance().update(chunkData);
- log.info(String.format(
- "Unable to build a stori for surl %s for user %s %s: %s", chunkData
- .getSURL(), DataHelper.getRequestor(chunkData), e.getClass()
- .getCanonicalName(), e.getMessage()));
gsm.failedChunk(chunkData);
+ return;
}
- if (stori != null) {
- /* Collection of children! */
- // TODO MICHELE here if the recursion on directory is supported
- // substiture the following withe the commented one
- Collection storiChildren = stori.getChildren(chunkData
- .getDirOption());
-
- log.debug("PtGFeeder - Number of children in parent: "
- + storiChildren.size());
-
- // FIXME MICHELE why here we set the diroption in this way? maybe it
- // is correct in this other way:
- // new TDirOption(childStoRI.isDirectory() (this method doesn't
- // exists), (childStoRI.isDirectory() ? auxChunkData.dirOption() :
- // false).isAllLevelRecursive(), (childStoRI.isDirectory() ?
- // auxChunkData.dirOption().getNumLevel() > 0 ?
- // (auxChunkData.dirOption().getNumLevel()-1)) : 0 ) :0));
- TDirOption notDir = new TDirOption(false, false, 0);
-
- PtGPersistentChunkData childData;
- for (StoRI storiChild : storiChildren) {
- try {
- childData = new PtGPersistentChunkData(chunkData.getUser(),
- chunkData.getRequestToken(), storiChild.getSURL(),
- chunkData.getPinLifeTime(), notDir,
- chunkData.getTransferProtocols(), chunkData.getFileSize(),
- chunkData.getStatus(), chunkData.getTransferURL());
- /* fill in new db row and set the PrimaryKey of ChildData! */
- PtGChunkCatalog.getInstance().addChild(childData);
- log.debug("PtGFeeder - added child data: " + childData);
-
- /* add chunk for global status consideration */
- gsm.addChunk(childData);
- /* manage chunk */
- manageNotDirectory(childData);
- } catch (InvalidSurlRequestDataAttributesException e) {
- log.error("ERROR in PtGFeeder! While expanding recursive request,"
- + " it was not possible to create a new PtGPersistentChunkData! "
- + e);
- }
- }
- log.debug("PtGFeeder - expansion completed.");
- /*
- * A request on a Directory is considered done whether there is somethig
- * to expand or not!
- */
- // FIXME MICHELE maybe here as in BOL we have to set the success status
- // and not pinned
- chunkData
- .changeStatusSRM_FILE_PINNED("srmPrepareToGet with dirOption set: "
- + "request successfully expanded!");
- PtGChunkCatalog.getInstance().update(chunkData);
- gsm.successfulChunk(chunkData);
- }
- } catch (InvalidTDirOptionAttributesException e) {
- // Could not create TDirOption that specifies no-expansion!
- chunkData.changeStatusSRM_FAILURE("srmPrepareToGet with dirOption set:"
- + " expansion failure due to internal error!");
- PtGChunkCatalog.getInstance().update(chunkData);
-
- log.error("UNEXPECTED ERROR in PtGFeeder! Could not"
- + " create TDirOption specifying non-expansion!\n" + e);
- log.error("Request: " + rsd.requestToken());
- log.error("Chunk: " + chunkData);
- gsm.failedChunk(chunkData);
+ }
+
+ Collection storiChildren = null;
+
+ try {
+
+ storiChildren = stori.getChildren(chunkData.getDirOption());
+
} catch (InvalidDescendantsEmptyRequestException e) {
+
+ log.debug("ATTENTION in PtGFeeder! PtGFeeder received request to expand "
+ + "empty directory.");
/*
* The expanded directory was empty, anyway a request on a Directory is
* considered done whether there is somethig to expand or not!
*/
- chunkData
- .changeStatusSRM_FILE_PINNED("BEWARE! srmPrepareToGet with dirOption"
- + " set: it referred to a directory that was empty!");
+ chunkData.changeStatusSRM_FILE_PINNED("BEWARE! srmPrepareToGet with "
+ + "dirOption set: it referred to a directory that was empty!");
PtGChunkCatalog.getInstance().update(chunkData);
-
- log.debug("ATTENTION in PtGFeeder! PtGFeeder received "
- + "request to expand empty directory.");
gsm.successfulChunk(chunkData);
- }
+ return;
- catch (InvalidDescendantsPathRequestException e) {
- // Attempting to expand non existent directory!
- chunkData
- .changeStatusSRM_INVALID_PATH("srmPrepareToGet with dirOption set:"
- + " it referred to a non-existent directory!");
- PtGChunkCatalog.getInstance().update(chunkData);
-
+ } catch (InvalidDescendantsPathRequestException e) {
+
log.debug("ATTENTION in PtGFeeder! PtGFeeder received request"
+ " to expand non-existing directory.");
+ // Attempting to expand non existent directory!
+ chunkData.changeStatusSRM_INVALID_PATH("srmPrepareToGet with dirOption "
+ + "set: it referred to a non-existent directory!");
+ PtGChunkCatalog.getInstance().update(chunkData);
gsm.failedChunk(chunkData);
+ return;
+
} catch (InvalidDescendantsFileRequestException e) {
+
+ log.debug("ATTENTION in PtGFeeder! PtGFeeder received request to "
+ + "expand a file.");
// Attempting to expand a file!
- chunkData
- .changeStatusSRM_INVALID_PATH("srmPrepareToGet with dirOption set:"
- + " a file was asked to be expanded!");
+ chunkData.changeStatusSRM_INVALID_PATH("srmPrepareToGet with dirOption "
+ + "set: a file was asked to be expanded!");
PtGChunkCatalog.getInstance().update(chunkData);
-
- log
- .debug("ATTENTION in PtGFeeder! PtGFeeder received request to expand a file.");
gsm.failedChunk(chunkData);
+ return;
+
} catch (InvalidDescendantsAuthRequestException e) {
+
+ log.debug("ATTENTION in PtGFeeder! PtGFeeder received request to"
+ + " expand a directory for which the user has no rights.");
// No rights to directory!
- chunkData
- .changeStatusSRM_AUTHORIZATION_FAILURE("srmPrepareToGet with dirOption set:"
- + " user has no right to access directory!");
+ chunkData.changeStatusSRM_AUTHORIZATION_FAILURE("srmPrepareToGet with "
+ + "dirOption set: user has no right to access directory!");
PtGChunkCatalog.getInstance().update(chunkData);
-
- log.debug("ATTENTION in PtGFeeder! PtGFeeder received request to"
- + " expand a directory for which the user has no rights."); // info
gsm.failedChunk(chunkData);
+ return;
}
+
+ log.debug("PtGFeeder - Number of children in parent: {}", storiChildren.size());
+
+ TDirOption notDir = null;
+
+ try {
+
+ notDir = new TDirOption(false, false, 0);
+
+ } catch (InvalidTDirOptionAttributesException e) {
+
+ log.error("UNEXPECTED ERROR in PtGFeeder! Could not create TDirOption "
+ + "specifying non-expansion!\n{}\nRequest: {}\nChunk: {}",
+ e.getMessage(), rsd.requestToken(), chunkData, e);
+
+ chunkData.changeStatusSRM_FAILURE("srmPrepareToGet with dirOption set:"
+ + " expansion failure due to internal error!");
+ PtGChunkCatalog.getInstance().update(chunkData);
+ gsm.failedChunk(chunkData);
+ return;
+ }
+
+ PtGPersistentChunkData childData;
+ for (StoRI storiChild : storiChildren) {
+ try {
+ childData = new PtGPersistentChunkData(chunkData.getUser(),
+ chunkData.getRequestToken(), storiChild.getSURL(),
+ chunkData.getPinLifeTime(), notDir,
+ chunkData.getTransferProtocols(), chunkData.getFileSize(),
+ chunkData.getStatus(), chunkData.getTransferURL());
+ /* fill in new db row and set the PrimaryKey of ChildData! */
+ PtGChunkCatalog.getInstance().addChild(childData);
+ log.debug("PtGFeeder - added child data: {}", childData);
+
+ /* add chunk for global status consideration */
+ gsm.addChunk(childData);
+ /* manage chunk */
+ manageNotDirectory(childData);
+ } catch (InvalidSurlRequestDataAttributesException e) {
+ log.error("ERROR in PtGFeeder! While expanding recursive request,"
+ + " it was not possible to create a new PtGPersistentChunkData! {}",
+ e.getMessage(), e);
+ }
+ }
+ log.debug("PtGFeeder - expansion completed.");
+ /*
+ * A request on a Directory is considered done whether there is something
+ * to expand or not!
+ */
+ chunkData.changeStatusSRM_FILE_PINNED("srmPrepareToGet with dirOption "
+ + "set: request successfully expanded!");
+ PtGChunkCatalog.getInstance().update(chunkData);
+ gsm.successfulChunk(chunkData);
}
/**
diff --git a/src/main/java/it/grid/storm/asynch/PtGPersistentChunk.java b/src/main/java/it/grid/storm/asynch/PtGPersistentChunk.java
index a1c34fcb..5a8b1283 100644
--- a/src/main/java/it/grid/storm/asynch/PtGPersistentChunk.java
+++ b/src/main/java/it/grid/storm/asynch/PtGPersistentChunk.java
@@ -134,18 +134,18 @@ public Boolean completeRequest(TapeRecallStatus recallStatus) {
boolean success = super.completeRequest(recallStatus);
persistStatus();
+
if (success) {
-
+
gsm.successfulChunk((PtGPersistentChunkData) requestData);
- log.info("Completed PtG request (" + rsd.requestToken()
- + "), file successfully recalled from tape: "
- + requestData.getSURL().toString());
+ log.info("Completed PtG request ({}), file successfully recalled from "
+ + "tape: {}", rsd.requestToken(), requestData.getSURL().toString());
+
} else {
+
gsm.failedChunk((PtGPersistentChunkData) requestData);
- log
- .error("BoL request (" + rsd.requestToken()
- + "), file not recalled from tape: "
- + requestData.getSURL().toString());
+ log.error("BoL request ({}), file not recalled from tape: {}",
+ rsd.requestToken(), requestData.getSURL().toString());
}
return success;
}
@@ -170,13 +170,12 @@ public String getRequestToken() {
@Override
public boolean isResultSuccess() {
- boolean result = false;
if ((requestData.getStatus().getStatusCode()
.equals(TStatusCode.SRM_FILE_PINNED))
|| requestData.getStatus().isSRM_SUCCESS()) {
- result = true;
+ return true;
}
- return result;
+ return false;
}
@Override
diff --git a/src/main/java/it/grid/storm/asynch/PtP.java b/src/main/java/it/grid/storm/asynch/PtP.java
index f5c4b8fd..ab9553b2 100644
--- a/src/main/java/it/grid/storm/asynch/PtP.java
+++ b/src/main/java/it/grid/storm/asynch/PtP.java
@@ -158,126 +158,103 @@ public PtP(PtPData chunkData) throws InvalidRequestAttributesException {
@Override
public void doIt() {
- log.debug("Handling PtP chunk for user DN: "
- + DataHelper.getRequestor(requestData) + "; for SURL: "
- + requestData.getSURL());
- if (!verifySurlStatusTransition(requestData.getSURL(),
- requestData.getRequestToken())) {// should return SRM_DUPLICATION_ERROR if
- // file overwrite disabled instead of
- // SRM_FILE_BUSY
+ String user = DataHelper.getRequestor(requestData);
+ TSURL surl = requestData.getSURL();
+ TRequestToken rToken = requestData.getRequestToken();
+
+ log.debug("Handling PtP chunk for user DN: {}; for SURL: {}", user, surl);
+
+ if (!verifySurlStatusTransition(surl, rToken)) {
+ // should return SRM_DUPLICATION_ERROR if file overwrite is disabled,
+ // instead of SRM_FILE_BUSY
failure = true;
- requestData.changeStatusSRM_FILE_BUSY("The surl " + requestData.getSURL()
- + " is currently busy");
+ requestData.changeStatusSRM_FILE_BUSY("The surl " + surl + " is currently busy");
log.info("Unable to perform the PTP request, surl busy");
printRequestOutcome(requestData);
return;
}
+
requestData.changeStatusSRM_REQUEST_INPROGRESS("request in progress");
+
StoRI fileStoRI = null;
- if (requestData instanceof IdentityInputData) {
- try {
- fileStoRI = NamespaceDirector.getNamespace().resolveStoRIbySURL(
- requestData.getSURL(), ((IdentityInputData) requestData).getUser());
- } catch (UnapprochableSurlException e) {
- requestData.changeStatusSRM_AUTHORIZATION_FAILURE(e.getMessage());
- log.info(String.format(
- "Unable to build a stori for surl %s for user %s %s: %s", requestData
- .getSURL(), DataHelper.getRequestor(requestData), e.getClass()
- .getCanonicalName(), e.getMessage()));
- printRequestOutcome(requestData);
- return;
- } catch (IllegalArgumentException e) {
- requestData
- .changeStatusSRM_INTERNAL_ERROR(e.getMessage());
- log.error("Unable to get StoRI for surl " + requestData.getSURL()
- + " IllegalArgumentException: " + e.getMessage());
- printRequestOutcome(requestData);
- return;
- } catch (NamespaceException e) {
- requestData.changeStatusSRM_INTERNAL_ERROR(e.getMessage());
- log.info(String.format(
- "Unable to build a stori for surl %s for user %s %s: %s", requestData
- .getSURL(), DataHelper.getRequestor(requestData), e.getClass()
- .getCanonicalName(), e.getMessage()));
- printRequestOutcome(requestData);
- return;
- } catch (InvalidSURLException e) {
- requestData.changeStatusSRM_INVALID_PATH(e.getMessage());
- log.info(String.format(
- "Unable to build a stori for surl %s for user %s %s: %s", requestData
- .getSURL(), DataHelper.getRequestor(requestData), e.getClass()
- .getCanonicalName(), e.getMessage()));
- printRequestOutcome(requestData);
- return;
+
+ try {
+
+ if (requestData instanceof IdentityInputData) {
+ fileStoRI = NamespaceDirector.getNamespace().resolveStoRIbySURL(surl,
+ ((IdentityInputData) requestData).getUser());
+ } else {
+ fileStoRI = NamespaceDirector.getNamespace().resolveStoRIbySURL(surl);
}
- } else {
- try {
- fileStoRI = NamespaceDirector.getNamespace().resolveStoRIbySURL(
- requestData.getSURL());
- } catch (UnapprochableSurlException e) {
- log.info(String.format("Unable to build a stori for surl %s %s: %s",
- requestData.getSURL(), e.getClass().getCanonicalName(),
- e.getMessage()));
- requestData.changeStatusSRM_AUTHORIZATION_FAILURE(e.getMessage());
- printRequestOutcome(requestData);
- return;
- } catch (IllegalArgumentException e) {
- log.error(String.format("Unable to build a stori for surl %s %s: %s",
- requestData.getSURL(), e.getClass().getCanonicalName(),
- e.getMessage()));
- requestData.changeStatusSRM_INTERNAL_ERROR(e.getMessage());
- printRequestOutcome(requestData);
- return;
- } catch (NamespaceException e) {
- log.info(String.format("Unable to build a stori for surl %s %s: %s",
- requestData.getSURL(), e.getClass().getCanonicalName(),
- e.getMessage()));
- requestData.changeStatusSRM_INTERNAL_ERROR(e.getMessage());
- printRequestOutcome(requestData);
- return;
- } catch (InvalidSURLException e) {
- log.info(String.format("Unable to build a stori for surl %s %s: %s",
- requestData.getSURL(), e.getClass().getCanonicalName(),
- e.getMessage()));
- requestData.changeStatusSRM_INVALID_PATH(e.getMessage());
+
+ } catch (UnapprochableSurlException e) {
+ log.info("Unable to build a stori for surl {} for user {}. "
+ + "UnapprochableSurlExceptions: {}", surl, user, e.getMessage());
+ requestData.changeStatusSRM_AUTHORIZATION_FAILURE(e.getMessage());
+ } catch (IllegalArgumentException e) {
+ log.error("Unable to build a stori for surl {} for user {}. "
+ + "IllegalArgumentException: {}", surl, user, e.getMessage(), e);
+ requestData.changeStatusSRM_INTERNAL_ERROR(e.getMessage());
+ } catch (NamespaceException e) {
+ log.error("Unable to build a stori for surl {} for user {}. "
+ + "NamespaceException: {}", surl, user, e.getMessage(), e);
+ requestData.changeStatusSRM_INTERNAL_ERROR(e.getMessage());
+ } catch (InvalidSURLException e) {
+ log.info("Unable to build a stori for surl {} for user {}. "
+ + "InvalidSURLException: {}", surl, user, e.getMessage());
+ requestData.changeStatusSRM_INVALID_PATH(e.getMessage());
+ } finally {
+ if (fileStoRI == null) {
+ // Failed!
+ failure = true;
printRequestOutcome(requestData);
return;
}
}
+
boolean exists = false;
try {
+
exists = fileStoRI.getLocalFile().exists();
+
} catch (SecurityException e) {
- requestData
- .changeStatusSRM_FAILURE("StoRM is not allowed to work on requested file!");
+ log.error("ATTENTION in PtPChunk! PtPChunk received a SecurityException "
+ + "from Java SecurityManager: StoRM cannot check for the existence of "
+ + "file: {}; exception: {}", fileStoRI.getLocalFile().toString(),
+ e.getMessage(), e);
failure = true;
- log
- .error("ATTENTION in PtPChunk! PtPChunk received a SecurityException from Java SecurityManager: StoRM cannot check for the existence of file: "
- + fileStoRI.getLocalFile().toString() + "; exception: " + e);
+ requestData.changeStatusSRM_FAILURE("StoRM is not allowed to work on "
+ + "requested file!");
printRequestOutcome(requestData);
return;
}
+
if (!exists) {
+
manageNotExistentFile(fileStoRI);
+
} else {
- if (requestData.overwriteOption() == TOverwriteMode.ALWAYS
- || requestData.overwriteOption() == TOverwriteMode.WHENFILESAREDIFFERENT) {
+
+ TOverwriteMode mode = requestData.overwriteOption();
+
+ if (mode.equals(TOverwriteMode.ALWAYS) || mode.equals(TOverwriteMode.WHENFILESAREDIFFERENT)) {
+
manageOverwriteExistingFile(fileStoRI);
+
+ } else if (mode.equals(TOverwriteMode.NEVER)) {
+
+ requestData.changeStatusSRM_DUPLICATION_ERROR("Cannot srmPut file "
+ + "because it already exists!");
+ failure = true;
+
} else {
- if (requestData.overwriteOption() == TOverwriteMode.NEVER) {
- requestData
- .changeStatusSRM_DUPLICATION_ERROR("Cannot srmPut file because it already exists!");
- failure = true;
- } else {
- // unexpected overwrite option!!!
- requestData
- .changeStatusSRM_FAILURE("Unexpected overwrite option! Processing failed!");
- failure = true;
- log
- .error("UNEXPECTED ERROR in PtPChunk! The specified overwrite option is unknown!");
- log.error("Received Overwrite Option: "
- + requestData.overwriteOption());
- }
+
+ log.error("UNEXPECTED ERROR in PtPChunk! The specified overwrite "
+ + "option '{}' is unknown!", mode);
+ requestData.changeStatusSRM_FAILURE("Unexpected overwrite option! "
+ + "Processing failed!");
+ failure = true;
+
}
}
printRequestOutcome(requestData);
@@ -353,8 +330,8 @@ private void manageOverwriteExistingFile(StoRI fileStoRI) {
requestData.changeStatusSRM_AUTHORIZATION_FAILURE("Write access to "
+ requestData.getSURL() + " denied!");
failure = true;
- log.debug("Write access to " + requestData.getSURL() + " for user "
- + DataHelper.getRequestor(requestData) + " denied!");
+ log.debug("Write access to {} for user {} denied!",
+ requestData.getSURL(), DataHelper.getRequestor(requestData));
} else {
manageAnomaly(decision);
}
@@ -381,8 +358,8 @@ private void managePermit(StoRI fileStoRI) {
.changeStatusSRM_AUTHORIZATION_FAILURE("Create/Write access for "
+ requestData.getSURL() + " in Storage Area: " + token + " denied!");
failure = true;
- log.debug("Create/Write access for " + requestData.getSURL()
- + " in Storage Area: " + token + " denied!");
+ log.debug("Create/Write access for {} in Storage Area: {} denied!",
+ requestData.getSURL(), token);
return;
}
TTURL auxTURL;
@@ -391,23 +368,22 @@ private void managePermit(StoRI fileStoRI) {
} catch (IllegalArgumentException e) {
requestData.changeStatusSRM_FAILURE("Unable to decide TURL!");
failure = true;
- log
- .error("ERROR in PtPChunk! Null TURLPrefix in PtPChunkData caused StoRI to be unable to establish TTURL! IllegalArgumentException: "
- + e);
+ log.error("ERROR in PtPChunk! Null TURLPrefix in PtPChunkData caused "
+ + "StoRI to be unable to establish TTURL! IllegalArgumentException: {}",
+ e.getMessage(), e);
return;
} catch (InvalidGetTURLProtocolException e) {
- requestData
- .changeStatusSRM_NOT_SUPPORTED("Unable to build TURL with specified transfer protocols!");
+ requestData.changeStatusSRM_NOT_SUPPORTED("Unable to build TURL with "
+ + "specified transfer protocols!");
failure = true;
log.error("ERROR in PtPChunk! No valid transfer protocol found.");
return;
} catch (TURLBuildingException e) {
- requestData
- .changeStatusSRM_FAILURE("Unable to build the TURL for the provided transfer protocol");
+ requestData.changeStatusSRM_FAILURE("Unable to build the TURL for the "
+ + "provided transfer protocol");
failure = true;
- log
- .error("ERROR in PtPChunk! There was a failure building the TURL. : TURLBuildingException "
- + e);
+ log.error("ERROR in PtPChunk! There was a failure building the TURL. "
+ + "TURLBuildingException: {} ", e.getMessage(), e);
return;
}
boolean canTraverse;
@@ -419,9 +395,9 @@ private void managePermit(StoRI fileStoRI) {
requestData.changeStatusSRM_FAILURE("Unable to find local user for "
+ DataHelper.getRequestor(requestData));
failure = true;
- log.error("ERROR in PtGChunk! Unable to find LocalUser for "
- + DataHelper.getRequestor(requestData) + "! CannotMapUserException: "
- + e.getMessage());
+ log.error("ERROR in PtGChunk! Unable to find LocalUser for {}! "
+ + "CannotMapUserException: {}", DataHelper.getRequestor(requestData),
+ e.getMessage(), e);
return;
}
if (canTraverse) {
@@ -435,23 +411,22 @@ private void managePermit(StoRI fileStoRI) {
requestData.changeStatusSRM_FAILURE("Unable to find local user for "
+ DataHelper.getRequestor(requestData));
failure = true;
- log.error("ERROR in PtGChunk! Unable to find LocalUser for "
- + DataHelper.getRequestor(requestData)
- + "! CannotMapUserException: " + e.getMessage());
+ log.error("ERROR in PtGChunk! Unable to find LocalUser for {}! "
+ + "CannotMapUserException: {}", DataHelper.getRequestor(requestData),
+ e.getMessage(), e);
return;
}
if (!canWrite) {
// URGENT!!!
// roll back! ok3, ok2 and ok1
} else {
- log
- .debug("PTP CHUNK. Addition of ReadWrite ACL on file successfully completed for "
- + fileStoRI.getAbsolutePath());
+ log.debug("PTP CHUNK. Addition of ReadWrite ACL on file successfully "
+ + "completed for {}", fileStoRI.getAbsolutePath());
requestData.setTransferURL(auxTURL);
- requestData
- .changeStatusSRM_SPACE_AVAILABLE("srmPrepareToPut successfully handled!");
+ requestData.changeStatusSRM_SPACE_AVAILABLE("srmPrepareToPut "
+ + "successfully handled!");
failure = false;
- if (requestData.fileStorageType() == TFileStorageType.VOLATILE) {
+ if (requestData.fileStorageType().equals(TFileStorageType.VOLATILE)) {
VolatileAndJiTCatalog.getInstance().trackVolatile(
fileStoRI.getPFN(), Calendar.getInstance(),
requestData.fileLifetime());
@@ -509,8 +484,8 @@ private boolean verifyPath(StoRI fileStoRI) {
}
requestData.changeStatusSRM_INVALID_PATH(errorString);
failure = true;
- log.debug(errorString + " Parent points to "
- + parentStoRI.getLocalFile().toString() + ".");
+ log.debug("{} Parent points to {}.", errorString,
+ parentStoRI.getLocalFile().toString());
return false;
}
}
@@ -519,17 +494,19 @@ private boolean verifyPath(StoRI fileStoRI) {
private boolean setParentAcl(StoRI fileStoRI, LocalUser localUser) {
- log.debug("PtPChunk: setting parent traverse ACL for "
- + fileStoRI.getAbsolutePath() + " to user " + localUser);
+ log.debug("PtPChunk: setting parent traverse ACL for {} to user {}",
+ fileStoRI.getAbsolutePath(), localUser);
+
boolean automaticDirectoryCreation = Configuration.getInstance()
.getAutomaticDirectoryCreation();
+
for (StoRI parentStoRI : fileStoRI.getParents()) {
LocalFile parentFile = parentStoRI.getLocalFile();
- log.debug("PtPChunk TraverseStep - processing parent "
- + parentFile.toString());
+ log.debug("PtPChunk TraverseStep - processing parent {}",
+ parentFile.toString());
if (!prepareDirectory(parentFile, automaticDirectoryCreation)) {
- log.warn("Unable to perform directory preparation step on parent file "
- + parentFile.getAbsolutePath());
+ log.warn("Unable to perform directory preparation step on parent "
+ + "file {}", parentFile.getAbsolutePath());
failure = true;
return false;
} else {
@@ -561,23 +538,21 @@ private boolean prepareDirectory(LocalFile f, boolean canCreate)
throws SecurityException {
if ((!f.exists()) && (!canCreate)) {
- requestData
- .changeStatusSRM_INVALID_PATH("Directory structure as specified in SURL does not exist!");
+ requestData.changeStatusSRM_INVALID_PATH("Directory structure as "
+ + "specified in SURL does not exist!");
failure = true;
- log
- .debug("ATTENTION in PtPChunk! Directory structure as specified in "
- + f
- + " does not exist, and automatic directory creation is disbaled! Failing this chunk of request!"); // info
+ log.debug("ATTENTION in PtPChunk! Directory structure as specified "
+ + "in {} does not exist, and automatic directory creation is disbaled! "
+ + "Failing this chunk of request!", f);
return false;
} else {
if (!f.exists()) {
if (f.mkdirs()) {
- requestData
- .changeStatusSRM_INTERNAL_ERROR("Local filesystem error: could not crete directory!");
+ requestData.changeStatusSRM_INTERNAL_ERROR("Local filesystem error: "
+ + "could not crete directory!");
failure = true;
- log
- .error("ERROR in PtPChunk! Filesystem was unable to successfully create directory: "
- + f.toString());
+ log.error("ERROR in PtPChunk! Filesystem was unable to successfully "
+ + "create directory: {}", f.toString());
return false;
}
}
@@ -594,16 +569,15 @@ private boolean managePermitSetFileStep(StoRI fileStoRI)
setDefaultAcl(fileStoRI);
setTapeManagementAcl(fileStoRI);
return true;
- } else {
- return false;
- }
- } else {
- setDefaultAcl(fileStoRI);
- setTapeManagementAcl(fileStoRI);
- setHttpsServiceAcl(fileStoRI.getLocalFile(),
- FilesystemPermission.ReadWrite);
- return true;
- }
+ }
+ return false;
+ }
+
+ setDefaultAcl(fileStoRI);
+ setTapeManagementAcl(fileStoRI);
+ setHttpsServiceAcl(fileStoRI.getLocalFile(),
+ FilesystemPermission.ReadWrite);
+ return true;
}
/**
@@ -614,8 +588,9 @@ private boolean managePermitSetFileStep(StoRI fileStoRI, LocalUser localUser) {
// BEWARE THAT READ PERMISSION IS NEEDED BECAUSE GRID_FTP SERVER _ALSO_
// REQUIRES READ RIGHTS ELSE IT WON T BE ABLE TO WRITE THE FILE!!!
- log.debug("PtPChunk: setting RW ACL for " + fileStoRI.getAbsolutePath()
- + " for user " + localUser);
+ log.debug("PtPChunk: setting RW ACL for {} for user {}",
+ fileStoRI.getAbsolutePath(), localUser);
+
try {
if (!setAcl(fileStoRI, localUser, FilesystemPermission.ReadWrite,
fileStoRI.hasJustInTimeACLs())) {
@@ -639,27 +614,26 @@ private boolean setAcl(StoRI parentStoRI, LocalUser localUser,
if (hasJustInTimeACLs) {
return setJiTAcl(parentStoRI, localUser, permission);
- } else {
- return setAoTAcl(parentStoRI, localUser, permission);
- }
+ }
+ return setAoTAcl(parentStoRI, localUser, permission);
}
private boolean setJiTAcl(StoRI fileStori, LocalUser localUser,
FilesystemPermission permission) throws Exception {
- log.debug("SrmMkdir: Adding JiT ACL " + permission + " to user "
- + localUser + " for directory : '" + fileStori.getAbsolutePath() + "'");
+ log.debug("SrmMkdir: Adding JiT ACL {} to user {} for directory: '{}'",
+ permission, localUser, fileStori.getAbsolutePath());
+
try {
AclManagerFSAndHTTPS.getInstance().grantUserPermission(
fileStori.getLocalFile(), localUser, permission);
} catch (IllegalArgumentException e) {
- log
- .error("Unable to grant user traverse permission on parent file. IllegalArgumentException: "
- + e.getMessage());
+ log.error("Unable to grant user traverse permission on parent file. "
+ + "IllegalArgumentException: {}", e.getMessage(), e);
return false;
}
+
boolean response;
-
FilesystemPermission fp = fileStori.getLocalFile()
.getEffectiveUserPermission(localUser);
if (fp != null) {
@@ -669,15 +643,14 @@ private boolean setJiTAcl(StoRI fileStori, LocalUser localUser,
response = true;
} else {
log.error("ATTENTION in PtPChunk! The local filesystem has"
- + " a mask that does not allow " + permission + " User-ACL to "
- + "be set up on" + fileStori.getLocalFile().toString() + "!");
+ + " a mask that does not allow {} User-ACL to be set up on!",
+ permission, fileStori.getLocalFile().toString());
response = false;
}
} else {
- log.error("ERROR in PtPChunk! A " + permission + " User-ACL was set on "
- + fileStori.getAbsolutePath() + " for user " + localUser.toString()
- + " but when subsequently verifying its effectivity,"
- + " a null ACE was found!");
+ log.error("ERROR in PtPChunk! A {} User-ACL was set on {} for user {} but "
+ + "when subsequently verifying its effectivity, a null ACE was found!",
+ permission, fileStori.getAbsolutePath(), localUser.toString());
throw new Exception("Unable to verify user ACL");
}
return response;
@@ -686,19 +659,19 @@ private boolean setJiTAcl(StoRI fileStori, LocalUser localUser,
private boolean setAoTAcl(StoRI fileStori, LocalUser localUser,
FilesystemPermission permission) throws Exception {
- log.debug("SrmMkdir: Adding AoT ACL " + permission + " to user "
- + localUser + " for directory : '" + fileStori.getAbsolutePath() + "'");
+ log.debug("SrmMkdir: Adding AoT ACL {} to user {} for directory: '{}'",
+ permission, localUser, fileStori.getAbsolutePath());
+
try {
AclManagerFSAndHTTPS.getInstance().grantGroupPermission(
fileStori.getLocalFile(), localUser, permission);
} catch (IllegalArgumentException e) {
- log
- .error("Unable to grant user traverse permission on parent file. IllegalArgumentException: "
- + e.getMessage());
+ log.error("Unable to grant user traverse permission on parent file. "
+ + "IllegalArgumentException: {}", e.getMessage(), e);
return false;
}
- boolean response;
+ boolean response;
FilesystemPermission fp = fileStori.getLocalFile()
.getEffectiveGroupPermission(localUser);
if (fp != null) {
@@ -706,15 +679,14 @@ private boolean setAoTAcl(StoRI fileStori, LocalUser localUser,
response = true;
} else {
log.error("ATTENTION in PtPChunk! The local filesystem has a mask"
- + " that does not allow Traverse Group-ACL to be set up on"
- + fileStori.getLocalFile().toString() + "!");
+ + " that does not allow Traverse Group-ACL to be set up on {}!",
+ fileStori.getLocalFile().toString());
response = false;
}
} else {
- log.error("ERROR in PtPChunk! A Traverse Group-ACL was set on "
- + fileStori.getAbsolutePath() + " for user " + localUser.toString()
- + " but when subsequently verifying its effectivity, "
- + "a null ACE was found!");
+ log.error("ERROR in PtPChunk! A Traverse Group-ACL was set on {} for "
+ + "user {} but when subsequently verifying its effectivity, a null ACE "
+ + "was found!", fileStori.getAbsolutePath(), localUser.toString());
response = false;
}
return response;
@@ -722,8 +694,8 @@ private boolean setAoTAcl(StoRI fileStori, LocalUser localUser,
private void setHttpsServiceParentAcl(StoRI fileStoRI) {
- log.debug("SrmMkdir: Adding parent https ACL for directory : '"
- + fileStoRI.getAbsolutePath() + "' parents");
+ log.debug("SrmMkdir: Adding parent https ACL for directory: '{}' parents",
+ fileStoRI.getAbsolutePath());
for (StoRI parentStoRI : fileStoRI.getParents()) {
setHttpsServiceAcl(parentStoRI.getLocalFile(),
FilesystemPermission.Traverse);
@@ -733,15 +705,15 @@ private void setHttpsServiceParentAcl(StoRI fileStoRI) {
private void setHttpsServiceAcl(LocalFile file,
FilesystemPermission permission) {
- log.debug("SrmMkdir: Adding https ACL " + permission + "for directory : '"
- + file + "'");
+ log.debug("SrmMkdir: Adding https ACL {} for directory : '{}'",
+ permission, file);
+
try {
AclManagerFSAndHTTPS.getInstance().grantHttpsServiceGroupPermission(file,
permission);
} catch (IllegalArgumentException e) {
- log
- .error("Unable to grant user permission on the created folder. IllegalArgumentException: "
- + e.getMessage());
+ log.error("Unable to grant user permission on the created folder. "
+ + "IllegalArgumentException: {}", e.getMessage(), e);
requestData.getStatus().extendExplaination(
"Unable to grant group permission on the created folder");
}
@@ -753,8 +725,8 @@ private void setHttpsServiceAcl(LocalFile file,
*/
private boolean managePermitReserveSpaceStep(StoRI fileStoRI) {
- log.debug("PtPChunk: entered ReserveSpaceStep for "
- + fileStoRI.getAbsolutePath());
+ log.debug("PtPChunk: entered ReserveSpaceStep for {}",
+ fileStoRI.getAbsolutePath());
TSizeInBytes size = requestData.expectedFileSize();
TSpaceToken spaceToken = requestData.getSpaceToken();
LocalFile localFile = fileStoRI.getLocalFile();
@@ -778,10 +750,9 @@ private boolean managePermitReserveSpaceStep(StoRI fileStoRI) {
*/
TSpaceToken SASpaceToken = sp.getTokenFromStoRI(PtP.log, fileStoRI);
if (SASpaceToken == null || SASpaceToken.isEmpty()) {
- log
- .error("PtPChunk - ReserveSpaceStep: Unable to get a valid TSpaceToken for stori "
- + fileStoRI
- + " . Unable to verify storage area space initialization");
+ log.error("PtPChunk - ReserveSpaceStep: Unable to get a valid "
+ + "TSpaceToken for stori {} . Unable to verify storage area space "
+ + "initialization", fileStoRI);
requestData
.changeStatusSRM_FAILURE("No valid space token for the Storage Area");
failure = true; // gsm.failedChunk(chunkData);
@@ -790,14 +761,12 @@ private boolean managePermitReserveSpaceStep(StoRI fileStoRI) {
if (!sp.isSAInitialized(PtP.log, fileStoRI)
&& SpaceInfoManager.isInProgress(SASpaceToken)) {
/* Trust we got space, let the request pass */
- log
- .debug("PtPChunk: ReserveSpaceStep: the storage area space initialization is in progress, "
- + "optimistic approach, considering we got enough space");
+ log.debug("PtPChunk: ReserveSpaceStep: the storage area space "
+ + "initialization is in progress, optimistic approach, considering "
+ + "we got enough space");
} else {
- log
- .debug("PtPChunk - ReserveSpaceStep: no free space on Storage Area!");
- requestData
- .changeStatusSRM_FAILURE("No free space on Storage Area");
+ log.debug("PtPChunk - ReserveSpaceStep: no free space on Storage Area!");
+ requestData.changeStatusSRM_FAILURE("No free space on Storage Area");
failure = true;
return false;
}
@@ -809,78 +778,41 @@ private boolean managePermitReserveSpaceStep(StoRI fileStoRI) {
// set space!
boolean successful = localFile.createNewFile();
if ((!successful)
- && (requestData.overwriteOption() == TOverwriteMode.NEVER)) {
- // atomic operation of creation of file if non existent, failed:
- // so the file
- // did exist before. The Overwrite option was set to NEVER, so
- // fail request!
- //
- // this test is done here, in case concurrent PtP chunks get
- // executed at the
- // same time: this is the _only_ place where the concurrent
- // operation can be
- // spotted without incurring in exceptionally tough
- // syncronisation issues!
- //
- // File exists but Overwrite set to NEVER!!!
- log
- .debug("PtPChunk - ReserveSpaceStep: no overwrite allowed! Failing chunk... ");
- requestData
- .changeStatusSRM_DUPLICATION_ERROR("Cannot srmPut file because it already exists!");
- failure = true; // gsm.failedChunk(chunkData);
+ && (requestData.overwriteOption().equals(TOverwriteMode.NEVER))) {
+
+ log.debug("PtPChunk - ReserveSpaceStep: no overwrite allowed! "
+ + "Failing chunk... ");
+ requestData.changeStatusSRM_DUPLICATION_ERROR("Cannot srmPut file "
+ + "because it already exists!");
+ failure = true;
return false;
+
} else if (!successful
&& TStatusCode.SRM_SPACE_AVAILABLE.equals(SurlStatusManager
- .getSurlStatus(requestData.getSURL())))// PtPChunkCatalog.getInstance().isSRM_SPACE_AVAILABLE(requestData.getSURL()))
- {
- // atomic operation of creation of file if non existent, failed:
- // so the file
- // did exist before. A check in the catalogue shows that there
- // is a past request
- // which has the SURL in SRM_SPACE_AVAILABLE! So request must be
- // failed with
- // SRM_FILE_BUSY
- //
- // WARNING! Unfortunately although this test is done here, in
- // case concurrent PtP
- // chunks get executed at the same time, it is still NOT
- // guaranteed that one of the
- // two PtP will get an SRM_FILE_BUSY.
- //
- // The operation isSRM_SPACE_AVAILABLE _is_ atomic because that
- // method is
- // synchronised. But the couple createNewFile AND
- // isSRM_FILE_BUSY
- // is NOT atomic! Hence the inability to guarantee one of the
- // two
- // will get an SRM_FILE_BUSY.
- //
- // Putting the check here minimizes the chances, but cannot be
- // eliminated
- // altogether.
- //
- // fail request with SRM_FILE_BUSY
- requestData
- .changeStatusSRM_FILE_BUSY("Requested file is still in SRM_SPACE_AVAILABLE state!");
+ .getSurlStatus(requestData.getSURL()))) {
+
+ requestData.changeStatusSRM_FILE_BUSY("Requested file is still in "
+ + "SRM_SPACE_AVAILABLE state!");
failure = true;
- log
- .debug("ATTENTION in PtPChunk! PtPChunk received request for SURL that is still in SRM_SPACE_AVAILABLE state!");
+ log.debug("ATTENTION in PtPChunk! PtPChunk received request for SURL "
+ + "that is still in SRM_SPACE_AVAILABLE state!");
return false;
} else if ((spaceToken.isEmpty()) && (size.isEmpty())) {
- log
- .debug("PtPChunk - ReserveSpaceStep: no SpaceToken and no FileSize specified; mock file will be created... ");
+ log.debug("PtPChunk - ReserveSpaceStep: no SpaceToken and no FileSize "
+ + "specified; mock file will be created... ");
} else if ((spaceToken.isEmpty()) && (!size.isEmpty())) {
- log
- .debug("PtPChunk - ReserveSpaceStep: no SpaceToken available but there is a FileSize specified; implicit space reservation taking place...");
+ log.debug("PtPChunk - ReserveSpaceStep: no SpaceToken available but "
+ + "there is a FileSize specified; implicit space reservation "
+ + "taking place...");
fileStoRI.allotSpaceForFile(size);
} else if ((!spaceToken.isEmpty()) && (!size.isEmpty())) {
- log
- .debug("PtPChunk - ReserveSpaceStep: SpaceToken available and FileSize specified; reserving space by token...");
+ log.debug("PtPChunk - ReserveSpaceStep: SpaceToken available and "
+ + "FileSize specified; reserving space by token...");
if (!isExistingSpaceToken(spaceToken)) {
- requestData
- .changeStatusSRM_INVALID_REQUEST("The provided Space Token does not exists");
- log.info("PtPChunk execution failed. The space token " + spaceToken
- + " provided by user does not exists");
+ requestData.changeStatusSRM_INVALID_REQUEST("The provided Space Token "
+ + "does not exists");
+ log.info("PtPChunk execution failed. The space token {} provided by "
+ + "user does not exists", spaceToken);
return false;
} else {
fileStoRI.allotSpaceByToken(spaceToken, size);
@@ -889,20 +821,20 @@ private boolean managePermitReserveSpaceStep(StoRI fileStoRI) {
// spaceToken is NOT empty but size IS!
// Use of EMPTY Space Size. That means total size of Storage
// Space will be used!!
- log
- .debug("PtPChunk - ReserveSpaceStep: SpaceToken available and FileSize specified; reserving space by token...");
+ log.debug("PtPChunk - ReserveSpaceStep: SpaceToken available and "
+ + "FileSize specified; reserving space by token...");
if (!isExistingSpaceToken(spaceToken)) {
- requestData
- .changeStatusSRM_INVALID_REQUEST("The provided Space Token does not exists");
- log.info("PtPChunk execution failed. The space token " + spaceToken
- + " provided by user does not exists");
+ requestData.changeStatusSRM_INVALID_REQUEST("The provided Space Token "
+ + "does not exists");
+ log.info("PtPChunk execution failed. The space token {} provided by "
+ + "user does not exists", spaceToken);
return false;
} else {
fileStoRI.allotSpaceByToken(spaceToken);
}
}
- log.debug("PtPChunk: finished ReserveSpaceStep for "
- + fileStoRI.getAbsolutePath());
+ log.debug("PtPChunk: finished ReserveSpaceStep for {}",
+ fileStoRI.getAbsolutePath());
return true;
} catch (SecurityException e) {
// file.createNewFile could not create file because the Java
@@ -911,72 +843,60 @@ private boolean managePermitReserveSpaceStep(StoRI fileStoRI) {
// local system administrator
// who applied a strict local policy, and policies as specified by
// the PolicyCollector!
- requestData
- .changeStatusSRM_FAILURE("Space Management step in srmPrepareToPut failed!");
+ requestData.changeStatusSRM_FAILURE("Space Management step in "
+ + "srmPrepareToPut failed!");
failure = true;
- log
- .error("ERROR in PtPChunk! During space reservation step in PtP, could not create file: "
- + localFile.toString()
- + "; Java s SecurityManager does not allow writing the file! " + e);
+ log.error("ERROR in PtPChunk! During space reservation step in PtP, "
+ + "could not create file: {}; Java s SecurityManager does not allow "
+ + "writing the file! ", localFile.toString(), e);
return false;
} catch (IOException e) {
// file.createNewFile could not create file because of a local IO
// Error!
- requestData
- .changeStatusSRM_FAILURE("Space Management step in srmPrepareToPut failed!");
+ requestData.changeStatusSRM_FAILURE("Space Management step in "
+ + "srmPrepareToPut failed!");
failure = true;
- log
- .error("ERROR in PtPChunk! During space reservation step in PtP, an error occured while trying to create the file:"
- + localFile.toString() + "; error: " + e);
+ log.error("ERROR in PtPChunk! During space reservation step in PtP, "
+ + "an error occured while trying to create the file: {}; error: {}",
+ localFile.toString(), e.getMessage(), e);
return false;
} catch (it.grid.storm.filesystem.InvalidPermissionOnFileException e) {
// I haven t got the right to create a file as StoRM user!
// This is thrown when executing createNewFile method!
- requestData
- .changeStatusSRM_FAILURE("Space Management step in srmPrepareToPut failed!");
+ requestData.changeStatusSRM_FAILURE("Space Management step in "
+ + "srmPrepareToPut failed!");
failure = true;
- log
- .error("ERROR in PtPChunk! During space reservation step in PtP, an attempt to create file "
- + localFile.toString()
- + " failed because StoRM lacks the privileges to do so! Exception follows: "
- + e);
+ log.error("ERROR in PtPChunk! During space reservation step in PtP, an "
+ + "attempt to create file {} failed because StoRM lacks the privileges "
+ + "to do so! Exception follows: {}", localFile.toString(),
+ e.getMessage(), e);
return false;
} catch (ReservationException e) {
// Something went wrong while using space reservation component!
- requestData
- .changeStatusSRM_FAILURE("Space Management step in srmPrepareToPut failed!");
+ requestData.changeStatusSRM_FAILURE("Space Management step in "
+ + "srmPrepareToPut failed!");
failure = true;
- log
- .error("ERROR in PtPChunk! Space component failed! Exception follows: "
- + e);
+ log.error("ERROR in PtPChunk! Space component failed! Exception "
+ + "follows: {}", e.getMessage(), e);
return false;
} catch (ExpiredSpaceTokenException e) {
// The supplied space token is expired
- requestData
- .changeStatusSRM_SPACE_LIFETIME_EXPIRED("The provided Space Token has expired its lifetime");
+ requestData.changeStatusSRM_SPACE_LIFETIME_EXPIRED("The provided Space "
+ + "Token has expired its lifetime");
spacefailure = true;
- log.info("PtPChunk execution failed. ExpiredSpaceTokenException : "
- + e.getMessage());
+ log.info("PtPChunk execution failed. ExpiredSpaceTokenException: {}",
+ e.getMessage());
return false;
} catch (Exception e) {
// This could be thrown by Java from Filesystem component given that
- // there is GPFS under the hoods,
- // but I do not know exactly how java.io.File behaves with an ACL
- // capable filesystem!!
- requestData
- .changeStatusSRM_FAILURE("Space Management step in srmPrepareToPut failed!");
+ // there is GPFS under the hoods, but I do not know exactly how
+ // java.io.File behaves with an ACL capable filesystem!!
+ requestData.changeStatusSRM_FAILURE("Space Management step in "
+ + "srmPrepareToPut failed!");
failure = true;
- log
- .error("ERROR in PtPChunk - space Step! Unexpected error in reserve space step of PtP for file "
- + localFile.toString() + "! Exception follows: " + e);
- log.error("Complete error stack trace follows: ");
- StackTraceElement[] ste = e.getStackTrace();
- if (ste != null) {
- for (StackTraceElement element : ste) {
- log.error(element.toString());
- }
- }
-
+ log.error("ERROR in PtPChunk - space Step! Unexpected error in reserve "
+ + "space step of PtP for file {}! Exception follows: {}",
+ localFile.toString(), e.getMessage(), e);
// ROOLBACK??
// The file already exists!!!
return false;
@@ -989,18 +909,15 @@ private boolean isExistingSpaceToken(TSpaceToken spaceToken) throws Exception {
try {
spaceData = new ReservedSpaceCatalog().getStorageSpace(spaceToken);
} catch (TransferObjectDecodingException e) {
- log
- .error("Unable to build StorageSpaceData from StorageSpaceTO. TransferObjectDecodingException: "
- + e.getMessage());
- throw new Exception(
- "Error retrieving Storage Area information from Token. TransferObjectDecodingException : "
- + e.getMessage());
+ log.error("Unable to build StorageSpaceData from StorageSpaceTO."
+ + " TransferObjectDecodingException: {}", e.getMessage());
+ throw new Exception("Error retrieving Storage Area information from Token."
+ + " TransferObjectDecodingException: " + e.getMessage());
} catch (DataAccessException e) {
- log.error("Unable to build get StorageSpaceTO. DataAccessException: "
- + e.getMessage());
- throw new Exception(
- "Error retrieving Storage Area information from Token. DataAccessException : "
- + e.getMessage());
+ log.error("Unable to build get StorageSpaceTO. DataAccessException: {}",
+ e.getMessage());
+ throw new Exception("Error retrieving Storage Area information from Token."
+ + " DataAccessException: " + e.getMessage());
}
return spaceData != null;
}
@@ -1012,25 +929,23 @@ private void setDefaultAcl(StoRI fileStoRI) {
if (dacl != null && !dacl.isEmpty()) {
for (ACLEntry ace : dacl.getACL()) {
if (ace.isValid()) {
- log.debug("Adding DefaultACL for the gid: " + ace.getGroupID()
- + " with permission: " + ace.getFilePermissionString());
+ log.debug("Adding DefaultACL for the gid: {} with permission: {}",
+ ace.getGroupID(), ace.getFilePermissionString());
LocalUser u = new LocalUser(ace.getGroupID(), ace.getGroupID());
if (ace.getFilesystemPermission() == null) {
- log
- .warn("Unable to setting up the ACL. ACl entry permission is null!");
+ log.warn("Unable to setting up the ACL. ACl entry permission "
+ + "is null!");
} else {
try {
AclManagerFSAndHTTPS.getInstance().grantGroupPermission(
fileStoRI.getLocalFile(), u, ace.getFilesystemPermission());
} catch (IllegalArgumentException e) {
- log
- .error("Unable to grant group permission on the file. IllegalArgumentException: "
- + e.getMessage());
+ log.error("Unable to grant group permission on the file. "
+ + "IllegalArgumentException: {}", e.getMessage(), e);
}
}
}
}
-
}
}
@@ -1060,8 +975,8 @@ private void manageDeny() {
requestData.changeStatusSRM_AUTHORIZATION_FAILURE("Create/Write access to "
+ requestData.getSURL() + " denied!");
failure = true;
- log.debug("Create/Write access to " + requestData.getSURL() + " for user "
- + DataHelper.getRequestor(requestData) + " denied!"); // info
+ log.debug("Create/Write access to {}, for user {} denied!",
+ requestData.getSURL(), DataHelper.getRequestor(requestData));
}
/**
@@ -1083,9 +998,9 @@ private void manageAnomaly(AuthzDecision decision) {
requestData
.changeStatusSRM_FAILURE("Missing Policy! Access rights cannot be established!");
failure = true;
- log
- .error("PtPChunk: PolicyCollector warned of missing policies for the supplied SURL!");
- log.error("Requested SURL: " + requestData.getSURL());
+ log.error("PtPChunk: PolicyCollector warned of missing policies for the "
+ + "supplied SURL!");
+ log.error("Requested SURL: {}", requestData.getSURL());
break;
case INDETERMINATE:
// PolicyCollector error
@@ -1093,7 +1008,7 @@ private void manageAnomaly(AuthzDecision decision) {
.changeStatusSRM_FAILURE("PolicyCollector error! Access rights cannot be established!");
failure = true;
log.error("PtPChunk: PolicyCollector encountered internal problems!");
- log.error("Requested SURL: " + requestData.getSURL());
+ log.error("Requested SURL: {}", requestData.getSURL());
break;
default:
// Unexpected policy!
@@ -1102,7 +1017,7 @@ private void manageAnomaly(AuthzDecision decision) {
failure = true;
log
.error("PtPChunk: unexpected policy returned by PolicyCollector for the supplied SURL!");
- log.error("Requested SURL: " + requestData.getSURL());
+ log.error("Requested SURL: {}", requestData.getSURL());
break;
}
}
diff --git a/src/main/java/it/grid/storm/asynch/PtPBuilder.java b/src/main/java/it/grid/storm/asynch/PtPBuilder.java
index bf9154be..f2382b9b 100644
--- a/src/main/java/it/grid/storm/asynch/PtPBuilder.java
+++ b/src/main/java/it/grid/storm/asynch/PtPBuilder.java
@@ -66,9 +66,8 @@ public static PtP build(PrepareToPutInputData inputData)
status = new TReturnStatus(TStatusCode.SRM_REQUEST_QUEUED,
"Synchronous request created");
} catch (InvalidTReturnStatusAttributeException e) {
- log
- .error("Unable to build TReturnStatus. InvalidTReturnStatusAttributeException: "
- + e.getMessage());
+ log.error("Unable to build TReturnStatus. "
+ + "InvalidTReturnStatusAttributeException: {}", e.getMessage());
throw new BuilderException(
"Error building PtP TReturnStatus. Building failed");
}
@@ -88,29 +87,26 @@ public static PtP build(PrepareToPutInputData inputData)
}
data.store();
} catch (InvalidPtPDataAttributesException e) {
- log
- .error("Unable to build PtPChunkData. InvalidPtPChunkDataAttributesException: "
- + e.getMessage());
+ log.error("Unable to build PtPChunkData. "
+ + "InvalidPtPChunkDataAttributesException: {}", e.getMessage());
throw new BuilderException(
"Error building PtP PtPChunkData. Building failed");
} catch (InvalidFileTransferDataAttributesException e) {
- log
- .error("Unable to build PtPChunkData. InvalidFileTransferChunkDataAttributesException: "
- + e.getMessage());
+ log.error("Unable to build PtPChunkData. "
+ + "InvalidFileTransferChunkDataAttributesException: {}", e.getMessage());
throw new BuilderException(
"Error building PtP PtPChunkData. Building failed");
} catch (InvalidSurlRequestDataAttributesException e) {
- log
- .error("Unable to build PtPChunkData. InvalidSurlRequestDataAttributesException: "
- + e.getMessage());
+ log.error("Unable to build PtPChunkData. "
+ + "InvalidSurlRequestDataAttributesException: ", e.getMessage());
throw new BuilderException(
"Error building PtP PtPChunkData. Building failed");
}
try {
return new PtP(data);
} catch (InvalidRequestAttributesException e) {
- log.error("Unable to build PtP. InvalidRequestAttributesException: "
- + e.getMessage());
+ log.error("Unable to build PtP. "
+ + "InvalidRequestAttributesException: {}", e.getMessage());
throw new BuilderException("Error building PtP. Building failed");
}
}
diff --git a/src/main/java/it/grid/storm/asynch/PtPFeeder.java b/src/main/java/it/grid/storm/asynch/PtPFeeder.java
index a94a70e9..fcaf5eeb 100644
--- a/src/main/java/it/grid/storm/asynch/PtPFeeder.java
+++ b/src/main/java/it/grid/storm/asynch/PtPFeeder.java
@@ -83,9 +83,8 @@ public PtPFeeder(RequestSummaryData rsd)
this.rsd = rsd;
gsm = new GlobalStatusManager(rsd.requestToken());
} catch (InvalidOverallRequestAttributeException e) {
- log
- .error("ATTENTION in PtPFeeder! Programming bug when creating GlobalStatusManager! "
- + e);
+ log.error("ATTENTION in PtPFeeder! Programming bug when creating "
+ + "GlobalStatusManager! {}", e.getMessage());
throw new InvalidPtPFeederAttributesException(rsd, gu, null);
}
}
@@ -96,19 +95,18 @@ public PtPFeeder(RequestSummaryData rsd)
*/
public void doIt() {
- log.debug("PtPFeeder: pre-processing " + rsd.requestToken());
+ log.debug("PtPFeeder: pre-processing {}", rsd.requestToken());
/* Get all parts in request */
Collection chunks = PtPChunkCatalog.getInstance()
.lookup(rsd.requestToken());
if (chunks.isEmpty()) {
- log
- .warn("ATTENTION in PtPFeeder! This SRM put request contained nothing to process! "
- + rsd.requestToken());
+ log.warn("ATTENTION in PtPFeeder! This SRM put request contained nothing "
+ + "to process! {}", rsd.requestToken());
RequestSummaryCatalog.getInstance().failRequest(rsd,
"This SRM put request contained nothing to process!");
} else {
manageChunks(chunks);
- log.debug("PtPFeeder: finished pre-processing " + rsd.requestToken());
+ log.debug("PtPFeeder: finished pre-processing {}", rsd.requestToken());
}
}
@@ -120,7 +118,7 @@ public void doIt() {
*/
private void manageChunks(Collection chunksData) {
- log.debug("PtPFeeder: number of chunks in request " + chunksData.size());
+ log.debug("PtPFeeder: number of chunks in request {}", chunksData.size());
/* chunk currently being processed */
for (PtPPersistentChunkData chunkData : chunksData) {
/* add chunk for global status consideration */
@@ -134,8 +132,8 @@ private void manageChunks(Collection chunksData) {
*/
log.warn("PtPFeeder: srmPtP contract violation! toSURL"
+ " does not refer to this machine!");
- log.warn("Request: " + rsd.requestToken());
- log.warn("Chunk: " + chunkData);
+ log.warn("Request: {}", rsd.requestToken());
+ log.warn("Chunk: {}", chunkData);
chunkData.changeStatusSRM_FAILURE("SRM protocol violation!"
+ " Cannot do an srmPtP of a SURL that is not local!");
@@ -171,7 +169,8 @@ private void manage(PtPPersistentChunkData auxChunkData) {
.schedule(new PtPPersistentChunk(rsd, auxChunkData, gsm));
log.debug("PtPFeeder - chunk scheduled.");
} catch (IllegalArgumentException e) {
- log.error("Unable to schedule the chunk. IllegalArgumentException: " + e);
+ log.error("Unable to schedule the chunk. IllegalArgumentException: {}",
+ e.getMessage(), e);
auxChunkData.changeStatusSRM_FAILURE("StoRM internal error"
+ " does not allow this chunk to be processed!");
@@ -179,19 +178,18 @@ private void manage(PtPPersistentChunkData auxChunkData) {
PtPChunkCatalog.getInstance().update(auxChunkData);
gsm.failedChunk(auxChunkData);
} catch (InvalidRequestAttributesException e) {
- log.error("UNEXPECTED ERROR in PtPFeeder! Chunk could not be created!\n"
- + e);
+ log.error("UNEXPECTED ERROR in PtPFeeder! Chunk could not be "
+ + "created!\n{}", e.getMessage(), e);
- auxChunkData.changeStatusSRM_FAILURE("StoRM internal error"
- + " does not allow this chunk to be processed!");
+ auxChunkData.changeStatusSRM_FAILURE("StoRM internal error does not "
+ + "allow this chunk to be processed!");
PtPChunkCatalog.getInstance().update(auxChunkData);
gsm.failedChunk(auxChunkData);
} catch (SchedulerException e) {
/* Internal error of scheduler! */
- log
- .error("UNEXPECTED ERROR in ChunkScheduler! Chunk could not be scheduled!\n"
- + e);
+ log.error("UNEXPECTED ERROR in ChunkScheduler! Chunk could not be "
+ + "scheduled!\n{}", e.getMessage(), e);
auxChunkData.changeStatusSRM_FAILURE("StoRM internal scheduler "
+ "error prevented this chunk from being processed!");
diff --git a/src/main/java/it/grid/storm/asynch/PtPPersistentChunk.java b/src/main/java/it/grid/storm/asynch/PtPPersistentChunk.java
index 629beeba..9fddbc2d 100644
--- a/src/main/java/it/grid/storm/asynch/PtPPersistentChunk.java
+++ b/src/main/java/it/grid/storm/asynch/PtPPersistentChunk.java
@@ -89,16 +89,16 @@ public String getRequestToken() {
@Override
public void persistStatus() {
- PtPPersistentChunk.log.debug("Persisting status of request : "
- + rsd.requestToken() + " on SURL " + this.requestData.getSURL());
+ PtPPersistentChunk.log.debug("Persisting status of request: {} on SURL {}",
+ rsd.requestToken(), requestData.getSURL());
PtPChunkCatalog.getInstance().update((PtPPersistentChunkData) requestData);
}
@Override
public void updateGlobalStatus() {
- PtPPersistentChunk.log.debug("Updating global status for request : "
- + rsd.requestToken() + " on SURL " + this.requestData.getSURL());
+ PtPPersistentChunk.log.debug("Updating global status for request: {} on "
+ + "SURL ", rsd.requestToken(), requestData.getSURL());
if (failure) {
gsm.failedChunk((PtPPersistentChunkData) requestData);
} else {
diff --git a/src/main/java/it/grid/storm/asynch/PushCopyGetVisitor.java b/src/main/java/it/grid/storm/asynch/PushCopyGetVisitor.java
index a250b7d6..c3ffca7c 100644
--- a/src/main/java/it/grid/storm/asynch/PushCopyGetVisitor.java
+++ b/src/main/java/it/grid/storm/asynch/PushCopyGetVisitor.java
@@ -77,9 +77,8 @@ public Copy.Result visit(VisitableCopy copy) {
parameters.add(4, copy.getLocalrt());
return copy.buildOperationResult(parameters, ResultType.GET);
} catch (Exception e) {
- copy.getLog().error(
- "ERROR IN PushCopyChunk! Cannot initiate local PtG! Requested SURL: "
- + copy.getRequestData().getSURL());
+ copy.getLog().error("ERROR IN PushCopyChunk! Cannot initiate local PtG! "
+ + "Requested SURL: {}", copy.getRequestData().getSURL());
copy.getLog().error(e.getMessage(), e);
return copy.buildOperationResult("Cannot initiate local PtG! " + e,
ResultType.GET);
diff --git a/src/main/java/it/grid/storm/asynch/PushCopyPutVisitor.java b/src/main/java/it/grid/storm/asynch/PushCopyPutVisitor.java
index 8fd33837..b2ed73b2 100644
--- a/src/main/java/it/grid/storm/asynch/PushCopyPutVisitor.java
+++ b/src/main/java/it/grid/storm/asynch/PushCopyPutVisitor.java
@@ -46,7 +46,7 @@ public Result visit(VisitableCopy copy) {
.getRequestData().getSpaceToken(), getFileSize,
TransferProtocol.GSIFTP, "StoRM Remote PtP for (push) srmCopy", copy
.getRequestData().getOverwriteOption(), retryTime);
- copy.getLog().debug("... got it! Reply was: " + reply);
+ copy.getLog().debug("... got it! Reply was: {}", reply);
// Polling...
long timeOut = new Date().getTime()
+ Configuration.getInstance().getSRMClientPutTimeOut() * 1000;
@@ -69,20 +69,17 @@ public Result visit(VisitableCopy copy) {
.getDestinationSURL());
replyCode = statusOfPutRequestReply.returnStatus().getStatusCode();
timedOut = (new Date().getTime() > timeOut);
- copy.getLog().debug(
- "PUSH COPY CHUNK: reply was " + statusOfPutRequestReply
- + "; the reply code was: " + replyCode + "; timedOut is:"
- + timedOut);
+ copy.getLog().debug("PUSH COPY CHUNK: reply was {}; the reply code "
+ + "was: {}; timedOut is: {}", statusOfPutRequestReply, replyCode,
+ timedOut);
} while (((replyCode == TStatusCode.SRM_REQUEST_QUEUED)
- || (replyCode == TStatusCode.SRM_REQUEST_INPROGRESS) || (replyCode == TStatusCode.SRM_INTERNAL_ERROR))
+ || (replyCode == TStatusCode.SRM_REQUEST_INPROGRESS)
+ || (replyCode == TStatusCode.SRM_INTERNAL_ERROR))
&& !timedOut);
} catch (SRMClientException e2) {
// The SRMClient statusOfPutRequest functionality failed!
- copy
- .getLog()
- .error(
- "ERROR IN PushCopyChunk! PutOperation failed: SRMClient could not do an srmStatusOfPutRequest! "
- + e2);
+ copy.getLog().error("ERROR IN PushCopyChunk! PutOperation failed: "
+ + "SRMClient could not do an srmStatusOfPutRequest! {}", e2);
StringBuffer sb = new StringBuffer();
sb.append("Parameters passed to client: ");
sb.append("requestToken: ");
@@ -109,9 +106,8 @@ public Result visit(VisitableCopy copy) {
ResultType.PUT);
}
// The remote operation completed!!!
- copy.getLog().debug(
- "PushCopyChunk! The PutOperation completed! "
- + statusOfPutRequestReply.returnStatus());
+ copy.getLog().debug("PushCopyChunk! The PutOperation completed! {}",
+ statusOfPutRequestReply.returnStatus());
ArrayList
- *
- *
- * Copyright: Copyright (c) 2006
- *
- *
- *
- * Company: INFN-CNAF and ICTP/eGrid project
- *
- *
- * @author Riccardo Zappi
- * @version 1.0
- */
public interface NamespaceInterface {
/**
@@ -465,5 +420,4 @@ public VirtualFSInterface resolveVFSbyRoot(String absolutePath)
public VirtualFSInterface resolveVFSbySpaceToken(TSpaceToken spaceToken)
throws NamespaceException;
-
-}
+}
\ No newline at end of file
diff --git a/src/main/java/it/grid/storm/namespace/NamespaceValidator.java b/src/main/java/it/grid/storm/namespace/NamespaceValidator.java
index 47b14c82..eb84dae3 100644
--- a/src/main/java/it/grid/storm/namespace/NamespaceValidator.java
+++ b/src/main/java/it/grid/storm/namespace/NamespaceValidator.java
@@ -24,32 +24,11 @@
import org.xml.sax.SAXParseException;
import org.xml.sax.helpers.DefaultHandler;
-/**
- *
- * Title:
- *
- *
- *
- * Description:
- *
- *
- *
- * Copyright: Copyright (c) 2006
- *
- *
- *
- * Company: INFN-CNAF and ICTP/eGrid project
- *
- *
- * @author Riccardo Zappi
- * @version 1.0
- */
public class NamespaceValidator {
private Logger log = LoggerFactory.getLogger(NamespaceValidator.class);
public boolean validateSchema(String SchemaUrl, String XmlDocumentUrl) {
-
boolean valid = false;
SAXParser parser = new SAXParser();
try {
@@ -71,36 +50,21 @@ public boolean validateSchema(String SchemaUrl, String XmlDocumentUrl) {
log.info("Namespace Document is valid with Schema");
valid = true;
}
- } catch (java.io.IOException ioe) {
- log.error("IOException" + ioe.getMessage());
- } catch (SAXException e) {
- log.error("SAXException" + e.getMessage());
+ } catch (Throwable e) {
+ log.error(e.getMessage(), e);
}
return valid;
}
- /**
- * manageErrorWithinNamespace
- *
- * @param handler
- * Validator
- */
private void manageErrorWithinNamespace(
it.grid.storm.namespace.NamespaceValidator.Validator handler) {
- StringBuffer sb = new StringBuffer();
- sb.append("##############################################" + "\n");
- sb.append("### WARNING : namespace.xml INVALID ###" + "\n");
- sb.append("##############################################" + "\n");
- sb.append("# Please check it. " + "\n");
- sb.append("# The error is : " + handler.saxParseException.getMessage()
- + "\n");
- sb.append("# at line : " + handler.saxParseException.getLineNumber()
- + ", column " + handler.saxParseException.getColumnNumber() + "\n");
- sb.append("# in entity : " + handler.saxParseException.getSystemId()
- + "\n");
- sb.append("##############################################" + "\n");
- log.error("\n" + sb.toString());
+ log.error("namespace.xml validation error.");
+ log.error("Error: {} line: {}, column: {}, entity: {}",
+ handler.saxParseException.getMessage(),
+ handler.saxParseException.getLineNumber(),
+ handler.saxParseException.getColumnNumber(),
+ handler.saxParseException.getSystemId());
}
private class Validator extends DefaultHandler {
@@ -111,11 +75,12 @@ private class Validator extends DefaultHandler {
@Override
public void error(SAXParseException exception) throws SAXException {
- log.error("ERROR : " + exception.getMessage());
- log.error(" at line " + exception.getLineNumber() + ", column "
- + exception.getColumnNumber());
- log.error(" in entity " + exception.getSystemId());
-
+ log.error("XML error: {}. Line: {}, column: {}, entity: {}",
+ exception.getMessage(),
+ exception.getLineNumber(),
+ exception.getColumnNumber(),
+ exception.getSystemId());
+
validationError = true;
saxParseException = exception;
}
@@ -123,10 +88,11 @@ public void error(SAXParseException exception) throws SAXException {
@Override
public void fatalError(SAXParseException exception) throws SAXException {
- log.error("FATAL ERROR: " + exception.getMessage());
- log.error(" at line " + exception.getLineNumber() + ", column "
- + exception.getColumnNumber());
- log.error(" in entity " + exception.getSystemId());
+ log.error("XML FATAL error: {}. Line: {}, column: {}, entity: {}",
+ exception.getMessage(),
+ exception.getLineNumber(),
+ exception.getColumnNumber(),
+ exception.getSystemId());
validationError = true;
saxParseException = exception;
@@ -135,10 +101,11 @@ public void fatalError(SAXParseException exception) throws SAXException {
@Override
public void warning(SAXParseException exception) throws SAXException {
- log.error("Warning: " + exception.getMessage());
- log.error(" at line " + exception.getLineNumber() + ", column "
- + exception.getColumnNumber());
- log.error(" in entity " + exception.getSystemId());
+ log.warn("XML warning: {}. Line: {}, column: {}, entity: {}",
+ exception.getMessage(),
+ exception.getLineNumber(),
+ exception.getColumnNumber(),
+ exception.getSystemId());
}
}
diff --git a/src/main/java/it/grid/storm/namespace/StoRI.java b/src/main/java/it/grid/storm/namespace/StoRI.java
index 6d06c961..92ac6e61 100644
--- a/src/main/java/it/grid/storm/namespace/StoRI.java
+++ b/src/main/java/it/grid/storm/namespace/StoRI.java
@@ -17,40 +17,29 @@
package it.grid.storm.namespace;
-import java.util.*;
-
-import it.grid.storm.common.types.*;
-import it.grid.storm.filesystem.*;
-import it.grid.storm.namespace.model.*;
-import it.grid.storm.srm.types.*;
-import it.grid.storm.namespace.ExpiredSpaceTokenException;
+import it.grid.storm.common.types.PFN;
+import it.grid.storm.common.types.StFN;
+import it.grid.storm.common.types.TURLPrefix;
+import it.grid.storm.filesystem.LocalFile;
+import it.grid.storm.filesystem.ReservationException;
+import it.grid.storm.filesystem.Space;
+import it.grid.storm.namespace.model.MappingRule;
+import it.grid.storm.namespace.model.StoRIType;
+import it.grid.storm.srm.types.TDirOption;
+import it.grid.storm.srm.types.TLifeTimeInSeconds;
+import it.grid.storm.srm.types.TSURL;
+import it.grid.storm.srm.types.TSizeInBytes;
+import it.grid.storm.srm.types.TSpaceToken;
+import it.grid.storm.srm.types.TTURL;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
public interface StoRI {
- /*****************************************************************************
- * BUILDING METHODs
- ****************************************************************************/
-
public void setStoRIType(StoRIType type);
- /*****************************************************************************
- * READ METHODs
- ***************************************************************************/
-
- /**
- * getTURL
- *
- * Create new Transport URL selecting correct protocol between
- * TransferProtocols specified by input parameter and TransferProtocol
- * assigned at Virtual Organization at Creation time. *
- *
- * @param prefixOfAcceptedTransferProtocols
- * TURLPrefix Collection of @link TransferProcol specified in SRM
- * Request.
- * @return TTURL : TransportURL for StoRI.
- * @throws InvalidGetTURLNullPrefixAttributeException
- * @throws Exception
- */
public TTURL getTURL(TURLPrefix prefixOfAcceptedTransferProtocols)
throws IllegalArgumentException, InvalidGetTURLProtocolException,
TURLBuildingException;
@@ -97,10 +86,6 @@ public TTURL getTURL(TURLPrefix prefixOfAcceptedTransferProtocols)
public MappingRule getMappingRule();
- /*****************************************************************************
- * BUSINESS METHODs
- ****************************************************************************/
-
public ArrayList getChildren(TDirOption dirOption)
throws InvalidDescendantsEmptyRequestException,
InvalidDescendantsAuthRequestException,
@@ -111,11 +96,6 @@ public ArrayList getChildren(TDirOption dirOption)
public boolean hasJustInTimeACLs();
- /**
- * Method that returns an ordered list of parent StoRI objects, starting from
- * the root and excluding the StoRI itself. If no parents are present, an
- * empty List is returned instead.
- */
public List getParents();
public void allotSpaceForFile(TSizeInBytes totSize)
diff --git a/src/main/java/it/grid/storm/namespace/StoRIImpl.java b/src/main/java/it/grid/storm/namespace/StoRIImpl.java
index 9c3b50c5..11d41bcc 100644
--- a/src/main/java/it/grid/storm/namespace/StoRIImpl.java
+++ b/src/main/java/it/grid/storm/namespace/StoRIImpl.java
@@ -45,7 +45,6 @@
import it.grid.storm.namespace.naming.NamingConst;
import it.grid.storm.namespace.naming.SURL;
import it.grid.storm.namespace.util.userinfo.LocalGroups;
-import it.grid.storm.srm.types.InvalidTSURLAttributesException;
import it.grid.storm.srm.types.TDirOption;
import it.grid.storm.srm.types.TLifeTimeInSeconds;
import it.grid.storm.srm.types.TSURL;
@@ -62,23 +61,6 @@
import org.slf4j.Logger;
-/**
- *
- * Title:
- *
- *
- * Description:
- *
- *
- * Copyright: Copyright (c) 2006
- *
- *
- * Company: INFN-CNAF and ICTP/eGrid project
- *
- *
- * @author Riccardo Zappi
- * @version 1.0
- */
public class StoRIImpl implements StoRI {
private Logger log = NamespaceDirector.getLogger();
@@ -111,58 +93,52 @@ public class StoRIImpl implements StoRI {
// Boolean status for full detailed metadata
private boolean volatileInformationAreSet = false;
- /*****************************************************************************
- * BUILDING METHODs
- ****************************************************************************/
-
public StoRIImpl(VirtualFSInterface vfs, MappingRule winnerRule,
String relativeStFN, StoRIType type) {
if (vfs != null) {
this.vfs = vfs;
- this.capability = (Capability) vfs.getCapabilities();
+ capability = (Capability) vfs.getCapabilities();
} else {
- log.error("!!! StoRI built without VFS!!?!");
+ log.error("StoRI built without VFS!");
}
- /**
- * Retrieve from StFN the various part.
- */
+
if (winnerRule != null) {
- this.stfnRoot = winnerRule.getStFNRoot();
- this.stfn = stfnRoot + NamingConst.SEPARATOR + relativeStFN;
+ stfnRoot = winnerRule.getStFNRoot();
+ stfn = stfnRoot + NamingConst.SEPARATOR + relativeStFN;
- this.vfsRoot = vfs.getRootPath();
+ vfsRoot = vfs.getRootPath();
this.relativeStFN = relativeStFN;
- this.stfnPath = NamespaceUtil.getStFNPath(stfn);
+ stfnPath = NamespaceUtil.getStFNPath(stfn);
- this.relativePath = NamespaceUtil.consumeFileName(relativeStFN);
+ relativePath = NamespaceUtil.consumeFileName(relativeStFN);
if (relativePath != null) {
if (relativePath.startsWith(NamingConst.SEPARATOR)) {
- this.relativePath = relativePath.substring(1);
+ relativePath = relativePath.substring(1);
}
} else {
- this.relativePath = "/";
+ relativePath = "/";
}
- this.fileName = NamespaceUtil.getFileName(relativeStFN);
- log.debug("StFN Filename : " + fileName + " [StFN = '" + relativeStFN
- + "']");
+ fileName = NamespaceUtil.getFileName(relativeStFN);
+ log.debug("StFN Filename : {} [StFN = '{}']", fileName,
+ relativeStFN);
if (type == null) {
if (relativeStFN.endsWith(NamingConst.SEPARATOR)) {
- this.type = StoRIType.FOLDER;
+ type = StoRIType.FOLDER;
} else {
- this.type = StoRIType.UNKNOWN;
+ type = StoRIType.UNKNOWN;
}
} else {
this.type = type;
}
} else {
- log.warn("StoRI built without MAPPIG RULE!!");
+ log.warn("StoRI built without mapping rule");
}
}
@@ -192,10 +168,11 @@ public StoRIImpl(VirtualFSInterface vfs, String stfnStr,
this.stfnRoot = null;
this.fileName = NamespaceUtil.getFileName(stfnStr);
- log.debug("StFN Filename : " + fileName + " [StFN = '" + stfnStr + "']");
+ log.debug("StFN Filename : {} [StFN = '{}']", fileName,
+ stfnStr);
this.stfnPath = NamespaceUtil.getStFNPath(stfnStr);
- log.debug("StFN StFNPath : " + stfnPath + " [StFN = '" + stfnStr + "']");
+ log.debug("StFN StFNPath : {} [StFN = '{}']", stfnPath, stfnStr);
}
@@ -206,20 +183,19 @@ public void allotSpaceByToken(TSpaceToken token) throws ReservationException,
if (spaceDriver == null) {
try {
this.spaceDriver = vfs.getSpaceSystemDriverInstance();
- } catch (NamespaceException ex) {
- log.error("Error while retrieving Space System Driver for VFS ", ex);
+ } catch (NamespaceException e) {
+ log.error(e.getMessage(), e);
throw new ReservationException(
- "Error while retrieving Space System Driver for VFS ");
+ "Error while retrieving Space System Driver for VFS", e);
}
}
try {
vfs.useAllSpaceForFile(token, this);
- } catch (NamespaceException ex1) {
- log.error("Error while using Space with token '" + token + "' for "
- + this.fileName, ex1);
- throw new ReservationException("Error while using Space with token '"
- + token + "' for " + this.fileName);
+ } catch (NamespaceException e) {
+ log.error("Error using space token {} for file {}: {}",
+ token, fileName, e.getMessage(),e);
+ throw new ReservationException(e.getMessage(), e);
}
}
@@ -227,24 +203,22 @@ public void allotSpaceByToken(TSpaceToken token) throws ReservationException,
public void allotSpaceByToken(TSpaceToken token, TSizeInBytes totSize)
throws ReservationException, ExpiredSpaceTokenException {
- // Retrieve SpaceSystem Driver
if (spaceDriver == null) {
try {
this.spaceDriver = vfs.getSpaceSystemDriverInstance();
- } catch (NamespaceException ex) {
- log.error("Error while retrieving Space System Driver for VFS ", ex);
+ } catch (NamespaceException e) {
+ log.error(e.getMessage(),e);
throw new ReservationException(
- "Error while retrieving Space System Driver for VFS ");
+ "Error while retrieving Space System Driver for VFS", e);
}
}
try {
vfs.useSpaceForFile(token, this, totSize);
- } catch (NamespaceException ex1) {
- log.error("Error while using Space with token '" + token + "' for "
- + this.fileName, ex1);
- throw new ReservationException("Error while using Space with token '"
- + token + "' for " + this.fileName);
+ } catch (NamespaceException e) {
+ log.error("Error using space token {} for file {}: {}",
+ token, fileName, e.getMessage(),e);
+ throw new ReservationException(e.getMessage(), e);
}
}
@@ -255,51 +229,32 @@ public void allotSpaceForFile(TSizeInBytes totSize)
if (spaceDriver == null) {
try {
this.spaceDriver = vfs.getSpaceSystemDriverInstance();
- } catch (NamespaceException ex) {
- log.error("Error while retrieving Space System Driver for VFS ", ex);
+ } catch (NamespaceException e) {
+ log.error("Error while retrieving Space System Driver for VFS {}",
+ e.getMessage(), e);
+
throw new ReservationException(
- "Error while retrieving Space System Driver for VFS ");
+ "Error while retrieving Space System Driver for VFS", e);
}
}
- // Make SILHOUETTE for File
try {
vfs.makeSilhouetteForFile(this, totSize);
- } catch (NamespaceException ex1) {
- log.error("Error while constructing 'Space Silhouette' for "
- + this.fileName, ex1);
+ } catch (NamespaceException e) {
+ log.error(e.getMessage(),e);
throw new ReservationException(
- "Error while constructing 'Space Silhouette' for " + this.fileName);
+ "Error while constructing 'Space Silhouette' for " + this.fileName, e);
}
log.debug("Space built. Space " + this.getSpace().getSpaceFile().getPath());
-
- // Make "space" physically in underlying file system
this.getSpace().allot();
-
}
public String getAbsolutePath() {
return vfs.getRootPath() + NamingConst.SEPARATOR + relativeStFN;
}
- /*****************************************************************************
- * BUSINESS METHODs
- ****************************************************************************/
-
- /**
- * Returns the SURL lifetime. This method queries the DB and retrieves also
- * the startTime. The DB is queried only on the first invocation of this or
- * the getFileStartTime() methods, therefore subsequent invocations of these
- * two methods are computationally lighter.
- *
- * If the file is PERMANENT, or this StoRI refeers to a non-valid file then -1
- * is returned.
- *
- * @return TLifeTimeInSeconds
- */
public TLifeTimeInSeconds getFileLifeTime() {
-
if (!(volatileInformationAreSet)) {
setVolatileInformation();
}
@@ -311,18 +266,6 @@ public String getFilename() {
return this.fileName;
}
- /**
- * Returns the SURL start time (time from which starts the lifetime). This
- * method queries the DB and retrieves also the lifetime of the SURL. The DB
- * is queried only on the first invocation of this or the getFileLifeTime()
- * methods, therefore subsequent invocations of these two methods are
- * computationally lighter.
- *
- * If the file is permanent or this StoRI refeers to a non-valid file then
- * NULL is retuned!
- *
- * @return Date
- */
public Date getFileStartTime() {
if (!(volatileInformationAreSet)) {
@@ -360,8 +303,8 @@ public ArrayList getChildren(TDirOption dirOption)
} else { // Creation of StoRI LIST
NamespaceInterface namespace = NamespaceDirector.getNamespace();
for (String childPath : pathList) {
- log.debug(":Creation of new StoRI with path : "
- + childPath);
+ log.debug(":Creation of new StoRI with path: {}",
+ childPath);
try {
StoRI childStorI = namespace.resolveStoRIbyAbsolutePath(childPath);
@@ -392,7 +335,6 @@ public LocalFile getLocalFile() {
}
public MappingRule getMappingRule() {
-
return this.winnerRule;
}
@@ -424,9 +366,8 @@ public PFN getPFN() {
if (pfn == null) {
try {
this.pfn = PFN.make(getAbsolutePath());
- } catch (InvalidPFNAttributeException ex) {
- log.error("Unable to build the PFN in the VFS '" + getVFSName()
- + "' with this path :'" + getAbsolutePath() + "'");
+ } catch (InvalidPFNAttributeException e) {
+ log.error(e.getMessage(),e);
}
}
return this.pfn;
@@ -485,30 +426,18 @@ public TSURL getSURL() {
if (this.surl == null) {
try {
this.surl = TSURL.makeFromStringValidate(buildSURLString());
- } catch (InvalidTSURLAttributesException ex) {
- log.error("Unable to build the SURL with relative path : '"
- + relativePath + "'", ex);
- } catch (NamespaceException ex) {
- /** @todo Handle this exception */
- log.error("Unable to build the SURL with relative path : '"
- + relativePath + "'", ex);
+ } catch (Throwable e) {
+ log.error("Unable to build the SURL with relative path: {}. {}",
+ relativePath, e.getMessage(), e);
}
-
}
return surl;
}
- /*****************************************************************************
- * READ METHODs
- *
- * @throws Exception
- ***************************************************************************/
-
public TTURL getTURL(TURLPrefix desiredProtocols)
throws IllegalArgumentException, InvalidGetTURLProtocolException,
TURLBuildingException {
- // TransportProtocol protocolPrefix = null;
TTURL resultTURL = null;
if (desiredProtocols == null || desiredProtocols.size() == 0) {
@@ -519,24 +448,26 @@ public TTURL getTURL(TURLPrefix desiredProtocols)
+ desiredProtocols);
} else {
- /**
- * Retrieve Protocol to build the TURL
- */
// Within the request there are some protocol preferences
// Calculate the intersection between Desired Protocols and Available
// Protocols
ArrayList desiredP = new ArrayList(
desiredProtocols.getDesiredProtocols());
+
ArrayList availableP = new ArrayList(
this.capability.getAllManagedProtocols());
+
desiredP.retainAll(availableP);
+
if (desiredP.isEmpty()) {
- // No match found!
log
.error("stori:No match with Protocol Preferences and Protocol Managed!");
throw new InvalidGetTURLProtocolException(desiredProtocols);
+
} else {
- log.debug("Protocol matching.. Intersection size:" + desiredP.size());
+
+ log.debug("Protocol matching.. Intersection size: {}",
+ desiredP.size());
Protocol choosen = null;
Authority authority = null;
@@ -545,15 +476,15 @@ public TTURL getTURL(TURLPrefix desiredProtocols)
while (!turlBuilt && index < desiredP.size()) {
choosen = desiredP.get(index);
authority = null;
- log.debug("Selected Protocol :" + choosen);
+ log.debug("Selected Protocol: {}", choosen);
if (capability.isPooledProtocol(choosen)) {
log.debug("The protocol selected is in POOL Configuration");
try {
authority = getPooledAuthority(choosen);
} catch (BalancingStrategyException e) {
log
- .warn("Unable to get the pool member to be used to build the turl. BalancerException : "
- + e.getMessage());
+ .warn("Unable to get the pool member to be used to build the turl. BalancerException : {}",
+ e.getMessage());
index++;
continue;
}
@@ -564,9 +495,9 @@ public TTURL getTURL(TURLPrefix desiredProtocols)
.getManagedProtocolByScheme(choosen);
if (protList.size() > 1) { // Strange case
log
- .warn("More than one protocol "
- + choosen
- + " defined but NOT in POOL Configuration. Taking the first one.");
+ .warn("More than one protocol {}"
+ + " defined but NOT in POOL Configuration. Taking the first one.",
+ choosen);
}
transProt = protList.get(0);
authority = transProt.getAuthority();
@@ -585,7 +516,6 @@ public TTURL getTURL(TURLPrefix desiredProtocols)
}
public VirtualFSInterface getVirtualFileSystem() {
-
return this.vfs;
}
@@ -615,14 +545,13 @@ public void setGroupTapeRead() {
try {
localFile.setGroupOwnership(groupName);
} catch (FSException e) {
- log.warn("Unable to change in the new group owner ('" + groupName
- + "') of the file: " + localFile.getAbsolutePath());
+ log.warn("Unable to change in the new group owner '{}' for file '{}': {}",
+ groupName, localFile.getAbsolutePath(), e.getMessage(), e);
}
} else {
- log.warn("The group for Read buffer in Tape support '" + groupName
- + "' is not defined.");
+ log.warn("The group for Read buffer in Tape support '{}' is not defined",
+ groupName);
}
-
}
public void setGroupTapeWrite() {
@@ -635,22 +564,20 @@ public void setGroupTapeWrite() {
try {
localFile.setGroupOwnership(groupName);
} catch (FSException e) {
- log.warn("Unable to change in the new group owner ('" + groupName
- + "') of the file: " + localFile.getAbsolutePath());
+ log.warn("Unable to change in the new group owner '{}' for file '{}': {}",
+ groupName, localFile.getAbsolutePath(), e.getMessage(), e);
}
} else {
- log.warn("The group for Write buffer in Tape support '" + groupName
- + "' is not defined.");
+ log.warn("The group for Write buffer in Tape support '{}' is not defined",
+ groupName);
}
}
public void setMappingRule(MappingRule winnerRule) {
-
this.winnerRule = winnerRule;
}
public void setSpace(Space space) {
-
this.space = space;
}
@@ -688,7 +615,6 @@ public String toString() {
}
private String buildSURLString() throws NamespaceException {
-
String stfn = stfnRoot + NamingConst.SEPARATOR + relativeStFN;
SURL surl = new SURL(stfn);
return surl.toString();
@@ -720,10 +646,9 @@ private TTURL buildTURL(Protocol protocol, Authority authority)
try {
result = TURLBuilder.buildHTTPTURL(authority, this.getLocalFile());
} catch (HTTPSPluginException e) {
- log.error("Unable to build the TURL for protocol "
- + protocol.toString() + " for authority " + authority.toString()
- + " and file " + this.getLocalFile().toString()
- + " . HTTPSPluginException: " + e.getMessage());
+ log.error("Unable to build the TURL for protocol {} for authority {} and file {}. {}",
+ protocol, authority, this.getLocalFile().toString(),
+ e.getMessage(),e);
throw new InvalidProtocolForTURLException(e, protocol.getSchema());
}
break; // HTTP Protocol
@@ -731,10 +656,9 @@ private TTURL buildTURL(Protocol protocol, Authority authority)
try {
result = TURLBuilder.buildHTTPSTURL(authority, this.getLocalFile());
} catch (HTTPSPluginException e) {
- log.error("Unable to build the TURL for protocol "
- + protocol.toString() + " for authority " + authority.toString()
- + " and file " + this.getLocalFile().toString()
- + " . HTTPSPluginException: " + e.getMessage());
+ log.error("Unable to build the TURL for protocol {} for authority {} and file {}. {}",
+ protocol, authority, this.getLocalFile().toString(),
+ e.getMessage(),e);
throw new InvalidProtocolForTURLException(e, protocol.getSchema());
}
break; // HTTPS Protocol
diff --git a/src/main/java/it/grid/storm/namespace/TURLBuilder.java b/src/main/java/it/grid/storm/namespace/TURLBuilder.java
index cb958b37..43965fd0 100644
--- a/src/main/java/it/grid/storm/namespace/TURLBuilder.java
+++ b/src/main/java/it/grid/storm/namespace/TURLBuilder.java
@@ -46,33 +46,22 @@ private static TTURL buildTURL(Protocol protocol, Authority authority,
try {
turlString = protocol.getProtocolPrefix() + authority.toString()
+ extraSlashes + physicalFN.getValue();
- log.debug("turlString used to build the TURL : " + turlString);
+ log.debug("turlString used to build the TURL : {}", turlString);
turl = TTURL.makeFromString(turlString);
} catch (InvalidTTURLAttributesException ex) {
- log.error("Error while constructing TURL with Authority :'" + authority
- + "'; EXCEP: " + ex);
+ log.error("Error while constructing TURL with Authority '{}': {}",
+ authority, ex.getMessage(), ex);
}
return turl;
}
- /**
- * buildFileTURL
- *
- * @return TTURL
- */
public static TTURL buildFileTURL(Authority authority, PFN physicalFN) {
- // Authority for Protocol File is empty
String extraSlashesForFile = Configuration.getInstance()
.getExtraSlashesForFileTURL();
return buildTURL(Protocol.FILE, authority, extraSlashesForFile, physicalFN);
}
- /**
- * buildGsiftpTURL
- *
- * @return TTURL
- */
public static TTURL buildGsiftpTURL(Authority authority, PFN physicalFN) {
String extraSlashesForGSIFTP = Configuration.getInstance()
@@ -81,11 +70,6 @@ public static TTURL buildGsiftpTURL(Authority authority, PFN physicalFN) {
physicalFN);
}
- /**
- * buildRFIOTURL
- *
- * @return TTURL
- */
public static TTURL buildRFIOTURL(Authority authority, PFN physicalFN) {
String extraSlashesForRFIO = Configuration.getInstance()
@@ -93,11 +77,6 @@ public static TTURL buildRFIOTURL(Authority authority, PFN physicalFN) {
return buildTURL(Protocol.RFIO, authority, extraSlashesForRFIO, physicalFN);
}
- /**
- * buildROOTTURL
- *
- * @return TTURL
- */
public static TTURL buildROOTTURL(Authority authority, PFN physicalFN) {
String extraSlashesForROOT = Configuration.getInstance()
@@ -105,54 +84,22 @@ public static TTURL buildROOTTURL(Authority authority, PFN physicalFN) {
return buildTURL(Protocol.ROOT, authority, extraSlashesForROOT, physicalFN);
}
- /**
- * buildHHTPTURL
- *
- * @param authority
- * @param physicalFN
- * @return
- * @throws Exception
- * @throws IllegalStateException
- */
- // TODO HTTPS TURL
public static TTURL buildHTTPTURL(Authority authority, LocalFile localFile)
throws HTTPSPluginException {
- // ????? NEEDED ??? String extraSlashesFor?? =
- // Configuration.getInstance().getExtraSlashesFor??PTURL();
- // return buildTURL(Protocol.HTTP, authority, extraSlashesForGSIFTP,
- // physicalFN) ;
-
String serviceRelativePath = HTTPPluginManager
.getHTTPSPluginInstance()
- .mapLocalPath(authority.getServiceHostname(), localFile.getAbsolutePath());// HTTPSPluginInterface.MapLocalPath(localFile.getAbsolutePath());
+ .mapLocalPath(authority.getServiceHostname(), localFile.getAbsolutePath());
+
return buildTURL(Protocol.HTTP, authority, "", serviceRelativePath);
}
- /**
- * buildHHTPTURL
- *
- * @param authority
- * @param physicalFN
- * @return
- * @throws Exception
- * @throws IllegalStateException
- */
- // TODO HTTPS TURL
public static TTURL buildHTTPSTURL(Authority authority, LocalFile localFile)
throws HTTPSPluginException {
- // ????? NEEDED ??? String extraSlashesFor?? =
- // Configuration.getInstance().getExtraSlashesFor??PTURL();
- // return buildTURL(Protocol.HTTP, authority, extraSlashesForGSIFTP,
- // physicalFN) ;
-
- // String servicePath =
- // HTTPPluginManager.getHTTPSPluginInstance().getServicePath(); //
- // HTTPSPluginInterface.getServicePath();
String serviceRelativePath = HTTPPluginManager
.getHTTPSPluginInstance()
- .mapLocalPath(authority.getServiceHostname(), localFile.getAbsolutePath());// HTTPSPluginInterface.MapLocalPath(localFile.getAbsolutePath());
+ .mapLocalPath(authority.getServiceHostname(), localFile.getAbsolutePath());
return buildTURL(Protocol.HTTPS, authority, "", serviceRelativePath);
}
@@ -164,16 +111,12 @@ private static TTURL buildTURL(Protocol protocol, Authority authority,
try {
turlString = protocol.getProtocolPrefix() + authority.toString()
+ extraSlashes + serviceRelativePath;
- log.debug("turlString used to build the TURL : " + turlString);
+ log.debug("turlString used to build the TURL : {}", turlString);
turl = TTURL.makeFromString(turlString);
- } catch (InvalidTTURLAttributesException ex) {
- log.error("Error while constructing TURL with Authority :'" + authority
- + "'; EXCEP: " + ex);
+ } catch (InvalidTTURLAttributesException e) {
+ log.error("Error while constructing TURL with Authority '{}'. {}",
+ authority, e.getMessage(), e);
}
return turl;
}
-
- // TODO MICHELE HTTPS here add the method that builds the HTTPS turl using the
- // installed connector
-
-}
+}
\ No newline at end of file
diff --git a/src/main/java/it/grid/storm/namespace/TURLBuildingException.java b/src/main/java/it/grid/storm/namespace/TURLBuildingException.java
index ed5d2bab..4a84df0f 100644
--- a/src/main/java/it/grid/storm/namespace/TURLBuildingException.java
+++ b/src/main/java/it/grid/storm/namespace/TURLBuildingException.java
@@ -2,27 +2,21 @@
public class TURLBuildingException extends Exception {
- public TURLBuildingException() {
+ private static final long serialVersionUID = 1L;
- // TODO Auto-generated constructor stub
+ public TURLBuildingException() {
}
public TURLBuildingException(String message) {
-
super(message);
- // TODO Auto-generated constructor stub
}
public TURLBuildingException(Throwable cause) {
-
super(cause);
- // TODO Auto-generated constructor stub
}
public TURLBuildingException(String message, Throwable cause) {
-
super(message, cause);
- // TODO Auto-generated constructor stub
}
}
diff --git a/src/main/java/it/grid/storm/namespace/UnapprochableSurlException.java b/src/main/java/it/grid/storm/namespace/UnapprochableSurlException.java
index b3406c5c..49729734 100644
--- a/src/main/java/it/grid/storm/namespace/UnapprochableSurlException.java
+++ b/src/main/java/it/grid/storm/namespace/UnapprochableSurlException.java
@@ -2,14 +2,10 @@
public class UnapprochableSurlException extends Exception {
- public UnapprochableSurlException(String string) {
+ private static final long serialVersionUID = -1004206794152723169L;
+ public UnapprochableSurlException(String string) {
super(string);
}
- /**
- *
- */
- private static final long serialVersionUID = -1004206794152723169L;
-
}
diff --git a/src/main/java/it/grid/storm/namespace/VirtualFSInterface.java b/src/main/java/it/grid/storm/namespace/VirtualFSInterface.java
index 5d04744a..a0c84456 100644
--- a/src/main/java/it/grid/storm/namespace/VirtualFSInterface.java
+++ b/src/main/java/it/grid/storm/namespace/VirtualFSInterface.java
@@ -35,26 +35,6 @@
import java.util.List;
-/**
- *
- * Title:
- *
- *
- *
- * Description:
- *
- *
- *
- * Copyright: Copyright (c) 2006
- *
- *
- *
- * Company:
- *
- *
- * @author not attributable
- * @version 1.0
- */
public interface VirtualFSInterface {
public String getFSType();
@@ -92,10 +72,6 @@ public interface VirtualFSInterface {
public List getApproachableRules()
throws NamespaceException;
- /**************************************************
- * Methods used to retrieve the Status of VFS
- **************************************************/
-
public TSizeInBytes getUsedNearlineSpace() throws NamespaceException;
public TSizeInBytes getUsedOnlineSpace() throws NamespaceException;
@@ -104,41 +80,21 @@ public List getApproachableRules()
public TSizeInBytes getAvailableNearlineSpace() throws NamespaceException;
- /**************************************************
- * Methods used to create new FILE
- **************************************************/
-
public StoRI createFile(String relativePath) throws NamespaceException;
public StoRI createFile(String relativePath, StoRIType type);
- /**************************************************
- * Methods Used for implicit space reservation
- **************************************************/
-
- /**
- * Associate the file with a Space with the presumed size and StoRI name (PURE
- * implicit reservation)
- */
public void makeSilhouetteForFile(StoRI stori, TSizeInBytes presumedSize)
throws NamespaceException;
- // Use for the "not-so-implicit" space reservation the space file specified by
- // token
public void useSpaceForFile(TSpaceToken token, StoRI file,
TSizeInBytes sizePresumed) throws ExpiredSpaceTokenException,
NamespaceException;
- // Use for the "not-so-implicit" space reservation the space file specified by
- // token
public void useAllSpaceForFile(TSpaceToken token, StoRI file)
throws ExpiredSpaceTokenException, NamespaceException;
- /**************************************************
- * Methods Used for EXPLICIT space reservation
- **************************************************/
-
public StoRI createSpace(String relativePath, long guaranteedSize,
long totalSize) throws NamespaceException;
@@ -152,11 +108,6 @@ public StoRI createSpace(long guarSize, long totalSize)
public StoRI createSpace() throws NamespaceException;
- /**************************************************
- * Methods Used as utility for SPACE management
- **************************************************/
-
- // Return a StoRI representing a new Space
public TSizeInBytes splitSpace(StoRI spaceOrig, StoRI file, long sizePresumed)
throws NamespaceException;
@@ -166,10 +117,6 @@ public StorageSpaceData getSpaceByAlias(String alias)
public void storeSpaceByToken(StorageSpaceData spaceData)
throws NamespaceException;
- /**************************************************
- * Methods Used for Default use
- **************************************************/
-
public StoRI createDefaultStoRI() throws NamespaceException;
public long getCreationTime();
From 8bdc190fa201f79ff6ede3bc68537ae0b5e6aa14 Mon Sep 17 00:00:00 2001
From: Andrea Ceccanti
Date: Thu, 6 Feb 2014 16:38:47 +0100
Subject: [PATCH 29/45] More logging rationalization work
---
.../java/it/grid/storm/info/BackgroundDU.java | 65 ++---
.../it/grid/storm/info/BackgroundDUTasks.java | 3 +-
.../it/grid/storm/info/CatalogUpdater.java | 42 ++-
.../java/it/grid/storm/info/InfoService.java | 1 -
.../it/grid/storm/info/SAInfoException.java | 1 -
.../it/grid/storm/info/SpaceInfoManager.java | 247 ++++++------------
.../it/grid/storm/info/TestBackgroundDU.java | 89 -------
.../grid/storm/info/TestSpaceInfoManager.java | 29 --
.../jna/lcmaps/lcmaps_account_info_t.java | 11 -
.../java/it/grid/storm/logging/Files.java | 7 +-
10 files changed, 128 insertions(+), 367 deletions(-)
delete mode 100644 src/main/java/it/grid/storm/info/TestBackgroundDU.java
delete mode 100644 src/main/java/it/grid/storm/info/TestSpaceInfoManager.java
diff --git a/src/main/java/it/grid/storm/info/BackgroundDU.java b/src/main/java/it/grid/storm/info/BackgroundDU.java
index e45c7fdf..cf360187 100644
--- a/src/main/java/it/grid/storm/info/BackgroundDU.java
+++ b/src/main/java/it/grid/storm/info/BackgroundDU.java
@@ -28,7 +28,7 @@
public class BackgroundDU {
- private static final Logger LOG = LoggerFactory.getLogger(BackgroundDU.class);
+ private static final Logger log= LoggerFactory.getLogger(BackgroundDU.class);
private List todoTasks = new ArrayList();
@@ -117,7 +117,7 @@ public void startExecution() {
}
// Clean todo Task list;
todoTasks.clear();
- LOG.info("Submitted all the DU task.");
+ log.info("Submitted all the DU task.");
completionTaskHandle = singleExec.submit(new CompletionTask());
}
@@ -140,24 +140,19 @@ public void stopExecution(boolean sweetDead) {
}
try {
completionTaskHandle.get(millisecToWait, TimeUnit.MILLISECONDS);
- } catch (TimeoutException te) {
- LOG.debug("Timeout excep. " + te);
- } catch (InterruptedException ie) {
- LOG.debug("Interrupted excep. " + ie);
- } catch (ExecutionException ee) {
- LOG.debug("Execution excep. " + ee);
+ } catch (Throwable e){
+ log.debug(e.getMessage(),e);
} finally {
completionTaskHandle.cancel(true);
- LOG.debug("Completion task forced to be canceled.");
+ log.debug("Completion task forced to be canceled.");
}
try {
- LOG.debug("Shutting down..");
+ log.debug("Shutting down..");
shutdown(false, 1000);
- LOG.debug("Shutted down!");
+ log.debug("Shutted down!");
} catch (InterruptedException ie) {
- LOG.debug("Interrupted excep. " + ie);
+ log.debug("Interrupted excep. " + ie);
}
-
}
/**
@@ -176,8 +171,8 @@ private void shutdown(boolean interrupt, long waitMillis)
throws InterruptedException {
if (interrupt) {
- LOG.debug("Tasks killed: " + exec.shutdownNow().size());
- LOG.debug("Tasks killed: " + singleExec.shutdownNow().size());
+ log.debug("Tasks killed: {}", exec.shutdownNow().size());
+ log.debug("Tasks killed: {}",singleExec.shutdownNow().size());
} else {
exec.shutdown();
singleExec.shutdown();
@@ -186,11 +181,11 @@ private void shutdown(boolean interrupt, long waitMillis)
exec.awaitTermination(waitMillis, TimeUnit.MILLISECONDS);
singleExec.awaitTermination(waitMillis, TimeUnit.MILLISECONDS);
} finally {
- LOG.debug("Tasks killed: " + exec.shutdownNow().size());
- LOG.debug("Tasks killed: " + singleExec.shutdownNow().size());
+ log.debug("Tasks killed: {}", exec.shutdownNow().size());
+ log.debug("Tasks killed: {}", singleExec.shutdownNow().size());
}
- LOG.debug("EXEC is terminated? : " + exec.isTerminated());
- LOG.debug("SingleEXEC is terminated? : " + singleExec.isTerminated());
+ log.debug("EXEC is terminated? : {}" , exec.isTerminated());
+ log.debug("SingleEXEC is terminated? : {}" , singleExec.isTerminated());
}
/**
@@ -198,19 +193,15 @@ private void shutdown(boolean interrupt, long waitMillis)
*/
private void processCompletedTask(DUResult duResult) {
- LOG.trace("******* Store the result of DU ('" + duResult.getAbsRootPath()
- + "')*******");
- LOG.debug("---- DU RESULT of '" + duResult.getAbsRootPath() + "' ----");
- LOG.info(duResult.toString());
+ log.trace("BackgroundDU.processCompletedTask. duResult={}", duResult);
+
+ log.info(duResult.toString());
if (duResult.getCmdResult().equals(ExitCode.SUCCESS)) {
successResults.add(duResult);
} else {
failureResults.add(duResult);
}
- LOG.debug("------------------------------------------------------");
-
SpaceInfoManager.getInstance().updateSA(duResult);
-
}
/**
@@ -221,7 +212,7 @@ private class CompletionTask implements Runnable {
private boolean completeTask() throws InterruptedException {
- LOG.debug("Checking for complete a task..");
+ log.trace("BackgroundDU.CompletionTask.completeTask");
boolean poison = false;
Future completedTask;
DUResult duResult = null;
@@ -230,12 +221,12 @@ private boolean completeTask() throws InterruptedException {
completedTask = completionService.take();
// Add the processed task.
completedTasks.add(completedTask);
- LOG.debug("Completed Tasks: " + completedTasks.size());
+ log.debug("Completed Tasks: {}", completedTasks.size());
// Wait 1 second to check if there is a result
duResult = completedTask.get(1, TimeUnit.SECONDS);
- LOG.debug("Completed Task : " + duResult.toString());
+ log.debug("Completed Task : {}", duResult.toString());
if (duResult.isPoisoned()) {
- LOG.debug("POISONED the DU Completion Service!!!");
+ log.debug("POISONED the DU Completion Service!!!");
poison = true;
} else {
toCheckTasks.remove(completedTask);
@@ -243,21 +234,21 @@ private boolean completeTask() throws InterruptedException {
} catch (ExecutionException e) {
Throwable cause = e.getCause();
if (!(cause instanceof InterruptedException)) {
- LOG.error("Completion Task failed with unhandled exception", cause);
+ log.error("Completion Task failed with unhandled exception", cause);
}
} catch (TimeoutException e) {
- LOG.info("Completion Task terminated due to a TimeOut. Cause: "
- + e.getCause().getMessage());
+ log.info("Completion Task terminated due to a TimeOut. Cause: {}"
+ , e.getCause().getMessage());
} catch (CancellationException e) {
- LOG.info("Completion Task was cancelled. Cause: "
- + e.getCause().getMessage());
+ log.info("Completion Task was cancelled. Cause: {}"
+ , e.getCause().getMessage());
}
if (duResult != null) {
// a DUResult was created, store the results.
processCompletedTask(duResult);
} else {
- LOG
+ log
.warn("DU completed but unable to manage the result (something wrong was happen).");
}
return poison;
@@ -271,7 +262,7 @@ public void run() {
poison_pill = completeTask();
}
} catch (InterruptedException ie) {
- LOG.info("CompletionTask has been terminated by an interruption. ");
+ log.info("CompletionTask has been terminated by an interruption. ");
Thread.currentThread().interrupt();
}
}
diff --git a/src/main/java/it/grid/storm/info/BackgroundDUTasks.java b/src/main/java/it/grid/storm/info/BackgroundDUTasks.java
index 03f0f275..5713cad8 100644
--- a/src/main/java/it/grid/storm/info/BackgroundDUTasks.java
+++ b/src/main/java/it/grid/storm/info/BackgroundDUTasks.java
@@ -18,8 +18,7 @@
public class BackgroundDUTasks {
private Set tasks = new HashSet();
- private static final Logger LOG = LoggerFactory
- .getLogger(BackgroundDUTasks.class);
+
private static final AtomicInteger taskId = new AtomicInteger();
public void addTask(TSpaceToken token, String path) throws SAInfoException {
diff --git a/src/main/java/it/grid/storm/info/CatalogUpdater.java b/src/main/java/it/grid/storm/info/CatalogUpdater.java
index 79131b89..b3ecd2a8 100644
--- a/src/main/java/it/grid/storm/info/CatalogUpdater.java
+++ b/src/main/java/it/grid/storm/info/CatalogUpdater.java
@@ -25,8 +25,9 @@
public class CatalogUpdater {
- private static final Logger LOG = LoggerFactory
+ private static final Logger log = LoggerFactory
.getLogger(CatalogUpdater.class);
+
private final ExecutorService saver = Executors.newFixedThreadPool(1,
new NamedThreadFactory("CatalogSaver"));
@@ -40,8 +41,8 @@ public Future> saveData(TSpaceToken token, DUResult duResult)
try {
saverFuture = saver.submit(new NamedThread(new SaveSA(token, duResult),
"SaverThread"));
- } catch (RejectedExecutionException rej) {
- LOG.error("Unable to start Saver tasks." + rej.getMessage());
+ } catch (RejectedExecutionException e) {
+ log.error("Unable to start Saver tasks. {}", e.getMessage(), e);
}
return saverFuture;
}
@@ -51,7 +52,7 @@ public void stopSaver() {
try {
shutdown(false, 1000);
} catch (InterruptedException ex) {
- LOG.debug("DU Info SAVER is interrupted.");
+ log.debug("DU Info SAVER is interrupted.");
}
}
@@ -59,16 +60,16 @@ private void shutdown(boolean interrupt, long waitMillis)
throws InterruptedException {
if (interrupt) {
- LOG.debug("Tasks killed: " + saver.shutdownNow().size());
+ log.debug("Tasks killed: {}", saver.shutdownNow().size());
} else {
saver.shutdown();
}
try {
saver.awaitTermination(waitMillis, TimeUnit.MILLISECONDS);
} finally {
- LOG.debug("Tasks killed: " + saver.shutdownNow().size());
+ log.debug("Tasks killed: {}", saver.shutdownNow().size());
}
- LOG.debug("SAVER is terminated? : " + saver.isTerminated());
+ log.debug("SAVER terminated? : {}", saver.isTerminated());
}
private class SaveSA implements Runnable {
@@ -85,8 +86,7 @@ public SaveSA(TSpaceToken spaceToken, DUResult duResult) {
public void run() {
- // TODO errors are not managed in this function
- LOG.debug("Saving info into DB... ");
+ log.debug("Saving info into DB... ");
StorageSpaceData ssd = null;
if (SpaceInfoManager.getInstance().testMode.get()) {
// this IS a TEST!
@@ -97,7 +97,7 @@ public void run() {
ssd.setSpaceToken(sT);
ssd.setSpaceFileName(spaceFN);
} catch (InvalidPFNAttributeException e) {
- LOG.error("Unable to create PFN. " + e);
+ log.error("Unable to create PFN. {}", e.getMessage(), e);
}
} else {
@@ -106,12 +106,12 @@ public void run() {
try {
ssd = spaceCatalog.getStorageSpace(sT);
} catch (TransferObjectDecodingException e) {
- LOG
- .error("Unable to build StorageSpaceData from StorageSpaceTO. TransferObjectDecodingException: "
- + e.getMessage());
+ log
+ .error("Unable to build StorageSpaceData from StorageSpaceTO. TransferObjectDecodingException: {}",
+ e.getMessage(), e);
} catch (DataAccessException e) {
- LOG.error("Unable to build get StorageSpaceTO. DataAccessException: "
- + e.getMessage());
+ log.error("Unable to build get StorageSpaceTO. DataAccessException: {}",
+ e.getMessage(),e);
}
}
@@ -121,22 +121,18 @@ public void run() {
TSizeInBytes us = TSizeInBytes.make(usedSize, SizeUnit.BYTES);
ssd.setUsedSpaceSize(us);
} catch (InvalidTSizeAttributesException e) {
- LOG.error("Negative size?");
+ log.error(e.getMessage(),e);
}
if (SpaceInfoManager.getInstance().testMode.get()) {
- // this IS a TEST!
- LOG.debug("Saved SSD info into the DB ");
+ log.debug("Saved SSD info into the DB ");
} else {
- // This is not a TEST!
// Update the SSD into the DB
spaceCatalog.updateStorageSpace(ssd);
}
// Notify the manager about the saving was success
SpaceInfoManager.getInstance().savedSA(duResult);
- LOG.debug(String.format("DU info of %s is saved into DB.",
- duResult.getAbsRootPath()));
+ log.debug("DU info for {} saved. ", duResult.getAbsRootPath());
}
-
}
-}
+}
\ No newline at end of file
diff --git a/src/main/java/it/grid/storm/info/InfoService.java b/src/main/java/it/grid/storm/info/InfoService.java
index fcc8d9c7..be7d96f1 100644
--- a/src/main/java/it/grid/storm/info/InfoService.java
+++ b/src/main/java/it/grid/storm/info/InfoService.java
@@ -8,7 +8,6 @@ public class InfoService {
private static final Logger log = LoggerFactory.getLogger(InfoService.class);
public static String getResourcePackage() {
-
return "it.grid.storm.info.remote.resources";
}
diff --git a/src/main/java/it/grid/storm/info/SAInfoException.java b/src/main/java/it/grid/storm/info/SAInfoException.java
index 5a1a66b3..2686f449 100644
--- a/src/main/java/it/grid/storm/info/SAInfoException.java
+++ b/src/main/java/it/grid/storm/info/SAInfoException.java
@@ -5,7 +5,6 @@ public class SAInfoException extends Exception {
private static final long serialVersionUID = 1L;
public SAInfoException(String message) {
-
super(message);
}
diff --git a/src/main/java/it/grid/storm/info/SpaceInfoManager.java b/src/main/java/it/grid/storm/info/SpaceInfoManager.java
index 02cb8d59..5111cadc 100644
--- a/src/main/java/it/grid/storm/info/SpaceInfoManager.java
+++ b/src/main/java/it/grid/storm/info/SpaceInfoManager.java
@@ -55,7 +55,8 @@
public class SpaceInfoManager {
- private final Logger LOG;
+ private static final Logger log =
+ LoggerFactory.getLogger(SpaceInfoManager.class);
private static final SpaceInfoManager instance = new SpaceInfoManager();
private int timeOutDurationInSec = 7200; // 2 hours per task (This value is
// multiplied by attempt)
@@ -78,12 +79,7 @@ public class SpaceInfoManager {
private int quotas = 0;
private int quotasDefined = 0;
- /**
- *
- */
private SpaceInfoManager() {
-
- LOG = LoggerFactory.getLogger(SpaceInfoManager.class);
List vfsS = retrieveSAtoInitializeWithQuota();
if (vfsS != null) {
this.quotasDefined = vfsS.size();
@@ -92,11 +88,7 @@ private SpaceInfoManager() {
}
}
- /**
- * @return the quotasDefined
- */
public final int getQuotasDefined() {
-
return quotasDefined;
}
@@ -104,12 +96,10 @@ public final int getQuotasDefined() {
private int attempt = 1;
public static SpaceInfoManager getInstance() {
-
return instance;
}
public static boolean isInProgress() {
-
boolean result = false;
if (SpaceInfoManager.getInstance().tasksToComplete.get() > 0) {
result = true;
@@ -156,7 +146,7 @@ private int startBackGroundDU() {
// This call populate the Task Queue: "bDUTasks"
SpaceInfoManager.getInstance().foundSAtoAnalyze();
result = SpaceInfoManager.getInstance().bDUTasks.howManyTask();
- LOG.debug(String.format("Tasks: %d", result));
+ log.debug("Tasks: {}", result);
// Submit the tasks
SpaceInfoManager.getInstance().submitTasks(
SpaceInfoManager.getInstance().bDUTasks);
@@ -225,13 +215,13 @@ public List retrieveQuotaNamesToUse() {
List quotaNames = new ArrayList();
List vfsList = retrieveSAtoInitializeWithQuota();
for (VirtualFSInterface vfsEntry : vfsList) {
- LOG.debug("vfsEntry (AliasName): " + vfsEntry.getAliasName());
+ log.debug("vfsEntry (AliasName): {}", vfsEntry.getAliasName());
String quotaName = vfsEntry.getCapabilities().getQuota()
.getQuotaElementName();
- LOG.debug("Found this quotaName to check: '" + quotaName + "'");
+ log.debug("Found this quotaName to check: '{}'", quotaName);
quotaNames.add(quotaName);
}
- LOG.debug("Number of quotaNames: " + quotaNames.size());
+ log.debug("Number of quotaNames: {}" ,quotaNames.size());
return quotaNames;
}
@@ -244,13 +234,11 @@ public List retrieveSAtoInitializeWithQuota() {
vfsSet = new ArrayList(NamespaceDirector
.getNamespace().getAllDefinedVFS());
} catch (NamespaceException e) {
- LOG
- .error("Unable to get the defined Virtual File Systems. NamespaceException : "
- + e.getMessage());
- LOG.error("Returning an empty list");
+ log.error(e.getMessage(),e);
+ log.error("Returning an empty VFS list");
return new ArrayList();
}
- LOG.debug("Found '" + vfsSet.size() + "' VFS defined in Namespace.xml");
+ log.debug("Found '{}' VFS defined in Namespace.xml", vfsSet.size());
List vfsSetQuota = new ArrayList();
if (vfsSet.size() > 0) { // Exists at least a VFS defined
for (VirtualFSInterface vfsItem : vfsSet) {
@@ -259,7 +247,7 @@ public List retrieveSAtoInitializeWithQuota() {
}
}
}
- LOG.debug("Number of VFS with Quota enabled: " + vfsSetQuota.size());
+ log.debug("Number of VFS with Quota enabled: {}", vfsSetQuota.size());
return vfsSetQuota;
}
@@ -300,16 +288,16 @@ private void fakeSAtoAnalyze(List absPaths) {
StorageSpaceData ssd = new StorageSpaceData();
try {
PFN spaceFN = PFN.make(pathNorm);
- LOG.trace("PFN : " + spaceFN);
+ log.trace("PFN : " , spaceFN);
ssd.setSpaceToken(TSpaceToken.make(new it.grid.storm.common.GUID()
.toString()));
ssd.setSpaceFileName(spaceFN);
toAnalyze.add(ssd);
} catch (InvalidTSpaceTokenAttributesException e) {
- LOG.error("Unable to create Space Token. " + e);
+ log.error("Unable to create Space Token. {}", e.getMessage(), e);
} catch (InvalidPFNAttributeException e) {
- LOG.error("Unable to create PFN. " + e);
+ log.error("Unable to create PFN. {}", e.getMessage(),e);
}
}
@@ -318,21 +306,16 @@ private void fakeSAtoAnalyze(List absPaths) {
String absPath = ssd.getSpaceFileNameString();
try {
bDUTasks.addTask(sT, absPath);
- LOG.debug(String.format(
- "Added %s to the DU-Task Queue. (Task queue size:%d)", absPath,
- bDUTasks.howManyTask()));
+ log.debug("Added {} to the DU-Task Queue. (Task queue size: {})",
+ absPath,
+ bDUTasks.howManyTask());
} catch (SAInfoException e) {
- LOG.error("Unable to add task with '" + absPath + "' absolute path."
- + e.getMessage());
+ log.error(e.getMessage(), e);
}
}
- LOG.info(String.format("Background DU tasks size: %d", bDUTasks.getTasks()
- .size()));
+ log.info("Background DU tasks size: {}", bDUTasks.getTasks().size());
}
- /**
- * Populate with DU tasks
- */
private void foundSAtoAnalyze() {
List toAnalyze = spaceCatalog
@@ -341,36 +324,30 @@ private void foundSAtoAnalyze() {
TSpaceToken sT = ssd.getSpaceToken();
String absPath = ssd.getSpaceFileNameString();
if (sT == null || absPath == null) {
- LOG
- .error("Unable to submit DU test, StorageSpaceData returns null values: SpaceToken="
- + sT + " , SpaceFileNameString=" + absPath);
+ log
+ .error("Unable to submit DU test, StorageSpaceData returns "
+ + "null values: SpaceToken={}, SpaceFileNameString={}",
+ sT, absPath);
} else {
try {
bDUTasks.addTask(sT, absPath);
- LOG.debug("Added " + absPath + " to the DU-Task Queue. (size:"
- + bDUTasks.howManyTask() + ")");
+ log.debug("Added {} to the DU-Task Queue. (size: {})",
+ absPath, bDUTasks.howManyTask());
+
} catch (SAInfoException e) {
- LOG.error("Unable to add task with '" + absPath + "' absolute path."
- + e.getMessage());
+ log.error(e.getMessage(),e);
}
}
}
}
void stopExecution() {
-
+ log.trace("SpaceInfoManager.stopExecution");
bDU.stopExecution(true);
persist.stopSaver();
- LOG.debug("Stopping Background DU executions.");
}
- /**
- * Used to update the DB if the Task is root, otherwise manage the split DU
- *
- * @param taskDU
- * @param result
- */
void updateSA(DUResult result) {
// Retrieve BDUTask
@@ -382,7 +359,7 @@ void updateSA(DUResult result) {
try {
bDUTasks.updateTask(task);
} catch (SAInfoException e1) {
- LOG.error("Something strange happen.." + e1);
+ log.error("Something strange happen.. {}", e1.getMessage(), e1);
}
// Check if the result is success, otherwise ...
@@ -396,25 +373,23 @@ void updateSA(DUResult result) {
persist.saveData(st, result);
} catch (SAInfoException e) {
- LOG.error("Unable to persist the DU result of '"
- + result.getAbsRootPath() + "' " + e);
+ log.error(e.getMessage(),e);
}
} else {
// Logging the failure
- LOG.warn(String.format(
- "DU of space with %s token is terminated with status %s", task
- .getSpaceToken().toString(), result.getCmdResult()));
+ log.warn("DU of space with {} token is terminated with status {}", task
+ .getSpaceToken().toString(), result.getCmdResult());
}
// Decrease the number of tasks to complete
// - note: a task is complete despite of the final status (Success or
// failure it is same)
int ttc = tasksToComplete.decrementAndGet();
- LOG.debug("TaskToComplete: " + ttc);
+ log.debug("TaskToComplete: {}", ttc);
if (tasksToComplete.get() <= 0) {
// All the tasks are completed.
- LOG.info("All the tasks are completed!");
+ log.info("All the tasks are completed!");
// Check for failed tasks
for (BgDUTask bTask : bDUTasks.getTasks()) {
@@ -428,77 +403,46 @@ void updateSA(DUResult result) {
// Update the attempt and maintain the task in processing queue
bTask.increaseAttempt();
if (bTask.getAttempt() > MaxAttempt) {
- LOG.error("Unable to compute Space Used for the SA with root '"
- + bTask.getAbsPath() + "' for the reason :"
- + bTask.getDuResult().getCmdResult());
+
+ log.error("Unable to compute Space Used for the SA with root {}. Reason: {}",
+ bTask.getAbsPath(),
+ bTask.getDuResult().getCmdResult());
+
failures.incrementAndGet();
} else {
// Retry
try {
bDUTasks.updateTask(bTask);
} catch (SAInfoException e) {
- LOG.error("Something starnge happen." + e);
+ log.error(e.getMessage(),e);
}
}
-
}
}
int s = success.get();
int f = failures.get();
int tot = numberOfTasks.get();
int r = tot - s - f;
- LOG.debug(String.format(
- "Total DU Tasks are %d (success:%d; to-retry:%d; failure:%d).", tot, s,
- r, f));
+ log.debug("Total DU Tasks are {} (success: {}; to-retry: {}; failure: {}.",
+ tot, s, r, f);
+
if (r == 0) {
- // No more retry, so shutdown bDU
stopExecution();
}
}
}
- /**
- * Method called when DUResult has been saved into the DB
- *
- * @param taskDU
- * @param result
- */
void savedSA(DUResult result) {
-
this.tasksToSave.decrementAndGet();
- LOG.debug("Result saved..");
-
- // Check if all the tasks has been processed
- // if (this.tasksToComplete.get()<=0) {
- // //All the tasks has been processed
- // //Check if there was some failures
- // if ((failures.get()) >0) {
- // attempt++;
- // if (attempt>MaxAttempt) {
- // //No more retry, so shutdown bDU
- // bDU.stopExecution();
- // persist.stopSaver();
- // LOG.debug("Stopping Background DU executions.");
- // } else {
- // LOG.info("-- Resubmit DU tasks --");
- // //Remove from tasks queue successfully tasks
- // bDUTasks.removeSuccessTask();
- //
- // submitTasks(bDUTasks);
- // }
- // }
- // }
+ log.debug("Result saved..");
}
- /**
- * Submit all the tasks to a BackgroundDU
- */
void submitTasks(BackgroundDUTasks tasks) {
bDU = new BackgroundDU(timeOutDurationInSec * attempt, TimeUnit.SECONDS);
Collection tasksToSubmit = tasks.getTasks();
- LOG.debug("tasks to submit: " + tasksToSubmit);
+ log.debug("tasks to submit: {}", tasksToSubmit);
int size = tasksToSubmit.size();
this.numberOfTasks = new AtomicInteger(size);
this.tasksToComplete = new AtomicInteger(size);
@@ -506,29 +450,21 @@ void submitTasks(BackgroundDUTasks tasks) {
this.failures = new AtomicInteger(0);
this.success = new AtomicInteger(0);
- LOG.info("Submitting " + this.tasksToComplete + " DU tasks.");
+ log.info("Submitting {} DU tasks.", tasksToComplete);
+
for (BgDUTask task : tasksToSubmit) {
- // task.getSpaceToken();
bDU.addStorageArea(task.getAbsPath(), task.getTaskId());
}
- LOG.info("Setting fake used space to " + this.tasksToComplete
- + " DU tasks.");
- // Set fake used space, in order to avoid -1 result during the computation
+ log.info("Setting fake used space to {} DU tasks.", tasksToComplete);
setFakeUsedSpace(tasksToSubmit);
- LOG.info("Start DU background execution");
+ log.info("Start DU background execution");
bDU.startExecution();
-
}
- /**
- *
- * @param tasksToSubmit
- */
private void setFakeUsedSpace(Collection tasksToSubmit) {
- // TODO errors are not managed in this function
ReservedSpaceCatalog spaceCatalog = new ReservedSpaceCatalog();
for (BgDUTask task : tasksToSubmit) {
TSpaceToken sToken = task.getSpaceToken();
@@ -536,30 +472,26 @@ private void setFakeUsedSpace(Collection tasksToSubmit) {
try {
ssd = spaceCatalog.getStorageSpace(sToken);
} catch (TransferObjectDecodingException e) {
- LOG
- .error("Unable to build StorageSpaceData from StorageSpaceTO. TransferObjectDecodingException: "
- + e.getMessage());
+ log
+ .error("Unable to build StorageSpaceData from StorageSpaceTO. TransferObjectDecodingException: {}",
+ e.getMessage(),e);
} catch (DataAccessException e) {
- LOG.error("Unable to build get StorageSpaceTO. DataAccessException: "
- + e.getMessage());
+ log.error("Unable to build get StorageSpaceTO. DataAccessException: {}",
+ e.getMessage(),e);
}
TSizeInBytes totalSize = ssd.getTotalSpaceSize();
TSizeInBytes fakeUsed = TSizeInBytes.makeEmpty();
try {
fakeUsed = TSizeInBytes.make(totalSize.value() / 2, SizeUnit.BYTES);
} catch (InvalidTSizeAttributesException e) {
- LOG.warn("Unable to create Fake Size to set to used_size");
+ log.warn("Unable to create Fake Size to set to used_size. {}",
+ e.getMessage());
}
- ssd.setUsedSpaceSize(fakeUsed); // By default also freeSize will be
- // updated.
+ ssd.setUsedSpaceSize(fakeUsed);
spaceCatalog.updateStorageSpace(ssd);
}
-
}
- /**
- * @return
- */
public int initSpaceFromINIFile() {
List toAnalyze = spaceCatalog
@@ -579,15 +511,12 @@ public int initSpaceFromINIFile() {
saUsedSize.getUsedSize(), saUsedSize.getUpdateTime());
storageSpaceUpdated++;
} catch (IllegalArgumentException e) {
- LOG
- .error("Unable to updated used space on persistence for Storage Area "
- + saUsedSize.getSaName()
- + " to value "
- + saUsedSize.getUsedSize()
- + " with update time "
- + saUsedSize.getUpdateTime()
- + ". IllegalArgumentException: "
- + e.getMessage());
+ log.error("Error updating used space for SA {} to value {} with update time {}. {}",
+ saUsedSize.getSaName(),
+ saUsedSize.getUsedSize(),
+ saUsedSize.getUpdateTime(),
+ e.getMessage(),
+ e);
}
} else {
try {
@@ -595,13 +524,12 @@ public int initSpaceFromINIFile() {
saUsedSize.getUsedSize());
storageSpaceUpdated++;
} catch (IllegalArgumentException e) {
- LOG
- .error("Unable to updated used space on persistence for Storage Area "
- + saUsedSize.getSaName()
- + " to value "
- + saUsedSize.getUsedSize()
- + ". IllegalArgumentException: "
- + e.getMessage());
+ log.error("Error updating used space for SA {} to value {} with update time {}. {}",
+ saUsedSize.getSaName(),
+ saUsedSize.getUsedSize(),
+ saUsedSize.getUpdateTime(),
+ e.getMessage(),
+ e);
}
}
}
@@ -609,64 +537,47 @@ public int initSpaceFromINIFile() {
return storageSpaceUpdated;
}
- /**
- * @return
- */
private void printInitializedStorageAreas(List saAlias) {
try {
for (VirtualFSInterface vfs : NamespaceDirector.getNamespace()
.getAllDefinedVFS()) {
if (!(saAlias.contains(vfs.getSpaceTokenDescription()))) {
- LOG.debug("SA '" + vfs.getAliasName() + "' is already initialized");
+ log.debug("SA {} already initialized", vfs.getAliasName());
}
}
} catch (NamespaceException e) {
- // never thrown
- LOG.error(
- "Unexpected Exception: NamespaceException on getAllDefinedVFS: ", e);
+ log.error(e.getMessage(), e);
}
}
- /**
- * @param saAlias
- * @param usedSize
- * @throws IllegalArgumentException
- */
private void updateUsedSpaceOnPersistence(String saName, Long usedSize)
throws IllegalArgumentException {
if (saName == null || usedSize == null) {
- LOG.error("Received null arguments: saName = " + saName + " usedSize = "
- + usedSize);
+ log.error("Null arguments: saName={} usedSize={}",
+ saName, usedSize);
throw new IllegalArgumentException("Received null arguments: saName = "
+ saName + " usedSize = " + usedSize);
}
updateUsedSpaceOnPersistence(saName, usedSize, null);
}
- /**
- * @param saName
- * @param usedSize
- * @param updateTime
- */
private void updateUsedSpaceOnPersistence(String saName, Long usedSize,
Date updateTime) throws IllegalArgumentException {
if (saName == null || usedSize == null) {
- LOG.error("Received null arguments: saName = " + saName + " usedSize = "
- + usedSize);
+ log.error("Null arguments: saName={} usedSize={}",
+ saName, usedSize);
throw new IllegalArgumentException("Received null arguments: saName = "
+ saName + " usedSize = " + usedSize);
}
StorageSpaceData ssd = spaceCatalog.getStorageSpaceByAlias(saName);
if (ssd != null) {
- // Update the used space size with new value
try {
ssd.setUsedSpaceSize(TSizeInBytes.make(usedSize, SizeUnit.BYTES));
} catch (InvalidTSizeAttributesException e) {
- LOG.error("Invalid Used Size: " + usedSize
- + " . InvalidTSizeAttributesException: " + e.getMessage());
+ log.error(e.getMessage(),e);
throw new IllegalArgumentException("Invalid Used Size: " + usedSize
+ " Unable to update Storage Space");
}
@@ -676,13 +587,13 @@ private void updateUsedSpaceOnPersistence(String saName, Long usedSize,
} else {
spaceCatalog.updateStorageSpace(ssd, updateTime);
}
- LOG.debug("StorageSpace table updated for SA: '" + saName
- + "' with used size = " + usedSize);
+ log.debug("StorageSpace table updated for SA: '{}' with used size = {}",
+ saName, usedSize);
+
} else {
- LOG.warn("Unable to retrieve StorageSpaceData with Alias: " + saName);
+ log.warn("Unable to retrieve StorageSpaceData with Alias: {}", saName);
throw new IllegalArgumentException(
"Unable to retrieve StorageSpaceData with Alias: " + saName);
}
-
}
}
diff --git a/src/main/java/it/grid/storm/info/TestBackgroundDU.java b/src/main/java/it/grid/storm/info/TestBackgroundDU.java
deleted file mode 100644
index 12a1e400..00000000
--- a/src/main/java/it/grid/storm/info/TestBackgroundDU.java
+++ /dev/null
@@ -1,89 +0,0 @@
-package it.grid.storm.info;
-
-import it.grid.storm.space.DUResult;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Arrays;
-
-public class TestBackgroundDU {
-
- private static final Logger LOG = LoggerFactory
- .getLogger(TestBackgroundDU.class);
- private static BackgroundDU bDu = new BackgroundDU(60, TimeUnit.SECONDS);
- private static TestBackgroundDU tBDU = new TestBackgroundDU();
-
- public void initSA(List paths) {
-
- int count = 0;
- for (String path : paths) {
- LOG.debug("Adding :'" + path + "'");
- bDu.addStorageArea(path, count);
- count++;
- }
- }
-
- public void startComputation() {
-
- LOG.debug("Starting Computation.. in background");
- bDu.startExecution();
- LOG.debug(".. computation started");
- }
-
- /**
- * @param args
- */
- public static void main(String[] args) {
-
- LOG.debug("arg.length : " + args.length);
- if (args.length == 0) {
- List paths = new ArrayList();
- paths.add(System.getProperty("user.dir"));
- paths.add(System.getProperty("user.dir") + File.separator + "..");
- paths.add(System.getProperty("user.dir") + File.separator + ".."
- + File.separator + "TreeTraversal");
- tBDU.initSA(paths);
- } else {
- List paths = Arrays.asList(args);
- tBDU.initSA(paths);
- }
- LOG.debug("how many? :" + bDu.howManyTaskToComplete());
- tBDU.startComputation();
- int howTodos = bDu.howManyTaskToComplete();
- while (howTodos > 0) {
- howTodos = bDu.howManyTaskToComplete();
- LOG.debug("Task to complete: " + howTodos);
- LOG.debug("Task success : " + bDu.howManyTaskSuccess());
- LOG.debug("Task failed : " + bDu.howManyTaskFailure());
- try {
- Thread.sleep(5000);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- LOG.debug("***********************************");
- LOG.debug("***********************************");
- LOG.debug("***********************************");
-
- bDu.stopExecution(false);
- Set results = bDu.getSuccessTasks();
- for (DUResult duResult : results) {
- LOG.debug("duResult : " + duResult);
- }
- Set failedTasks = bDu.getFailureTasks();
- for (DUResult duResult : failedTasks) {
- LOG.debug("failed duResult : " + duResult);
- }
- bDu = null;
-
- }
-
-}
diff --git a/src/main/java/it/grid/storm/info/TestSpaceInfoManager.java b/src/main/java/it/grid/storm/info/TestSpaceInfoManager.java
deleted file mode 100644
index 224f4092..00000000
--- a/src/main/java/it/grid/storm/info/TestSpaceInfoManager.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package it.grid.storm.info;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-public abstract class TestSpaceInfoManager {
-
- /**
- * @param args
- */
- public static void main(String[] args) {
-
- List paths = new ArrayList();
- paths.add(System.getProperty("user.dir"));
- // paths.add(System.getProperty("user.dir")+File.separator+"..");
- paths.add(System.getProperty("user.dir") + File.separator + ".."
- + File.separator + "TreeTraversal");
- SpaceInfoManager.getInstance().startTest(paths);
- // try {
- // Thread.sleep(1500);
- // } catch (InterruptedException e) {
- // // TODO Auto-generated catch block
- // e.printStackTrace();
- // }
- // SpaceInfoManager.stop();
- }
-
-}
diff --git a/src/main/java/it/grid/storm/jna/lcmaps/lcmaps_account_info_t.java b/src/main/java/it/grid/storm/jna/lcmaps/lcmaps_account_info_t.java
index a202cab4..31ed6ecf 100644
--- a/src/main/java/it/grid/storm/jna/lcmaps/lcmaps_account_info_t.java
+++ b/src/main/java/it/grid/storm/jna/lcmaps/lcmaps_account_info_t.java
@@ -25,17 +25,6 @@
import com.sun.jna.Structure;
import com.sun.jna.ptr.IntByReference;
-/**
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that
- * uses a
- * few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA.
- */
public class lcmaps_account_info_t extends Structure {
// / < the uid of the local account
diff --git a/src/main/java/it/grid/storm/logging/Files.java b/src/main/java/it/grid/storm/logging/Files.java
index 29d4df84..355bf135 100644
--- a/src/main/java/it/grid/storm/logging/Files.java
+++ b/src/main/java/it/grid/storm/logging/Files.java
@@ -21,13 +21,9 @@
import java.io.FileInputStream;
import java.io.IOException;
-/** A utility class for working with files. */
public final class Files {
- /** Constructor. */
- private Files() {
-
- }
+ private Files() {}
/**
* A convenience method for getting a file and requiring it to be a readable
@@ -44,7 +40,6 @@ private Files() {
* read
*/
public static File getReadableFile(String filePath) throws IOException {
-
return getFile(filePath, true, true, true, false);
}
From e9a4699b5bd2eff067e2f99485e6a623555dc0d0 Mon Sep 17 00:00:00 2001
From: enricovianello
Date: Thu, 6 Feb 2014 17:28:04 +0100
Subject: [PATCH 30/45] Fix log calls in storm backend - package
it.grid.storm.catalogs
---
.../grid/storm/catalogs/AnonymousPtGData.java | 7 +-
.../grid/storm/catalogs/AnonymousPtPData.java | 13 +-
.../grid/storm/catalogs/BoLChunkCatalog.java | 206 ++++-------
.../it/grid/storm/catalogs/BoLChunkDAO.java | 321 +++++++----------
.../grid/storm/catalogs/BoLChunkDataTO.java | 1 -
.../java/it/grid/storm/catalogs/BoLData.java | 7 +-
.../catalogs/BoLPersistentChunkData.java | 7 +-
.../grid/storm/catalogs/CopyChunkCatalog.java | 64 ++--
.../it/grid/storm/catalogs/CopyChunkDAO.java | 73 ++--
.../grid/storm/catalogs/CopyChunkDataTO.java | 1 -
.../java/it/grid/storm/catalogs/CopyData.java | 5 -
.../catalogs/CopyPersistentChunkData.java | 6 +-
...validCopyChunkDataAttributesException.java | 2 +
...educedBoLChunkDataAttributesException.java | 2 +
...educedPtGChunkDataAttributesException.java | 2 +
...educedPtPChunkDataAttributesException.java | 2 +
...RequestSummaryDataAttributesException.java | 2 +
.../InvalidRetrievedDataException.java | 2 +
.../InvalidSpaceDataAttributesException.java | 5 +-
.../catalogs/MalformedGridUserException.java | 2 +
.../MultipleDataEntriesException.java | 2 +
.../storm/catalogs/NoDataFoundException.java | 2 +
.../grid/storm/catalogs/PtGChunkCatalog.java | 254 ++++---------
.../it/grid/storm/catalogs/PtGChunkDAO.java | 336 +++++++-----------
.../grid/storm/catalogs/PtGChunkDataTO.java | 2 -
.../catalogs/PtGPersistentChunkData.java | 7 +-
.../grid/storm/catalogs/PtPChunkCatalog.java | 189 ++--------
.../it/grid/storm/catalogs/PtPChunkDAO.java | 187 ++++------
.../grid/storm/catalogs/PtPChunkDataTO.java | 1 -
.../catalogs/PtPPersistentChunkData.java | 12 +-
.../storm/catalogs/ReducedBoLChunkDataTO.java | 1 -
.../catalogs/ReducedCopyChunkDataTO.java | 1 -
.../storm/catalogs/ReducedPtGChunkDataTO.java | 1 -
.../storm/catalogs/ReducedPtPChunkDataTO.java | 1 -
.../storm/catalogs/RequestSummaryCatalog.java | 243 ++++++-------
.../storm/catalogs/RequestSummaryDAO.java | 293 ++++++---------
.../storm/catalogs/ReservedSpaceCatalog.java | 180 +++++-----
.../catalogs/SizeInBytesIntConverter.java | 3 +-
.../catalogs/SpaceTokenStringConverter.java | 3 +-
.../SurlMultyOperationRequestData.java | 81 ++---
.../grid/storm/catalogs/SurlRequestData.java | 13 +-
.../storm/catalogs/VolatileAndJiTCatalog.java | 289 +++++++--------
.../storm/catalogs/VolatileAndJiTDAO.java | 155 ++++----
43 files changed, 1152 insertions(+), 1834 deletions(-)
diff --git a/src/main/java/it/grid/storm/catalogs/AnonymousPtGData.java b/src/main/java/it/grid/storm/catalogs/AnonymousPtGData.java
index f8a02d1f..615c590f 100644
--- a/src/main/java/it/grid/storm/catalogs/AnonymousPtGData.java
+++ b/src/main/java/it/grid/storm/catalogs/AnonymousPtGData.java
@@ -75,6 +75,8 @@ public AnonymousPtGData(TSURL SURL, TLifeTimeInSeconds lifeTime,
super(SURL, desiredProtocols, status, transferURL);
if (lifeTime == null || dirOption == null || fileSize == null) {
+ log.debug("Invalid arguments: lifeTime={}, dirOption={}, fileSize={}",
+ lifeTime, dirOption, fileSize);
throw new InvalidPtGDataAttributesException(SURL, lifeTime, dirOption,
desiredProtocols, fileSize, status, transferURL);
@@ -231,9 +233,4 @@ public boolean equals(Object obj) {
return true;
}
- @Override
- protected Logger getLog() {
-
- return log;
- }
}
diff --git a/src/main/java/it/grid/storm/catalogs/AnonymousPtPData.java b/src/main/java/it/grid/storm/catalogs/AnonymousPtPData.java
index a07b5e77..3951642f 100644
--- a/src/main/java/it/grid/storm/catalogs/AnonymousPtPData.java
+++ b/src/main/java/it/grid/storm/catalogs/AnonymousPtPData.java
@@ -37,7 +37,8 @@
public class AnonymousPtPData extends AnonymousFileTransferData implements
PtPData {
- static final Logger log = LoggerFactory.getLogger(AnonymousPtPData.class);
+ private static final Logger log = LoggerFactory.getLogger(AnonymousPtPData.class);
+
protected TSpaceToken spaceToken;
protected TLifeTimeInSeconds pinLifetime;
protected TLifeTimeInSeconds fileLifetime;
@@ -58,6 +59,10 @@ public AnonymousPtPData(TSURL toSURL, TLifeTimeInSeconds pinLifetime,
if (pinLifetime == null || fileLifetime == null || spaceToken == null
|| fileStorageType == null || expectedFileSize == null
|| overwriteOption == null) {
+ log.debug("Invalid arguments: pinLifetime={}, fileLifetime={}, "
+ + "spaceToken={}, fileStorageType={}, expectedFileSize={}, "
+ + "overwriteOption={}", pinLifetime, fileLifetime, spaceToken,
+ fileStorageType, expectedFileSize, overwriteOption);
throw new InvalidPtPDataAttributesException(toSURL, pinLifetime,
fileLifetime, fileStorageType, spaceToken, expectedFileSize,
transferProtocols, overwriteOption, status, transferURL);
@@ -70,12 +75,6 @@ public AnonymousPtPData(TSURL toSURL, TLifeTimeInSeconds pinLifetime,
this.overwriteOption = overwriteOption;
}
- @Override
- protected Logger getLog() {
-
- return log;
- }
-
/*
* (non-Javadoc)
*
diff --git a/src/main/java/it/grid/storm/catalogs/BoLChunkCatalog.java b/src/main/java/it/grid/storm/catalogs/BoLChunkCatalog.java
index b17d9399..b6bdaf69 100644
--- a/src/main/java/it/grid/storm/catalogs/BoLChunkCatalog.java
+++ b/src/main/java/it/grid/storm/catalogs/BoLChunkCatalog.java
@@ -118,35 +118,30 @@ public static BoLChunkCatalog getInstance() {
synchronized public Collection lookup(TRequestToken rt) {
Collection chunkCollection = dao.find(rt);
- log.debug("BoL CHUNK CATALOG: retrieved data " + chunkCollection);
+ log.debug("BoL CHUNK CATALOG: retrieved data {}", chunkCollection);
List list = new ArrayList();
if (chunkCollection.isEmpty()) {
- log
- .warn("BoL CHUNK CATALOG! No chunks found in persistence for specified request: "
- + rt);
- } else {
- // TODO MICHELE USER_SURL here I can update all requests that has
- // not the new fields set alltogether in a bunch, adding a method to
- // the DAO for this purpose
- BoLPersistentChunkData chunk;
- for (BoLChunkDataTO chunkTO : chunkCollection) {
- chunk = makeOne(chunkTO, rt);
- if (chunk != null) {
- list.add(chunk);
- // TODO MICHELE SURL STORE
- // SurlStatusStore.getInstance().storeSurlStatus(chunk.getSURL(),
- // chunk.getStatus().getStatusCode());
- if (!this.isComplete(chunkTO)) {
- try {
- dao.updateIncomplete(this.completeTO(chunkTO, chunk));
- } catch (InvalidReducedBoLChunkDataAttributesException e) {
- log
- .warn("PtG CHUNK CATALOG! unable to add missing informations on DB to the request: "
- + e);
- }
- }
- }
+ log.warn("BoL CHUNK CATALOG! No chunks found in persistence for specified "
+ + "request: {}", rt);
+ return list;
+ }
+
+ BoLPersistentChunkData chunk;
+ for (BoLChunkDataTO chunkTO : chunkCollection) {
+ chunk = makeOne(chunkTO, rt);
+ if (chunk == null) {
+ continue;
+ }
+ list.add(chunk);
+ if (isComplete(chunkTO)) {
+ continue;
+ }
+ try {
+ dao.updateIncomplete(completeTO(chunkTO, chunk));
+ } catch (InvalidReducedBoLChunkDataAttributesException e) {
+ log.warn("BoL CHUNK CATALOG! unable to add missing informations on DB "
+ + "to the request: {}", e.getMessage());
}
}
log.debug("BoL CHUNK CATALOG: returning " + list);
@@ -184,7 +179,7 @@ private BoLPersistentChunkData makeOne(BoLChunkDataTO auxTO, TRequestToken rt) {
long max = Configuration.getInstance().getPinLifetimeMaximum();
if (pinLifeTime > max) {
log.warn("PinLifeTime is greater than the max value allowed. "
- + "Drop the value to the max = " + max + " seconds");
+ + "Drop the value to the max = {} seconds", max);
pinLifeTime = max;
}
lifeTime = TLifeTimeInSeconds.make(pinLifeTime, TimeUnit.SECONDS);
@@ -250,7 +245,7 @@ private BoLPersistentChunkData makeOne(BoLChunkDataTO auxTO, TRequestToken rt) {
} catch (InvalidSurlRequestDataAttributesException e) {
dao.signalMalformedBoLChunk(auxTO);
log.warn("BoL CHUNK CATALOG! Retrieved malformed BoL "
- + "chunk data from persistence. Dropping chunk from request " + rt);
+ + "chunk data from persistence. Dropping chunk from request {}", rt);
log.warn(e.getMessage(), e);
log.warn(errorSb.toString());
}
@@ -401,38 +396,30 @@ synchronized public BoLPersistentChunkData refreshStatus(
// Call the dao refresh method to synch with the db status
BoLChunkDataTO auxTO = dao.refresh(inputChunk.getPrimaryKey());
- log.debug("BoL CHUNK CATALOG: retrieved data " + auxTO);
+ log.debug("BoL CHUNK CATALOG: retrieved data {}", auxTO);
if (auxTO == null) {
- log
- .warn("BoL CHUNK CATALOG! Empty TO found in persistence for specified request: "
- + inputChunk.getPrimaryKey());
- } else {
- /*
- * In this first version the only field updated is the Status. Once
- * updated, the new status is rewritten into the input ChunkData
- */
-
- // status
- TReturnStatus status = null;
- TStatusCode code = StatusCodeConverter.getInstance().toSTORM(
- auxTO.getStatus());
- if (code != TStatusCode.EMPTY) {
- try {
- status = new TReturnStatus(code, auxTO.getErrString());
- } catch (InvalidTReturnStatusAttributeException e) {
- log
- .debug("BoL Chunk: Unable to build the Return Status from the String '"
- + auxTO.getErrString()
- + " and code '"
- + auxTO.getStatus()
- + "''." + e);
+ log.warn("BoL CHUNK CATALOG! Empty TO found in persistence for specified "
+ + "request: {}", inputChunk.getPrimaryKey());
+ return inputChunk;
+ }
+
+ /*
+ * In this first version the only field updated is the Status. Once
+ * updated, the new status is rewritten into the input ChunkData
+ */
+
+ // status
+ TReturnStatus status = null;
+ TStatusCode code = StatusCodeConverter.getInstance().toSTORM(auxTO.getStatus());
+ if (code != TStatusCode.EMPTY) {
+ try {
+ status = new TReturnStatus(code, auxTO.getErrString());
+ } catch (InvalidTReturnStatusAttributeException e) {
+ log.debug("BoL Chunk: Unable to build the Return Status from the String "
+ + "'{}' and code '{}'.", auxTO.getErrString(), auxTO.getStatus());
}
}
inputChunk.setStatus(status);
- // TODO MICHELE SURL STORE
- // SurlStatusStore.getInstance().storeSurlStatus(inputChunk.getSURL(),
- // status.getStatusCode());
- }
return inputChunk;
}
@@ -453,26 +440,23 @@ synchronized public Collection lookupReducedBoLChunkData(
Collection reducedChunkDataTOs = dao.findReduced(rt
.getValue());
- log.debug("BoL CHUNK CATALOG: retrieved data " + reducedChunkDataTOs);
+ log.debug("BoL CHUNK CATALOG: retrieved data {}", reducedChunkDataTOs);
ArrayList list = new ArrayList();
if (reducedChunkDataTOs.isEmpty()) {
- log.debug("BoL CHUNK CATALOG! No chunks found in persistence for " + rt);
+ log.debug("BoL CHUNK CATALOG! No chunks found in persistence for {}", rt);
} else {
ReducedBoLChunkData reducedChunkData = null;
for (ReducedBoLChunkDataTO reducedChunkDataTO : reducedChunkDataTOs) {
reducedChunkData = makeOneReduced(reducedChunkDataTO);
if (reducedChunkData != null) {
list.add(reducedChunkData);
- // TODO MICHELE SURL STORE
- // SurlStatusStore.getInstance().storeSurlStatus(reducedChunkData.fromSURL(),
- // reducedChunkData.status().getStatusCode());
if (!this.isComplete(reducedChunkDataTO)) {
- this.completeTO(reducedChunkDataTO, reducedChunkData);
+ completeTO(reducedChunkDataTO, reducedChunkData);
dao.updateIncomplete(reducedChunkDataTO);
}
}
}
- log.debug("BoL CHUNK CATALOG: returning " + list);
+ log.debug("BoL CHUNK CATALOG: returning {}", list);
}
return list;
}
@@ -517,7 +501,7 @@ private Collection lookupBoLChunkData(
}
Collection chunkDataTOCollection = dao.find(surlsUniqueIDs,
surlsArray, user.getDn());
- log.debug("PtG CHUNK CATALOG: retrieved data " + chunkDataTOCollection);
+ log.debug("BoL CHUNK CATALOG: retrieved data {}", chunkDataTOCollection);
return buildChunkDataList(chunkDataTOCollection);
}
@@ -533,7 +517,7 @@ public Collection lookupBoLChunkData(List surls)
}
Collection chunkDataTOCollection = dao.find(surlsUniqueIDs,
surlsArray);
- log.debug("PtG CHUNK CATALOG: retrieved data " + chunkDataTOCollection);
+ log.debug("BoL CHUNK CATALOG: retrieved data {}", chunkDataTOCollection);
return buildChunkDataList(chunkDataTOCollection);
}
@@ -541,29 +525,24 @@ private Collection buildChunkDataList(
Collection chunkDataTOCollection) {
List list = new ArrayList();
- // TODO MICHELE USER_SURL here I can update all requests that has
- // not the new fields set alltogether in a bunch, adding a method to
- // the DAO for this purpose
BoLPersistentChunkData chunk;
for (BoLChunkDataTO chunkTO : chunkDataTOCollection) {
chunk = makeOne(chunkTO);
- if (chunk != null) {
- list.add(chunk);
- // TODO MICHELE SURL STORE
- // SurlStatusStore.getInstance().storeSurlStatus(chunk.getSURL(),
- // chunk.getStatus().getStatusCode());
- if (!this.isComplete(chunkTO)) {
- try {
- dao.updateIncomplete(this.completeTO(chunkTO, chunk));
- } catch (InvalidReducedBoLChunkDataAttributesException e) {
- log
- .warn("PtG CHUNK CATALOG! unable to add missing informations on DB to the request: "
- + e);
- }
- }
+ if (chunk == null) {
+ continue;
+ }
+ list.add(chunk);
+ if (isComplete(chunkTO)) {
+ continue;
+ }
+ try {
+ dao.updateIncomplete(this.completeTO(chunkTO, chunk));
+ } catch (InvalidReducedBoLChunkDataAttributesException e) {
+ log.warn("BoL CHUNK CATALOG! unable to add missing informations "
+ + "on DB to the request: {}", e.getMessage());
}
}
- log.debug("BoL CHUNK CATALOG: returning " + list);
+ log.debug("BoL CHUNK CATALOG: returning {}", list);
return list;
}
@@ -604,38 +583,8 @@ synchronized public Collection lookupReducedBoLChunkData(
}
Collection chunkDataTOCollection = dao.findReduced(
gu.getDn(), surlsUniqueIDs, surls);
- log.debug("BoL CHUNK CATALOG: retrieved data " + chunkDataTOCollection);
+ log.debug("BoL CHUNK CATALOG: retrieved data {}", chunkDataTOCollection);
return buildReducedChunkDataList(chunkDataTOCollection);
- // ArrayList list = new
- // ArrayList();
- // if(chunkDataTOCollection.isEmpty())
- // {
- // log.debug("BoL CHUNK CATALOG! No chunks found in persistence for " + gu +
- // " " + chunkDataTOCollection);
- // }
- // else
- // {
- // ReducedBoLChunkData reducedChunkData;
- // for(ReducedBoLChunkDataTO reducedChunkDataTO : chunkDataTOCollection)
- // {
- // reducedChunkData = makeOneReduced(reducedChunkDataTO);
- // if(reducedChunkData != null)
- // {
- // list.add(reducedChunkData);
- // // TODO MICHELE SURL STORE
- // //
- // SurlStatusStore.getInstance().storeSurlStatus(reducedChunkData.fromSURL(),
- // reducedChunkData.status().getStatusCode());
- // if(!this.isComplete(reducedChunkDataTO))
- // {
- // this.completeTO(reducedChunkDataTO, reducedChunkData);
- // dao.updateIncomplete(reducedChunkDataTO);
- // }
- // }
- // }
- // log.debug("BoL CHUNK CATALOG: returning " + list);
- // }
- // return list;
}
private Collection buildReducedChunkDataList(
@@ -647,16 +596,13 @@ private Collection buildReducedChunkDataList(
reducedChunkData = makeOneReduced(reducedChunkDataTO);
if (reducedChunkData != null) {
list.add(reducedChunkData);
- // TODO MICHELE SURL STORE
- // SurlStatusStore.getInstance().storeSurlStatus(reducedChunkData.fromSURL(),
- // reducedChunkData.status().getStatusCode());
if (!this.isComplete(reducedChunkDataTO)) {
this.completeTO(reducedChunkDataTO, reducedChunkData);
dao.updateIncomplete(reducedChunkDataTO);
}
}
}
- log.debug("BoL CHUNK CATALOG: returning " + list);
+ log.debug("BoL CHUNK CATALOG: returning {}", list);
return list;
}
@@ -747,10 +693,6 @@ synchronized public void addChild(BoLPersistentChunkData chunkData) {
/* add the entry and update the Primary Key field */
dao.addChild(to);
- // TODO MICHELE SURL STORE
- // SurlStatusStore.getInstance().storeSurlStatus(chunkData.getSURL(),
- // chunkData.getStatus().getStatusCode());
- /* set the assigned PrimaryKey! */
chunkData.setPrimaryKey(to.getPrimaryKey());
}
@@ -793,10 +735,6 @@ synchronized public void add(BoLPersistentChunkData chunkData,
/* add the entry and update the Primary Key field! */
dao.addNew(to, gu.getDn());
- // TODO MICHELE SURL STORE
- // SurlStatusStore.getInstance().storeSurlStatus(chunkData.getSURL(),
- // chunkData.getStatus().getStatusCode());
- /* set the assigned PrimaryKey! */
chunkData.setPrimaryKey(to.getPrimaryKey());
}
@@ -809,9 +747,6 @@ synchronized public void add(BoLPersistentChunkData chunkData,
synchronized public boolean isSRM_FILE_PINNED(TSURL surl) {
return (dao.numberInSRM_SUCCESS(surl.uniqueId()) > 0);
- // TODO MICHELE SURL STORE
- // return
- // TStatusCode.SRM_SUCCESS.equals(SurlStatusStore.getInstance().getSurlStatus(surl));
}
/**
@@ -831,9 +766,6 @@ synchronized public void transitSRM_SUCCESStoSRM_RELEASED(
int index = 0;
for (ReducedBoLChunkData chunkData : chunks) {
if (chunkData != null) {
- // TODO MICHELE SURL STORE
- // SurlStatusStore.getInstance().storeSurlStatus(chunkData.fromSURL(),
- // chunkData.status().getStatusCode());
primaryKeys[index] = chunkData.primaryKey();
index++;
}
@@ -863,10 +795,6 @@ synchronized public void transitSRM_SUCCESStoSRM_ABORTED(TSURL surl,
}
dao.transitSRM_SUCCESStoSRM_ABORTED(surl.uniqueId(), surl.toString(),
explanation);
- // TODO MICHELE SURL STORE
- // SurlStatusStore.getInstance().storeSurlStatus(surl,TStatusCode.SRM_ABORTED);
- // PinnedFilesCatalog.getInstance().removeAllJit(surl);
- // PinnedfilesCatalog.getInstance().removeVolatile(surl);
}
/**
@@ -877,12 +805,6 @@ synchronized public void transitSRM_SUCCESStoSRM_ABORTED(TSURL surl,
synchronized public void transitExpiredSRM_SUCCESS() {
dao.transitExpiredSRM_SUCCESS();
- // TODO MICHELE SURL STORE
- // for (TSURL surl : expiredSurls)
- // {
- // SurlStatusStore.getInstance().storeSurlStatus(surl,
- // TStatusCode.SRM_RELEASED);
- // }
}
public void updateFromPreviousStatus(TRequestToken requestToken,
diff --git a/src/main/java/it/grid/storm/catalogs/BoLChunkDAO.java b/src/main/java/it/grid/storm/catalogs/BoLChunkDAO.java
index 2e5d9193..325f2d03 100644
--- a/src/main/java/it/grid/storm/catalogs/BoLChunkDAO.java
+++ b/src/main/java/it/grid/storm/catalogs/BoLChunkDAO.java
@@ -139,16 +139,13 @@ public synchronized void addChild(BoLChunkDataTO to) {
// insertion
try {
- // WARNING!!!! We are forced to run a query to get the ID of the request,
- // which should
- // NOT be so
- // because the corresponding request object should have been changed with
- // the extra
- // field! However, it is not possible
- // at the moment to perform such change because of strict deadline and the
- // change could
- // wreak havoc
- // the code. So we are forced to make this query!!!
+ /* WARNING!!!! We are forced to run a query to get the ID of the request,
+ * which should NOT be so because the corresponding request object should
+ * have been changed with the extra field! However, it is not possible
+ * at the moment to perform such change because of strict deadline and
+ * the change could wreak havoc the code. So we are forced to make this
+ * query!!!
+ */
// begin transaction
con.setAutoCommit(false);
@@ -163,7 +160,7 @@ public synchronized void addChild(BoLChunkDataTO to) {
id.setString(1, to.getRequestToken());
logWarnings(id.getWarnings());
- log.debug("BoL CHUNK DAO: addChild; " + id.toString());
+ log.debug("BoL CHUNK DAO: addChild; {}", id.toString());
rsid = id.executeQuery();
logWarnings(id.getWarnings());
@@ -180,12 +177,12 @@ public synchronized void addChild(BoLChunkDataTO to) {
// update primary key reading the generated key
to.setPrimaryKey(id_s);
} catch (SQLException e) {
- log.error("BoL CHUNK DAO: unable to complete addChild! BoLChunkDataTO: "
- + to + "; exception received:" + e);
+ log.error("BoL CHUNK DAO: unable to complete addChild! BoLChunkDataTO: {}; "
+ + "exception received: {}", to, e.getMessage(), e);
rollback(con);
} catch (Exception e) {
- log.error("BoL CHUNK DAO: unable to complete addChild! BoLChunkDataTO: "
- + to + "; exception received:" + e);
+ log.error("BoL CHUNK DAO: unable to complete addChild! BoLChunkDataTO: {}; "
+ + "exception received: {}", to, e.getMessage(), e);
rollback(con);
} finally {
close(rsid);
@@ -254,7 +251,7 @@ public synchronized void addNew(BoLChunkDataTO to, String client_dn) {
addNew.setInt(9, to.getDeferredStartTime());
logWarnings(addNew.getWarnings());
- log.trace("BoL CHUNK DAO: addNew; " + addNew.toString());
+ log.trace("BoL CHUNK DAO: addNew; {}", addNew.toString());
addNew.execute();
logWarnings(addNew.getWarnings());
@@ -272,7 +269,7 @@ public synchronized void addNew(BoLChunkDataTO to, String client_dn) {
addProtocols.setString(2, i.next());
logWarnings(addProtocols.getWarnings());
- log.trace("BoL CHUNK DAO: addNew; " + addProtocols.toString());
+ log.trace("BoL CHUNK DAO: addNew; {}", addProtocols.toString());
addProtocols.execute();
logWarnings(addProtocols.getWarnings());
}
@@ -289,13 +286,12 @@ public synchronized void addNew(BoLChunkDataTO to, String client_dn) {
// update primary key reading the generated key
to.setPrimaryKey(id_s);
} catch (SQLException e) {
- log
- .error("BoL CHUNK DAO: Rolling back! Unable to complete addNew! BoLChunkDataTO: "
- + to + "; exception received:" + e);
+ log.error("BoL CHUNK DAO: Rolling back! Unable to complete addNew! "
+ + "BoLChunkDataTO: {}; exception received: {}", to, e.getMessage(), e);
rollback(con);
} catch (Exception e) {
- log.error("BoL CHUNK DAO: unable to complete addNew! BoLChunkDataTO: "
- + to + "; exception received:" + e);
+ log.error("BoL CHUNK DAO: unable to complete addNew! BoLChunkDataTO: {}; "
+ + "exception received: {}", to, e.getMessage(), e);
rollback(con);
} finally {
close(rs_new);
@@ -343,7 +339,7 @@ private synchronized int fillBoLTables(BoLChunkDataTO to, int requestQueueID)
addDirOption.setInt(3, to.getNumLevel());
logWarnings(addDirOption.getWarnings());
- log.trace("BoL CHUNK DAO: addNew; " + addDirOption.toString());
+ log.trace("BoL CHUNK DAO: addNew; {}", addDirOption.toString());
addDirOption.execute();
logWarnings(addDirOption.getWarnings());
@@ -363,14 +359,13 @@ private synchronized int fillBoLTables(BoLChunkDataTO to, int requestQueueID)
addBoL.setString(3, to.getFromSURL());
logWarnings(addBoL.getWarnings());
- // TODO MICHELE USER_SURL set new fields
addBoL.setString(4, to.normalizedStFN());
logWarnings(addBoL.getWarnings());
addBoL.setInt(5, to.sulrUniqueID());
logWarnings(addBoL.getWarnings());
- log.trace("BoL CHUNK DAO: addNew; " + addBoL.toString());
+ log.trace("BoL CHUNK DAO: addNew; {}", addBoL.toString());
addBoL.execute();
logWarnings(addBoL.getWarnings());
@@ -394,8 +389,6 @@ private synchronized int fillBoLTables(BoLChunkDataTO to, int requestQueueID)
addChild.execute();
logWarnings(addChild.getWarnings());
- // rs_s = addChild.getGeneratedKeys();
- // return extractID(rs_s);
return id_g;
} finally {
close(rs_do);
@@ -422,7 +415,6 @@ public synchronized void update(BoLChunkDataTO to) {
}
PreparedStatement updateFileReq = null;
try {
- // TODO MICHELE USER_SURL set new fields
// ready updateFileReq...
updateFileReq = con
.prepareStatement("UPDATE request_queue rq JOIN (status_BoL sb, request_BoL rb) ON (rq.ID=rb.request_queueID AND sb.request_BoLID=rb.ID)"
@@ -441,7 +433,6 @@ public synchronized void update(BoLChunkDataTO to) {
updateFileReq.setInt(4, to.getLifeTime());
logWarnings(updateFileReq.getWarnings());
- // TODO MICHELE USER_SURL fill new fields
updateFileReq.setString(5, to.normalizedStFN());
logWarnings(updateFileReq.getWarnings());
@@ -451,11 +442,11 @@ public synchronized void update(BoLChunkDataTO to) {
updateFileReq.setLong(7, to.getPrimaryKey());
logWarnings(updateFileReq.getWarnings());
// execute update
- log.trace("BoL CHUNK DAO: update method; " + updateFileReq.toString());
+ log.trace("BoL CHUNK DAO: update method; {}", updateFileReq.toString());
updateFileReq.executeUpdate();
logWarnings(updateFileReq.getWarnings());
} catch (SQLException e) {
- log.error("BoL CHUNK DAO: Unable to complete update! " + e);
+ log.error("BoL CHUNK DAO: Unable to complete update! {}", e.getMessage(), e);
} finally {
close(updateFileReq);
}
@@ -467,16 +458,14 @@ public synchronized void update(BoLChunkDataTO to) {
*
* @param chunkTO
*/
- // TODO MICHELE USER_SURL new method
public synchronized void updateIncomplete(ReducedBoLChunkDataTO chunkTO) {
if (!checkConnection()) {
- log
- .error("BoL CHUNK DAO: updateIncomplete - unable to get a valid connection!");
+ log.error("BoL CHUNK DAO: updateIncomplete - unable to get a valid connection!");
return;
}
- String str = "UPDATE request_BoL SET normalized_sourceSURL_StFN=?, sourceSURL_uniqueID=? "
- + "WHERE ID=?";
+ String str = "UPDATE request_BoL SET normalized_sourceSURL_StFN=?, "
+ + "sourceSURL_uniqueID=? WHERE ID=?";
PreparedStatement stmt = null;
try {
stmt = con.prepareStatement(str);
@@ -491,11 +480,12 @@ public synchronized void updateIncomplete(ReducedBoLChunkDataTO chunkTO) {
stmt.setLong(3, chunkTO.primaryKey());
logWarnings(stmt.getWarnings());
- log.trace("BoL CHUNK DAO - update incomplete: " + stmt.toString());
+ log.trace("BoL CHUNK DAO - update incomplete: {}", stmt.toString());
stmt.executeUpdate();
logWarnings(stmt.getWarnings());
} catch (SQLException e) {
- log.error("BoL CHUNK DAO: Unable to complete update incomplete! " + e);
+ log.error("BoL CHUNK DAO: Unable to complete update incomplete! {}",
+ e.getMessage(), e);
} finally {
close(stmt);
}
@@ -533,16 +523,13 @@ public synchronized BoLChunkDataTO refresh(long primary_key) {
logWarnings(find.getWarnings());
BoLChunkDataTO aux = null;
- // The result shoul be un
- // TODO REMOVE THIS WHILE
while (rs.next()) {
aux = new BoLChunkDataTO();
aux.setStatus(rs.getInt("statusCode"));
}
return aux;
} catch (SQLException e) {
- log.error("BoL CHUNK DAO: " + e);
- /* Return null TransferObject! */
+ log.error("BoL CHUNK DAO: {}", e.getMessage(), e);
return null;
} finally {
close(rs);
@@ -586,7 +573,7 @@ public synchronized Collection find(TRequestToken requestToken)
find.setString(1, strToken);
logWarnings(find.getWarnings());
- log.trace("BoL CHUNK DAO: find method; " + find.toString());
+ log.trace("BoL CHUNK DAO: find method; {}", find.toString());
rs = find.executeQuery();
logWarnings(find.getWarnings());
while (rs.next()) {
@@ -595,7 +582,6 @@ public synchronized Collection find(TRequestToken requestToken)
close(rs);
close(find);
- // TODO MICHELE USER_SURL get new fields
// get chunks of the request
str = "SELECT sb.statusCode, rq.timeStamp, rq.pinLifetime, rq.deferredStartTime, rb.ID, rb.sourceSURL, rb.normalized_sourceSURL_StFN, rb.sourceSURL_uniqueID, d.isSourceADirectory, d.allLevelRecursive, d.numOfLevels "
+ "FROM request_queue rq JOIN (request_BoL rb, status_BoL sb) "
@@ -612,7 +598,7 @@ public synchronized Collection find(TRequestToken requestToken)
StatusCodeConverter.getInstance().toDB(TStatusCode.SRM_ABORTED));
logWarnings(find.getWarnings());
- log.trace("BoL CHUNK DAO: find method; " + find.toString());
+ log.trace("BoL CHUNK DAO: find method; {}", find.toString());
rs = find.executeQuery();
logWarnings(find.getWarnings());
@@ -626,7 +612,6 @@ public synchronized Collection find(TRequestToken requestToken)
chunkDataTO.setTimeStamp(rs.getTimestamp("rq.timeStamp"));
chunkDataTO.setPrimaryKey(rs.getLong("rb.ID"));
chunkDataTO.setFromSURL(rs.getString("rb.sourceSURL"));
- // TODO MICHELE USER_SURL fill new fields
chunkDataTO.setNormalizedStFN(rs
.getString("rb.normalized_sourceSURL_StFN"));
@@ -643,7 +628,7 @@ public synchronized Collection find(TRequestToken requestToken)
}
return list;
} catch (SQLException e) {
- log.error("BOL CHUNK DAO: " + e);
+ log.error("BOL CHUNK DAO: {}", e.getMessage(), e);
/* Return empty Collection! */
return new ArrayList();
} finally {
@@ -660,14 +645,12 @@ public synchronized Collection findReduced(
String reqtoken) {
if (!checkConnection()) {
- log
- .error("BoL CHUNK DAO: findReduced - unable to get a valid connection!");
+ log.error("BoL CHUNK DAO: findReduced - unable to get a valid connection!");
return new ArrayList();
}
PreparedStatement find = null;
ResultSet rs = null;
try {
- // TODO MICHELE USER_SURL get new fields
// get reduced chunks
String str = "SELECT sb.statusCode, rb.ID, rb.sourceSURL, rb.normalized_sourceSURL_StFN, rb.sourceSURL_uniqueID "
+ "FROM request_queue rq JOIN (request_BoL rb, status_BoL sb) "
@@ -680,8 +663,7 @@ public synchronized Collection findReduced(
find.setString(1, reqtoken);
logWarnings(find.getWarnings());
- log.trace("BoL CHUNK DAO! findReduced with request token; "
- + find.toString());
+ log.trace("BoL CHUNK DAO! findReduced with request token; {}", find.toString());
rs = find.executeQuery();
logWarnings(find.getWarnings());
@@ -691,19 +673,17 @@ public synchronized Collection findReduced(
chunkDataTO.setStatus(rs.getInt("sb.statusCode"));
chunkDataTO.setPrimaryKey(rs.getLong("rb.ID"));
chunkDataTO.setFromSURL(rs.getString("rb.sourceSURL"));
- // TODO MICHELE USER_SURL fill new fields
chunkDataTO.setNormalizedStFN(rs
.getString("rb.normalized_sourceSURL_StFN"));
int uniqueID = rs.getInt("rb.sourceSURL_uniqueID");
if (!rs.wasNull()) {
chunkDataTO.setSurlUniqueID(uniqueID);
}
-
list.add(chunkDataTO);
}
return list;
} catch (SQLException e) {
- log.error("BOL CHUNK DAO: " + e);
+ log.error("BOL CHUNK DAO: {}", e.getMessage(), e);
/* Return empty Collection! */
return new ArrayList();
} finally {
@@ -721,17 +701,12 @@ public synchronized Collection findReduced(
TRequestToken requestToken, int[] surlUniqueIDs, String[] surls) {
if (!checkConnection()) {
- log
- .error("BoL CHUNK DAO: findReduced - unable to get a valid connection!");
- return new ArrayList(); // return empty Collection!
+ log.error("BoL CHUNK DAO: findReduced - unable to get a valid connection!");
+ return new ArrayList();
}
PreparedStatement find = null;
ResultSet rs = null;
try {
- // TODO MICHELE USER_SURL get new fields and select on the uniqueID and on
- // the fromSurl
- // TODO MICHELE USER_SURL when the uniqueID and normalized surl will be
- // made on the FrontEnd remove the String[] surls parameter
/*
* NOTE: we search also on the fromSurl because otherwise we lost all
* request_Bol that have not the uniqueID set because are not yet been
@@ -752,8 +727,7 @@ public synchronized Collection findReduced(
find.setString(1, requestToken.getValue());
logWarnings(find.getWarnings());
- log.trace("BoL CHUNK DAO! findReduced with griduser+surlarray; "
- + find.toString());
+ log.trace("BoL CHUNK DAO! findReduced with griduser+surlarray; {}", find.toString());
rs = find.executeQuery();
logWarnings(find.getWarnings());
@@ -763,20 +737,18 @@ public synchronized Collection findReduced(
chunkDataTO.setStatus(rs.getInt("sb.statusCode"));
chunkDataTO.setPrimaryKey(rs.getLong("rb.ID"));
chunkDataTO.setFromSURL(rs.getString("rb.sourceSURL"));
- // TODO MICHELE USER_SURL fill new fields
chunkDataTO.setNormalizedStFN(rs
.getString("rb.normalized_sourceSURL_StFN"));
int uniqueID = rs.getInt("rb.sourceSURL_uniqueID");
if (!rs.wasNull()) {
chunkDataTO.setSurlUniqueID(uniqueID);
}
-
list.add(chunkDataTO);
}
return list;
} catch (SQLException e) {
- log.error("BoL CHUNK DAO: " + e);
- return new ArrayList(); // return empty Collection!
+ log.error("BoL CHUNK DAO: {}", e.getMessage(), e);
+ return new ArrayList();
} finally {
close(rs);
close(find);
@@ -792,17 +764,12 @@ public synchronized Collection findReduced(
String griduser, int[] surlUniqueIDs, String[] surls) {
if (!checkConnection()) {
- log
- .error("BoL CHUNK DAO: findReduced - unable to get a valid connection!");
- return new ArrayList(); // return empty Collection!
+ log.error("BoL CHUNK DAO: findReduced - unable to get a valid connection!");
+ return new ArrayList();
}
PreparedStatement find = null;
ResultSet rs = null;
try {
- // TODO MICHELE USER_SURL get new fields and select on the uniqueID and on
- // the fromSurl
- // TODO MICHELE USER_SURL when the uniqueID and normalized surl will be
- // made on the FrontEnd remove the String[] surls parameter
/*
* NOTE: we search also on the fromSurl because otherwise we lost all
* request_Bol that have not the uniqueID set because are not yet been
@@ -823,8 +790,7 @@ public synchronized Collection findReduced(
find.setString(1, griduser);
logWarnings(find.getWarnings());
- log.trace("BoL CHUNK DAO! findReduced with griduser+surlarray; "
- + find.toString());
+ log.trace("BoL CHUNK DAO! findReduced with griduser+surlarray; {}", find.toString());
rs = find.executeQuery();
logWarnings(find.getWarnings());
@@ -834,20 +800,18 @@ public synchronized Collection findReduced(
chunkDataTO.setStatus(rs.getInt("sb.statusCode"));
chunkDataTO.setPrimaryKey(rs.getLong("rb.ID"));
chunkDataTO.setFromSURL(rs.getString("rb.sourceSURL"));
- // TODO MICHELE USER_SURL fill new fields
chunkDataTO.setNormalizedStFN(rs
.getString("rb.normalized_sourceSURL_StFN"));
int uniqueID = rs.getInt("rb.sourceSURL_uniqueID");
if (!rs.wasNull()) {
chunkDataTO.setSurlUniqueID(uniqueID);
}
-
list.add(chunkDataTO);
}
return list;
} catch (SQLException e) {
- log.error("BoL CHUNK DAO: " + e);
- return new ArrayList(); // return empty Collection!
+ log.error("BoL CHUNK DAO: {}", e.getMessage(), e);
+ return new ArrayList();
} finally {
close(rs);
close(find);
@@ -860,13 +824,10 @@ public synchronized Collection findReduced(
* in the isSRM_SUCCESS method invocation. In case of any error, 0 is
* returned.
*/
- // TODO MICHELE USER_SURL use the unique ID to perform the select on the
- // request_Bol table
public synchronized int numberInSRM_SUCCESS(int surlUniqueID) {
if (!checkConnection()) {
- log
- .error("BoL CHUNK DAO: numberInSRM_SUCCESS - unable to get a valid connection!");
+ log.error("BoL CHUNK DAO: numberInSRM_SUCCESS - unable to get a valid connection!");
return 0;
}
String str = "SELECT COUNT(rb.ID) "
@@ -886,8 +847,7 @@ public synchronized int numberInSRM_SUCCESS(int surlUniqueID) {
StatusCodeConverter.getInstance().toDB(TStatusCode.SRM_SUCCESS));
logWarnings(find.getWarnings());
- log.trace("BoL CHUNK DAO - numberInSRM_SUCCESS method: "
- + find.toString());
+ log.trace("BoL CHUNK DAO - numberInSRM_SUCCESS method: {}", find.toString());
rs = find.executeQuery();
logWarnings(find.getWarnings());
@@ -897,9 +857,8 @@ public synchronized int numberInSRM_SUCCESS(int surlUniqueID) {
}
return numberFileSuccessful;
} catch (SQLException e) {
- log
- .error("BoL CHUNK DAO! Unable to determine numberInSRM_SUCCESS! Returning 0! "
- + e);
+ log.error("BoL CHUNK DAO! Unable to determine numberInSRM_SUCCESS! "
+ + "Returning 0! ", e.getMessage(), e);
return 0;
} finally {
close(rs);
@@ -922,8 +881,7 @@ public synchronized int numberInSRM_SUCCESS(int surlUniqueID) {
public synchronized void signalMalformedBoLChunk(BoLChunkDataTO auxTO) {
if (!checkConnection()) {
- log
- .error("BoL CHUNK DAO: signalMalformedBoLChunk - unable to get a valid connection!");
+ log.error("BoL CHUNK DAO: signalMalformedBoLChunk - unable to get a valid connection!");
return;
}
String signalSQL = "UPDATE status_BoL SET statusCode="
@@ -937,13 +895,13 @@ public synchronized void signalMalformedBoLChunk(BoLChunkDataTO auxTO) {
signal.setString(1, "Request is malformed!");
logWarnings(signal.getWarnings());
- log.trace("BoL CHUNK DAO: signalMalformed; " + signal.toString());
+ log.trace("BoL CHUNK DAO: signalMalformed; {}", signal.toString());
signal.executeUpdate();
logWarnings(signal.getWarnings());
} catch (SQLException e) {
- log.error("BoLChunkDAO! Unable to signal in DB that the"
- + " request was malformed! Request: " + auxTO.toString()
- + "; Exception: " + e.toString());
+ log.error("BoLChunkDAO! Unable to signal in DB that the request was "
+ + "malformed! Request: {}; Exception: {}", auxTO.toString(),
+ e.toString(), e);
} finally {
close(signal);
}
@@ -956,15 +914,10 @@ public synchronized void signalMalformedBoLChunk(BoLChunkDataTO auxTO) {
*
* @return
*/
- // TODO MICHELE USER_SURL debug
public synchronized List transitExpiredSRM_SUCCESS() {
- // TODO: put a limit on the queries.....
- // TODO MICHELE USER_SURL moved the checks for surl requests from the surl
- // tring to the surl unique ID
if (!checkConnection()) {
- log
- .error("BoL CHUNK DAO: transitExpiredSRM_SUCCESS - unable to get a valid connection!");
+ log.error("BoL CHUNK DAO: transitExpiredSRM_SUCCESS - unable to get a valid connection!");
return new ArrayList();
}
@@ -998,8 +951,8 @@ public synchronized List transitExpiredSRM_SUCCESS() {
TSURL tsurl = TSURL.makeFromStringWellFormed(sourceSURL);
uniqueID = tsurl.uniqueId();
} catch (InvalidTSURLAttributesException e) {
- log.warn("BoLChunkDAO! unable to build the TSURL from "
- + sourceSURL + " : InvalidTSURLAttributesException " + e);
+ log.warn("BoLChunkDAO! unable to build the TSURL from {}: "
+ + "InvalidTSURLAttributesException ", sourceSURL, e.getMessage());
}
}
expiredSurlMap.put(sourceSURL, uniqueID);
@@ -1007,12 +960,12 @@ public synchronized List transitExpiredSRM_SUCCESS() {
if (expiredSurlMap.isEmpty()) {
commit(con);
- log
- .trace("BoLChunkDAO! No chunk of BoL request was transited from SRM_SUCCESS to SRM_RELEASED.");
+ log.trace("BoLChunkDAO! No chunk of BoL request was transited from "
+ + "SRM_SUCCESS to SRM_RELEASED.");
return new ArrayList();
}
} catch (SQLException e) {
- log.error("BoLChunkDAO! SQLException." + e);
+ log.error("BoLChunkDAO! SQLException.", e.getMessage(), e);
rollback(con);
return new ArrayList();
} finally {
@@ -1040,8 +993,8 @@ public synchronized List transitExpiredSRM_SUCCESS() {
StatusCodeConverter.getInstance().toDB(TStatusCode.SRM_SUCCESS));
logWarnings(prepStatement.getWarnings());
- log.trace("BoL CHUNK DAO - transitExpiredSRM_SUCCESS method: "
- + prepStatement.toString());
+ log.trace("BoL CHUNK DAO - transitExpiredSRM_SUCCESS method: {}",
+ prepStatement.toString());
int count = prepStatement.executeUpdate();
logWarnings(prepStatement.getWarnings());
@@ -1050,14 +1003,12 @@ public synchronized List transitExpiredSRM_SUCCESS() {
log.trace("BoLChunkDAO! No chunk of BoL request was"
+ " transited from SRM_SUCCESS to SRM_RELEASED.");
} else {
- log.info("BoLChunkDAO! " + count
- + " chunks of BoL requests were transited from"
- + " SRM_SUCCESS to SRM_RELEASED.");
+ log.info("BoLChunkDAO! {} chunks of BoL requests were transited from "
+ + "SRM_SUCCESS to SRM_RELEASED.", count);
}
} catch (SQLException e) {
- log
- .error("BoLChunkDAO! Unable to transit expired SRM_SUCCESS chunks of BoL requests, to SRM_RELEASED! "
- + e);
+ log.error("BoLChunkDAO! Unable to transit expired SRM_SUCCESS chunks of "
+ + "BoL requests, to SRM_RELEASED! ", e.getMessage(), e);
rollback(con);
return new ArrayList();
} finally {
@@ -1096,8 +1047,8 @@ public synchronized List transitExpiredSRM_SUCCESS() {
TSURL tsurl = TSURL.makeFromStringWellFormed(sourceSURL);
uniqueID = tsurl.uniqueId();
} catch (InvalidTSURLAttributesException e) {
- log.warn("BoLChunkDAO! unable to build the TSURL from "
- + sourceSURL + " : InvalidTSURLAttributesException " + e);
+ log.warn("BoLChunkDAO! unable to build the TSURL from {}: "
+ + "InvalidTSURLAttributesException ", sourceSURL, e.getMessage());
}
}
pinnedSurlSet.add(uniqueID);
@@ -1127,8 +1078,8 @@ public synchronized List transitExpiredSRM_SUCCESS() {
TSURL tsurl = TSURL.makeFromStringWellFormed(sourceSURL);
uniqueID = tsurl.uniqueId();
} catch (InvalidTSURLAttributesException e) {
- log.warn("BoLChunkDAO! unable to build the TSURL from "
- + sourceSURL + " : InvalidTSURLAttributesException " + e);
+ log.warn("BoLChunkDAO! unable to build the TSURL from {}: "
+ + "InvalidTSURLAttributesException {}", sourceSURL, e.getMessage());
}
}
pinnedSurlSet.add(uniqueID);
@@ -1137,7 +1088,7 @@ public synchronized List transitExpiredSRM_SUCCESS() {
commit(con);
} catch (SQLException e) {
- log.error("BoLChunkDAO! SQLException." + e);
+ log.error("BoLChunkDAO! SQLException. {}", e.getMessage(), e);
rollback(con);
} finally {
close(prepStatement);
@@ -1151,9 +1102,8 @@ public synchronized List transitExpiredSRM_SUCCESS() {
try {
surl = TSURL.makeFromStringValidate(surlEntry.getKey());
} catch (InvalidTSURLAttributesException e) {
- log
- .error("Invalid SURL, cannot release the pin (Extended Attribute): "
- + surlEntry.getKey());
+ log.error("Invalid SURL, cannot release the pin "
+ + "(Extended Attribute): {}", surlEntry.getKey());
continue;
}
expiredSurlList.add(surl);
@@ -1161,11 +1111,8 @@ public synchronized List transitExpiredSRM_SUCCESS() {
try {
stori = NamespaceDirector.getNamespace().resolveStoRIbySURL(surl);
} catch (Throwable e) {
- log
- .error(String.format(
- "Invalid SURL %s cannot release the pin. %s: %s",
- surlEntry.getKey(), e.getClass().getCanonicalName(),
- e.getMessage()));
+ log.error("Invalid SURL {} cannot release the pin. {}: {}",
+ surlEntry.getKey(), e.getClass().getCanonicalName(), e.getMessage());
continue;
}
@@ -1188,14 +1135,9 @@ public synchronized void transitSRM_SUCCESStoSRM_ABORTED(int surlUniqueID,
String surl, String explanation) {
if (!checkConnection()) {
- log
- .error("BoL CHUNK DAO: transitSRM_SUCCESStoSRM_ABORTED - unable to get a valid connection!");
+ log.error("BoL CHUNK DAO: transitSRM_SUCCESStoSRM_ABORTED - unable to get a valid connection!");
return;
}
- // TODO MICHELE USER_SURL use the unique ID to perform the select on the
- // request_Bol table (removed a bug)
- // TODO MICHELE USER_SURL when the uniqueID and normalized surl is provided
- // by the FrontEnd remove the String surl parameter
String str = "UPDATE "
+ "status_BoL sb JOIN request_BoL rb ON sb.request_BoLID=rb.ID "
+ "SET sb.statusCode=?, sb.explanation=?, sb.transferURL=NULL "
@@ -1221,20 +1163,19 @@ public synchronized void transitSRM_SUCCESStoSRM_ABORTED(int surlUniqueID,
stmt.setString(5, surl);
logWarnings(stmt.getWarnings());
- log.trace("BoL CHUNK DAO - transitSRM_SUCCESStoSRM_ABORTED: "
- + stmt.toString());
+ log.trace("BoL CHUNK DAO - transitSRM_SUCCESStoSRM_ABORTED: {}", stmt.toString());
int count = stmt.executeUpdate();
logWarnings(stmt.getWarnings());
if (count > 0) {
- log.info("BoL CHUNK DAO! " + count
- + " chunks were transited from SRM_SUCCESS to SRM_ABORTED.");
+ log.info("BoL CHUNK DAO! {} chunks were transited from SRM_SUCCESS "
+ + "to SRM_ABORTED.", count);
} else {
- log.trace("BoL CHUNK DAO! No chunks were transited "
- + "from SRM_SUCCESS to SRM_ABORTED.");
+ log.trace("BoL CHUNK DAO! No chunks were transited from SRM_SUCCESS "
+ + "to SRM_ABORTED.");
}
} catch (SQLException e) {
- log.error("BoL CHUNK DAO! Unable to transitSRM_SUCCESStoSRM_ABORTED! "
- + e);
+ log.error("BoL CHUNK DAO! Unable to transitSRM_SUCCESStoSRM_ABORTED! {}",
+ e.getMessage(), e);
} finally {
close(stmt);
}
@@ -1250,17 +1191,10 @@ public synchronized void transitSRM_SUCCESStoSRM_ABORTED(int surlUniqueID,
public synchronized void transitSRM_SUCCESStoSRM_RELEASED(long[] ids) {
if (!checkConnection()) {
- log
- .error("BoL CHUNK DAO: transitSRM_SUCCESStoSRM_RELEASED - unable to get a valid connection!");
+ log.error("BoL CHUNK DAO: transitSRM_SUCCESStoSRM_RELEASED - unable to get a valid connection!");
return;
}
- String str =
- // "UPDATE "
- // +
- // "status_BoL s JOIN (request_BoL rg, request_queue r) ON s.request_BoLID=rg.ID AND rg.request_queueID=r.ID "
- // + "SET s.statusCode=? " + "WHERE s.statusCode=? AND s.ID IN "
- // + makeWhereString(ids);
- "UPDATE " + "status_BoL " + "SET statusCode=? "
+ String str = "UPDATE status_BoL SET statusCode=? "
+ "WHERE statusCode=? AND request_BoLID IN " + makeWhereString(ids);
PreparedStatement stmt = null;
try {
@@ -1274,23 +1208,20 @@ public synchronized void transitSRM_SUCCESStoSRM_RELEASED(long[] ids) {
StatusCodeConverter.getInstance().toDB(TStatusCode.SRM_SUCCESS));
logWarnings(stmt.getWarnings());
- log.trace("BoL CHUNK DAO - transitSRM_SUCCESStoSRM_RELEASED: "
- + stmt.toString());
+ log.trace("BoL CHUNK DAO - transitSRM_SUCCESStoSRM_RELEASED: {}",
+ stmt.toString());
int count = stmt.executeUpdate();
logWarnings(stmt.getWarnings());
if (count == 0) {
log.trace("BoL CHUNK DAO! No chunk of BoL request "
+ "was transited from SRM_SUCCESS to SRM_RELEASED.");
} else {
- log
- .info("BoL CHUNK DAO! "
- + count
- + " chunks of BoL requests were transited from SRM_SUCCESS to SRM_RELEASED.");
+ log.info("BoL CHUNK DAO! {} chunks of BoL requests were transited "
+ + "from SRM_SUCCESS to SRM_RELEASED.", count);
}
} catch (SQLException e) {
- log
- .error("BoL CHUNK DAO! Unable to transit chunks from SRM_SUCCESS to SRM_RELEASED! "
- + e);
+ log.error("BoL CHUNK DAO! Unable to transit chunks from SRM_SUCCESS "
+ + "to SRM_RELEASED! {}", e.getMessage(), e);
} finally {
close(stmt);
}
@@ -1308,8 +1239,7 @@ public synchronized void transitSRM_SUCCESStoSRM_RELEASED(long[] ids,
* the where subquery.
*/
if (!checkConnection()) {
- log
- .error("BoL CHUNK DAO: transitSRM_SUCCESStoSRM_RELEASED - unable to get a valid connection!");
+ log.error("BoL CHUNK DAO: transitSRM_SUCCESStoSRM_RELEASED - unable to get a valid connection!");
return;
}
String str = "UPDATE "
@@ -1328,21 +1258,20 @@ public synchronized void transitSRM_SUCCESStoSRM_RELEASED(long[] ids,
StatusCodeConverter.getInstance().toDB(TStatusCode.SRM_SUCCESS));
logWarnings(stmt.getWarnings());
- log.trace("BoL CHUNK DAO - transitSRM_SUCCESStoSRM_RELEASED: "
- + stmt.toString());
+ log.trace("BoL CHUNK DAO - transitSRM_SUCCESStoSRM_RELEASED: {}",
+ stmt.toString());
int count = stmt.executeUpdate();
logWarnings(stmt.getWarnings());
if (count == 0) {
log.trace("BoL CHUNK DAO! No chunk of BoL request was "
+ "transited from SRM_SUCCESS to SRM_RELEASED.");
} else {
- log.info("BoL CHUNK DAO! " + count
- + " chunks of BoL requests were transited "
- + "from SRM_SUCCESS to SRM_RELEASED.");
+ log.info("BoL CHUNK DAO! {} chunks of BoL requests were transited "
+ + "from SRM_SUCCESS to SRM_RELEASED.", count);
}
} catch (SQLException e) {
log.error("BoL CHUNK DAO! Unable to transit chunks "
- + "from SRM_SUCCESS to SRM_RELEASED! " + e);
+ + "from SRM_SUCCESS to SRM_RELEASED! {}", e.getMessage(), e);
} finally {
close(stmt);
}
@@ -1372,8 +1301,8 @@ private void close(Statement stmt) {
try {
stmt.close();
} catch (Exception e) {
- log.error("BoL CHUNK DAO! Unable to close Statement " + stmt.toString()
- + " - Exception: " + e);
+ log.error("BoL CHUNK DAO! Unable to close Statement {} - Exception: {}",
+ stmt.toString(), e.getMessage(), e);
}
}
}
@@ -1385,7 +1314,7 @@ private void commit(Connection con) {
con.commit();
con.setAutoCommit(true);
} catch (SQLException e) {
- log.error("BoL, SQL EXception", e);
+ log.error("BoL, SQL EXception {}", e.getMessage(), e);
}
}
}
@@ -1401,7 +1330,7 @@ private void rollback(Connection con) {
con.setAutoCommit(true);
log.error("BoL CHUNK DAO: roll back successful!");
} catch (SQLException e2) {
- log.error("BoL CHUNK DAO: roll back failed! " + e2);
+ log.error("BoL CHUNK DAO: roll back failed! {}", e2.getMessage(), e2);
}
}
}
@@ -1417,12 +1346,11 @@ private int extractID(ResultSet rs) throws Exception {
}
if (rs.next()) {
return rs.getInt(1);
- } else {
- log.error("BoL CHUNK DAO! It was not possible to establish "
- + "the assigned autoincrement primary key!");
- throw new Exception(
- "BoL CHUNK DAO! It was not possible to establish the assigned autoincrement primary key!");
}
+ log.error("BoL CHUNK DAO! It was not possible to establish "
+ + "the assigned autoincrement primary key!");
+ throw new Exception(
+ "BoL CHUNK DAO! It was not possible to establish the assigned autoincrement primary key!");
}
/**
@@ -1431,9 +1359,9 @@ private int extractID(ResultSet rs) throws Exception {
private void logWarnings(SQLWarning w) {
if (w != null) {
- log.debug("BoL CHUNK DAO: " + w.toString());
+ log.debug("BoL CHUNK DAO: {}", w.toString());
while ((w = w.getNextWarning()) != null) {
- log.debug("BoL CHUNK DAO: " + w.toString());
+ log.debug("BoL CHUNK DAO: {}", w.toString());
}
}
}
@@ -1487,7 +1415,7 @@ private String makeSurlString(String[] surls) {
requestedSURL = SURL.makeSURLfromString(surls[i]);
} catch (NamespaceException e) {
log.error(e.getMessage());
- log.debug("Skip '" + surls[i] + "' during query creation");
+ log.debug("Skip '{}' during query creation", surls[i]);
continue;
}
@@ -1524,9 +1452,11 @@ private boolean setUpConnection() {
response = con.isValid(0);
}
} catch (ClassNotFoundException e) {
- log.error("BoL CHUNK DAO! Exception in setUpConnection! " + e);
+ log.error("BoL CHUNK DAO! Exception in setUpConnection! {}",
+ e.getMessage(), e);
} catch (SQLException e) {
- log.error("BoL CHUNK DAO! Exception in setUpConenction! " + e);
+ log.error("BoL CHUNK DAO! Exception in setUpConenction! {}",
+ e.getMessage(), e);
}
return response;
}
@@ -1558,8 +1488,8 @@ private void takeDownConnection() {
try {
con.close();
} catch (SQLException e) {
- log
- .error("BoL CHUNK DAO! Exception in takeDownConnection method: " + e);
+ log.error("BoL CHUNK DAO! Exception in takeDownConnection method: {}",
+ e.getMessage(), e);
}
}
}
@@ -1642,22 +1572,19 @@ public synchronized void doUpdateStatusOnMatchingStatus(
.setInt(2, StatusCodeConverter.getInstance().toDB(expectedStatusCode));
logWarnings(stmt.getWarnings());
- log.trace("BOL CHUNK DAO - updateStatusOnMatchingStatus: "
- + stmt.toString());
+ log.trace("BOL CHUNK DAO - updateStatusOnMatchingStatus: {}", stmt.toString());
int count = stmt.executeUpdate();
logWarnings(stmt.getWarnings());
if (count == 0) {
- log.trace("BOL CHUNK DAO! No chunk of BOL request was"
- + " updated from " + expectedStatusCode + " to " + newStatusCode
- + ".");
+ log.trace("BOL CHUNK DAO! No chunk of BOL request was updated from {} "
+ + "to {}.", expectedStatusCode, newStatusCode);
} else {
- log.debug("BOL CHUNK DAO! " + count
- + " chunks of BOL requests were updated from " + expectedStatusCode
- + " to " + newStatusCode + ".");
+ log.debug("BOL CHUNK DAO! {} chunks of BOL requests were updated "
+ + "from {} to {}.", count, expectedStatusCode, newStatusCode);
}
} catch (SQLException e) {
- log.error("BOL CHUNK DAO! Unable to updated from " + expectedStatusCode
- + " to " + newStatusCode + " !" + e);
+ log.error("BOL CHUNK DAO! Unable to updated from {} to {}!",
+ expectedStatusCode, newStatusCode, e);
} finally {
close(stmt);
}
@@ -1705,7 +1632,6 @@ private synchronized Collection find(int[] surlsUniqueIDs,
PreparedStatement find = null;
ResultSet rs = null;
try {
- // TODO MICHELE USER_SURL get new fields
// get chunks of the request
String str = "SELECT rq.ID, rq.r_token, sb.statusCode, rq.timeStamp, rq.pinLifetime, "
+ "rq.deferredStartTime, rb.ID, rb.sourceSURL, rb.normalized_sourceSURL_StFN, "
@@ -1725,7 +1651,7 @@ private synchronized Collection find(int[] surlsUniqueIDs,
List list = new ArrayList();
- log.trace("BOL CHUNK DAO - find method: " + find.toString());
+ log.trace("BOL CHUNK DAO - find method: {}", find.toString());
rs = find.executeQuery();
logWarnings(find.getWarnings());
BoLChunkDataTO chunkDataTO = null;
@@ -1739,7 +1665,6 @@ private synchronized Collection find(int[] surlsUniqueIDs,
chunkDataTO.setTimeStamp(rs.getTimestamp("rq.timeStamp"));
chunkDataTO.setPrimaryKey(rs.getLong("rb.ID"));
chunkDataTO.setFromSURL(rs.getString("rb.sourceSURL"));
- // TODO MICHELE USER_SURL fill new fields
chunkDataTO.setNormalizedStFN(rs
.getString("rb.normalized_sourceSURL_StFN"));
@@ -1756,7 +1681,7 @@ private synchronized Collection find(int[] surlsUniqueIDs,
}
return list;
} catch (SQLException e) {
- log.error("BOL CHUNK DAO: " + e);
+ log.error("BOL CHUNK DAO: {}", e.getMessage(), e);
/* return empty Collection! */
return new ArrayList();
} finally {
diff --git a/src/main/java/it/grid/storm/catalogs/BoLChunkDataTO.java b/src/main/java/it/grid/storm/catalogs/BoLChunkDataTO.java
index 0d26e038..e2889297 100644
--- a/src/main/java/it/grid/storm/catalogs/BoLChunkDataTO.java
+++ b/src/main/java/it/grid/storm/catalogs/BoLChunkDataTO.java
@@ -43,7 +43,6 @@ public class BoLChunkDataTO {
private long primaryKey = -1; // ID primary key of record in DB
private String fromSURL = " ";
private boolean dirOption; // initialised in constructor
- // TODO MICHELE USER_SURL added new fields
private String normalizedStFN = null;
private Integer surlUniqueID = null;
/* Database table request_Get fields END */
diff --git a/src/main/java/it/grid/storm/catalogs/BoLData.java b/src/main/java/it/grid/storm/catalogs/BoLData.java
index ca2d767a..a96bd1d6 100644
--- a/src/main/java/it/grid/storm/catalogs/BoLData.java
+++ b/src/main/java/it/grid/storm/catalogs/BoLData.java
@@ -147,16 +147,11 @@ public void setLifeTime(long lifeTimeInSeconds) {
try {
lifeTime = TLifeTimeInSeconds.make(lifeTimeInSeconds, TimeUnit.SECONDS);
} catch (IllegalArgumentException e) {
+ log.error(e.getMessage(), e);
return;
}
this.lifeTime = lifeTime;
}
- @Override
- protected Logger getLog() {
-
- return BoLData.log;
- }
-
}
diff --git a/src/main/java/it/grid/storm/catalogs/BoLPersistentChunkData.java b/src/main/java/it/grid/storm/catalogs/BoLPersistentChunkData.java
index b68df3c7..651686cb 100644
--- a/src/main/java/it/grid/storm/catalogs/BoLPersistentChunkData.java
+++ b/src/main/java/it/grid/storm/catalogs/BoLPersistentChunkData.java
@@ -72,6 +72,7 @@ public BoLPersistentChunkData(TRequestToken requestToken, TSURL fromSURL,
super(fromSURL, lifeTime, dirOption, desiredProtocols, fileSize, status,
transferURL, deferredStartTime);
if (requestToken == null) {
+ log.debug("BoLPersistentChunkData: requestToken is null!");
throw new InvalidBoLPersistentChunkDataAttributesException(requestToken,
fromSURL, lifeTime, dirOption, desiredProtocols, fileSize, status,
transferURL);
@@ -105,12 +106,6 @@ public void setPrimaryKey(long l) {
primaryKey = l;
}
- @Override
- protected Logger getLog() {
-
- return BoLPersistentChunkData.log;
- }
-
@Override
public long getIdentifier() {
diff --git a/src/main/java/it/grid/storm/catalogs/CopyChunkCatalog.java b/src/main/java/it/grid/storm/catalogs/CopyChunkCatalog.java
index 49b1728c..d04e7e64 100644
--- a/src/main/java/it/grid/storm/catalogs/CopyChunkCatalog.java
+++ b/src/main/java/it/grid/storm/catalogs/CopyChunkCatalog.java
@@ -100,9 +100,6 @@ synchronized public void update(CopyPersistentChunkData cd) {
to.setTargetSurlUniqueID(new Integer(cd.getDestinationSURL().uniqueId()));
dao.update(to);
- // TODO MICHELE SURL STORE
- // SurlStatusStore.getInstance().storeSurlStatus(cd.getSURL(),
- // cd.getStatus().getStatusCode());
}
/**
@@ -121,7 +118,7 @@ synchronized public Collection lookup(
TRequestToken rt) {
Collection chunkDataTOs = dao.find(rt);
- log.debug("COPY CHUNK CATALOG: retrieved data " + chunkDataTOs);
+ log.debug("COPY CHUNK CATALOG: retrieved data {}", chunkDataTOs);
return buildChunkDataList(chunkDataTOs, rt);
}
@@ -132,21 +129,21 @@ private Collection buildChunkDataList(
CopyPersistentChunkData chunk;
for (CopyChunkDataTO chunkTO : chunkDataTOs) {
chunk = makeOne(chunkTO, rt);
- if (chunk != null) {
- list.add(chunk);
-
- if (!this.isComplete(chunkTO)) {
- try {
- dao.updateIncomplete(this.completeTO(chunkTO, chunk));
- } catch (InvalidReducedCopyChunkDataAttributesException e) {
- log
- .warn("PtG CHUNK CATALOG! unable to add missing informations on DB to the request: "
- + e);
- }
- }
+ if (chunk == null) {
+ continue;
+ }
+ list.add(chunk);
+ if (isComplete(chunkTO)) {
+ continue;
+ }
+ try {
+ dao.updateIncomplete(completeTO(chunkTO, chunk));
+ } catch (InvalidReducedCopyChunkDataAttributesException e) {
+ log.warn("COPY CHUNK CATALOG! unable to add missing informations on "
+ + "DB to the request: {}", e.getMessage());
}
}
- log.debug("COPY CHUNK CATALOG: returning " + list + "\n\n");
+ log.debug("COPY CHUNK CATALOG: returning {}\n\n", list);
return list;
}
@@ -157,21 +154,21 @@ private Collection buildChunkDataList(
CopyPersistentChunkData chunk;
for (CopyChunkDataTO chunkTO : chunkDataTOs) {
chunk = makeOne(chunkTO);
- if (chunk != null) {
- list.add(chunk);
-
- if (!this.isComplete(chunkTO)) {
- try {
- dao.updateIncomplete(this.completeTO(chunkTO, chunk));
- } catch (InvalidReducedCopyChunkDataAttributesException e) {
- log
- .warn("PtG CHUNK CATALOG! unable to add missing informations on DB to the request: "
- + e);
- }
- }
+ if (chunk == null) {
+ continue;
+ }
+ list.add(chunk);
+ if (isComplete(chunkTO)) {
+ continue;
+ }
+ try {
+ dao.updateIncomplete(completeTO(chunkTO, chunk));
+ } catch (InvalidReducedCopyChunkDataAttributesException e) {
+ log.warn("COPY CHUNK CATALOG! unable to add missing informations on DB "
+ + "to the request: {}", e.getMessage());
}
}
- log.debug("COPY CHUNK CATALOG: returning " + list + "\n\n");
+ log.debug("COPY CHUNK CATALOG: returning {}\n\n", list);
return list;
}
@@ -296,9 +293,8 @@ private CopyPersistentChunkData makeOne(CopyChunkDataTO chunkDataTO,
TFileStorageType fileStorageType = FileStorageTypeConverter.getInstance()
.toSTORM(chunkDataTO.fileStorageType());
if (fileStorageType == TFileStorageType.EMPTY) {
- log.error("\nTFileStorageType could not be "
- + "translated from its String representation! String: "
- + chunkDataTO.fileStorageType());
+ log.error("\nTFileStorageType could not be translated from its String "
+ + "representation! String: {}", chunkDataTO.fileStorageType());
// fail creation of PtPChunk!
fileStorageType = null;
}
@@ -357,7 +353,7 @@ private CopyPersistentChunkData makeOne(CopyChunkDataTO chunkDataTO,
} catch (InvalidSurlRequestDataAttributesException e) {
dao.signalMalformedCopyChunk(chunkDataTO);
log.warn("COPY CHUNK CATALOG! Retrieved malformed Copy"
- + " chunk data from persistence. Dropping chunk from request: " + rt);
+ + " chunk data from persistence. Dropping chunk from request: {}", rt);
log.warn(e.getMessage());
log.warn(errorSb.toString());
}
diff --git a/src/main/java/it/grid/storm/catalogs/CopyChunkDAO.java b/src/main/java/it/grid/storm/catalogs/CopyChunkDAO.java
index 07218764..15d2e313 100644
--- a/src/main/java/it/grid/storm/catalogs/CopyChunkDAO.java
+++ b/src/main/java/it/grid/storm/catalogs/CopyChunkDAO.java
@@ -123,7 +123,6 @@ public synchronized void update(CopyChunkDataTO to) {
}
PreparedStatement updateFileReq = null;
try {
- // TODO MICHELE USER_SURL set new fields
// ready updateFileReq...
updateFileReq = con
.prepareStatement("UPDATE request_queue rq JOIN (status_Copy sc, request_Copy rc) "
@@ -148,7 +147,6 @@ public synchronized void update(CopyChunkDataTO to) {
updateFileReq.setString(5, to.overwriteOption());
logWarnings(updateFileReq.getWarnings());
- // TODO MICHELE USER_SURL fill new fields
updateFileReq.setString(6, to.normalizedSourceStFN());
logWarnings(updateFileReq.getWarnings());
@@ -168,7 +166,8 @@ public synchronized void update(CopyChunkDataTO to) {
updateFileReq.executeUpdate();
logWarnings(updateFileReq.getWarnings());
} catch (SQLException e) {
- log.error("COPY CHUNK DAO: Unable to complete update! " + e);
+ log.error("COPY CHUNK DAO: Unable to complete update! {}",
+ e.getMessage(), e);
} finally {
close(updateFileReq);
}
@@ -180,7 +179,6 @@ public synchronized void update(CopyChunkDataTO to) {
*
* @param chunkTO
*/
- // TODO MICHELE USER_SURL new method
public synchronized void updateIncomplete(ReducedCopyChunkDataTO chunkTO) {
if (!checkConnection()) {
@@ -210,11 +208,12 @@ public synchronized void updateIncomplete(ReducedCopyChunkDataTO chunkTO) {
stmt.setLong(5, chunkTO.primaryKey());
logWarnings(stmt.getWarnings());
- log.trace("COPY CHUNK DAO - update incomplete: " + stmt.toString());
+ log.trace("COPY CHUNK DAO - update incomplete: {}", stmt.toString());
stmt.executeUpdate();
logWarnings(stmt.getWarnings());
} catch (SQLException e) {
- log.error("COPY CHUNK DAO: Unable to complete update incomplete! " + e);
+ log.error("COPY CHUNK DAO: Unable to complete update incomplete! {}",
+ e.getMessage(), e);
} finally {
close(stmt);
}
@@ -254,7 +253,6 @@ public synchronized Collection find(
PreparedStatement find = null;
ResultSet rs = null;
try {
- // TODO MICHELE USER_SURL get new fields
/* get chunks of the request */
str = "SELECT rq.s_token, rq.config_FileStorageTypeID, rq.config_OverwriteID, rq.fileLifetime, rc.ID, rc.sourceSURL, rc.targetSURL, rc.normalized_sourceSURL_StFN, rc.sourceSURL_uniqueID, rc.normalized_targetSURL_StFN, rc.targetSURL_uniqueID, d.isSourceADirectory, d.allLevelRecursive, d.numOfLevels "
+ "FROM request_queue rq JOIN (request_Copy rc, status_Copy sc) "
@@ -289,7 +287,6 @@ public synchronized Collection find(
chunkDataTO.setLifeTime(rs.getInt("rq.fileLifetime"));
chunkDataTO.setPrimaryKey(rs.getLong("rc.ID"));
chunkDataTO.setFromSURL(rs.getString("rc.sourceSURL"));
- // TODO MICHELE USER_SURL fill new fields
chunkDataTO.setNormalizedSourceStFN(rs
.getString("rc.normalized_sourceSURL_StFN"));
int uniqueID = rs.getInt("rc.sourceSURL_uniqueID");
@@ -298,7 +295,6 @@ public synchronized Collection find(
}
chunkDataTO.setToSURL(rs.getString("rc.targetSURL"));
- // TODO MICHELE USER_SURL fill new fields
chunkDataTO.setNormalizedTargetStFN(rs
.getString("rc.normalized_sourceSURL_StFN"));
uniqueID = rs.getInt("rc.sourceSURL_uniqueID");
@@ -310,7 +306,7 @@ public synchronized Collection find(
}
return list;
} catch (SQLException e) {
- log.error("COPY CHUNK DAO: " + e);
+ log.error("COPY CHUNK DAO: {}", e.getMessage(), e);
/* return empty Collection! */
return new ArrayList();
} finally {
@@ -332,7 +328,6 @@ public synchronized Collection find(
PreparedStatement find = null;
ResultSet rs = null;
try {
- // TODO MICHELE USER_SURL get new fields
/* get chunks of the request */
str = "SELECT rq.s_token, rq.config_FileStorageTypeID, rq.config_OverwriteID, rq.fileLifetime, rc.ID, rc.sourceSURL, rc.targetSURL, rc.normalized_sourceSURL_StFN, rc.sourceSURL_uniqueID, rc.normalized_targetSURL_StFN, rc.targetSURL_uniqueID, d.isSourceADirectory, d.allLevelRecursive, d.numOfLevels "
+ "FROM request_queue rq JOIN (request_Copy rc, status_Copy sc) "
@@ -350,7 +345,7 @@ public synchronized Collection find(
find.setString(1, strToken);
logWarnings(find.getWarnings());
- log.debug("COPY CHUNK DAO: find method; " + find.toString());
+ log.debug("COPY CHUNK DAO: find method; {}", find.toString());
rs = find.executeQuery();
logWarnings(find.getWarnings());
@@ -366,7 +361,6 @@ public synchronized Collection find(
chunkDataTO.setLifeTime(rs.getInt("rq.fileLifetime"));
chunkDataTO.setPrimaryKey(rs.getLong("rc.ID"));
chunkDataTO.setFromSURL(rs.getString("rc.sourceSURL"));
- // TODO MICHELE USER_SURL fill new fields
chunkDataTO.setNormalizedSourceStFN(rs
.getString("rc.normalized_sourceSURL_StFN"));
int uniqueID = rs.getInt("rc.sourceSURL_uniqueID");
@@ -375,7 +369,6 @@ public synchronized Collection find(
}
chunkDataTO.setToSURL(rs.getString("rc.targetSURL"));
- // TODO MICHELE USER_SURL fill new fields
chunkDataTO.setNormalizedTargetStFN(rs
.getString("rc.normalized_sourceSURL_StFN"));
uniqueID = rs.getInt("rc.sourceSURL_uniqueID");
@@ -387,7 +380,7 @@ public synchronized Collection find(
}
return list;
} catch (SQLException e) {
- log.error("COPY CHUNK DAO: " + e);
+ log.error("COPY CHUNK DAO: {}", e.getMessage(), e);
/* return empty Collection! */
return new ArrayList();
} finally {
@@ -438,9 +431,9 @@ public synchronized void signalMalformedCopyChunk(CopyChunkDataTO auxTO) {
signal.executeUpdate();
logWarnings(signal.getWarnings());
} catch (SQLException e) {
- log.error("CopyChunkDAO! Unable to signal in DB that the"
- + "request was malformed! Request: " + auxTO.toString()
- + "; Exception: " + e.toString());
+ log.error("CopyChunkDAO! Unable to signal in DB that the request was "
+ + "malformed! Request: {}; Error: {}", auxTO.toString(),
+ e.getMessage(), e);
} finally {
close(signal);
}
@@ -455,8 +448,8 @@ private void close(Statement stmt) {
try {
stmt.close();
} catch (Exception e) {
- log.error("COPY CHUNK DAO! Unable to close Statement "
- + stmt.toString() + " - Exception: " + e);
+ log.error("COPY CHUNK DAO! Unable to close Statement {} - Error: {}",
+ stmt.toString(), e.getMessage(), e);
}
}
}
@@ -470,7 +463,8 @@ private void close(ResultSet rset) {
try {
rset.close();
} catch (Exception e) {
- log.error("COPY CHUNK DAO! Unable to close ResultSet! Exception: " + e);
+ log.error("COPY CHUNK DAO! Unable to close ResultSet! Error: {}",
+ e.getMessage(), e);
}
}
}
@@ -481,9 +475,9 @@ private void close(ResultSet rset) {
private void logWarnings(SQLWarning w) {
if (w != null) {
- log.debug("COPY CHUNK DAO: " + w.toString());
+ log.debug("COPY CHUNK DAO: {}", w.toString());
while ((w = w.getNextWarning()) != null) {
- log.debug("COPY CHUNK DAO: " + w.toString());
+ log.debug("COPY CHUNK DAO: {}", w.toString());
}
}
}
@@ -505,9 +499,11 @@ private boolean setUpConnection() {
response = con.isValid(0);
}
} catch (ClassNotFoundException e) {
- log.error("COPY CHUNK DAO! Exception in setUpConnection! " + e);
+ log.error("COPY CHUNK DAO! Exception in setUpConnection! {}",
+ e.getMessage(), e);
} catch (SQLException e) {
- log.error("COPY CHUNK DAO! Exception in setUpConnection! " + e);
+ log.error("COPY CHUNK DAO! Exception in setUpConnection! {}",
+ e.getMessage(), e);
}
return response;
}
@@ -539,8 +535,8 @@ private void takeDownConnection() {
try {
con.close();
} catch (SQLException e) {
- log.error("COPY CHUNK DAO! Exception in takeDownConnection method: "
- + e);
+ log.error("COPY CHUNK DAO! Exception in takeDownConnection method: {}",
+ e.getMessage(), e);
}
}
}
@@ -623,22 +619,19 @@ public synchronized void doUpdateStatusOnMatchingStatus(
.setInt(2, StatusCodeConverter.getInstance().toDB(expectedStatusCode));
logWarnings(stmt.getWarnings());
- log.trace("COPY CHUNK DAO - updateStatusOnMatchingStatus: "
- + stmt.toString());
+ log.trace("COPY CHUNK DAO - updateStatusOnMatchingStatus: {}", stmt.toString());
int count = stmt.executeUpdate();
logWarnings(stmt.getWarnings());
if (count == 0) {
- log.trace("COPY CHUNK DAO! No chunk of COPY request was"
- + " updated from " + expectedStatusCode + " to " + newStatusCode
- + ".");
+ log.trace("COPY CHUNK DAO! No chunk of COPY request was updated "
+ + "from {} to {}.", expectedStatusCode, newStatusCode);
} else {
- log.debug("COPY CHUNK DAO! " + count
- + " chunks of COPY requests were updated from " + expectedStatusCode
- + " to " + newStatusCode + ".");
+ log.debug("COPY CHUNK DAO! {} chunks of COPY requests were updated "
+ + "from {} to {}.", count, expectedStatusCode, newStatusCode);
}
} catch (SQLException e) {
- log.error("COPY CHUNK DAO! Unable to updated from " + expectedStatusCode
- + " to " + newStatusCode + " !" + e);
+ log.error("COPY CHUNK DAO! Unable to updated from {} to {}! {}",
+ expectedStatusCode, newStatusCode, e.getMessage(), e);
} finally {
close(stmt);
}
@@ -740,7 +733,7 @@ private synchronized Collection find(int[] surlsUniqueIDs,
List list = new ArrayList();
- log.trace("COPY CHUNK DAO - find method: " + find.toString());
+ log.trace("COPY CHUNK DAO - find method: {}", find.toString());
rs = find.executeQuery();
logWarnings(find.getWarnings());
CopyChunkDataTO chunkDataTO = null;
@@ -755,7 +748,6 @@ private synchronized Collection find(int[] surlsUniqueIDs,
chunkDataTO.setLifeTime(rs.getInt("rq.fileLifetime"));
chunkDataTO.setPrimaryKey(rs.getLong("rc.ID"));
chunkDataTO.setFromSURL(rs.getString("rc.sourceSURL"));
- // TODO MICHELE USER_SURL fill new fields
chunkDataTO.setNormalizedSourceStFN(rs
.getString("rc.normalized_sourceSURL_StFN"));
int uniqueID = rs.getInt("rc.sourceSURL_uniqueID");
@@ -764,7 +756,6 @@ private synchronized Collection find(int[] surlsUniqueIDs,
}
chunkDataTO.setToSURL(rs.getString("rc.targetSURL"));
- // TODO MICHELE USER_SURL fill new fields
chunkDataTO.setNormalizedTargetStFN(rs
.getString("rc.normalized_sourceSURL_StFN"));
uniqueID = rs.getInt("rc.sourceSURL_uniqueID");
@@ -775,7 +766,7 @@ private synchronized Collection find(int[] surlsUniqueIDs,
}
return list;
} catch (SQLException e) {
- log.error("COPY CHUNK DAO: " + e);
+ log.error("COPY CHUNK DAO: {}", e.getMessage(), e);
/* return empty Collection! */
return new ArrayList();
} finally {
diff --git a/src/main/java/it/grid/storm/catalogs/CopyChunkDataTO.java b/src/main/java/it/grid/storm/catalogs/CopyChunkDataTO.java
index 802dfaba..03a02ef6 100644
--- a/src/main/java/it/grid/storm/catalogs/CopyChunkDataTO.java
+++ b/src/main/java/it/grid/storm/catalogs/CopyChunkDataTO.java
@@ -41,7 +41,6 @@ public class CopyChunkDataTO {
private long primaryKey = -1; // ID primary key of record in DB
private String fromSURL = " ";
private String toSURL = " ";
- // TODO MICHELE USER_SURL added new fields
private String normalizedSourceStFN = null;
private Integer sourceSurlUniqueID = null;
private String normalizedTargetStFN = null;
diff --git a/src/main/java/it/grid/storm/catalogs/CopyData.java b/src/main/java/it/grid/storm/catalogs/CopyData.java
index 80a78e13..5d1437fc 100644
--- a/src/main/java/it/grid/storm/catalogs/CopyData.java
+++ b/src/main/java/it/grid/storm/catalogs/CopyData.java
@@ -153,9 +153,4 @@ public void changeStatusSRM_FATAL_INTERNAL_ERROR(String explanation) {
setStatus(TStatusCode.SRM_FATAL_INTERNAL_ERROR, explanation);
}
- @Override
- protected Logger getLog() {
-
- return CopyData.log;
- }
}
diff --git a/src/main/java/it/grid/storm/catalogs/CopyPersistentChunkData.java b/src/main/java/it/grid/storm/catalogs/CopyPersistentChunkData.java
index 49365371..c9c1185a 100644
--- a/src/main/java/it/grid/storm/catalogs/CopyPersistentChunkData.java
+++ b/src/main/java/it/grid/storm/catalogs/CopyPersistentChunkData.java
@@ -68,6 +68,7 @@ public CopyPersistentChunkData(TRequestToken requestToken, TSURL fromSURL,
super(fromSURL, destinationSURL, lifetime, fileStorageType, spaceToken,
overwriteOption, status);
if (requestToken == null) {
+ log.debug("CopyPersistentChunkData: requestToken is null!");
throw new InvalidCopyPersistentChunkDataAttributesException(requestToken,
fromSURL, destinationSURL, lifetime, fileStorageType, spaceToken,
overwriteOption, status);
@@ -106,9 +107,4 @@ public long getIdentifier() {
return getPrimaryKey();
}
- @Override
- protected Logger getLog() {
-
- return CopyPersistentChunkData.log;
- }
}
diff --git a/src/main/java/it/grid/storm/catalogs/InvalidCopyChunkDataAttributesException.java b/src/main/java/it/grid/storm/catalogs/InvalidCopyChunkDataAttributesException.java
index ebba2a06..167c4873 100644
--- a/src/main/java/it/grid/storm/catalogs/InvalidCopyChunkDataAttributesException.java
+++ b/src/main/java/it/grid/storm/catalogs/InvalidCopyChunkDataAttributesException.java
@@ -37,6 +37,8 @@
*/
public class InvalidCopyChunkDataAttributesException extends Exception {
+ private static final long serialVersionUID = 6786154038995023512L;
+
// booleans that indicate whether the corresponding variable is null
private boolean nullRequestToken;
private boolean nullFromSURL;
diff --git a/src/main/java/it/grid/storm/catalogs/InvalidReducedBoLChunkDataAttributesException.java b/src/main/java/it/grid/storm/catalogs/InvalidReducedBoLChunkDataAttributesException.java
index a3f4e96b..448ef835 100644
--- a/src/main/java/it/grid/storm/catalogs/InvalidReducedBoLChunkDataAttributesException.java
+++ b/src/main/java/it/grid/storm/catalogs/InvalidReducedBoLChunkDataAttributesException.java
@@ -30,6 +30,8 @@
*/
public class InvalidReducedBoLChunkDataAttributesException extends Exception {
+ private static final long serialVersionUID = -8145580437017768234L;
+
// booleans that indicate whether the corresponding variable is null
private boolean nullFromSURL;
private boolean nullStatus;
diff --git a/src/main/java/it/grid/storm/catalogs/InvalidReducedPtGChunkDataAttributesException.java b/src/main/java/it/grid/storm/catalogs/InvalidReducedPtGChunkDataAttributesException.java
index 920389c9..06be96cf 100644
--- a/src/main/java/it/grid/storm/catalogs/InvalidReducedPtGChunkDataAttributesException.java
+++ b/src/main/java/it/grid/storm/catalogs/InvalidReducedPtGChunkDataAttributesException.java
@@ -30,6 +30,8 @@
*/
public class InvalidReducedPtGChunkDataAttributesException extends Exception {
+ private static final long serialVersionUID = -7943458526292568164L;
+
// booleans that indicate whether the corresponding variable is null
private boolean nullFromSURL;
private boolean nullStatus;
diff --git a/src/main/java/it/grid/storm/catalogs/InvalidReducedPtPChunkDataAttributesException.java b/src/main/java/it/grid/storm/catalogs/InvalidReducedPtPChunkDataAttributesException.java
index f4047d5d..d3d54b8c 100644
--- a/src/main/java/it/grid/storm/catalogs/InvalidReducedPtPChunkDataAttributesException.java
+++ b/src/main/java/it/grid/storm/catalogs/InvalidReducedPtPChunkDataAttributesException.java
@@ -32,6 +32,8 @@
*/
public class InvalidReducedPtPChunkDataAttributesException extends Exception {
+ private static final long serialVersionUID = 4945626188325362854L;
+
// booleans that indicate whether the corresponding variable is null
private boolean nullToSURL;
private boolean nullStatus;
diff --git a/src/main/java/it/grid/storm/catalogs/InvalidRequestSummaryDataAttributesException.java b/src/main/java/it/grid/storm/catalogs/InvalidRequestSummaryDataAttributesException.java
index c12c3e4a..ceb1650b 100644
--- a/src/main/java/it/grid/storm/catalogs/InvalidRequestSummaryDataAttributesException.java
+++ b/src/main/java/it/grid/storm/catalogs/InvalidRequestSummaryDataAttributesException.java
@@ -32,6 +32,8 @@
*/
public class InvalidRequestSummaryDataAttributesException extends Exception {
+ private static final long serialVersionUID = -7729349713696058669L;
+
// booleans true if the corresponding variablesare null or negative
private boolean nullRequestType = true;
private boolean nullRequestToken = true;
diff --git a/src/main/java/it/grid/storm/catalogs/InvalidRetrievedDataException.java b/src/main/java/it/grid/storm/catalogs/InvalidRetrievedDataException.java
index 315da618..5a252b65 100644
--- a/src/main/java/it/grid/storm/catalogs/InvalidRetrievedDataException.java
+++ b/src/main/java/it/grid/storm/catalogs/InvalidRetrievedDataException.java
@@ -28,6 +28,8 @@
*/
public class InvalidRetrievedDataException extends Exception {
+ private static final long serialVersionUID = -3645913441787012438L;
+
private String requestToken;
private String requestType;
private int totalFilesInThisRequest;
diff --git a/src/main/java/it/grid/storm/catalogs/InvalidSpaceDataAttributesException.java b/src/main/java/it/grid/storm/catalogs/InvalidSpaceDataAttributesException.java
index 6c7eeb50..dd0e2ff9 100644
--- a/src/main/java/it/grid/storm/catalogs/InvalidSpaceDataAttributesException.java
+++ b/src/main/java/it/grid/storm/catalogs/InvalidSpaceDataAttributesException.java
@@ -32,11 +32,10 @@
public class InvalidSpaceDataAttributesException extends Exception {
+ private static final long serialVersionUID = -5317879266114702669L;
+
private boolean nullAuth = true;
- private boolean nullType = true;
private boolean nullToken = true;
- private boolean negSpaceDes = true;
- private boolean negSpaceGuar = true;
public InvalidSpaceDataAttributesException(GridUserInterface guser) {
diff --git a/src/main/java/it/grid/storm/catalogs/MalformedGridUserException.java b/src/main/java/it/grid/storm/catalogs/MalformedGridUserException.java
index 80206bd5..2a952b3a 100644
--- a/src/main/java/it/grid/storm/catalogs/MalformedGridUserException.java
+++ b/src/main/java/it/grid/storm/catalogs/MalformedGridUserException.java
@@ -27,6 +27,8 @@
*/
public class MalformedGridUserException extends Exception {
+ private static final long serialVersionUID = 5607710323595609428L;
+
public String toString() {
return "MalformedGridUserException";
diff --git a/src/main/java/it/grid/storm/catalogs/MultipleDataEntriesException.java b/src/main/java/it/grid/storm/catalogs/MultipleDataEntriesException.java
index dd631af5..134b13ff 100644
--- a/src/main/java/it/grid/storm/catalogs/MultipleDataEntriesException.java
+++ b/src/main/java/it/grid/storm/catalogs/MultipleDataEntriesException.java
@@ -29,6 +29,8 @@
*/
public class MultipleDataEntriesException extends Exception {
+ private static final long serialVersionUID = 427636739469695868L;
+
private TRequestToken requestToken;
/**
diff --git a/src/main/java/it/grid/storm/catalogs/NoDataFoundException.java b/src/main/java/it/grid/storm/catalogs/NoDataFoundException.java
index 42fd85a1..bc44544a 100644
--- a/src/main/java/it/grid/storm/catalogs/NoDataFoundException.java
+++ b/src/main/java/it/grid/storm/catalogs/NoDataFoundException.java
@@ -29,6 +29,8 @@
*/
public class NoDataFoundException extends Exception {
+ private static final long serialVersionUID = -718255813130266566L;
+
private TRequestToken requestToken;
/**
diff --git a/src/main/java/it/grid/storm/catalogs/PtGChunkCatalog.java b/src/main/java/it/grid/storm/catalogs/PtGChunkCatalog.java
index 3fcec5a0..4404656f 100644
--- a/src/main/java/it/grid/storm/catalogs/PtGChunkCatalog.java
+++ b/src/main/java/it/grid/storm/catalogs/PtGChunkCatalog.java
@@ -138,9 +138,6 @@ synchronized public void update(PtGPersistentChunkData chunkData) {
}
dao.update(to);
- // TODO MICHELE SURL STORE
- // SurlStatusStore.getInstance().storeSurlStatus(cd.getSURL(),
- // cd.getStatus().getStatusCode());
}
/**
@@ -160,44 +157,35 @@ synchronized public PtGPersistentChunkData refreshStatus(
log.debug("PtG CHUNK CATALOG: retrieved data " + chunkDataTO);
if (chunkDataTO == null) {
- log
- .warn("PtG CHUNK CATALOG! Empty TO found in persistence for specified request: "
- + inputChunk.getPrimaryKey());
- } else {
- /*
- * In this first version the only field updated is the Status. Once
- * updated, the new status is rewritten into the input ChunkData
- */
-
- // status
- TReturnStatus status = null;
- TStatusCode code = StatusCodeConverter.getInstance().toSTORM(
- chunkDataTO.status());
- if (code != TStatusCode.EMPTY) {
- try {
- status = new TReturnStatus(code, chunkDataTO.errString());
- } catch (InvalidTReturnStatusAttributeException e) {
- log
- .error("PtGChunk : Unable to build the Return Status from the String '"
- + chunkDataTO.errString()
- + " and code '"
- + chunkDataTO.status()
- + "''." + e);
- }
- }
- inputChunk.setStatus(status);
- // TODO MICHELE SURL STORE
- // SurlStatusStore.getInstance().storeSurlStatus(inputChunk.getSURL(),
- // status.getStatusCode());
- TTURL turl = null;
+ log.warn("PtG CHUNK CATALOG! Empty TO found in persistence for specified "
+ + "request: {}", inputChunk.getPrimaryKey());
+ return inputChunk;
+ }
+
+ /*
+ * In this first version the only field updated is the Status. Once
+ * updated, the new status is rewritten into the input ChunkData
+ */
+
+ // status
+ TReturnStatus status = null;
+ TStatusCode code = StatusCodeConverter.getInstance().toSTORM(chunkDataTO.status());
+ if (code != TStatusCode.EMPTY) {
try {
- turl = TTURL.makeFromString(chunkDataTO.turl());
- } catch (InvalidTTURLAttributesException e) {
- log.info("PtGChunkCatalog (FALSE-ERROR-in-abort-refresh-status?):"
- + " built a TURL with protocol NULL (retrieved from the DB..)");
+ status = new TReturnStatus(code, chunkDataTO.errString());
+ } catch (InvalidTReturnStatusAttributeException e) {
+ log.error("PtGChunk : Unable to build the Return Status from the String '{}' and code '{}'. {}", chunkDataTO.errString(), chunkDataTO.status(), e.getMessage());
}
- inputChunk.setTransferURL(turl);
}
+ inputChunk.setStatus(status);
+ TTURL turl = null;
+ try {
+ turl = TTURL.makeFromString(chunkDataTO.turl());
+ } catch (InvalidTTURLAttributesException e) {
+ log.info("PtGChunkCatalog (FALSE-ERROR-in-abort-refresh-status?):"
+ + " built a TURL with protocol NULL (retrieved from the DB..)");
+ }
+ inputChunk.setTransferURL(turl);
return inputChunk;
}
@@ -219,31 +207,25 @@ synchronized public Collection lookup(TRequestToken rt)
log.debug("PtG CHUNK CATALOG: retrieved data " + chunkTOs);
ArrayList list = new ArrayList();
if (chunkTOs.isEmpty()) {
- log
- .warn("PtG CHUNK CATALOG! No chunks found in persistence for specified request: "
- + rt);
- } else {
- // TODO MICHELE USER_SURL here I can update all requests that has not the
- // new fields set alltogether in a bunch, adding a method to the DAO for
- // this purpose
- PtGPersistentChunkData chunk;
- for (PtGChunkDataTO chunkTO : chunkTOs) {
- chunk = makeOne(chunkTO, rt);
- if (chunk != null) {
- list.add(chunk);
- // TODO MICHELE SURL STORE
- // SurlStatusStore.getInstance().storeSurlStatus(chunk.getSURL(),
- // chunk.getStatus().getStatusCode());
- if (!this.isComplete(chunkTO)) {
- try {
- dao.updateIncomplete(this.completeTO(chunkTO, chunk));
- } catch (InvalidReducedPtGChunkDataAttributesException e) {
- log
- .warn("PtG CHUNK CATALOG! unable to add missing informations on DB to the request: "
- + e);
- }
- }
- }
+ log.warn("PtG CHUNK CATALOG! No chunks found in persistence for "
+ + "specified request: {}", rt);
+ return list;
+ }
+ PtGPersistentChunkData chunk;
+ for (PtGChunkDataTO chunkTO : chunkTOs) {
+ chunk = makeOne(chunkTO, rt);
+ if (chunk == null) {
+ continue;
+ }
+ list.add(chunk);
+ if (isComplete(chunkTO)) {
+ continue;
+ }
+ try {
+ dao.updateIncomplete(this.completeTO(chunkTO, chunk));
+ } catch (InvalidReducedPtGChunkDataAttributesException e) {
+ log.warn("PtG CHUNK CATALOG! unable to add missing informations on DB "
+ + "to the request: {}", e.getMessage());
}
}
log.debug("PtG CHUNK CATALOG: returning " + list);
@@ -282,7 +264,7 @@ private PtGPersistentChunkData makeOne(PtGChunkDataTO chunkDataTO,
long max = Configuration.getInstance().getPinLifetimeMaximum();
if (pinLifeTime > max) {
log.warn("PinLifeTime is greater than the max value allowed."
- + " Drop the value to the max = " + max + " seconds");
+ + " Drop the value to the max = {} seconds", max);
pinLifeTime = max;
}
lifeTime = TLifeTimeInSeconds.make((pinLifeTime), TimeUnit.SECONDS);
@@ -342,9 +324,8 @@ private PtGPersistentChunkData makeOne(PtGChunkDataTO chunkDataTO,
}
} catch (IllegalArgumentException e) {
- log
- .error("Unexpected error on voms grid user creation. Contact StoRM Support : IllegalArgumentException "
- + e.getMessage());
+ log.error("Unexpected error on voms grid user creation."
+ + " IllegalArgumentException: {}", e.getMessage(), e);
}
// transferURL
/*
@@ -361,10 +342,8 @@ private PtGPersistentChunkData makeOne(PtGChunkDataTO chunkDataTO,
aux.setPrimaryKey(chunkDataTO.primaryKey());
} catch (InvalidSurlRequestDataAttributesException e) {
dao.signalMalformedPtGChunk(chunkDataTO);
- log
- .warn("PtG CHUNK CATALOG! Retrieved malformed"
- + " PtG chunk data from persistence. Dropping chunk from request "
- + rt);
+ log.warn("PtG CHUNK CATALOG! Retrieved malformed PtG chunk data from "
+ + "persistence. Dropping chunk from request {}", rt);
log.warn(e.getMessage(), e);
log.warn(errorSb.toString());
}
@@ -486,26 +465,23 @@ synchronized public Collection lookupReducedPtGChunkData(
Collection reducedChunkDataTOs = dao.findReduced(rt
.getValue());
- log.debug("PtG CHUNK CATALOG: retrieved data " + reducedChunkDataTOs);
+ log.debug("PtG CHUNK CATALOG: retrieved data {}", reducedChunkDataTOs);
ArrayList list = new ArrayList();
if (reducedChunkDataTOs.isEmpty()) {
- log.debug("PtG CHUNK CATALOG! No chunks found in persistence for " + rt);
+ log.debug("PtG CHUNK CATALOG! No chunks found in persistence for {}", rt);
} else {
ReducedPtGChunkData reducedChunkData = null;
for (ReducedPtGChunkDataTO reducedChunkDataTO : reducedChunkDataTOs) {
reducedChunkData = makeOneReduced(reducedChunkDataTO);
if (reducedChunkData != null) {
list.add(reducedChunkData);
- // TODO MICHELE SURL STORE
- // SurlStatusStore.getInstance().storeSurlStatus(reducedChunkData.fromSURL(),
- // reducedChunkData.status().getStatusCode());
if (!this.isComplete(reducedChunkDataTO)) {
this.completeTO(reducedChunkDataTO, reducedChunkData);
dao.updateIncomplete(reducedChunkDataTO);
}
}
}
- log.debug("PtG CHUNK CATALOG: returning " + list);
+ log.debug("PtG CHUNK CATALOG: returning {}", list);
}
return list;
}
@@ -523,7 +499,7 @@ public Collection lookupReducedPtGChunkData(
}
Collection chunkDataTOCollection = dao.findReduced(
requestToken, surlsUniqueIDs, surlsArray);
- log.debug("PtG CHUNK CATALOG: retrieved data " + chunkDataTOCollection);
+ log.debug("PtG CHUNK CATALOG: retrieved data {}", chunkDataTOCollection);
return buildReducedChunkDataList(chunkDataTOCollection);
}
@@ -551,7 +527,7 @@ private Collection lookupPtGChunkData(
}
Collection chunkDataTOCollection = dao.find(surlsUniqueIDs,
surlsArray, user.getDn());
- log.debug("PtG CHUNK CATALOG: retrieved data " + chunkDataTOCollection);
+ log.debug("PtG CHUNK CATALOG: retrieved data {}", chunkDataTOCollection);
return buildChunkDataList(chunkDataTOCollection);
}
@@ -567,7 +543,7 @@ public Collection lookupPtGChunkData(List surls)
}
Collection chunkDataTOCollection = dao.find(surlsUniqueIDs,
surlsArray);
- log.debug("PtG CHUNK CATALOG: retrieved data " + chunkDataTOCollection);
+ log.debug("PtG CHUNK CATALOG: retrieved data {}", chunkDataTOCollection);
return buildChunkDataList(chunkDataTOCollection);
}
@@ -575,26 +551,21 @@ private Collection buildChunkDataList(
Collection chunkDataTOCollection) {
ArrayList list = new ArrayList();
- // TODO MICHELE USER_SURL here I can update all requests that has not the
- // new fields set alltogether
- // in a bunch, adding a method to the DAO for this purpose
PtGPersistentChunkData chunk;
for (PtGChunkDataTO chunkTO : chunkDataTOCollection) {
chunk = makeOne(chunkTO);
- if (chunk != null) {
- list.add(chunk);
- // TODO MICHELE SURL STORE
- // SurlStatusStore.getInstance().storeSurlStatus(chunk.getSURL(),
- // chunk.getStatus().getStatusCode());
- if (!this.isComplete(chunkTO)) {
- try {
- dao.updateIncomplete(this.completeTO(chunkTO, chunk));
- } catch (InvalidReducedPtGChunkDataAttributesException e) {
- log
- .warn("PtG CHUNK CATALOG! unable to add missing informations on DB to the request: "
- + e);
- }
- }
+ if (chunk == null) {
+ continue;
+ }
+ list.add(chunk);
+ if (isComplete(chunkTO)) {
+ continue;
+ }
+ try {
+ dao.updateIncomplete(this.completeTO(chunkTO, chunk));
+ } catch (InvalidReducedPtGChunkDataAttributesException e) {
+ log.warn("PtG CHUNK CATALOG! unable to add missing informations on "
+ + "DB to the request: ", e.getMessage());
}
}
return list;
@@ -635,38 +606,8 @@ synchronized public Collection lookupReducedPtGChunkData(
}
Collection chunkDataTOCollection = dao.findReduced(
gu.getDn(), surlsUniqueIDs, surls);
- log.debug("PtG CHUNK CATALOG: retrieved data " + chunkDataTOCollection);
+ log.debug("PtG CHUNK CATALOG: retrieved data {}", chunkDataTOCollection);
return buildReducedChunkDataList(chunkDataTOCollection);
- // ArrayList list = new ArrayList();
- // if(chunkDataTOCollection.isEmpty())
- // {
- // log.debug("PtG CHUNK CATALOG! No chunks found in persistence for " + gu +
- // " "
- // + chunkDataTOCollection);
- // }
- // else
- // {
- // ReducedPtGChunkData reducedChunkData;
- // for(ReducedPtGChunkDataTO reducedChunkDataTO : chunkDataTOCollection)
- // {
- // reducedChunkData = makeOneReduced(reducedChunkDataTO);
- // if(reducedChunkData != null)
- // {
- // list.add(reducedChunkData);
- // // TODO MICHELE SURL STORE
- // //
- // SurlStatusStore.getInstance().storeSurlStatus(reducedChunkData.fromSURL(),
- // reducedChunkData.status().getStatusCode());
- // if(!this.isComplete(reducedChunkDataTO))
- // {
- // this.completeTO(reducedChunkDataTO, reducedChunkData);
- // dao.updateIncomplete(reducedChunkDataTO);
- // }
- // }
- // }
- // log.debug("PtG CHUNK CATALOG: returning " + list);
- // }
- // return list;
}
private Collection buildReducedChunkDataList(
@@ -678,16 +619,13 @@ private Collection buildReducedChunkDataList(
reducedChunkData = makeOneReduced(reducedChunkDataTO);
if (reducedChunkData != null) {
list.add(reducedChunkData);
- // TODO MICHELE SURL STORE
- // SurlStatusStore.getInstance().storeSurlStatus(reducedChunkData.fromSURL(),
- // reducedChunkData.status().getStatusCode());
- if (!this.isComplete(reducedChunkDataTO)) {
- this.completeTO(reducedChunkDataTO, reducedChunkData);
+ if (!isComplete(reducedChunkDataTO)) {
+ completeTO(reducedChunkDataTO, reducedChunkData);
dao.updateIncomplete(reducedChunkDataTO);
}
}
}
- log.debug("PtG CHUNK CATALOG: returning " + list);
+ log.debug("PtG CHUNK CATALOG: returning {}",list);
return list;
}
@@ -786,9 +724,6 @@ synchronized public void addChild(PtGPersistentChunkData chunkData) {
}
/* add the entry and update the Primary Key field! */
dao.addChild(to);
- // TODO MICHELE SURL STORE
- // SurlStatusStore.getInstance().storeSurlStatus(chunkData.getSURL(),
- // chunkData.getStatus().getStatusCode());
/* set the assigned PrimaryKey! */
chunkData.setPrimaryKey(to.primaryKey());
}
@@ -838,9 +773,6 @@ synchronized public void add(PtGPersistentChunkData chunkData,
dao.addNew(to, gu.getDn()); // add the entry and update the Primary Key
// field!
- // TODO MICHELE SURL STORE
- // SurlStatusStore.getInstance().storeSurlStatus(chunkData.getSURL(),
- // chunkData.getStatus().getStatusCode());
chunkData.setPrimaryKey(to.primaryKey()); // set the assigned PrimaryKey!
}
@@ -853,9 +785,7 @@ synchronized public void add(PtGPersistentChunkData chunkData,
synchronized public boolean isSRM_FILE_PINNED(TSURL surl) {
return (dao.numberInSRM_FILE_PINNED(surl.uniqueId()) > 0);
- // TODO MICHELE SURL STORE
- // return
- // TStatusCode.SRM_FILE_PINNED.equals(SurlStatusStore.getInstance().getSurlStatus(surl));
+
}
/**
@@ -882,44 +812,12 @@ synchronized public void transitSRM_FILE_PINNEDtoSRM_RELEASED(
dao.transitSRM_FILE_PINNEDtoSRM_RELEASED(primaryKeys, token);
for (ReducedPtGChunkData chunkData : chunks) {
if (chunkData != null) {
- // TODO MICHELE SURL STORE
- // SurlStatusStore.getInstance().storeSurlStatus(chunkData.fromSURL(),
- // chunkData.status().getStatusCode());
primaryKeys[index] = chunkData.primaryKey();
index++;
}
}
}
- /**
- * This method is intended to be used by srmRm to transit all PtG chunks on
- * the given SURL which are in the SRM_FILE_PINNED state, to SRM_ABORTED. The
- * supplied String will be used as explanation in those chunks return status.
- * The global status of the request is _not_ changed.
- *
- * The TURL of those requests will automatically be set to empty. Notice that
- * both removeAllJit(SURL) and removeVolatile(SURL) are automatically invoked
- * on PinnedFilesCatalog, to remove any entry and corresponding physical ACLs.
- *
- * Beware, that the chunks may be part of requests that have finished, or that
- * still have not finished because other chunks are being processed.
- */
- // synchronized public void transitSRM_FILE_PINNEDtoSRM_ABORTED(TSURL
- // surl,String explanation) {
- // /* Actually (BE 1.5.4-0) not used*/
- // if(explanation == null)
- // {
- // explanation = "";
- // }
- // dao.transitSRM_FILE_PINNEDtoSRM_ABORTED(surl.uniqueId(), surl.rawSurl(),
- // explanation);
- // // TODO MICHELE SURL STORE
- // //
- // SurlStatusStore.getInstance().storeSurlStatus(surl,TStatusCode.SRM_ABORTED);
- // //PinnedFilesCatalog.getInstance().removeAllJit(surl);
- // //PinnedfilesCatalog.getInstance().removeVolatile(surl);
- // }
-
/**
* Method used to force transition to SRM_RELEASED from SRM_FILE_PINNED, of
* all PtG Requests whose pinLifetime has expired and the state still has not
@@ -928,12 +826,6 @@ synchronized public void transitSRM_FILE_PINNEDtoSRM_RELEASED(
synchronized public void transitExpiredSRM_FILE_PINNED() {
List expiredSurls = dao.transitExpiredSRM_FILE_PINNED();
- // TODO MICHELE SURL STORE
- // for (TSURL surl : expiredSurls)
- // {
- // SurlStatusStore.getInstance().storeSurlStatus(surl,
- // TStatusCode.SRM_RELEASED);
- // }
}
public void updateStatus(TRequestToken requestToken, TSURL surl,
diff --git a/src/main/java/it/grid/storm/catalogs/PtGChunkDAO.java b/src/main/java/it/grid/storm/catalogs/PtGChunkDAO.java
index 5c6cb016..0f82a9b3 100644
--- a/src/main/java/it/grid/storm/catalogs/PtGChunkDAO.java
+++ b/src/main/java/it/grid/storm/catalogs/PtGChunkDAO.java
@@ -164,7 +164,7 @@ public synchronized void addChild(PtGChunkDataTO to) {
id.setString(1, to.requestToken());
logWarnings(id.getWarnings());
- log.debug("PTG CHUNK DAO: addChild; " + id.toString());
+ log.debug("PTG CHUNK DAO: addChild; {}", id.toString());
rsid = id.executeQuery();
logWarnings(id.getWarnings());
@@ -181,24 +181,16 @@ public synchronized void addChild(PtGChunkDataTO to) {
// update primary key reading the generated key
to.setPrimaryKey(id_s);
} catch (SQLException e) {
- log.error("PTG CHUNK DAO: unable to complete addChild! PtGChunkDataTO: "
- + to + "; exception received:" + e);
+ log.error("PTG CHUNK DAO: unable to complete addChild! "
+ + "PtGChunkDataTO: {}; error: {}", to, e.getMessage(), e);
rollback(con);
} catch (Exception e) {
- log.error("PTG CHUNK DAO: unable to complete addChild! PtGChunkDataTO: "
- + to + "; exception received:" + e);
+ log.error("PTG CHUNK DAO: unable to complete addChild! "
+ + "PtGChunkDataTO: {}; error: {}", to, e.getMessage(), e);
rollback(con);
} finally {
close(rsid);
close(id);
- // TODO MICHELE IMPORTANT test if the close done in the called method
- // doesn't causes troubles
- // close(rsdo);
- // close(addDirOption);
- // close(rsg);
- // close(addGet);
- // close(rs);
- // close(addChild);
}
}
@@ -210,7 +202,6 @@ public synchronized void addChild(PtGChunkDataTO to) {
* The supplied PtGChunkData is used to fill in all the DB tables where file
* specific info gets recorded: it _adds_ a new request!
*/
- // TODO MICHELE USER_SURL refactored
public synchronized void addNew(PtGChunkDataTO to, String client_dn) {
if (!checkConnection()) {
@@ -262,7 +253,7 @@ public synchronized void addNew(PtGChunkDataTO to, String client_dn) {
addNew.setTimestamp(8, new Timestamp(new Date().getTime()));
logWarnings(addNew.getWarnings());
- log.trace("PTG CHUNK DAO: addNew; " + addNew.toString());
+ log.trace("PTG CHUNK DAO: addNew; {}", addNew.toString());
addNew.execute();
logWarnings(addNew.getWarnings());
@@ -280,7 +271,7 @@ public synchronized void addNew(PtGChunkDataTO to, String client_dn) {
addProtocols.setString(2, i.next());
logWarnings(addProtocols.getWarnings());
- log.trace("PTG CHUNK DAO: addNew; " + addProtocols.toString());
+ log.trace("PTG CHUNK DAO: addNew; {}", addProtocols.toString());
addProtocols.execute();
logWarnings(addProtocols.getWarnings());
}
@@ -297,26 +288,17 @@ public synchronized void addNew(PtGChunkDataTO to, String client_dn) {
// update primary key reading the generated key
to.setPrimaryKey(id_s);
} catch (SQLException e) {
- log
- .error("PTG CHUNK DAO: Rolling back! Unable to complete addNew! PtGChunkDataTO: "
- + to + "; exception received:" + e);
+ log.error("PTG CHUNK DAO: Rolling back! Unable to complete addNew! "
+ + "PtGChunkDataTO: {}; error: {}", to, e.getMessage(), e);
rollback(con);
} catch (Exception e) {
- log.error("PTG CHUNK DAO: unable to complete addNew! PtGChunkDataTO: "
- + to + "; exception received:" + e);
+ log.error("PTG CHUNK DAO: unable to complete addNew! "
+ + "PtGChunkDataTO: {}; error: {}", to, e.getMessage(), e);
rollback(con);
} finally {
close(rs_new);
- // TODO MICHELE IMPORTANT test if the close done in the called method
- // doesn't causes troubles
- // close(rs_do);
- // close(rs_g);
- // close(rs_s);
close(addNew);
close(addProtocols);
- // close(addDirOption);
- // close(addGet);
- // close(addChild);
}
}
@@ -359,7 +341,7 @@ private synchronized int fillPtGTables(PtGChunkDataTO to, int requestQueueID)
addDirOption.setInt(3, to.numLevel());
logWarnings(addDirOption.getWarnings());
- log.trace("PTG CHUNK DAO: addNew; " + addDirOption.toString());
+ log.trace("PTG CHUNK DAO: addNew; {}", addDirOption.toString());
addDirOption.execute();
logWarnings(addDirOption.getWarnings());
@@ -379,14 +361,13 @@ private synchronized int fillPtGTables(PtGChunkDataTO to, int requestQueueID)
addGet.setString(3, to.fromSURL());
logWarnings(addGet.getWarnings());
- // TODO MICHELE USER_SURL set new fields
addGet.setString(4, to.normalizedStFN());
logWarnings(addGet.getWarnings());
addGet.setInt(5, to.surlUniqueID());
logWarnings(addGet.getWarnings());
- log.trace("PTG CHUNK DAO: addNew; " + addGet.toString());
+ log.trace("PTG CHUNK DAO: addNew; {}", addGet.toString());
addGet.execute();
logWarnings(addGet.getWarnings());
@@ -406,12 +387,10 @@ private synchronized int fillPtGTables(PtGChunkDataTO to, int requestQueueID)
addChild.setString(3, to.errString());
logWarnings(addChild.getWarnings());
- log.trace("PTG CHUNK DAO: addNew; " + addChild.toString());
+ log.trace("PTG CHUNK DAO: addNew; {}", addChild.toString());
addChild.execute();
logWarnings(addChild.getWarnings());
- // rs_s = addChild.getGeneratedKeys();
- // return extractID(rs_s);
return id_g;
} finally {
close(rs_do);
@@ -441,7 +420,6 @@ public synchronized void update(PtGChunkDataTO to) {
}
PreparedStatement updateFileReq = null;
try {
- // TODO MICHELE USER_SURL set new fields
// ready updateFileReq...
updateFileReq = con
.prepareStatement("UPDATE request_queue rq JOIN (status_Get sg, request_Get rg) ON (rq.ID=rg.request_queueID AND sg.request_GetID=rg.ID) "
@@ -464,7 +442,6 @@ public synchronized void update(PtGChunkDataTO to) {
updateFileReq.setInt(5, to.lifeTime());
logWarnings(updateFileReq.getWarnings());
- // TODO MICHELE USER_SURL fill new fields
updateFileReq.setString(6, to.normalizedStFN());
logWarnings(updateFileReq.getWarnings());
@@ -474,11 +451,12 @@ public synchronized void update(PtGChunkDataTO to) {
updateFileReq.setLong(8, to.primaryKey());
logWarnings(updateFileReq.getWarnings());
// execute update
- log.trace("PTG CHUNK DAO: update method; " + updateFileReq.toString());
+ log.trace("PTG CHUNK DAO: update method; {}", updateFileReq.toString());
updateFileReq.executeUpdate();
logWarnings(updateFileReq.getWarnings());
} catch (SQLException e) {
- log.error("PtG CHUNK DAO: Unable to complete update! " + e);
+ log.error("PtG CHUNK DAO: Unable to complete update! {}",
+ e.getMessage(), e);
} finally {
close(updateFileReq);
}
@@ -490,7 +468,6 @@ public synchronized void update(PtGChunkDataTO to) {
*
* @param chunkTO
*/
- // TODO MICHELE USER_SURL new method
public synchronized void updateIncomplete(ReducedPtGChunkDataTO chunkTO) {
if (!checkConnection()) {
@@ -514,11 +491,12 @@ public synchronized void updateIncomplete(ReducedPtGChunkDataTO chunkTO) {
stmt.setLong(3, chunkTO.primaryKey());
logWarnings(stmt.getWarnings());
- log.trace("PtG CHUNK DAO - update incomplete: " + stmt.toString());
+ log.trace("PtG CHUNK DAO - update incomplete: {}", stmt.toString());
stmt.executeUpdate();
logWarnings(stmt.getWarnings());
} catch (SQLException e) {
- log.error("PtG CHUNK DAO: Unable to complete update incomplete! " + e);
+ log.error("PtG CHUNK DAO: Unable to complete update incomplete! {}",
+ e.getMessage(), e);
} finally {
close(stmt);
}
@@ -555,14 +533,13 @@ public synchronized PtGChunkDataTO refresh(long primary_key) {
logWarnings(con.getWarnings());
find.setLong(1, primary_key);
logWarnings(find.getWarnings());
- log.trace("PTG CHUNK DAO: refresh status method; " + find.toString());
+ log.trace("PTG CHUNK DAO: refresh status method; {}", find.toString());
rs = find.executeQuery();
logWarnings(find.getWarnings());
PtGChunkDataTO chunkDataTO = null;
// The result shoul be un
- // TODO REMOVE THIS WHILE
while (rs.next()) {
chunkDataTO = new PtGChunkDataTO();
chunkDataTO.setStatus(rs.getInt("sg.statusCode"));
@@ -570,7 +547,7 @@ public synchronized PtGChunkDataTO refresh(long primary_key) {
}
return chunkDataTO;
} catch (SQLException e) {
- log.error("PTG CHUNK DAO: " + e);
+ log.error("PTG CHUNK DAO: {}", e.getMessage(), e);
/* Return null TransferObject! */
return null;
} finally {
@@ -626,7 +603,7 @@ public synchronized Collection find(TRequestToken requestToken)
find.setString(1, strToken);
logWarnings(find.getWarnings());
- log.trace("PTG CHUNK DAO: find method; " + find.toString());
+ log.trace("PTG CHUNK DAO: find method; {}", find.toString());
rs = find.executeQuery();
logWarnings(find.getWarnings());
while (rs.next()) {
@@ -635,7 +612,6 @@ public synchronized Collection find(TRequestToken requestToken)
close(rs);
close(find);
- // TODO MICHELE USER_SURL get new fields
// get chunks of the request
str = "SELECT sg.statusCode, rq.pinLifetime, rg.ID, rq.timeStamp, rq.client_dn, rq.proxy, rg.sourceSURL, "
+ "rg.normalized_sourceSURL_StFN, rg.sourceSURL_uniqueID, d.isSourceADirectory, "
@@ -665,8 +641,6 @@ public synchronized Collection find(TRequestToken requestToken)
chunkDataTO.setRequestToken(strToken);
chunkDataTO.setPrimaryKey(rs.getLong("rg.ID"));
chunkDataTO.setFromSURL(rs.getString("rg.sourceSURL"));
-
- // TODO MICHELE USER_SURL fill new fields
chunkDataTO.setNormalizedStFN(rs
.getString("rg.normalized_sourceSURL_StFN"));
int uniqueID = rs.getInt("rg.sourceSURL_uniqueID");
@@ -698,7 +672,7 @@ public synchronized Collection find(TRequestToken requestToken)
}
return list;
} catch (SQLException e) {
- log.error("PTG CHUNK DAO: " + e);
+ log.error("PTG CHUNK DAO: ", e.getMessage(), e);
/* Return empty Collection! */
return new ArrayList();
} finally {
@@ -722,7 +696,6 @@ public synchronized Collection findReduced(
PreparedStatement find = null;
ResultSet rs = null;
try {
- // TODO MICHELE USER_SURL get new fields
// get reduced chunks
String str = "SELECT sg.statusCode, rg.ID, rg.sourceSURL, rg.normalized_sourceSURL_StFN, rg.sourceSURL_uniqueID "
+ "FROM request_queue rq JOIN (request_Get rg, status_Get sg) "
@@ -735,8 +708,7 @@ public synchronized Collection findReduced(
find.setString(1, reqtoken);
logWarnings(find.getWarnings());
- log.trace("PtG CHUNK DAO! findReduced with request token; "
- + find.toString());
+ log.trace("PtG CHUNK DAO! findReduced with request token; {}", find.toString());
rs = find.executeQuery();
logWarnings(find.getWarnings());
@@ -746,7 +718,6 @@ public synchronized Collection findReduced(
reducedChunkDataTO.setStatus(rs.getInt("sg.statusCode"));
reducedChunkDataTO.setPrimaryKey(rs.getLong("rg.ID"));
reducedChunkDataTO.setFromSURL(rs.getString("rg.sourceSURL"));
- // TODO MICHELE USER_SURL fill new fields
reducedChunkDataTO.setNormalizedStFN(rs
.getString("rg.normalized_sourceSURL_StFN"));
int uniqueID = rs.getInt("rg.sourceSURL_uniqueID");
@@ -758,7 +729,7 @@ public synchronized Collection findReduced(
}
return list;
} catch (SQLException e) {
- log.error("PTG CHUNK DAO: " + e);
+ log.error("PTG CHUNK DAO: {}", e.getMessage(), e);
/* Return empty Collection! */
return new ArrayList();
} finally {
@@ -796,8 +767,7 @@ public synchronized Collection findReduced(
find.setString(1, requestToken.getValue());
logWarnings(find.getWarnings());
- log.trace("PtG CHUNK DAO! findReduced with griduser+surlarray; "
- + find.toString());
+ log.trace("PtG CHUNK DAO! findReduced with griduser+surlarray; {}", find.toString());
rs = find.executeQuery();
logWarnings(find.getWarnings());
@@ -807,7 +777,6 @@ public synchronized Collection findReduced(
chunkDataTO.setStatus(rs.getInt("sg.statusCode"));
chunkDataTO.setPrimaryKey(rs.getLong("rg.ID"));
chunkDataTO.setFromSURL(rs.getString("rg.sourceSURL"));
- // TODO MICHELE USER_SURL fill new fields
chunkDataTO.setNormalizedStFN(rs
.getString("rg.normalized_sourceSURL_StFN"));
int uniqueID = rs.getInt("rg.sourceSURL_uniqueID");
@@ -819,7 +788,7 @@ public synchronized Collection findReduced(
}
return list;
} catch (SQLException e) {
- log.error("PTG CHUNK DAO: " + e);
+ log.error("PTG CHUNK DAO: {}", e.getMessage(), e);
/* Return empty Collection! */
return new ArrayList();
} finally {
@@ -844,10 +813,6 @@ public synchronized Collection findReduced(
PreparedStatement find = null;
ResultSet rs = null;
try {
- // TODO MICHELE USER_SURL get new fields and select on the uniqueID and on
- // the fromSurl
- // TODO MICHELE USER_SURL when the uniqueID and normalized surl will be
- // made on the FrontEnd remove the String[] surls parameter
/*
* NOTE: we search also on the fromSurl because otherwise we lost all
* request_get that have not the uniqueID set because are not yet been
@@ -868,8 +833,7 @@ public synchronized Collection findReduced(
find.setString(1, griduser);
logWarnings(find.getWarnings());
- log.trace("PtG CHUNK DAO! findReduced with griduser+surlarray; "
- + find.toString());
+ log.trace("PtG CHUNK DAO! findReduced with griduser+surlarray; {}", find.toString());
rs = find.executeQuery();
logWarnings(find.getWarnings());
@@ -879,7 +843,6 @@ public synchronized Collection findReduced(
chunkDataTO.setStatus(rs.getInt("sg.statusCode"));
chunkDataTO.setPrimaryKey(rs.getLong("rg.ID"));
chunkDataTO.setFromSURL(rs.getString("rg.sourceSURL"));
- // TODO MICHELE USER_SURL fill new fields
chunkDataTO.setNormalizedStFN(rs
.getString("rg.normalized_sourceSURL_StFN"));
int uniqueID = rs.getInt("rg.sourceSURL_uniqueID");
@@ -891,7 +854,7 @@ public synchronized Collection findReduced(
}
return list;
} catch (SQLException e) {
- log.error("PTG CHUNK DAO: " + e);
+ log.error("PTG CHUNK DAO: {}", e.getMessage(), e);
/* Return empty Collection! */
return new ArrayList();
} finally {
@@ -935,13 +898,12 @@ public synchronized void signalMalformedPtGChunk(PtGChunkDataTO auxTO) {
signal.setString(1, "Request is malformed!");
logWarnings(signal.getWarnings());
- log.trace("PTG CHUNK DAO: signalMalformed; " + signal.toString());
+ log.trace("PTG CHUNK DAO: signalMalformed; {}", signal.toString());
signal.executeUpdate();
logWarnings(signal.getWarnings());
} catch (SQLException e) {
- log.error("PtGChunkDAO! Unable to signal in DB that the"
- + " request was malformed! Request: " + auxTO.toString()
- + "; Exception: " + e.toString());
+ log.error("PtGChunkDAO! Unable to signal in DB that the request was "
+ + "malformed! Request: {}; Exception: {}", auxTO.toString(), e.toString());
} finally {
close(signal);
}
@@ -956,7 +918,6 @@ public synchronized void signalMalformedPtGChunk(PtGChunkDataTO auxTO) {
*
* In case of any error, 0 is returned.
*/
- // TODO MICHELE USER_SURL use the unique ID to perform the select on the
// request_Get table
public synchronized int numberInSRM_FILE_PINNED(int surlUniqueID) {
@@ -982,8 +943,7 @@ public synchronized int numberInSRM_FILE_PINNED(int surlUniqueID) {
StatusCodeConverter.getInstance().toDB(TStatusCode.SRM_FILE_PINNED));
logWarnings(find.getWarnings());
- log.trace("PtG CHUNK DAO - numberInSRM_FILE_PINNED method: "
- + find.toString());
+ log.trace("PtG CHUNK DAO - numberInSRM_FILE_PINNED method: {}", find.toString());
rs = find.executeQuery();
logWarnings(find.getWarnings());
@@ -993,9 +953,8 @@ public synchronized int numberInSRM_FILE_PINNED(int surlUniqueID) {
}
return numberFilePinned;
} catch (SQLException e) {
- log
- .error("PtG CHUNK DAO! Unable to determine numberInSRM_FILE_PINNED! Returning 0! "
- + e);
+ log.error("PtG CHUNK DAO! Unable to determine numberInSRM_FILE_PINNED! "
+ + "Returning 0! {}", e.getMessage(), e);
return 0;
} finally {
close(rs);
@@ -1013,8 +972,6 @@ public synchronized int numberInSRM_FILE_PINNED(int surlUniqueID) {
*/
public synchronized List transitExpiredSRM_FILE_PINNED() {
- // TODO: put a limit on the queries.....
- // TODO MICHELE USER_SURL moved the checks for surl requests from the surl
// tring to the surl unique ID
if (!checkConnection()) {
log
@@ -1052,8 +1009,8 @@ public synchronized List transitExpiredSRM_FILE_PINNED() {
TSURL tsurl = TSURL.makeFromStringWellFormed(sourceSURL);
uniqueID = tsurl.uniqueId();
} catch (InvalidTSURLAttributesException e) {
- log.warn("PtGChunkDAO! unable to build the TSURL from "
- + sourceSURL + " : InvalidTSURLAttributesException " + e);
+ log.warn("PtGChunkDAO! unable to build the TSURL from {}: "
+ + "InvalidTSURLAttributesException {}", sourceSURL, e.getMessage(), e);
}
}
expiredSurlMap.put(sourceSURL, uniqueID);
@@ -1066,7 +1023,7 @@ public synchronized List transitExpiredSRM_FILE_PINNED() {
return new ArrayList();
}
} catch (SQLException e) {
- log.error("PtGChunkDAO! SQLException." + e);
+ log.error("PtGChunkDAO! SQLException. {}", e.getMessage(), e);
rollback(con);
return new ArrayList();
} finally {
@@ -1094,8 +1051,8 @@ public synchronized List transitExpiredSRM_FILE_PINNED() {
StatusCodeConverter.getInstance().toDB(TStatusCode.SRM_FILE_PINNED));
logWarnings(preparedStatement.getWarnings());
- log.trace("PtG CHUNK DAO - transitExpiredSRM_FILE_PINNED method: "
- + preparedStatement.toString());
+ log.trace("PtG CHUNK DAO - transitExpiredSRM_FILE_PINNED method: {}",
+ preparedStatement.toString());
int count = preparedStatement.executeUpdate();
logWarnings(preparedStatement.getWarnings());
@@ -1104,14 +1061,12 @@ public synchronized List transitExpiredSRM_FILE_PINNED() {
log.trace("PtGChunkDAO! No chunk of PtG request was "
+ "transited from SRM_FILE_PINNED to SRM_RELEASED.");
} else {
- log.info("PtGChunkDAO! " + count
- + " chunks of PtG requests were transited from"
- + " SRM_FILE_PINNED to SRM_RELEASED.");
+ log.info("PtGChunkDAO! {} chunks of PtG requests were transited from"
+ + " SRM_FILE_PINNED to SRM_RELEASED.", count);
}
} catch (SQLException e) {
- log
- .error("PtGChunkDAO! Unable to transit expired SRM_FILE_PINNED chunks of PtG requests, to SRM_RELEASED! "
- + e);
+ log.error("PtGChunkDAO! Unable to transit expired SRM_FILE_PINNED chunks "
+ + "of PtG requests, to SRM_RELEASED! {}", e.getMessage(), e);
rollback(con);
return new ArrayList();
} finally {
@@ -1151,8 +1106,8 @@ public synchronized List transitExpiredSRM_FILE_PINNED() {
TSURL tsurl = TSURL.makeFromStringWellFormed(sourceSURL);
uniqueID = tsurl.uniqueId();
} catch (InvalidTSURLAttributesException e) {
- log.warn("PtGChunkDAO! unable to build the TSURL from "
- + sourceSURL + " : InvalidTSURLAttributesException " + e);
+ log.warn("PtGChunkDAO! unable to build the TSURL from {}. "
+ + "InvalidTSURLAttributesException: {}", sourceSURL, e.getMessage());
}
}
pinnedSurlSet.add(uniqueID);
@@ -1161,21 +1116,11 @@ public synchronized List transitExpiredSRM_FILE_PINNED() {
close(preparedStatement);
// SURLs pinned by BoLs
- // TODO MICHELE USER_SURL uncomment this line when the development goes on
- // the BoL operation
str = "SELECT rb.sourceSURL , rb.sourceSURL_uniqueID FROM "
+ "request_BoL rb JOIN (status_BoL sb, request_queue rq) ON sb.request_BoLID=rb.ID AND rb.request_queueID=rq.ID "
+ "WHERE sb.statusCode=?"
+ " AND UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(rq.timeStamp) < rq.pinLifetime ";
- // str = "SELECT sourceSURL FROM "
- // +
- // "request_BoL rb JOIN (status_BoL s, request_queue r) ON s.request_BoLID=rb.ID AND rb.request_queueID=r.ID "
- // + "WHERE s.statusCode="
- // + StatusCodeConverter.getInstance().toDB(TStatusCode.SRM_SUCCESS)
- // +
- // " AND UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(r.timeStamp) < r.pinLifetime ";
-
preparedStatement = con.prepareStatement(str);
preparedStatement.setInt(1,
StatusCodeConverter.getInstance().toDB(TStatusCode.SRM_SUCCESS));
@@ -1184,8 +1129,6 @@ public synchronized List transitExpiredSRM_FILE_PINNED() {
logWarnings(preparedStatement.getWarnings());
while (res.next()) {
- // TODO MICHELE USER_SURL uncomment this line when the development goes
- // on the BoL operation
String sourceSURL = res.getString("rb.sourceSURL");
Integer uniqueID = new Integer(res.getInt("rb.sourceSURL_uniqueID"));
/* If the uniqueID is not setted compute it */
@@ -1194,15 +1137,15 @@ public synchronized List transitExpiredSRM_FILE_PINNED() {
TSURL tsurl = TSURL.makeFromStringWellFormed(sourceSURL);
uniqueID = tsurl.uniqueId();
} catch (InvalidTSURLAttributesException e) {
- log.warn("PtGChunkDAO! unable to build the TSURL from "
- + sourceSURL + " : InvalidTSURLAttributesException " + e);
+ log.warn("PtGChunkDAO! unable to build the TSURL from {}. "
+ + "InvalidTSURLAttributesException: {}", sourceSURL, e.getMessage(), e);
}
}
pinnedSurlSet.add(uniqueID);
}
commit(con);
} catch (SQLException e) {
- log.error("PtGChunkDAO! SQLException." + e);
+ log.error("PtGChunkDAO! SQLException. {}", e.getMessage(), e);
rollback(con);
} finally {
close(preparedStatement);
@@ -1216,9 +1159,8 @@ public synchronized List transitExpiredSRM_FILE_PINNED() {
try {
surl = TSURL.makeFromStringValidate(surlEntry.getKey());
} catch (InvalidTSURLAttributesException e) {
- log
- .error("Invalid SURL, cannot release the pin (Extended Attribute): "
- + surlEntry.getKey());
+ log.error("Invalid SURL, cannot release the pin "
+ + "(Extended Attribute): {}", surlEntry.getKey());
continue;
}
expiredSurlList.add(surl);
@@ -1226,11 +1168,8 @@ public synchronized List transitExpiredSRM_FILE_PINNED() {
try {
stori = NamespaceDirector.getNamespace().resolveStoRIbySURL(surl);
} catch (Throwable e) {
- log
- .error(String.format(
- "Invalid SURL %s cannot release the pin. %s: %s",
- surlEntry.getKey(), e.getClass().getCanonicalName(),
- e.getMessage()));
+ log.error("Invalid SURL {} cannot release the pin. {}: {}",
+ surlEntry.getKey(), e.getClass().getCanonicalName(), e.getMessage(), e);
continue;
}
@@ -1260,13 +1199,7 @@ public synchronized void transitSRM_FILE_PINNEDtoSRM_RELEASED(long[] ids) {
.error("PTG CHUNK DAO: transitSRM_FILE_PINNEDtoSRM_RELEASED - unable to get a valid connection!");
return;
}
- String str =
- // "UPDATE "
- // +
- // "status_Get s JOIN (request_Get rg, request_queue r) ON s.request_GetID=rg.ID AND rg.request_queueID=r.ID "
- // + "SET s.statusCode=? " + "WHERE s.statusCode=? AND s.ID IN "
- // + makeWhereString(ids);
- "UPDATE " + "status_Get sg " + "SET sg.statusCode=? "
+ String str = "UPDATE status_Get sg SET sg.statusCode=? "
+ "WHERE sg.statusCode=? AND sg.request_GetID IN " + makeWhereString(ids);
PreparedStatement stmt = null;
try {
@@ -1280,21 +1213,20 @@ public synchronized void transitSRM_FILE_PINNEDtoSRM_RELEASED(long[] ids) {
StatusCodeConverter.getInstance().toDB(TStatusCode.SRM_FILE_PINNED));
logWarnings(stmt.getWarnings());
- log.trace("PtG CHUNK DAO - transitSRM_FILE_PINNEDtoSRM_RELEASED: "
- + stmt.toString());
+ log.trace("PtG CHUNK DAO - transitSRM_FILE_PINNEDtoSRM_RELEASED: {}",
+ stmt.toString());
int count = stmt.executeUpdate();
logWarnings(stmt.getWarnings());
if (count == 0) {
log.trace("PtG CHUNK DAO! No chunk of PtG request was "
+ "transited from SRM_FILE_PINNED to SRM_RELEASED.");
} else {
- log.info("PtG CHUNK DAO! " + count
- + " chunks of PtG requests were transited "
- + "from SRM_FILE_PINNED to SRM_RELEASED.");
+ log.info("PtG CHUNK DAO! {} chunks of PtG requests were transited "
+ + "from SRM_FILE_PINNED to SRM_RELEASED.", count);
}
} catch (SQLException e) {
log.error("PtG CHUNK DAO! Unable to transit chunks"
- + " from SRM_FILE_PINNED to SRM_RELEASED! " + e);
+ + " from SRM_FILE_PINNED to SRM_RELEASED! {}", e.getMessage(), e);
} finally {
close(stmt);
}
@@ -1309,51 +1241,49 @@ public synchronized void transitSRM_FILE_PINNEDtoSRM_RELEASED(long[] ids,
if (token == null) {
transitSRM_FILE_PINNEDtoSRM_RELEASED(ids);
- } else {
- /*
- * If a request token has been specified, only the related Get requests
- * have to be released. This is done adding the r.r_token="..." clause in
- * the where subquery.
- */
- if (!checkConnection()) {
- log
- .error("PTG CHUNK DAO: transitSRM_FILE_PINNEDtoSRM_RELEASED - unable to get a valid connection!");
- return;
- }
- String str = "UPDATE "
- + "status_Get sg JOIN (request_Get rg, request_queue rq) ON sg.request_GetID=rg.ID AND rg.request_queueID=rq.ID "
- + "SET sg.statusCode=? " + "WHERE sg.statusCode=? AND rq.r_token='"
- + token.toString() + "' AND rg.ID IN " + makeWhereString(ids);
- PreparedStatement stmt = null;
- try {
- stmt = con.prepareStatement(str);
- logWarnings(con.getWarnings());
- stmt.setInt(1,
- StatusCodeConverter.getInstance().toDB(TStatusCode.SRM_RELEASED));
- logWarnings(stmt.getWarnings());
-
- stmt.setInt(2,
- StatusCodeConverter.getInstance().toDB(TStatusCode.SRM_FILE_PINNED));
- logWarnings(stmt.getWarnings());
-
- log.trace("PtG CHUNK DAO - transitSRM_FILE_PINNEDtoSRM_RELEASED: "
- + stmt.toString());
- int count = stmt.executeUpdate();
- logWarnings(stmt.getWarnings());
- if (count == 0) {
- log.trace("PtG CHUNK DAO! No chunk of PtG request was"
- + " transited from SRM_FILE_PINNED to SRM_RELEASED.");
- } else {
- log.info("PtG CHUNK DAO! " + count
- + " chunks of PtG requests were transited from "
- + "SRM_FILE_PINNED to SRM_RELEASED.");
- }
- } catch (SQLException e) {
- log.error("PtG CHUNK DAO! Unable to transit chunks from "
- + "SRM_FILE_PINNED to SRM_RELEASED! " + e);
- } finally {
- close(stmt);
+ return;
+ }
+
+ /*
+ * If a request token has been specified, only the related Get requests
+ * have to be released. This is done adding the r.r_token="..." clause in
+ * the where subquery.
+ */
+ if (!checkConnection()) {
+ log.error("PTG CHUNK DAO: transitSRM_FILE_PINNEDtoSRM_RELEASED - "
+ + "unable to get a valid connection!");
+ return;
+ }
+
+ String str = "UPDATE "
+ + "status_Get sg JOIN (request_Get rg, request_queue rq) ON sg.request_GetID=rg.ID AND rg.request_queueID=rq.ID "
+ + "SET sg.statusCode=? " + "WHERE sg.statusCode=? AND rq.r_token='"
+ + token.toString() + "' AND rg.ID IN " + makeWhereString(ids);
+ PreparedStatement stmt = null;
+ try {
+ stmt = con.prepareStatement(str);
+ logWarnings(con.getWarnings());
+ stmt.setInt(1,StatusCodeConverter.getInstance().toDB(TStatusCode.SRM_RELEASED));
+ logWarnings(stmt.getWarnings());
+
+ stmt.setInt(2,StatusCodeConverter.getInstance().toDB(TStatusCode.SRM_FILE_PINNED));
+ logWarnings(stmt.getWarnings());
+
+ log.trace("PtG CHUNK DAO - transitSRM_FILE_PINNEDtoSRM_RELEASED: {}", stmt.toString());
+ int count = stmt.executeUpdate();
+ logWarnings(stmt.getWarnings());
+ if (count == 0) {
+ log.trace("PtG CHUNK DAO! No chunk of PtG request was"
+ + " transited from SRM_FILE_PINNED to SRM_RELEASED.");
+ } else {
+ log.info("PtG CHUNK DAO! {} chunks of PtG requests were transited from "
+ + "SRM_FILE_PINNED to SRM_RELEASED.", count);
}
+ } catch (SQLException e) {
+ log.error("PtG CHUNK DAO! Unable to transit chunks from "
+ + "SRM_FILE_PINNED to SRM_RELEASED! {}", e.getMessage(), e);
+ } finally {
+ close(stmt);
}
}
@@ -1382,18 +1312,19 @@ public synchronized void updateStatus(TRequestToken requestToken,
stmt.setString(2, (explanation != null ? explanation : ""));
logWarnings(stmt.getWarnings());
- log.trace("PtG CHUNK DAO - updateStatus: " + stmt.toString());
+ log.trace("PtG CHUNK DAO - updateStatus: {}", stmt.toString());
int count = stmt.executeUpdate();
logWarnings(stmt.getWarnings());
if (count == 0) {
- log.trace("PtG CHUNK DAO! No chunk of PtG request was" + " updated to "
- + statusCode + ".");
+ log.trace("PtG CHUNK DAO! No chunk of PtG request was updated to {}.",
+ statusCode);
} else {
- log.info("PtG CHUNK DAO! " + count
- + " chunks of PtG requests were updated to " + statusCode + ".");
+ log.info("PtG CHUNK DAO! {} chunks of PtG requests were updated to {}.",
+ count, statusCode);
}
} catch (SQLException e) {
- log.error("PtG CHUNK DAO! Unable to updated to " + statusCode + " !" + e);
+ log.error("PtG CHUNK DAO! Unable to updated to {}! {}", statusCode,
+ e.getMessage(), e);
} finally {
close(stmt);
}
@@ -1496,22 +1427,19 @@ public synchronized void doUpdateStatusOnMatchingStatus(
.setInt(2, StatusCodeConverter.getInstance().toDB(expectedStatusCode));
logWarnings(stmt.getWarnings());
- log.trace("PtG CHUNK DAO - updateStatusOnMatchingStatus: "
- + stmt.toString());
+ log.trace("PtG CHUNK DAO - updateStatusOnMatchingStatus: {}", stmt.toString());
int count = stmt.executeUpdate();
logWarnings(stmt.getWarnings());
if (count == 0) {
- log.trace("PtG CHUNK DAO! No chunk of PtG request was"
- + " updated from " + expectedStatusCode + " to " + newStatusCode
- + ".");
+ log.trace("PtG CHUNK DAO! No chunk of PtG request was updated "
+ + "from {} to {}.", expectedStatusCode, newStatusCode);
} else {
- log.debug("PtG CHUNK DAO! " + count
- + " chunks of PtG requests were updated from " + expectedStatusCode
- + " to " + newStatusCode + ".");
+ log.debug("PtG CHUNK DAO! {} chunks of PtG requests were updated "
+ + "from {} to {}.", count, expectedStatusCode, newStatusCode);
}
} catch (SQLException e) {
- log.error("PtG CHUNK DAO! Unable to updated from " + expectedStatusCode
- + " to " + newStatusCode + " !" + e);
+ log.error("PtG CHUNK DAO! Unable to updated from {} to {}! {}",
+ expectedStatusCode, newStatusCode, e.getMessage(), e);
} finally {
close(stmt);
}
@@ -1526,7 +1454,8 @@ private void close(ResultSet rset) {
try {
rset.close();
} catch (Exception e) {
- log.error("PTG CHUNK DAO! Unable to close ResultSet! Exception: " + e);
+ log.error("PTG CHUNK DAO! Unable to close ResultSet! Error: {}",
+ e.getMessage(), e);
}
}
}
@@ -1540,8 +1469,8 @@ private void close(Statement stmt) {
try {
stmt.close();
} catch (Exception e) {
- log.error("PTG CHUNK DAO! Unable to close Statement " + stmt.toString()
- + " - Exception: " + e);
+ log.error("PTG CHUNK DAO! Unable to close Statement {} - Error: {}",
+ stmt.toString(), e.getMessage(), e);
}
}
}
@@ -1553,7 +1482,7 @@ private void commit(Connection con) {
con.commit();
con.setAutoCommit(true);
} catch (SQLException e) {
- log.error("PtG, SQL EXception", e);
+ log.error("PtG, SQL Exception: {}", e.getMessage(), e);
}
}
}
@@ -1569,7 +1498,7 @@ private void rollback(Connection con) {
con.setAutoCommit(true);
log.error("PTG CHUNK DAO: roll back successful!");
} catch (SQLException e2) {
- log.error("PTG CHUNK DAO: roll back failed! " + e2);
+ log.error("PTG CHUNK DAO: roll back failed! {}", e2.getMessage(), e2);
}
}
}
@@ -1599,9 +1528,9 @@ private int extractID(ResultSet rs) throws Exception {
private void logWarnings(SQLWarning w) {
if (w != null) {
- log.debug("PTG CHUNK DAO: " + w.toString());
+ log.debug("PTG CHUNK DAO: {}", w.toString());
while ((w = w.getNextWarning()) != null) {
- log.debug("PTG CHUNK DAO: " + w.toString());
+ log.debug("PTG CHUNK DAO: {}", w.toString());
}
}
}
@@ -1655,7 +1584,7 @@ private String makeSurlString(String[] surls) {
requestedSURL = SURL.makeSURLfromString(surls[i]);
} catch (NamespaceException e) {
log.error(e.getMessage());
- log.debug("Skip '" + surls[i] + "' during query creation");
+ log.debug("Skip '{}' during query creation", surls[i]);
continue;
}
@@ -1692,9 +1621,11 @@ private boolean setUpConnection() {
response = con.isValid(0);
}
} catch (ClassNotFoundException e) {
- log.error("PTG CHUNK DAO! Exception in setUpConnection! " + e);
+ log.error("PTG CHUNK DAO! Exception in setUpConnection! {}",
+ e.getMessage(), e);
} catch (SQLException e) {
- log.error("PTG CHUNK DAO! Exception in setUpConenction! " + e);
+ log.error("PTG CHUNK DAO! Exception in setUpConenction! {}",
+ e.getMessage(), e);
}
return response;
}
@@ -1726,8 +1657,8 @@ private void takeDownConnection() {
try {
con.close();
} catch (SQLException e) {
- log
- .error("PTG CHUNK DAO! Exception in takeDownConnection method: " + e);
+ log.error("PTG CHUNK DAO! Exception in takeDownConnection method: {}",
+ e.getMessage(), e);
}
}
}
@@ -1797,7 +1728,7 @@ private synchronized Collection find(int[] surlsUniqueIDs,
List list = new ArrayList();
- log.trace("PTG CHUNK DAO - find method: " + find.toString());
+ log.trace("PTG CHUNK DAO - find method: {}", find.toString());
rs = find.executeQuery();
logWarnings(find.getWarnings());
PtGChunkDataTO chunkDataTO = null;
@@ -1809,7 +1740,6 @@ private synchronized Collection find(int[] surlsUniqueIDs,
chunkDataTO.setPrimaryKey(rs.getLong("rg.ID"));
chunkDataTO.setFromSURL(rs.getString("rg.sourceSURL"));
- // TODO MICHELE USER_SURL fill new fields
chunkDataTO.setNormalizedStFN(rs
.getString("rg.normalized_sourceSURL_StFN"));
int uniqueID = rs.getInt("rg.sourceSURL_uniqueID");
@@ -1841,7 +1771,7 @@ private synchronized Collection find(int[] surlsUniqueIDs,
}
return list;
} catch (SQLException e) {
- log.error("PTG CHUNK DAO: " + e);
+ log.error("PTG CHUNK DAO: {}", e.getMessage(), e);
/* return empty Collection! */
return new ArrayList();
} finally {
diff --git a/src/main/java/it/grid/storm/catalogs/PtGChunkDataTO.java b/src/main/java/it/grid/storm/catalogs/PtGChunkDataTO.java
index 245c0b65..86329cf3 100644
--- a/src/main/java/it/grid/storm/catalogs/PtGChunkDataTO.java
+++ b/src/main/java/it/grid/storm/catalogs/PtGChunkDataTO.java
@@ -43,7 +43,6 @@ public class PtGChunkDataTO {
private long primaryKey = -1; // ID primary key of record in DB
private boolean dirOption; // initialised in constructor
private String fromSURL = " ";
- // TODO MICHELE USER_SURL added new fields
private String normalizedStFN = null;
private Integer surlUniqueID = null;
/* Database table request_Get fields END */
@@ -68,7 +67,6 @@ public PtGChunkDataTO() {
this.protocolList = TransferProtocolListConverter.toDB(protocolPreferences);
this.status = StatusCodeConverter.getInstance().toDB(
TStatusCode.SRM_REQUEST_QUEUED);
- // TODO MICHELE why? this field is from the DB like the fromSURL...
this.dirOption = false;
//
this.allLevelRecursive = false;
diff --git a/src/main/java/it/grid/storm/catalogs/PtGPersistentChunkData.java b/src/main/java/it/grid/storm/catalogs/PtGPersistentChunkData.java
index 90b3c6b0..a363e36c 100644
--- a/src/main/java/it/grid/storm/catalogs/PtGPersistentChunkData.java
+++ b/src/main/java/it/grid/storm/catalogs/PtGPersistentChunkData.java
@@ -85,6 +85,7 @@ public PtGPersistentChunkData(GridUserInterface auth,
super(auth, fromSURL, lifeTime, dirOption, desiredProtocols, fileSize,
status, transferURL);
if (requestToken == null) {
+ log.debug("PtGPersistentChunkData: requestToken is null!");
throw new InvalidPtGPersistentChunkDataAttributesException(requestToken,
fromSURL, lifeTime, dirOption, desiredProtocols, fileSize, status,
transferURL);
@@ -130,12 +131,6 @@ public void changeStatusSRM_FILE_PINNED(String explanation) {
setStatus(TStatusCode.SRM_FILE_PINNED, explanation);
}
- @Override
- protected Logger getLog() {
-
- return PtGPersistentChunkData.log;
- }
-
/*
* (non-Javadoc)
*
diff --git a/src/main/java/it/grid/storm/catalogs/PtPChunkCatalog.java b/src/main/java/it/grid/storm/catalogs/PtPChunkCatalog.java
index a5b61433..1d9cfa4a 100644
--- a/src/main/java/it/grid/storm/catalogs/PtPChunkCatalog.java
+++ b/src/main/java/it/grid/storm/catalogs/PtPChunkCatalog.java
@@ -109,10 +109,9 @@ public void run() {
.toArray(new Long[ids.size()]));
if (reduced.isEmpty()) {
- log
- .error("ATTENTION in PtP CHUNK CATALOG! Attempt to handle physical files for transited expired entries failed! "
- + "No data could be translated from persitence for PtP Chunks with ID "
- + ids);
+ log.error("ATTENTION in PtP CHUNK CATALOG! Attempt to handle physical "
+ + "files for transited expired entries failed! No data could be "
+ + "translated from persitence for PtP Chunks with ID {}", ids);
}
ArrayList surls = new ArrayList(reduced.size());
for (ReducedPtPChunkData data : reduced) {
@@ -164,9 +163,6 @@ synchronized public void update(PtPPersistentChunkData chunkData) {
}
dao.update(to);
- // TODO MICHELE SURL STORE
- // SurlStatusStore.getInstance().storeSurlStatus(cd.getSURL(),
- // cd.getStatus().getStatusCode());
}
/**
@@ -179,19 +175,14 @@ synchronized public PtPPersistentChunkData refreshStatus(
PtPPersistentChunkData inputChunk) {
PtPChunkDataTO auxTO = dao.refresh(inputChunk.getPrimaryKey());
- log.debug("PtP CHUNK CATALOG refreshStatus: retrieved data " + auxTO);
+ log.debug("PtP CHUNK CATALOG refreshStatus: retrieved data {}", auxTO);
if (auxTO == null) {
- log
- .warn("PtP CHUNK CATALOG! Empty TO found in persistence for specified request: "
- + inputChunk.getPrimaryKey());
+ log.warn("PtP CHUNK CATALOG! Empty TO found in persistence for specified "
+ + "request: {}", inputChunk.getPrimaryKey());
return null;
- } else {
- PtPPersistentChunkData data = makeOne(auxTO, inputChunk.getRequestToken());
- // TODO MICHELE SURL STORE
- // SurlStatusStore.getInstance().storeSurlStatus(data.getSURL(),
- // data.getStatus().getStatusCode());
- return data;
}
+ PtPPersistentChunkData data = makeOne(auxTO, inputChunk.getRequestToken());
+ return data;
}
/**
@@ -211,7 +202,7 @@ synchronized public Collection lookup(
final TRequestToken rt) {
Collection chunkTOs = dao.find(rt);
- log.debug("PtPChunkCatalog: retrieved data " + chunkTOs);
+ log.debug("PtPChunkCatalog: retrieved data {}", chunkTOs);
return buildChunkDataList(chunkTOs);
}
@@ -245,8 +236,8 @@ private PtPPersistentChunkData makeOne(PtPChunkDataTO auxTO, TRequestToken rt) {
// Check for max value allowed
long max = Configuration.getInstance().getPinLifetimeMaximum();
if (pinLifeTime > max) {
- log.warn("PinLifeTime is greater than the max value "
- + "allowed. Drop the value to the max = " + max + " seconds");
+ log.warn("PinLifeTime is greater than the max value allowed. Drop the "
+ + "value to the max = {} seconds", max);
pinLifeTime = max;
}
pinLifetime = TLifeTimeInSeconds.make(pinLifeTime, TimeUnit.SECONDS);
@@ -367,9 +358,8 @@ private PtPPersistentChunkData makeOne(PtPChunkDataTO auxTO, TRequestToken rt) {
}
} catch (IllegalArgumentException e) {
- log
- .error("Unexpected error on voms grid user creation. Contact StoRM Support : IllegalArgumentException "
- + e.getMessage());
+ log.error("Unexpected error on voms grid user creation. "
+ + "IllegalArgumentException: {}", e.getMessage(), e);
}
// transferURL
@@ -389,25 +379,25 @@ private PtPPersistentChunkData makeOne(PtPChunkDataTO auxTO, TRequestToken rt) {
} catch (InvalidPtPPersistentChunkDataAttributesException e) {
dao.signalMalformedPtPChunk(auxTO);
log.warn("PtP CHUNK CATALOG! Retrieved malformed PtP chunk data"
- + " from persistence. Dropping chunk from request: " + rt);
+ + " from persistence. Dropping chunk from request: {}", rt);
log.warn(e.getMessage(), e);
log.warn(errorSb.toString());
} catch (InvalidPtPDataAttributesException e) {
dao.signalMalformedPtPChunk(auxTO);
log.warn("PtP CHUNK CATALOG! Retrieved malformed PtP chunk data"
- + " from persistence. Dropping chunk from request: " + rt);
+ + " from persistence. Dropping chunk from request: {}", rt);
log.warn(e.getMessage(), e);
log.warn(errorSb.toString());
} catch (InvalidFileTransferDataAttributesException e) {
dao.signalMalformedPtPChunk(auxTO);
log.warn("PtP CHUNK CATALOG! Retrieved malformed PtP chunk data"
- + " from persistence. Dropping chunk from request: " + rt);
+ + " from persistence. Dropping chunk from request: {}", rt);
log.warn(e.getMessage(), e);
log.warn(errorSb.toString());
} catch (InvalidSurlRequestDataAttributesException e) {
dao.signalMalformedPtPChunk(auxTO);
log.warn("PtP CHUNK CATALOG! Retrieved malformed PtP chunk data"
- + " from persistence. Dropping chunk from request: " + rt);
+ + " from persistence. Dropping chunk from request: {}", rt);
log.warn(e.getMessage(), e);
log.warn(errorSb.toString());
}
@@ -526,36 +516,6 @@ synchronized public Collection lookupReducedPtPChunkData(
TRequestToken rt) {
return lookupReducedPtPChunkData(rt, new ArrayList(0));
- // Collection reducedChunkDataTOs =
- // dao.findReduced(rt.getValue(), null);
- // log.debug("PtP CHUNK CATALOG: retrieved data " + reducedChunkDataTOs);
- // ArrayList list = new
- // ArrayList();
- // if(reducedChunkDataTOs.isEmpty())
- // {
- // log.debug("PtP CHUNK CATALOG! No chunks found in persistence for " + rt);
- // }
- // else
- // {
- // ReducedPtPChunkData reducedChunkData;
- // for(ReducedPtPChunkDataTO reducedChunkDataTO : reducedChunkDataTOs)
- // {
- // reducedChunkData = makeOneReduced(reducedChunkDataTO);
- // if(reducedChunkData != null)
- // {
- // list.add(reducedChunkData);
- // SurlStatusStore.getInstance().storeSurlStatus(reducedChunkData.toSURL(),
- // reducedChunkData.status().getStatusCode());
- // if(!this.isComplete(reducedChunkDataTO))
- // {
- // this.completeTO(reducedChunkDataTO, reducedChunkData);
- // dao.updateIncomplete(reducedChunkDataTO);
- // }
- // }
- // }
- // log.debug("PtP CHUNK CATALOG: returning " + list);
- // }
- // return list;
}
public Collection lookupReducedPtPChunkData(
@@ -563,38 +523,8 @@ public Collection lookupReducedPtPChunkData(
Collection reducedChunkDataTOs = dao.findReduced(
requestToken.getValue(), surls);
- log.debug("PtP CHUNK CATALOG: retrieved data " + reducedChunkDataTOs);
+ log.debug("PtP CHUNK CATALOG: retrieved data {}", reducedChunkDataTOs);
return buildReducedChunkDataList(reducedChunkDataTOs);
- // ArrayList list = new
- // ArrayList();
- // if (reducedChunkDataTOs.isEmpty())
- // {
- // log.debug("PtP CHUNK CATALOG! No chunks found in persistence for " +
- // requestToken);
- // }
- // else
- // {
- // ReducedPtPChunkData reducedChunkData;
- // for (ReducedPtPChunkDataTO reducedChunkDataTO : reducedChunkDataTOs)
- // {
- // reducedChunkData = makeOneReduced(reducedChunkDataTO);
- // if (reducedChunkData != null)
- // {
- // list.add(reducedChunkData);
- // // TODO MICHELE SURL STORE
- // //
- // SurlStatusStore.getInstance().storeSurlStatus(reducedChunkData.toSURL(),
- // // reducedChunkData.status().getStatusCode());
- // if (!this.isComplete(reducedChunkDataTO))
- // {
- // this.completeTO(reducedChunkDataTO, reducedChunkData);
- // dao.updateIncomplete(reducedChunkDataTO);
- // }
- // }
- // }
- // log.debug("PtP CHUNK CATALOG: returning " + list);
- // }
- // return list;
}
public Collection lookupPtPChunkData(TSURL surl) {
@@ -622,7 +552,7 @@ private Collection lookupPtPChunkData(
}
Collection chunkDataTOs = dao.find(surlsUniqueIDs,
surlsArray, user.getDn());
- log.debug("PtP CHUNK CATALOG: retrieved data " + chunkDataTOs);
+ log.debug("PtP CHUNK CATALOG: retrieved data {}", chunkDataTOs);
return buildChunkDataList(chunkDataTOs);
}
@@ -638,7 +568,7 @@ public Collection lookupPtPChunkData(List surls)
}
Collection chunkDataTOs = dao.find(surlsUniqueIDs,
surlsArray);
- log.debug("PtP CHUNK CATALOG: retrieved data " + chunkDataTOs);
+ log.debug("PtP CHUNK CATALOG: retrieved data {}", chunkDataTOs);
return buildChunkDataList(chunkDataTOs);
}
@@ -649,23 +579,21 @@ private Collection buildChunkDataList(
PtPPersistentChunkData chunk;
for (PtPChunkDataTO chunkTO : chunkDataTOs) {
chunk = makeOne(chunkTO);
- if (chunk != null) {
- list.add(chunk);
- // TODO MICHELE SURL STORE
- // SurlStatusStore.getInstance().storeSurlStatus(chunk.getSURL(),
- // chunk.getStatus().getStatusCode());
- if (!this.isComplete(chunkTO)) {
- try {
- dao.updateIncomplete(this.completeTO(chunkTO, chunk));
- } catch (InvalidReducedPtPChunkDataAttributesException e) {
- log
- .warn("PtG CHUNK CATALOG! unable to add missing informations on DB to the request: "
- + e);
- }
- }
+ if (chunk == null) {
+ continue;
+ }
+ list.add(chunk);
+ if (isComplete(chunkTO)) {
+ continue;
+ }
+ try {
+ dao.updateIncomplete(completeTO(chunkTO, chunk));
+ } catch (InvalidReducedPtPChunkDataAttributesException e) {
+ log.warn("PtG CHUNK CATALOG! unable to add missing informations on "
+ + "DB to the request: {}", e.getMessage());
}
}
- log.debug("PtPChunkCatalog: returning " + list + "\n\n");
+ log.debug("PtPChunkCatalog: returning {}\n\n", list);
return list;
}
@@ -690,16 +618,13 @@ private Collection buildReducedChunkDataList(
reducedChunkData = makeOneReduced(reducedChunkDataTO);
if (reducedChunkData != null) {
list.add(reducedChunkData);
- // TODO MICHELE SURL STORE
- // SurlStatusStore.getInstance().storeSurlStatus(reducedChunkData.toSURL(),
- // reducedChunkData.status().getStatusCode());
if (!this.isComplete(reducedChunkDataTO)) {
this.completeTO(reducedChunkDataTO, reducedChunkData);
dao.updateIncomplete(reducedChunkDataTO);
}
}
}
- log.debug("PtP CHUNK CATALOG: returning " + list);
+ log.debug("PtP CHUNK CATALOG: returning {}", list);
return list;
}
@@ -719,37 +644,8 @@ synchronized public Collection lookupReducedPtPChunkData(
Collection reducedChunkDataTOs = dao
.findReduced(Arrays.asList(volids));
- log.debug("PtP CHUNK CATALOG: fetched data " + reducedChunkDataTOs);
+ log.debug("PtP CHUNK CATALOG: fetched data {}", reducedChunkDataTOs);
return buildReducedChunkDataList(reducedChunkDataTOs);
- // List list = new ArrayList();
- // if(reducedChunkDataTOs.isEmpty())
- // {
- // log.debug("PtP CHUNK CATALOG! No chunks found in persistence for " +
- // volids);
- // }
- // else
- // {
- // ReducedPtPChunkData reducedChunkData;
- // for(ReducedPtPChunkDataTO reducedChunkDataTO : reducedChunkDataTOs)
- // {
- // reducedChunkData = makeOneReduced(reducedChunkDataTO);
- // if(reducedChunkData != null)
- // {
- // list.add(reducedChunkData);
- // // TODO MICHELE SURL STORE
- // //
- // SurlStatusStore.getInstance().storeSurlStatus(reducedChunkData.toSURL(),
- // reducedChunkData.status().getStatusCode());
- // if(!this.isComplete(reducedChunkDataTO))
- // {
- // this.completeTO(reducedChunkDataTO, reducedChunkData);
- // dao.updateIncomplete(reducedChunkDataTO);
- // }
- // }
- // }
- // log.debug("PtP CHUNK CATALOG: returning " + list);
- // }
- // return list;
}
private ReducedPtPChunkData makeOneReduced(
@@ -833,9 +729,6 @@ private ReducedPtPChunkData makeOneReduced(
synchronized public boolean isSRM_SPACE_AVAILABLE(TSURL surl) {
return (dao.numberInSRM_SPACE_AVAILABLE(surl.uniqueId()) > 0);
- // TODO MICHELE SURL STORE
- // return
- // TStatusCode.SRM_SPACE_AVAILABLE.equals(SurlStatusStore.getInstance().getSurlStatus(surl));
}
/**
@@ -876,15 +769,6 @@ synchronized public void transitSRM_SPACE_AVAILABLEtoSRM_SUCCESS(
}
}
dao.transitSRM_SPACE_AVAILABLEtoSRM_SUCCESS(primaryKeys);
- // TODO MICHELE SURL STORE
- // for(TSURL surl : surls)
- // {
- // if(surl != null)
- // {
- // SurlStatusStore.getInstance().storeSurlStatus(surl,
- // TStatusCode.SRM_SUCCESS);
- // }
- // }
}
/**
@@ -911,9 +795,6 @@ synchronized public void transitSRM_SPACE_AVAILABLEtoSRM_ABORTED(TSURL surl,
}
dao.transitSRM_SPACE_AVAILABLEtoSRM_ABORTED(surl.uniqueId(),
surl.toString(), explanation);
- // TODO MICHELE SURL STORE
- // SurlStatusStore.getInstance().storeSurlStatus(surl,
- // TStatusCode.SRM_ABORTED);
}
public void updateStatus(TRequestToken requestToken, TSURL surl,
diff --git a/src/main/java/it/grid/storm/catalogs/PtPChunkDAO.java b/src/main/java/it/grid/storm/catalogs/PtPChunkDAO.java
index d1894705..44dbeeac 100644
--- a/src/main/java/it/grid/storm/catalogs/PtPChunkDAO.java
+++ b/src/main/java/it/grid/storm/catalogs/PtPChunkDAO.java
@@ -153,7 +153,6 @@ public synchronized void update(PtPChunkDataTO to) {
updatePut.setString(7, to.overwriteOption());
logWarnings(updatePut.getWarnings());
- // TODO MICHELE USER_SURL fill new fields
updatePut.setString(8, to.normalizedStFN());
logWarnings(updatePut.getWarnings());
@@ -163,11 +162,11 @@ public synchronized void update(PtPChunkDataTO to) {
updatePut.setLong(10, to.primaryKey());
logWarnings(updatePut.getWarnings());
// run updateStatusPut...
- log.trace("PtP CHUNK DAO - update method: " + updatePut.toString());
+ log.trace("PtP CHUNK DAO - update method: {}", updatePut.toString());
updatePut.executeUpdate();
logWarnings(updatePut.getWarnings());
} catch (SQLException e) {
- log.error("PtP CHUNK DAO: Unable to complete update! " + e);
+ log.error("PtP CHUNK DAO: Unable to complete update! {}", e.getMessage(), e);
} finally {
close(updatePut);
}
@@ -179,7 +178,6 @@ public synchronized void update(PtPChunkDataTO to) {
*
* @param chunkTO
*/
- // TODO MICHELE USER_SURL new method
public synchronized void updateIncomplete(ReducedPtPChunkDataTO chunkTO) {
if (!checkConnection()) {
@@ -203,11 +201,12 @@ public synchronized void updateIncomplete(ReducedPtPChunkDataTO chunkTO) {
stmt.setLong(3, chunkTO.primaryKey());
logWarnings(stmt.getWarnings());
- log.trace("PtP CHUNK DAO - update incomplete: " + stmt.toString());
+ log.trace("PtP CHUNK DAO - update incomplete: {}", stmt.toString());
stmt.executeUpdate();
logWarnings(stmt.getWarnings());
} catch (SQLException e) {
- log.error("PtP CHUNK DAO: Unable to complete update incomplete! " + e);
+ log.error("PtP CHUNK DAO: Unable to complete update incomplete! {}",
+ e.getMessage(), e);
} finally {
close(stmt);
}
@@ -247,7 +246,7 @@ public synchronized PtPChunkDataTO refresh(long primary_key) {
stmt.setLong(1, primary_key);
logWarnings(stmt.getWarnings());
- log.trace("PtP CHUNK DAO - refresh method: " + stmt.toString());
+ log.trace("PtP CHUNK DAO - refresh method: {}", stmt.toString());
rs = stmt.executeQuery();
logWarnings(stmt.getWarnings());
while (rs.next()) {
@@ -263,7 +262,7 @@ public synchronized PtPChunkDataTO refresh(long primary_key) {
stmt.setLong(1, primary_key);
logWarnings(stmt.getWarnings());
- log.trace("PtP CHUNK DAO - refresh method: " + stmt.toString());
+ log.trace("PtP CHUNK DAO - refresh method: {}", stmt.toString());
rs = stmt.executeQuery();
logWarnings(stmt.getWarnings());
@@ -279,7 +278,6 @@ public synchronized PtPChunkDataTO refresh(long primary_key) {
chunkDataTO.setRequestToken(rs.getString("rq.r_token"));
chunkDataTO.setPrimaryKey(rs.getLong("rp.ID"));
chunkDataTO.setToSURL(rs.getString("rp.targetSURL"));
- // TODO MICHELE USER_SURL fill new fields
chunkDataTO.setNormalizedStFN(rs
.getString("rp.normalized_targetSURL_StFN"));
int uniqueID = rs.getInt("rp.targetSURL_uniqueID");
@@ -307,16 +305,16 @@ public synchronized PtPChunkDataTO refresh(long primary_key) {
}
if (rs.next()) {
log.warn("ATTENTION in PtP CHUNK DAO! Possible DB corruption! "
- + "refresh method invoked for specific chunk with id "
- + primary_key + ", but found more than one such chunks!");
+ + "refresh method invoked for specific chunk with id {}, but found "
+ + "more than one such chunks!", primary_key);
}
} else {
log.warn("ATTENTION in PtP CHUNK DAO! Possible DB corruption! "
- + "refresh method invoked for specific chunk with id " + primary_key
- + ", but chunk NOT found in persistence!");
+ + "refresh method invoked for specific chunk with id {}, but chunk "
+ + "NOT found in persistence!", primary_key);
}
} catch (SQLException e) {
- log.error("PtP CHUNK DAO! Unable to refresh chunk! " + e);
+ log.error("PtP CHUNK DAO! Unable to refresh chunk! {}", e.getMessage(), e);
chunkDataTO = null;
} finally {
close(rs);
@@ -363,7 +361,7 @@ public synchronized Collection find(TRequestToken requestToken)
find.setString(1, strToken);
logWarnings(find.getWarnings());
- log.trace("PtP CHUNK DAO - find method: " + find.toString());
+ log.trace("PtP CHUNK DAO - find method: {}", find.toString());
rs = find.executeQuery();
logWarnings(find.getWarnings());
@@ -373,7 +371,6 @@ public synchronized Collection find(TRequestToken requestToken)
close(rs);
close(find);
- // TODO MICHELE USER_SURL get new fields
// get chunks of the request
str = "SELECT rq.config_FileStorageTypeID, rq.config_OverwriteID, rq.timeStamp, rq.pinLifetime, rq.fileLifetime, rq.s_token, rq.client_dn, rq.proxy, rp.ID, rp.targetSURL, rp.expectedFileSize, rp.normalized_targetSURL_StFN, rp.targetSURL_uniqueID, sp.statusCode "
+ "FROM request_queue rq JOIN (request_Put rp, status_Put sp) "
@@ -391,7 +388,7 @@ public synchronized Collection find(TRequestToken requestToken)
StatusCodeConverter.getInstance().toDB(TStatusCode.SRM_ABORTED));
logWarnings(find.getWarnings());
- log.trace("PtP CHUNK DAO - find method: " + find.toString());
+ log.trace("PtP CHUNK DAO - find method: {}", find.toString());
rs = find.executeQuery();
logWarnings(find.getWarnings());
PtPChunkDataTO chunkDataTO = null;
@@ -421,7 +418,6 @@ public synchronized Collection find(TRequestToken requestToken)
chunkDataTO.setPrimaryKey(rs.getLong("rp.ID"));
chunkDataTO.setToSURL(rs.getString("rp.targetSURL"));
- // TODO MICHELE USER_SURL fill new fields
chunkDataTO.setNormalizedStFN(rs
.getString("rp.normalized_targetSURL_StFN"));
int uniqueID = rs.getInt("rp.targetSURL_uniqueID");
@@ -437,7 +433,7 @@ public synchronized Collection find(TRequestToken requestToken)
}
return list;
} catch (SQLException e) {
- log.error("PTP CHUNK DAO: " + e);
+ log.error("PTP CHUNK DAO: {}", e.getMessage(), e);
/* return empty Collection! */
return new ArrayList();
} finally {
@@ -489,8 +485,7 @@ public synchronized Collection findReduced(
}
}
logWarnings(find.getWarnings());
- log.trace("PtP CHUNK DAO! findReduced with request token; "
- + find.toString());
+ log.trace("PtP CHUNK DAO! findReduced with request token; {}", find.toString());
rs = find.executeQuery();
logWarnings(find.getWarnings());
@@ -502,7 +497,6 @@ public synchronized Collection findReduced(
.getString("rq.config_FileStorageTypeID"));
reducedChunkDataTO.setPrimaryKey(rs.getLong("rp.ID"));
reducedChunkDataTO.setToSURL(rs.getString("rp.targetSURL"));
- // TODO MICHELE USER_SURL fill new fields
reducedChunkDataTO.setNormalizedStFN(rs
.getString("rp.normalized_targetSURL_StFN"));
int uniqueID = rs.getInt("rp.targetSURL_uniqueID");
@@ -515,7 +509,7 @@ public synchronized Collection findReduced(
}
return list;
} catch (SQLException e) {
- log.error("PTP CHUNK DAO: " + e);
+ log.error("PTP CHUNK DAO: {}", e.getMessage(), e);
/* return empty Collection! */
return new ArrayList();
} finally {
@@ -550,7 +544,7 @@ public synchronized Collection findReduced(
logWarnings(con.getWarnings());
List list = new ArrayList();
- log.trace("PtP CHUNK DAO! fetchReduced; " + find.toString());
+ log.trace("PtP CHUNK DAO! fetchReduced; {}", find.toString());
rs = find.executeQuery();
logWarnings(find.getWarnings());
@@ -562,7 +556,6 @@ public synchronized Collection findReduced(
.getString("rq.config_FileStorageTypeID"));
reducedChunkDataTO.setPrimaryKey(rs.getLong("rp.ID"));
reducedChunkDataTO.setToSURL(rs.getString("rp.targetSURL"));
- // TODO MICHELE USER_SURL fill new fields
reducedChunkDataTO.setNormalizedStFN(rs
.getString("rp.normalized_targetSURL_StFN"));
int uniqueID = rs.getInt("rp.targetSURL_uniqueID");
@@ -575,7 +568,7 @@ public synchronized Collection findReduced(
}
return list;
} catch (SQLException e) {
- log.error("PTP CHUNK DAO: " + e);
+ log.error("PTP CHUNK DAO: {}", e.getMessage(), e);
/* return empty Collection */
return new ArrayList();
} finally {
@@ -620,14 +613,14 @@ public synchronized void signalMalformedPtPChunk(PtPChunkDataTO auxTO) {
signal.setString(1, "This chunk of the request is malformed!");
logWarnings(signal.getWarnings());
- log.trace("PtP CHUNK DAO - signalMalformedPtPChunk method: "
- + signal.toString());
+ log.trace("PtP CHUNK DAO - signalMalformedPtPChunk method: {}",
+ signal.toString());
signal.executeUpdate();
logWarnings(signal.getWarnings());
} catch (SQLException e) {
log.error("PtPChunkDAO! Unable to signal in DB that a chunk of "
- + "the request was malformed! Request: " + auxTO.toString()
- + "; Exception: " + e.toString());
+ + "the request was malformed! Request: {}; Error: {}", auxTO.toString(),
+ e.getMessage(), e);
} finally {
close(signal);
}
@@ -646,11 +639,7 @@ public synchronized int numberInSRM_SPACE_AVAILABLE(int surlUniqueID) {
.error("PtP CHUNK DAO: numberInSRM_SPACE_AVAILABLE - unable to get a valid connection!");
return 0;
}
- /*
- * TODO MICHELE USER_SURL now that we have the unique ID the RIGHT can be
- * removed (not added the search on the id, but removed at all because we
- * check that the status is SRM_SPACE_AVAILABLE)
- */
+
String str = "SELECT COUNT(rp.ID) FROM status_Put sp JOIN request_Put rp "
+ "ON (sp.request_PutID=rp.ID) "
+ "WHERE rp.targetSURL_uniqueID=? AND sp.statusCode=?";
@@ -664,15 +653,12 @@ public synchronized int numberInSRM_SPACE_AVAILABLE(int surlUniqueID) {
stmt.setInt(1, surlUniqueID);
logWarnings(stmt.getWarnings());
- stmt
- .setInt(
- 2,
- StatusCodeConverter.getInstance().toDB(
- TStatusCode.SRM_SPACE_AVAILABLE));
+ stmt.setInt(2,StatusCodeConverter.getInstance().toDB(
+ TStatusCode.SRM_SPACE_AVAILABLE));
logWarnings(stmt.getWarnings());
- log.trace("PtP CHUNK DAO - numberInSRM_SPACE_AVAILABLE method: "
- + stmt.toString());
+ log.trace("PtP CHUNK DAO - numberInSRM_SPACE_AVAILABLE method: {}",
+ stmt.toString());
rs = stmt.executeQuery();
logWarnings(stmt.getWarnings());
@@ -683,7 +669,7 @@ public synchronized int numberInSRM_SPACE_AVAILABLE(int surlUniqueID) {
return numberSpaceAvailable;
} catch (SQLException e) {
log.error("PtPChunkDAO! Unable to determine "
- + "numberInSRM_SPACE_AVAILABLE! Returning 0! " + e);
+ + "numberInSRM_SPACE_AVAILABLE! Returning 0! {}", e.getMessage(), e);
return 0;
} finally {
close(rs);
@@ -724,8 +710,7 @@ public synchronized List getExpiredSRM_SPACE_AVAILABLE() {
TStatusCode.SRM_SPACE_AVAILABLE));
logWarnings(stmt.getWarnings());
- log.trace("PtP CHUNK DAO - transitExpiredSRM_SPACE_AVAILABLE: "
- + stmt.toString());
+ log.trace("PtP CHUNK DAO - transitExpiredSRM_SPACE_AVAILABLE: {}", stmt.toString());
rs = stmt.executeQuery();
logWarnings(stmt.getWarnings());
@@ -735,7 +720,7 @@ public synchronized List getExpiredSRM_SPACE_AVAILABLE() {
}
} catch (SQLException e) {
log.error("PtPChunkDAO! Unable to select expired "
- + "SRM_SPACE_AVAILABLE chunks of PtP requests.", e);
+ + "SRM_SPACE_AVAILABLE chunks of PtP requests. {}", e.getMessage(), e);
/* make an empty list! */
ids = new ArrayList();
@@ -776,15 +761,12 @@ public synchronized void transitSRM_SPACE_AVAILABLEtoSRM_SUCCESS(
StatusCodeConverter.getInstance().toDB(TStatusCode.SRM_SUCCESS));
logWarnings(stmt.getWarnings());
- stmt
- .setInt(
- 2,
- StatusCodeConverter.getInstance().toDB(
+ stmt.setInt(2, StatusCodeConverter.getInstance().toDB(
TStatusCode.SRM_SPACE_AVAILABLE));
logWarnings(stmt.getWarnings());
log.trace("PtP CHUNK DAO - "
- + "transitSRM_SPACE_AVAILABLEtoSRM_SUCCESS: " + stmt.toString());
+ + "transitSRM_SPACE_AVAILABLEtoSRM_SUCCESS: {}", stmt.toString());
int count = stmt.executeUpdate();
logWarnings(stmt.getWarnings());
@@ -793,13 +775,12 @@ public synchronized void transitSRM_SPACE_AVAILABLEtoSRM_SUCCESS(
log.trace("PtPChunkDAO! No chunk of PtP request was "
+ "transited from SRM_SPACE_AVAILABLE to SRM_SUCCESS.");
} else {
- log.info("PtPChunkDAO! " + count
- + " chunks of PtP requests were transited "
- + "from SRM_SPACE_AVAILABLE to SRM_SUCCESS.");
+ log.info("PtPChunkDAO! {} chunks of PtP requests were transited "
+ + "from SRM_SPACE_AVAILABLE to SRM_SUCCESS.", count);
}
} catch (SQLException e) {
log.error("PtPChunkDAO! Unable to transit chunks from "
- + "SRM_SPACE_AVAILABLE to SRM_SUCCESS! " + e);
+ + "SRM_SPACE_AVAILABLE to SRM_SUCCESS! {}", e.getMessage(), e);
} finally {
close(stmt);
}
@@ -835,10 +816,7 @@ public synchronized void transitSRM_SPACE_AVAILABLEtoSRM_ABORTED(
stmt.setString(2, explanation);
logWarnings(stmt.getWarnings());
- stmt
- .setInt(
- 3,
- StatusCodeConverter.getInstance().toDB(
+ stmt.setInt(3, StatusCodeConverter.getInstance().toDB(
TStatusCode.SRM_SPACE_AVAILABLE));
logWarnings(stmt.getWarnings());
@@ -849,20 +827,20 @@ public synchronized void transitSRM_SPACE_AVAILABLEtoSRM_ABORTED(
logWarnings(stmt.getWarnings());
log.trace("PtP CHUNK DAO - "
- + "transitSRM_SPACE_AVAILABLEtoSRM_ABORTED: " + stmt.toString());
+ + "transitSRM_SPACE_AVAILABLEtoSRM_ABORTED: {}", stmt.toString());
int count = stmt.executeUpdate();
logWarnings(stmt.getWarnings());
if (count > 0) {
- log.info("PtP CHUNK DAO! " + count + " chunks were transited from "
- + "SRM_SPACE_AVAILABLE to SRM_ABORTED.");
+ log.info("PtP CHUNK DAO! {} chunks were transited from "
+ + "SRM_SPACE_AVAILABLE to SRM_ABORTED.", count);
} else {
log.trace("PtP CHUNK DAO! No chunks "
+ "were transited from SRM_SPACE_AVAILABLE to SRM_ABORTED.");
}
} catch (SQLException e) {
log.error("PtP CHUNK DAO! Unable to "
- + "transitSRM_SPACE_AVAILABLEtoSRM_ABORTED! " + e);
+ + "transitSRM_SPACE_AVAILABLEtoSRM_ABORTED! {}", e.getMessage(), e);
} finally {
close(stmt);
}
@@ -877,8 +855,8 @@ private void close(Statement stmt) {
try {
stmt.close();
} catch (Exception e) {
- log.error("PTP CHUNK DAO! Unable to close Statement " + stmt.toString()
- + " - Exception: " + e);
+ log.error("PTP CHUNK DAO! Unable to close Statement {} - Error: {}",
+ stmt.toString(), e.getMessage(), e);
}
}
}
@@ -892,7 +870,8 @@ private void close(ResultSet rset) {
try {
rset.close();
} catch (Exception e) {
- log.error("PTP CHUNK DAO! Unable to close ResultSet! Exception: " + e);
+ log.error("PTP CHUNK DAO! Unable to close ResultSet! Error: {}",
+ e.getMessage(), e);
}
}
}
@@ -903,9 +882,9 @@ private void close(ResultSet rset) {
private void logWarnings(SQLWarning w) {
if (w != null) {
- log.debug("PTP CHUNK DAO: " + w.toString());
+ log.debug("PTP CHUNK DAO: {}", w.toString());
while ((w = w.getNextWarning()) != null) {
- log.debug("PTP CHUNK DAO: " + w.toString());
+ log.debug("PTP CHUNK DAO: {}", w.toString());
}
}
}
@@ -927,25 +906,6 @@ private String makeWhereString(List rowids) {
return sb.toString();
}
- // /**
- // * Method that returns a String containing all IDs.
- // */
- // private String makeWhereString(long[] rowids) {
- //
- // StringBuffer sb = new StringBuffer("(");
- // int n = rowids.length;
- // for(int i = 0; i < n; i++)
- // {
- // sb.append(rowids[i]);
- // if(i < (n - 1))
- // {
- // sb.append(",");
- // }
- // }
- // sb.append(")");
- // return sb.toString();
- // }
-
/**
* Auxiliary method that sets up the conenction to the DB.
*/
@@ -962,9 +922,11 @@ private boolean setUpConnection() {
response = con.isValid(0);
}
} catch (ClassNotFoundException e) {
- log.error("PTP CHUNK DAO! Exception in setUpConenction! " + e);
+ log.error("PTP CHUNK DAO! Exception in setUpConenction! {}",
+ e.getMessage(), e);
} catch (SQLException e) {
- log.error("PTP CHUNK DAO! Exception in setUpConnection! " + e);
+ log.error("PTP CHUNK DAO! Exception in setUpConnection! {}",
+ e.getMessage(), e);
}
return response;
}
@@ -996,8 +958,8 @@ private void takeDownConnection() {
try {
con.close();
} catch (SQLException e) {
- log.error("PTP CHUNK DAO! Exception in "
- + "takeDownConnection method - could not close connection! " + e);
+ log.error("PTP CHUNK DAO! Exception in takeDownConnection method - "
+ + "could not close connection! {}", e.getMessage(), e);
}
}
}
@@ -1063,19 +1025,19 @@ private void doUpdateStatus(TRequestToken requestToken, int[] surlsUniqueIDs,
stmt.setInt(1, StatusCodeConverter.getInstance().toDB(statusCode));
logWarnings(stmt.getWarnings());
- log.trace("PTP CHUNK DAO - updateStatus: " + stmt.toString());
+ log.trace("PTP CHUNK DAO - updateStatus: {}", stmt.toString());
int count = stmt.executeUpdate();
logWarnings(stmt.getWarnings());
if (count == 0) {
- log.trace("PTP CHUNK DAO! No chunk of PTP request was" + " updated to "
- + statusCode + ".");
+ log.trace("PTP CHUNK DAO! No chunk of PTP request was updated to {}.",
+ statusCode);
} else {
- log.info("PTP CHUNK DAO! " + count
- + " chunks of PTP requests were updated to " + statusCode + ".");
+ log.info("PTP CHUNK DAO! {} chunks of PTP requests were updated "
+ + "to {}.", count, statusCode);
}
} catch (SQLException e) {
- log.error("PTP CHUNK DAO! Unable to updated from to " + statusCode + " !"
- + e);
+ log.error("PTP CHUNK DAO! Unable to updated from to {}! {}", statusCode,
+ e.getMessage(), e);
} finally {
close(stmt);
}
@@ -1175,22 +1137,19 @@ private void doUpdateStatusOnMatchingStatus(TRequestToken requestToken,
.setInt(2, StatusCodeConverter.getInstance().toDB(expectedStatusCode));
logWarnings(stmt.getWarnings());
- log.trace("PTP CHUNK DAO - updateStatusOnMatchingStatus: "
- + stmt.toString());
+ log.trace("PTP CHUNK DAO - updateStatusOnMatchingStatus: {}", stmt.toString());
int count = stmt.executeUpdate();
logWarnings(stmt.getWarnings());
if (count == 0) {
- log.trace("PTP CHUNK DAO! No chunk of PTP request was"
- + " updated from " + expectedStatusCode + " to " + newStatusCode
- + ".");
+ log.trace("PTP CHUNK DAO! No chunk of PTP request was updated "
+ + "from {} to {}.", expectedStatusCode, newStatusCode);
} else {
- log.debug("PTP CHUNK DAO! " + count
- + " chunks of PTP requests were updated from " + expectedStatusCode
- + " to " + newStatusCode + ".");
+ log.debug("PTP CHUNK DAO! {} chunks of PTP requests were updated "
+ + "from {} to {}.", count, expectedStatusCode, newStatusCode);
}
} catch (SQLException e) {
- log.error("PTP CHUNK DAO! Unable to updated from " + expectedStatusCode
- + " to " + newStatusCode + " !" + e);
+ log.error("PTP CHUNK DAO! Unable to updated from {} to {}! Error: {}",
+ expectedStatusCode, newStatusCode, e.getMessage(), e);
} finally {
close(stmt);
}
@@ -1238,7 +1197,6 @@ private synchronized Collection find(int[] surlsUniqueIDs,
PreparedStatement find = null;
ResultSet rs = null;
try {
- // TODO MICHELE USER_SURL get new fields
// get chunks of the request
String str = "SELECT rq.ID, rq.r_token, rq.config_FileStorageTypeID, rq.config_OverwriteID, rq.timeStamp, rq.pinLifetime, rq.fileLifetime, "
+ "rq.s_token, rq.client_dn, rq.proxy, rp.ID, rp.targetSURL, rp.expectedFileSize, rp.normalized_targetSURL_StFN, rp.targetSURL_uniqueID, "
@@ -1259,7 +1217,7 @@ private synchronized Collection find(int[] surlsUniqueIDs,
List list = new ArrayList();
- log.trace("PtP CHUNK DAO - find method: " + find.toString());
+ log.trace("PtP CHUNK DAO - find method: {}", find.toString());
rs = find.executeQuery();
logWarnings(find.getWarnings());
PtPChunkDataTO chunkDataTO = null;
@@ -1289,7 +1247,6 @@ private synchronized Collection find(int[] surlsUniqueIDs,
chunkDataTO.setPrimaryKey(rs.getLong("rp.ID"));
chunkDataTO.setToSURL(rs.getString("rp.targetSURL"));
- // TODO MICHELE USER_SURL fill new fields
chunkDataTO.setNormalizedStFN(rs
.getString("rp.normalized_targetSURL_StFN"));
int uniqueID = rs.getInt("rp.targetSURL_uniqueID");
@@ -1304,7 +1261,7 @@ private synchronized Collection