Search in sources :

Example 1 with PoolManagerCellInfo

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);
}
Also used : CellPath(dmg.cells.nucleus.CellPath) CellAddressCore(dmg.cells.nucleus.CellAddressCore) PoolManagerCellInfo(diskCacheV111.poolManager.PoolManagerCellInfo) HashSet(java.util.HashSet) Set(java.util.Set) PoolCellInfo(diskCacheV111.pools.PoolCellInfo) PoolManagerCellInfo(diskCacheV111.poolManager.PoolManagerCellInfo) CellInfo(dmg.cells.nucleus.CellInfo) PingMessage(dmg.cells.network.PingMessage) LoginBrokerInfo(dmg.cells.services.login.LoginBrokerInfo)

Example 2 with PoolManagerCellInfo

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;
}
Also used : CellPath(dmg.cells.nucleus.CellPath) CellAddressCore(dmg.cells.nucleus.CellAddressCore) CacheException(diskCacheV111.util.CacheException) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) IOException(java.io.IOException) PoolManagerCellInfo(diskCacheV111.poolManager.PoolManagerCellInfo) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 3 with PoolManagerCellInfo

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;
}
Also used : CellPath(dmg.cells.nucleus.CellPath) CellAddressCore(dmg.cells.nucleus.CellAddressCore) PoolCellInfo(diskCacheV111.pools.PoolCellInfo) CountDownLatch(java.util.concurrent.CountDownLatch) PoolManagerCellInfo(diskCacheV111.poolManager.PoolManagerCellInfo) Map(java.util.Map)

Aggregations

PoolManagerCellInfo (diskCacheV111.poolManager.PoolManagerCellInfo)3 CellAddressCore (dmg.cells.nucleus.CellAddressCore)3 CellPath (dmg.cells.nucleus.CellPath)3 PoolCellInfo (diskCacheV111.pools.PoolCellInfo)2 Map (java.util.Map)2 CacheException (diskCacheV111.util.CacheException)1 PingMessage (dmg.cells.network.PingMessage)1 CellInfo (dmg.cells.nucleus.CellInfo)1 LoginBrokerInfo (dmg.cells.services.login.LoginBrokerInfo)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 Set (java.util.Set)1 TreeMap (java.util.TreeMap)1 CountDownLatch (java.util.concurrent.CountDownLatch)1