use of dmg.cells.nucleus.CellPath in project dcache by dCache.
the class PnfsManagerV3 method postProcessFlush.
private void postProcessFlush(CellMessage envelope, PoolFileFlushedMessage pnfsMessage) {
long timeout = envelope.getAdjustedTtl() - envelope.getLocalAge();
/* Asynchronously notify flush notification targets about the flush. */
PoolFileFlushedMessage notification = new PoolFileFlushedMessage(pnfsMessage.getPoolName(), pnfsMessage.getPnfsId(), pnfsMessage.getFileAttributes());
List<ListenableFuture<PoolFileFlushedMessage>> futures = new ArrayList<>();
for (String address : _flushNotificationTargets) {
futures.add(_stub.send(new CellPath(address), notification, timeout));
}
/* Only generate positive reply if all notifications succeeded. */
Futures.addCallback(Futures.allAsList(futures), new FutureCallback<List<PoolFileFlushedMessage>>() {
@Override
public void onSuccess(List<PoolFileFlushedMessage> result) {
pnfsMessage.setSucceeded();
reply();
}
@Override
public void onFailure(Throwable t) {
pnfsMessage.setFailed(CacheException.DEFAULT_ERROR_CODE, "PNFS manager failed while notifying other " + "components about the flush: " + t.getMessage());
reply();
}
private void reply() {
envelope.revertDirection();
sendMessage(envelope);
}
});
}
use of dmg.cells.nucleus.CellPath in project dcache by dCache.
the class PnfsManagerV3 method cancelUpload.
void cancelUpload(PnfsCancelUpload message) {
Subject subject = message.getSubject();
String explanation = message.getExplanation();
try {
checkRestriction(message, UPLOAD);
Set<FileAttribute> requested = message.getRequestedAttributes();
requested.addAll(EnumSet.of(PNFSID, NLINK, SIZE));
Collection<FileAttributes> deletedFiles = _nameSpaceProvider.cancelUpload(subject, message.getUploadPath(), message.getPath(), requested, explanation);
deletedFiles.stream().filter(// currently uploading
f -> f.isUndefined(SIZE)).filter(// with no hard links
f -> f.getNlink() == 1).map(FileAttributes::getPnfsId).forEach(id -> _cancelUploadNotificationTargets.stream().map(CellPath::new).forEach(p -> _stub.notify(p, new DoorCancelledUploadNotificationMessage(subject, id, explanation))));
message.setDeletedFiles(deletedFiles);
message.setSucceeded();
} catch (CacheException e) {
message.setFailed(e.getRc(), e.getMessage());
} catch (RuntimeException e) {
LOGGER.error("Cancel upload path failed", e);
message.setFailed(CacheException.UNEXPECTED_SYSTEM_EXCEPTION, e);
}
}
use of dmg.cells.nucleus.CellPath in project dcache by dCache.
the class PoolStatisticsV0 method getPoolRepositoryStatistics.
//
// expected format from 'rep ls -s -binary'
// Object[*]
// Object [2]
// 0 String <storageClass>
// 1 long[2]
// 0 # of bytes in repository
// 1 # of files in repository
//
private Map<String, Map<String, long[]>> getPoolRepositoryStatistics() throws InterruptedException, NoRouteToCellException, IOException {
LOGGER.info("getPoolRepositoryStatistics : asking PoolManager for cell info");
PoolManagerCellInfo info;
try {
info = _poolManager.sendAndWait(GET_CELL_INFO, PoolManagerCellInfo.class);
} catch (CacheException e) {
throw new IOException(e.getMessage(), e);
}
LOGGER.info("getPoolRepositoryStatistics : PoolManager replied : {}", info);
Map<String, Map<String, long[]>> map = new HashMap<>();
for (Map.Entry<String, CellAddressCore> pool : info.getPoolMap().entrySet()) {
CellAddressCore address = pool.getValue();
try {
LOGGER.info("getPoolRepositoryStatistics : asking {} for statistics", address);
Object[] result = _poolStub.sendAndWait(new CellPath(address), GET_REP_STATISTICS, Object[].class);
Map<String, long[]> classMap = new HashMap<>();
for (Object entry : result) {
Object[] e = (Object[]) entry;
classMap.put((String) e[0], (long[]) e[1]);
}
LOGGER.info("getPoolRepositoryStatistics : {} replied with {}", address, classMap);
map.put(pool.getKey(), classMap);
} catch (InterruptedException ie) {
LOGGER.warn("getPoolRepositoryStatistics : sendAndWait interrupted");
throw ie;
} catch (CacheException e) {
LOGGER.warn("getPoolRepositoryStatistics : {} : {}", address, e.getMessage());
}
}
return map;
}
use of dmg.cells.nucleus.CellPath in project dcache by dCache.
the class PoolStatisticsV0 method starting.
@Override
protected void starting() throws Exception {
Args args = getArgs();
if (args.argc() < 1) {
throw new IllegalArgumentException("Usage : ... <baseDirectory> " + "[-htmlBase=<htmlBase>|none] [-create] [-images=<images>]");
}
_poolManager = new CellStub(this, new CellPath(args.getOption("poolManager")), TimeUnit.MILLISECONDS.convert(args.getLongOption("poolManagerTimeout"), TimeUnit.valueOf(args.getOption("poolManagerTimeoutUnit"))));
_billing = new CellStub(this, new CellPath(args.getOption("billing")), TimeUnit.MILLISECONDS.convert(args.getLongOption("billingTimeout"), TimeUnit.valueOf(args.getOption("billingTimeoutUnit"))));
_poolStub = new CellStub(this, null, TimeUnit.MILLISECONDS.convert(args.getLongOption("poolTimeout"), TimeUnit.valueOf(args.getOption("poolTimeoutUnit"))));
_htmlBase = _dbBase = new File(args.argv(0));
String tmp = args.getOpt("htmlBase");
if ((tmp != null) && (!tmp.isEmpty())) {
if (tmp.equals("none")) {
_createHtmlTree = false;
} else {
_htmlBase = new File(tmp);
}
}
tmp = args.getOpt("domain");
if (tmp != null) {
_domainName = tmp;
}
if (args.hasOption("create")) {
if (!_dbBase.exists()) {
// noinspection ResultOfMethodCallIgnored
_dbBase.mkdirs();
}
if (_createHtmlTree && !_htmlBase.exists()) {
// noinspection ResultOfMethodCallIgnored
_htmlBase.mkdirs();
}
} else {
if ((!_dbBase.exists()) || (_createHtmlTree && !_htmlBase.exists())) {
throw new IllegalArgumentException("Either <baseDirectory> or <htmlBase> doesn't exist");
}
}
}
use of dmg.cells.nucleus.CellPath in project dcache by dCache.
the class TransferManagerHandler method killMover.
public void killMover(int moverId, String explanation) {
LOGGER.debug("sending mover kill to pool {} for moverId={}", pool, moverId);
PoolMoverKillMessage killMessage = new PoolMoverKillMessage(pool.getName(), moverId, "killed by TransferManagerHandler: " + explanation);
killMessage.setReplyRequired(false);
manager.getPoolStub().notify(new CellPath(pool.getAddress()), killMessage);
}
Aggregations