Skip to content

Commit

Permalink
poolmanager: Add named error codes for no-pool-configured and no-pool…
Browse files Browse the repository at this point in the history
…-online

Improves error messages when poolmanager is unable to find pools for a
transfer. In particular the 'no write pool configured' and 'no write pool
available' messages are simplified when sent to the FTP client, and the log
messages no longer use the legacy StorageInfo#toString method (instead only the
information that is actually involved in pool selection is logged).

Having two different error codes is important as one error is transient and the
other is not. Read pool selection currently uses some additional error codes
which should probably be changed to one of the two new values, but I leave that
for a future patch.

Target: trunk
Require-notes: yes
Require-book: yes
Acked-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
Patch: http://rb.dcache.org/r/6358/
  • Loading branch information
gbehrmann committed Dec 19, 2013
1 parent 5967210 commit 21588b7
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 21 deletions.
Expand Up @@ -2607,6 +2607,13 @@ private void retrieve(String file, long offset, long size,
case CacheException.NOT_DIR:
transfer.abort(550, "Not a directory");
break;
case CacheException.NO_POOL_CONFIGURED:
transfer.abort(552, "No read pool configured for this transfer", e);
break;
case CacheException.FILE_NOT_IN_REPOSITORY:
case CacheException.NO_POOL_ONLINE:
transfer.abort(452, "File is unavailable", e);
break;
default:
transfer.abort(451, "Operation failed: " + e.getMessage(), e);
break;
Expand Down Expand Up @@ -2716,6 +2723,12 @@ private void store(String file, Mode mode, String xferMode,
case CacheException.NOT_DIR:
transfer.abort(501, "Not a directory");
break;
case CacheException.NO_POOL_CONFIGURED:
transfer.abort(552, "No write pool configured for this transfer", e);
break;
case CacheException.NO_POOL_ONLINE:
transfer.abort(452, "No write pool available", e);
break;
default:
transfer.abort(451, "Operation failed: " + e.getMessage(), e);
break;
Expand Down
Expand Up @@ -34,7 +34,6 @@
import diskCacheV111.vehicles.IpProtocolInfo;
import diskCacheV111.vehicles.PoolManagerPoolInformation;
import diskCacheV111.vehicles.ProtocolInfo;
import diskCacheV111.vehicles.StorageInfos;

import dmg.cells.nucleus.CellMessage;

Expand All @@ -48,6 +47,7 @@
import org.dcache.vehicles.FileAttributes;

import static com.google.common.base.Predicates.*;
import static com.google.common.base.Strings.nullToEmpty;
import static com.google.common.collect.Iterables.*;
import static org.dcache.namespace.FileAttribute.*;

Expand Down Expand Up @@ -138,13 +138,8 @@ public Partition getCurrentPartition()
*/
private PoolPreferenceLevel[] match(DirectionType direction)
{
String hostName =
(_protocolInfo instanceof IpProtocolInfo)
? ((IpProtocolInfo) _protocolInfo).getSocketAddress().getAddress().getHostAddress()
: null;
String protocol =
_protocolInfo.getProtocol() + "/" +
_protocolInfo.getMajorVersion() ;
String hostName = getHostName();
String protocol = getProtocol();
return _selectionUnit.match(direction,
hostName,
protocol,
Expand Down Expand Up @@ -177,14 +172,22 @@ public List<List<PoolInfo>> getReadPools()
public PoolInfo selectWritePool(long preallocated)
throws CacheException
{
PoolPreferenceLevel[] levels = match(DirectionType.WRITE);
String hostName = getHostName();
String protocol = getProtocol();
PoolPreferenceLevel[] levels = _selectionUnit.match(DirectionType.WRITE,
hostName,
protocol,
_fileAttributes,
_linkGroup);

if (levels.length == 0) {
throw new CacheException(19,
"No write pools configured for <" +
StorageInfos.extractFrom(_fileAttributes) +
"> in the linkGroup " +
(_linkGroup == null ? "[none]" : _linkGroup));
throw new CacheException(CacheException.NO_POOL_CONFIGURED,
"No write links configured for [" +
"net=" + hostName +
",protocol=" + protocol +
",store=" + _fileAttributes.getStorageInfo().getStorageClass() + "@" + _fileAttributes.getStorageInfo().getHsm() +
",cache=" + nullToEmpty(_fileAttributes.getStorageInfo().getCacheClass()) +
",linkgroup=" + nullToEmpty(_linkGroup) + "]");
}

for (PoolPreferenceLevel level: levels) {
Expand All @@ -197,10 +200,13 @@ public PoolInfo selectWritePool(long preallocated)
}
}

throw new CacheException(20,
"No write pool available for <" + StorageInfos.extractFrom(_fileAttributes) +
"> in the linkGroup " +
(_linkGroup == null ? "[none]" : _linkGroup));
throw new CacheException(CacheException.NO_POOL_ONLINE,
"No write pools online for [" +
"net=" + hostName +
",protocol=" + protocol +
",store=" + _fileAttributes.getStorageInfo().getStorageClass() + "@" + _fileAttributes.getStorageInfo().getHsm() +
",cache=" + nullToEmpty(_fileAttributes.getStorageInfo().getCacheClass()) +
",linkgroup=" + nullToEmpty(_linkGroup) + "]");
}

@Override
Expand All @@ -223,14 +229,25 @@ public PoolInfo selectReadPool()
/* Get the prioritized list of allowed pools for this
* request.
*/
PoolPreferenceLevel[] level = match(DirectionType.READ);
String hostName = getHostName();
String protocol = getProtocol();
PoolPreferenceLevel[] level = _selectionUnit.match(DirectionType.READ,
hostName,
protocol,
_fileAttributes,
_linkGroup);

/* An empty array indicates that no links were found that
* could serve the request. No reason to try any further;
* not even a stage or P2P would help.
*/
if (level.length == 0) {
throw new CacheException("No links for this request");
throw new CacheException(CacheException.NO_POOL_CONFIGURED, "No read links configured [" +
"net=" + hostName +
",protocol=" + protocol +
",store=" + _fileAttributes.getStorageInfo().getStorageClass() + "@" + _fileAttributes.getStorageInfo().getHsm() +
",cache=" + nullToEmpty(_fileAttributes.getStorageInfo().getCacheClass()) +
",linkgroup=" + nullToEmpty(_linkGroup) + "]");
}

CostException fallback = null;
Expand Down Expand Up @@ -292,6 +309,17 @@ public PoolInfo selectReadPool()
throw new PermissionDeniedCacheException("File is online, but not in read-allowed pool");
}

private String getHostName() {
return (_protocolInfo instanceof IpProtocolInfo)
? ((IpProtocolInfo) _protocolInfo).getSocketAddress().getAddress().getHostAddress()
: null;
}

private String getProtocol() {
return _protocolInfo.getProtocol() + "/" +
_protocolInfo.getMajorVersion();
}

@Override
public Partition.P2pPair selectPool2Pool(boolean force)
throws CacheException
Expand Down
Expand Up @@ -108,6 +108,9 @@ public class CacheException extends Exception
public final static int SERVICE_UNAVAILABLE = 10023;


public static final int NO_POOL_CONFIGURED = 10024;
public static final int NO_POOL_ONLINE = 10025;

/**
* default error code. <b>It's recommended to use more specific error
* codes</b>
Expand Down
Expand Up @@ -87,6 +87,8 @@ public static CacheException exceptionOf(int errorCode, String message, Throwabl
case HSM_DELAY_ERROR:
case FILE_NOT_STORED:
case POOL_DISABLED:
case NO_POOL_CONFIGURED:
case NO_POOL_ONLINE:
default:
return new CacheException(errorCode, message, cause);
}
Expand Down
8 changes: 7 additions & 1 deletion modules/dcache/src/main/java/org/dcache/util/Transfer.java
Expand Up @@ -1035,8 +1035,14 @@ public synchronized void notifyBilling(int code, String error)
continue;
case CacheException.FILE_IN_CACHE:
throw e;
case CacheException.NO_POOL_CONFIGURED:
_log.error(e.getMessage());
throw e;
case CacheException.NO_POOL_ONLINE:
_log.warn(e.getMessage());
throw e;
default:
_log.error(e.toString());
_log.error(e.getMessage());
break;
}
lastFailure = e;
Expand Down

0 comments on commit 21588b7

Please sign in to comment.