use of diskCacheV111.vehicles.PoolMgrSelectPoolMsg in project dcache by dCache.
the class TransferManagerHandler method selectPool.
public void selectPool() {
protocol_info = manager.getProtocolInfo(transferRequest);
PoolMgrSelectPoolMsg request = store ? new PoolMgrSelectWritePoolMsg(fileAttributes, protocol_info) : new PoolMgrSelectReadPoolMsg(fileAttributes, protocol_info, _readPoolSelectionContext);
request.setBillingPath(pnfsPath);
request.setSubject(transferRequest.getSubject());
LOGGER.debug("PoolMgrSelectPoolMsg: {}", request);
setState(WAITING_FOR_POOL_INFO_STATE);
manager.persist(this);
CellStub.addCallback(manager.getPoolManagerStub().sendAsync(request), this, executor);
}
use of diskCacheV111.vehicles.PoolMgrSelectPoolMsg in project dcache by dCache.
the class Transfer method selectPoolAsync.
/**
* Selects a pool suitable for the transfer.
*/
public ListenableFuture<Void> selectPoolAsync(long timeout) {
if (getPool() != null) {
// we have a valid preselected pool. Let use it as long as clearPoolSelection is not called.
return immediateFuture(null);
}
FileAttributes fileAttributes = getFileAttributes();
ProtocolInfo protocolInfo = getProtocolInfoForPoolManager();
ListenableFuture<? extends PoolMgrSelectPoolMsg> reply;
if (isWrite()) {
long allocated = _allocated;
if (allocated == 0 && fileAttributes.isDefined(SIZE)) {
allocated = fileAttributes.getSize();
}
PoolMgrSelectWritePoolMsg request = new PoolMgrSelectWritePoolMsg(fileAttributes, protocolInfo, allocated);
request.setId(_id);
request.setSubject(_subject);
request.setBillingPath(getBillingPath());
request.setTransferPath(getTransferPath());
request.setIoQueueName(getIoQueue());
request.setExcludedHosts(_tried);
reply = _poolManager.sendAsync(request, timeout);
} else {
EnumSet<RequestState> allowedStates = getAllowedRequestStates();
try {
if (allowedStates.contains(RequestState.ST_STAGE) && !_checkStagePermission.canPerformStaging(_subject, fileAttributes, protocolInfo)) {
allowedStates.remove(RequestState.ST_STAGE);
}
} catch (IOException e) {
return immediateFailedFuture(new CacheException(CacheException.UNEXPECTED_SYSTEM_EXCEPTION, e.getMessage()));
}
PoolMgrSelectReadPoolMsg request = new PoolMgrSelectReadPoolMsg(fileAttributes, protocolInfo, getReadPoolSelectionContext(), allowedStates);
request.setId(_id);
request.setSubject(_subject);
request.setBillingPath(getBillingPath());
request.setTransferPath(getTransferPath());
request.setIoQueueName(getIoQueue());
request.setExcludedHosts(_tried);
reply = Futures.transform(_poolManager.sendAsync(request, timeout), (PoolMgrSelectReadPoolMsg msg) -> {
setReadPoolSelectionContext(msg.getContext());
return msg;
});
}
setStatusUntil("PoolManager: Selecting pool", reply);
return CellStub.transform(reply, (PoolMgrSelectPoolMsg msg) -> {
setPool(msg.getPool());
setFileAttributes(msg.getFileAttributes());
return null;
});
}
use of diskCacheV111.vehicles.PoolMgrSelectPoolMsg in project dcache by dCache.
the class TransferManagerHandler method success.
@Override
public void success(Message message) {
try {
if (message instanceof PnfsCreateEntryMessage) {
PnfsCreateEntryMessage create_msg = (PnfsCreateEntryMessage) message;
if (state == WAITING_FOR_PNFS_ENTRY_CREATION_INFO_STATE) {
setState(RECEIVED_PNFS_ENTRY_CREATION_INFO_STATE);
createEntryResponseArrived(create_msg);
return;
}
LOGGER.error(this.toString() + " got unexpected PnfsCreateEntryMessage " + " : " + create_msg + " ; Ignoring");
} else if (message instanceof PnfsGetFileAttributes) {
PnfsGetFileAttributes attributesMessage = (PnfsGetFileAttributes) message;
if (state == WAITING_FOR_PNFS_INFO_STATE) {
setState(RECEIVED_PNFS_INFO_STATE);
FileAttributes attributes = attributesMessage.getFileAttributes();
if (!attributes.isDefined(SIZE)) {
sendErrorReply(CacheException.FILE_IS_NEW, new FileIsNewCacheException());
return;
}
storageInfoArrived(attributesMessage.getPnfsId(), attributes);
return;
} else if (state == WAITING_FOR_PNFS_CHECK_BEFORE_DELETE_STATE) {
state = RECEIVED_PNFS_CHECK_BEFORE_DELETE_STATE;
deletePnfsEntry();
return;
} else if (state == WAITING_FOR_CREATED_FILE_INFO_STATE) {
state = RECEIVED_CREATED_FILE_INFO_STATE;
getFileAttributesArrived(attributesMessage.getFileAttributes());
return;
}
LOGGER.error(this.toString() + " got unexpected PnfsGetStorageInfoMessage " + " : " + attributesMessage + " ; Ignoring");
} else if (message instanceof PoolMgrSelectPoolMsg) {
PoolMgrSelectPoolMsg select_pool_msg = (PoolMgrSelectPoolMsg) message;
if (state == WAITING_FOR_POOL_INFO_STATE) {
setState(RECEIVED_POOL_INFO_STATE);
poolInfoArrived(select_pool_msg);
return;
}
LOGGER.error(this.toString() + " got unexpected PoolMgrSelectPoolMsg " + " : " + select_pool_msg + " ; Ignoring");
} else if (message instanceof PoolIoFileMessage) {
PoolIoFileMessage first_pool_reply = (PoolIoFileMessage) message;
if (state == WAITING_FIRST_POOL_REPLY_STATE) {
setState(RECEIVED_FIRST_POOL_REPLY_STATE);
poolFirstReplyArrived(first_pool_reply);
return;
}
LOGGER.error(this.toString() + " got unexpected PoolIoFileMessage " + " : " + first_pool_reply + " ; Ignoring");
} else if (message instanceof PnfsDeleteEntryMessage) {
PnfsDeleteEntryMessage deleteReply = (PnfsDeleteEntryMessage) message;
if (state == WAITING_FOR_PNFS_ENTRY_DELETE) {
setState(RECEIVED_PNFS_ENTRY_DELETE);
LOGGER.debug("Received PnfsDeleteEntryMessage, Deleted : {}", deleteReply.getPnfsPath());
sendErrorReply();
}
}
manager.persist(this);
} catch (RuntimeException e) {
LOGGER.error("Bug detected in transfermanager, please report this to <support@dCache.org>", e);
failure(1, "Bug detected: " + e);
}
}
Aggregations