use of diskCacheV111.poolManager.PoolManagerCellInfo in project dcache by dCache.
the class WebCollectorV3 method messageArrived.
@Override
public void messageArrived(CellMessage message) {
Object reply = message.getMessageObject();
int modified = 0;
if (reply instanceof LoginBrokerInfo) {
LoginBrokerInfo brokerInfo = (LoginBrokerInfo) reply;
synchronized (_infoLock) {
LOGGER.debug("Login broker reports: {}@{}", brokerInfo.getCellName(), brokerInfo.getDomainName());
if (addQuery(new CellAddressCore(brokerInfo.getCellName(), brokerInfo.getDomainName()))) {
modified++;
}
}
} else if (reply instanceof PingMessage) {
synchronized (_infoLock) {
addQuery(message.getSourceAddress());
}
} else {
CellPath path = message.getSourcePath();
CellAddressCore address = path.getSourceAddress();
CellQueryInfo info;
synchronized (_infoLock) {
info = _infoMap.get(address);
if (info == null) {
// We may have registered the cell as a well known cell
info = _infoMap.get(new CellAddressCore(address.getCellName()));
if (info == null) {
LOGGER.info("Unexpected reply arrived from: {}", path);
return;
}
}
}
if (reply instanceof CellInfo) {
LOGGER.debug("CellInfo: {}", ((CellInfo) reply).getCellName());
info.infoArrived((CellInfo) reply);
}
if (reply instanceof PoolManagerCellInfo) {
Set<CellAddressCore> pools = ((PoolManagerCellInfo) reply).getPoolCells();
synchronized (_infoLock) {
for (CellAddressCore pool : pools) {
if (addQuery(pool)) {
modified++;
}
}
}
}
}
_sleepHandler.topologyChanged(modified > 0);
}
use of diskCacheV111.poolManager.PoolManagerCellInfo 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 diskCacheV111.poolManager.PoolManagerCellInfo in project dcache by dCache.
the class PoolInfoObserverV3 method collectPoolInfo.
private PoolCellQueryContainer collectPoolInfo(final CellInfoContainer container) throws CacheException, InterruptedException, NoRouteToCellException {
PoolManagerCellInfo poolManagerInfo = _poolManager.sendAndWait("xgetcellinfo", PoolManagerCellInfo.class);
Set<CellAddressCore> pools = poolManagerInfo.getPoolCells();
final PoolCellQueryContainer result = new PoolCellQueryContainer();
final CountDownLatch latch = new CountDownLatch(pools.size());
for (final CellAddressCore pool : pools) {
final long start = System.currentTimeMillis();
Futures.addCallback(_pool.send(new CellPath(pool), "xgetcellinfo", PoolCellInfo.class), new FutureCallback<PoolCellInfo>() {
@Override
public void onSuccess(PoolCellInfo info) {
long now = System.currentTimeMillis();
long ping = now - start;
result.put(info.getCellName(), new PoolCellQueryInfo(info, ping, now));
container.addInfo(info.getCellName(), info);
latch.countDown();
}
@Override
public void onFailure(Throwable t) {
LOGGER.warn("Failed to query {}: {}", pool, t.getMessage());
latch.countDown();
}
});
}
latch.await();
Map<String, Map<String, Map<String, Object>>> allClasses = container.createExternalTopologyMap();
for (Map<String, Map<String, Object>> groupMap : allClasses.values()) {
for (Map<String, Object> tableMap : groupMap.values()) {
for (String poolName : tableMap.keySet()) {
tableMap.put(poolName, result.getInfoByName(poolName));
}
}
}
result.setTopology(allClasses);
return result;
}
Aggregations