Skip to content

Commit

Permalink
all: Fix several NPEs when submitting billing messages
Browse files Browse the repository at this point in the history
The recent changes for adding billing and transfer paths to billing messages has triggered
several NPEs, in particular when doing pool to pool transfers. Contrary to my initial believe,
there are plenty of cases in which a path isn't know and the billing/transfer paths thus
are null.

Target: trunk
Require-notes: no
Require-book: no
Request: 2.12
Request: 2.11
Request: 2.10
Acked-by: Albert Rossi <arossi@fnal.gov>
Patch: https://rb.dcache.org/r/8173/
(cherry picked from commit a766de3)
  • Loading branch information
gbehrmann committed Apr 28, 2015
1 parent 2b8c822 commit 1bfb844
Show file tree
Hide file tree
Showing 17 changed files with 42 additions and 73 deletions.
Expand Up @@ -2073,7 +2073,7 @@ public void fileAttributesAvailable()
getPoolMessage = new PoolMgrSelectWritePoolMsg(_fileAttributes, _protocolInfo, getPreallocated());
getPoolMessage.setIoQueueName(_ioQueueName );
if( _path != null ) {
getPoolMessage.setBillingPath(new FsPath(_info.getBillingPath()));
getPoolMessage.setBillingPath(_info.getBillingPath());
}
}else{
//
Expand Down Expand Up @@ -2226,8 +2226,8 @@ private void storeChecksumInPnfs( PnfsId pnfsId , String checksumString){
return ;
}

poolMessage.setBillingPath(new FsPath(_info.getBillingPath()));
poolMessage.setTransferPath(new FsPath(_info.getTransferPath()));
poolMessage.setBillingPath(_info.getBillingPath());
poolMessage.setTransferPath(_info.getTransferPath());
poolMessage.setId( _sessionId ) ;
poolMessage.setSubject(_subject);

Expand Down
Expand Up @@ -4270,7 +4270,7 @@ private void sendRemoveInfoToBilling(PnfsId pnfsId, FsPath path) {
DoorRequestInfoMessage infoRemove =
new DoorRequestInfoMessage(_cellAddress.toString(), "remove");
infoRemove.setSubject(_subject);
infoRemove.setBillingPath(path);
infoRemove.setBillingPath(path.toString());
infoRemove.setPnfsId(pnfsId);
infoRemove.setClient(_clientDataAddress.getAddress().getHostAddress());

Expand Down
Expand Up @@ -1127,7 +1127,7 @@ public void putDone(SRMUser user, String localTransferPath, URI surl, boolean ov
DoorRequestInfoMessage infoMsg =
new DoorRequestInfoMessage(getCellAddress().toString());
infoMsg.setSubject(subject);
infoMsg.setBillingPath(fullPath);
infoMsg.setBillingPath(fullPath.toString());
infoMsg.setTransferPath(localTransferPath);
infoMsg.setTransaction(CDC.getSession());
infoMsg.setPnfsId(msg.getPnfsId());
Expand Down
Expand Up @@ -2,8 +2,6 @@

import javax.security.auth.Subject;

import diskCacheV111.util.FsPath;

import org.dcache.auth.Subjects;

public class DoorRequestInfoMessage extends PnfsFileInfoMessage
Expand Down Expand Up @@ -92,9 +90,4 @@ public void setTransferPath(String path)
{
_transferPath = path;
}

public void setTransferPath(FsPath path)
{
setTransferPath(path.toString());
}
}
@@ -1,6 +1,5 @@
package diskCacheV111.vehicles;

import diskCacheV111.util.FsPath;
import diskCacheV111.util.PnfsId;

public class MoverInfoMessage extends PnfsFileInfoMessage
Expand Down Expand Up @@ -88,11 +87,6 @@ public void setTransferPath(String path)
_transferPath = path;
}

public void setTransferPath(FsPath path)
{
setTransferPath(path.toString());
}

public String getAdditionalInfo()
{
return _dataTransferred + " "
Expand Down
@@ -1,6 +1,7 @@
package diskCacheV111.vehicles;

import diskCacheV111.util.FsPath;
import java.util.Objects;

import diskCacheV111.util.PnfsId;

public abstract class PnfsFileInfoMessage extends InfoMessage
Expand Down Expand Up @@ -66,11 +67,6 @@ public String getBillingPath()

public void setBillingPath(String path)
{
_path = path;
}

public void setBillingPath(FsPath path)
{
setBillingPath(path.toString());
_path = Objects.toString(path, "Unknown");
}
}
@@ -1,6 +1,5 @@
package diskCacheV111.vehicles;

import diskCacheV111.util.FsPath;
import diskCacheV111.util.PnfsId;

public class PoolHitInfoMessage extends PnfsFileInfoMessage {
Expand Down Expand Up @@ -46,11 +45,6 @@ public void setTransferPath(String path)
_transferPath = path;
}

public void setTransferPath(FsPath path)
{
setTransferPath(path.toString());
}

public String toString()
{
return getInfoHeader()+" "+
Expand Down
Expand Up @@ -2,7 +2,6 @@

import java.util.EnumSet;

import diskCacheV111.util.FsPath;
import diskCacheV111.util.PnfsId;

import org.dcache.vehicles.FileAttributes;
Expand Down Expand Up @@ -84,24 +83,24 @@ public String getInitiator() {
return _initiator;
}

public FsPath getBillingPath()
public String getBillingPath()
{
return _pnfsPath != null ? new FsPath(_pnfsPath) : null;
return _pnfsPath != null ? _pnfsPath : null;
}

public void setBillingPath(FsPath path)
public void setBillingPath(String path)
{
_pnfsPath = path.toString();
_pnfsPath = path;
}

public FsPath getTransferPath()
public String getTransferPath()
{
return _transferPath != null ? new FsPath(_transferPath) : getBillingPath();
return _transferPath != null ? _transferPath : getBillingPath();
}

public void setTransferPath(FsPath path)
public void setTransferPath(String path)
{
_transferPath = path.toString();
_transferPath = path;
}

public FileAttributes getFileAttributes()
Expand Down
@@ -1,6 +1,5 @@
package diskCacheV111.vehicles;

import diskCacheV111.util.FsPath;
import diskCacheV111.util.PnfsId;

public class WarningPnfsFileInfoMessage extends PnfsFileInfoMessage
Expand Down Expand Up @@ -33,9 +32,4 @@ public void setTransferPath(String path)
{
_transferPath = path;
}

public void setTransferPath(FsPath path)
{
setTransferPath(path.toString());
}
}
Expand Up @@ -878,7 +878,7 @@ private void sendRemoveInfoToBilling(FileAttributes attributes, FsPath path)
new DoorRequestInfoMessage(getCellAddress().toString(), "remove");
Subject subject = getSubject();
infoRemove.setSubject(subject);
infoRemove.setBillingPath(path);
infoRemove.setBillingPath(path.toString());
infoRemove.setPnfsId(attributes.getPnfsId());
infoRemove.setFileSize(attributes.getSizeIfPresent().or(0L));
infoRemove.setClient(Subjects.getOrigin(subject).getAddress().getHostAddress());
Expand Down
Expand Up @@ -476,7 +476,7 @@ private void sendRemoveInfoToBilling(PnfsId pnfsId, FsPath path, Subject subject
DoorRequestInfoMessage infoRemove =
new DoorRequestInfoMessage(getCellAddress().toString(), "remove");
infoRemove.setSubject(subject);
infoRemove.setBillingPath(path);
infoRemove.setBillingPath(path.toString());
infoRemove.setPnfsId(pnfsId);
Origin origin = Subjects.getOrigin(subject);
if (origin != null) {
Expand Down
Expand Up @@ -755,8 +755,8 @@ private class PoolRequestHandler {
private StorageInfo _storageInfo;
private ProtocolInfo _protocolInfo;
private String _linkGroup;
private FsPath _billingPath;
private FsPath _transferPath;
private String _billingPath;
private String _transferPath;

private boolean _enforceP2P;
private int _destinationFileStatus = Pool2PoolTransferMsg.UNDETERMINED ;
Expand Down
Expand Up @@ -18,7 +18,6 @@

import diskCacheV111.doors.FTPTransactionLog;
import diskCacheV111.util.CacheException;
import diskCacheV111.util.FsPath;
import diskCacheV111.util.PnfsId;
import diskCacheV111.vehicles.DoorRequestInfoMessage;
import diskCacheV111.vehicles.DoorTransferFinishedMessage;
Expand Down Expand Up @@ -373,7 +372,7 @@ public void selectPool()
PoolMgrSelectPoolMsg request = store
? new PoolMgrSelectWritePoolMsg(fileAttributes, protocol_info)
: new PoolMgrSelectReadPoolMsg(fileAttributes, protocol_info, _readPoolSelectionContext);
request.setBillingPath(new FsPath(pnfsPath));
request.setBillingPath(pnfsPath);
request.setSubject(transferRequest.getSubject());
log.debug("PoolMgrSelectPoolMsg: " + request);
setState(WAITING_FOR_POOL_INFO_STATE);
Expand Down Expand Up @@ -409,8 +408,8 @@ public void startMoverOnThePool()
pool,
protocol_info,
fileAttributes);
poolMessage.setBillingPath(new FsPath(info.getBillingPath()));
poolMessage.setTransferPath(new FsPath(info.getTransferPath()));
poolMessage.setBillingPath(info.getBillingPath());
poolMessage.setTransferPath(info.getTransferPath());
poolMessage.setSubject(transferRequest.getSubject());
if (manager.getIoQueueName() != null) {
poolMessage.setIoQueueName(manager.getIoQueueName());
Expand Down
Expand Up @@ -55,21 +55,21 @@ public boolean getSkipCostUpdate()
public void setIoQueueName( String ioQueueName ){ _ioQueueName = ioQueueName ; }
public String getIoQueueName(){ return _ioQueueName ; }

public FsPath getBillingPath() {
return _pnfsPath != null ? new FsPath(_pnfsPath) : null;
public String getBillingPath() {
return _pnfsPath;
}

public void setBillingPath(FsPath pnfsPath) {
_pnfsPath = pnfsPath.toString();
public void setBillingPath(String pnfsPath) {
_pnfsPath = pnfsPath;
}

public FsPath getTransferPath()
public String getTransferPath()
{
return _transferPath != null ? new FsPath(_transferPath) : getBillingPath();
return _transferPath != null ? _transferPath : getBillingPath();
}

public void setTransferPath(FsPath path) {
_transferPath = path.toString();
public void setTransferPath(String path) {
_transferPath = path;
}

public void setLinkGroup(String linkGroup) {
Expand Down
Expand Up @@ -64,8 +64,8 @@ public abstract class AbstractMover<P extends ProtocolInfo, M extends AbstractMo
protected final ReplicaDescriptor _handle;
protected final IoMode _ioMode;
protected final TransferService<M> _transferService;
protected final FsPath _billingPath;
protected final FsPath _transferPath;
protected final String _billingPath;
protected final String _transferPath;
protected volatile int _errorCode;
protected volatile String _errorMessage = "";

Expand Down Expand Up @@ -165,13 +165,13 @@ public CellPath getPathToDoor()
}

@Override
public FsPath getBillingPath()
public String getBillingPath()
{
return _billingPath;
}

@Override
public FsPath getTransferPath()
public String getTransferPath()
{
return _transferPath;
}
Expand Down
Expand Up @@ -136,12 +136,12 @@ public interface Mover<T extends ProtocolInfo>
/**
* Returns the billable name space path of the file being transferred.
*/
FsPath getBillingPath();
String getBillingPath();

/**
* Returns the temporary name space path of the file being transferred.
*/
FsPath getTransferPath();
String getTransferPath();

/**
* Initiates the actual transfer phase. The operation is asynchronous. Completion
Expand Down
10 changes: 5 additions & 5 deletions modules/dcache/src/main/java/org/dcache/util/Transfer.java
Expand Up @@ -287,20 +287,20 @@ public synchronized void setFileAttributes(FileAttributes fileAttributes)
/**
* The name space path of the file being transferred.
*/
public synchronized FsPath getTransferPath()
public synchronized String getTransferPath()
{
return _path;
return _path.toString();
}

/**
* The billable name space path of the file being transferred.
*/
public synchronized FsPath getBillingPath()
public synchronized String getBillingPath()
{
if (_fileAttributes.isDefined(STORAGEINFO) && _fileAttributes.getStorageInfo().getKey("path") != null) {
return new FsPath(_fileAttributes.getStorageInfo().getKey("path"));
return _fileAttributes.getStorageInfo().getKey("path");
} else {
return _path;
return _path.toString();
}
}

Expand Down

0 comments on commit 1bfb844

Please sign in to comment.