Search in sources :

Example 1 with LoginBrokerInfo

use of dmg.cells.services.login.LoginBrokerInfo in project dcache by dCache.

the class TransferObserverV1 method createDoorPage.

// 
// the html stuff.
// 
private String createDoorPage(Collection<LoginBrokerInfo> doors) {
    HTMLBuilder page = new HTMLBuilder(_nucleus.getDomainContext());
    page.addHeader("/styles/doors.css", "Doors");
    page.beginTable("sortable", "cell", "Cell", "domain", "Domain", "protocol", "Protocol", "version", "Version", "host", "Host", "port", "Port", "load", "Load");
    for (LoginBrokerInfo door : doors) {
        InetAddress address = door.getAddresses().stream().max(Comparator.comparing(NetworkUtils.InetAddressScope::of)).get();
        page.beginRow(null, "odd");
        page.td("cell", door.getCellName());
        page.td("domain", door.getDomainName());
        page.td("protocol", door.getPreferredProtocolFamily());
        page.td("version", door.getProtocolVersion());
        page.td("host", address.getHostName());
        page.td("port", door.getPort());
        page.td("load", (int) (door.getLoad() * 100.0));
        page.endRow();
    }
    page.endTable();
    return page.toString();
}
Also used : HTMLBuilder(diskCacheV111.util.HTMLBuilder) InetAddress(java.net.InetAddress) LoginBrokerInfo(dmg.cells.services.login.LoginBrokerInfo)

Example 2 with LoginBrokerInfo

use of dmg.cells.services.login.LoginBrokerInfo 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 3 with LoginBrokerInfo

use of dmg.cells.services.login.LoginBrokerInfo in project dcache by dCache.

the class Storage method selectDoor.

/**
 * @param doorsByProtocol doors to select from, grouped by protocol
 * @param scope           minimum address scope required
 * @param family          preferred protocol family
 * @param protocols       protocol to select from, ordered by the clients preference
 * @param previousTurl    previous TURL used in the same bulk request
 * @param predicate       additional predicate to filter doors
 * @return A door matching the requirements or null if non match
 */
private LoginBrokerInfo selectDoor(Map<String, Collection<LoginBrokerInfo>> doorsByProtocol, InetAddressScope scope, ProtocolFamily family, List<String> protocols, URI previousTurl, Predicate<LoginBrokerInfo> predicate) {
    /* For DCAP we try to reuse the previous door in bulk requests.
         */
    if (previousTurl != null && previousTurl.getScheme().equals("dcap")) {
        LoginBrokerInfo door = findDoor(doorsByProtocol, previousTurl);
        if (door != null && predicate.apply(door)) {
            return door;
        }
    }
    /* Reduce the set of doors to those that expose the path, support one
         * of the protocols accepted by the client and not disallowed by the
         * server, and support the network "scope" of the client as determined
         * from the client's address.
         */
    Map<String, Iterable<LoginBrokerInfo>> doors = filterValues(filterKeys(doorsByProtocol, protocols::contains), d -> d.supports(scope) && predicate.apply(d));
    /* Attempt to match the protocol family of the SRM client. This is not
         * a hard requirement and we fall back to all families if necessary.
         */
    Map<String, Iterable<LoginBrokerInfo>> filtered = filterValues(doors, d -> d.supports(family));
    if (!filtered.isEmpty()) {
        doors = filtered;
    }
    /* Now choose one of the protocols based on our preferences and the
         * preference of the client.
         */
    String protocol = selectProtocol(doors.keySet(), protocols);
    if (protocol == null) {
        return null;
    }
    /* Now select one of the candidate doors. As our load information is not perfect, we choose
         * randomly from the least loaded doors.
         */
    return selectRandomDoor(doors.get(protocol));
}
Also used : LoginBrokerInfo(dmg.cells.services.login.LoginBrokerInfo)

Example 4 with LoginBrokerInfo

use of dmg.cells.services.login.LoginBrokerInfo in project dcache by dCache.

the class Storage method isLocalSurl.

@Override
public boolean isLocalSurl(URI surl) throws SRMInvalidPathException {
    // hostname or port number: a "Storage File Name" (stFN).
    if (!surl.isAbsolute()) {
        _log.debug("Identifying SURL {} as local: relative", surl);
        return true;
    }
    // Opaque URI means no '//' after '<schema>:', e.g., 'email:support@dcache.org'
    checkValidPath(!surl.isOpaque(), "surl is opaque");
    if (!surl.getScheme().equalsIgnoreCase("srm")) {
        // srmCOPY code calls isLocalSurl on all URIs.
        return false;
    }
    checkValidPath(surl.getHost() != null, "missing host");
    checkValidPath(!CharMatcher.whitespace().matchesAllOf(surl.getHost()), "empty host");
    Collection<LoginBrokerInfo> doors = loginBrokerSource.doors();
    boolean haveSrmDoor = doors.stream().anyMatch(d -> d.supportsProtocol(srmProtocol));
    if (!haveSrmDoor) {
        /*  We have SRM activity without (apparently) any SRM doors.  This
             *  is likely from an SrmManager starting up and attempting to
             *  continue incomplete (for srmBringOnline) or queud activity.
             */
        return true;
    }
    int port = surl.getPort();
    boolean result = false;
    try {
        InetAddress address = InetAddress.getByName(surl.getHost());
        result = doors.stream().anyMatch(i -> (port == -1 || port == i.getPort()) && i.supportsProtocol(srmProtocol) && i.getAddresses().stream().map(InetAddress::getHostAddress).anyMatch(n -> n.equalsIgnoreCase(address.getHostAddress())));
        if (_log.isDebugEnabled() && result == false) {
            StringBuilder sb = new StringBuilder();
            sb.append("Identifying SURL ").append(surl).append(" as non-local: no matching door:\n");
            for (LoginBrokerInfo i : doors) {
                sb.append("    ").append(i.toString()).append(" ");
                if (port != -1 && port != i.getPort()) {
                    sb.append("mismatch on port");
                } else if (!i.supportsProtocol(srmProtocol)) {
                    sb.append("mismatch on family");
                } else if (!i.getAddresses().stream().map(InetAddress::getHostAddress).anyMatch(n -> n.equalsIgnoreCase(address.getHostAddress()))) {
                    sb.append("mismatch on hostip: ");
                    sb.append(i.getAddresses().stream().map(InetAddress::getHostAddress).collect(Collectors.joining(", ")));
                } else {
                    sb.append("unknown reason");
                }
                sb.append('\n');
            }
            _log.debug(sb.toString());
        }
    } catch (UnknownHostException ignored) {
    }
    return result;
}
Also used : Arrays(java.util.Arrays) LoadingCache(com.google.common.cache.LoadingCache) FileIsNewCacheException(diskCacheV111.util.FileIsNewCacheException) Restriction(org.dcache.auth.attributes.Restriction) GetSpaceTokensKey(org.dcache.space.ReservationCaches.GetSpaceTokensKey) Subjects(org.dcache.auth.Subjects) CheckedFuture(com.google.common.util.concurrent.CheckedFuture) PermissionHandler(org.dcache.namespace.PermissionHandler) Restrictions(org.dcache.auth.attributes.Restrictions) InetAddress(java.net.InetAddress) PnfsHandler(diskCacheV111.util.PnfsHandler) PinManagerExtendPinMessage(org.dcache.pinmanager.PinManagerExtendPinMessage) Arrays.asList(java.util.Arrays.asList) PinManagerUnpinMessage(org.dcache.pinmanager.PinManagerUnpinMessage) Map(java.util.Map) TRetentionPolicyInfo(org.dcache.srm.v2_2.TRetentionPolicyInfo) SIZE(org.dcache.namespace.FileAttribute.SIZE) SRMException(org.dcache.srm.SRMException) EnumSet(java.util.EnumSet) CDC(dmg.cells.nucleus.CDC) PrintWriter(java.io.PrintWriter) TransferManagerMessage(diskCacheV111.vehicles.transferManager.TransferManagerMessage) CancellationException(java.util.concurrent.CancellationException) PNFSID(org.dcache.namespace.FileAttribute.PNFSID) Range(com.google.common.collect.Range) FileExistsCacheException(diskCacheV111.util.FileExistsCacheException) Set(java.util.Set) DirectoryStream(org.dcache.util.list.DirectoryStream) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) IpProtocolInfo(diskCacheV111.vehicles.IpProtocolInfo) DirectoryEntry(org.dcache.util.list.DirectoryEntry) Space(diskCacheV111.services.space.Space) AbstractCellComponent(dmg.cells.nucleus.AbstractCellComponent) Predicate(com.google.common.base.Predicate) PnfsCommitUpload(diskCacheV111.vehicles.PnfsCommitUpload) SRMNotSupportedException(org.dcache.srm.SRMNotSupportedException) Attributes(javax.naming.directory.Attributes) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) SRMInvalidPathException(org.dcache.srm.SRMInvalidPathException) Iterables.filter(com.google.common.collect.Iterables.filter) NullListPrinter(org.dcache.util.list.NullListPrinter) PnfsCreateUploadPath(diskCacheV111.vehicles.PnfsCreateUploadPath) TStatusCode(org.dcache.srm.v2_2.TStatusCode) Joiner(com.google.common.base.Joiner) Release(diskCacheV111.services.space.message.Release) NetworkUtils.isInetAddress(org.dcache.util.NetworkUtils.isInetAddress) FsPath(diskCacheV111.util.FsPath) SRMAbortedException(org.dcache.srm.SRMAbortedException) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) MINUTES(java.util.concurrent.TimeUnit.MINUTES) RemoteGsiftpTransferProtocolInfo(diskCacheV111.vehicles.transferManager.RemoteGsiftpTransferProtocolInfo) LoginBrokerInfo(dmg.cells.services.login.LoginBrokerInfo) ChainedPermissionHandler(org.dcache.namespace.ChainedPermissionHandler) CopyCallbacks(org.dcache.srm.CopyCallbacks) FileMetaData(org.dcache.srm.FileMetaData) ArrayList(java.util.ArrayList) InitialDirContext(javax.naming.directory.InitialDirContext) AbstractStorageElement(org.dcache.srm.AbstractStorageElement) NotDirCacheException(diskCacheV111.util.NotDirCacheException) CellStub(org.dcache.cells.CellStub) TYPE(org.dcache.namespace.FileAttribute.TYPE) RemoveFileCallback(org.dcache.srm.RemoveFileCallback) InetAddressScope(org.dcache.util.NetworkUtils.InetAddressScope) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) FileType(org.dcache.namespace.FileType) Futures.immediateFailedCheckedFuture(com.google.common.util.concurrent.Futures.immediateFailedCheckedFuture) PnfsId(diskCacheV111.util.PnfsId) Maps.filterKeys(com.google.common.collect.Maps.filterKeys) Iterables.isEmpty(com.google.common.collect.Iterables.isEmpty) SrmReleaseSpaceCallback(org.dcache.srm.SrmReleaseSpaceCallback) Executor(java.util.concurrent.Executor) LOCATIONS(org.dcache.namespace.FileAttribute.LOCATIONS) CharMatcher(com.google.common.base.CharMatcher) DirContext(javax.naming.directory.DirContext) Throwables(com.google.common.base.Throwables) UnsignedLong(org.apache.axis.types.UnsignedLong) SpaceState(diskCacheV111.services.space.SpaceState) UnknownHostException(java.net.UnknownHostException) ExecutionException(java.util.concurrent.ExecutionException) AtomicLong(java.util.concurrent.atomic.AtomicLong) Futures(com.google.common.util.concurrent.Futures) Reserve(diskCacheV111.services.space.message.Reserve) RemoteHttpDataTransferProtocolInfo(diskCacheV111.vehicles.RemoteHttpDataTransferProtocolInfo) FileAttribute(org.dcache.namespace.FileAttribute) SRMInvalidPathException.checkValidPath(org.dcache.srm.SRMInvalidPathException.checkValidPath) LoginBrokerSource(dmg.cells.services.login.LoginBrokerSource) SIMPLE_TYPE(org.dcache.namespace.FileAttribute.SIMPLE_TYPE) CancelTransferMessage(diskCacheV111.vehicles.transferManager.CancelTransferMessage) PosixPermissionHandler(org.dcache.namespace.PosixPermissionHandler) TAccessLatency(org.dcache.srm.v2_2.TAccessLatency) AccessLatency(diskCacheV111.util.AccessLatency) URISyntaxException(java.net.URISyntaxException) LoggerFactory(org.slf4j.LoggerFactory) Random(java.util.Random) NamingException(javax.naming.NamingException) SettableFuture(com.google.common.util.concurrent.SettableFuture) URIs(org.dcache.util.URIs) PnfsCancelUpload(diskCacheV111.vehicles.PnfsCancelUpload) Attribute(javax.naming.directory.Attribute) AccessType(org.dcache.acl.enums.AccessType) AbstractMessageCallback(org.dcache.cells.AbstractMessageCallback) SRMNonEmptyDirectoryException(org.dcache.srm.SRMNonEmptyDirectoryException) DirectoryListSource(org.dcache.util.list.DirectoryListSource) RemoteTransferManagerMessage(diskCacheV111.vehicles.transferManager.RemoteTransferManagerMessage) URI(java.net.URI) FileAttributes(org.dcache.vehicles.FileAttributes) Function(com.google.common.base.Function) CellMessageReceiver(dmg.cells.nucleus.CellMessageReceiver) SRMDuplicationException(org.dcache.srm.SRMDuplicationException) ImmutableMap(com.google.common.collect.ImmutableMap) GetSpaceMetaData(diskCacheV111.services.space.message.GetSpaceMetaData) Configuration(org.dcache.srm.util.Configuration) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) PinningActivityPolicy(diskCacheV111.srm.dcache.PinCompanion.PinningActivityPolicy) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException) InetSocketAddress(java.net.InetSocketAddress) Collectors(java.util.stream.Collectors) SRMSpaceLifetimeExpiredException(org.dcache.srm.SRMSpaceLifetimeExpiredException) CreateOption(org.dcache.namespace.CreateOption) CacheLoader(com.google.common.cache.CacheLoader) Objects(java.util.Objects) FileLocality(diskCacheV111.util.FileLocality) List(java.util.List) NamingEnumeration(javax.naming.NamingEnumeration) Optional(java.util.Optional) NetworkUtils(org.dcache.util.NetworkUtils) DoorRequestInfoMessage(diskCacheV111.vehicles.DoorRequestInfoMessage) CacheBuilder(com.google.common.cache.CacheBuilder) CellPath(dmg.cells.nucleus.CellPath) X509Credential(eu.emi.security.authn.x509.X509Credential) RetentionPolicy(diskCacheV111.util.RetentionPolicy) CellInfoProvider(dmg.cells.nucleus.CellInfoProvider) TransferFailedMessage(diskCacheV111.vehicles.transferManager.TransferFailedMessage) SRMInternalErrorException(org.dcache.srm.SRMInternalErrorException) RequestCredential(org.dcache.srm.request.RequestCredential) ProtocolFamily(java.net.ProtocolFamily) RemoteHttpsDataTransferProtocolInfo(diskCacheV111.vehicles.RemoteHttpsDataTransferProtocolInfo) HashMap(java.util.HashMap) TRetentionPolicy(org.dcache.srm.v2_2.TRetentionPolicy) TransferCompleteMessage(diskCacheV111.vehicles.transferManager.TransferCompleteMessage) PoolMonitorV5(diskCacheV111.poolManager.PoolMonitorV5) SRMExceedAllocationException(org.dcache.srm.SRMExceedAllocationException) SrmReserveSpaceCallback(org.dcache.srm.SrmReserveSpaceCallback) CacheException(diskCacheV111.util.CacheException) SRMInvalidRequestException(org.dcache.srm.SRMInvalidRequestException) Nonnull(javax.annotation.Nonnull) FileCorruptedCacheException(diskCacheV111.util.FileCorruptedCacheException) STORAGEINFO(org.dcache.namespace.FileAttribute.STORAGEINFO) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) TMetaDataSpace(org.dcache.srm.v2_2.TMetaDataSpace) Semaphore(java.util.concurrent.Semaphore) CacheEntryInfoMessage(org.dcache.vehicles.pool.CacheEntryInfoMessage) SRMUser(org.dcache.srm.SRMUser) PinManagerPinMessage(org.dcache.pinmanager.PinManagerPinMessage) SRMAuthorizationException(org.dcache.srm.SRMAuthorizationException) DirectoryListPrinter(org.dcache.util.list.DirectoryListPrinter) Maps(com.google.common.collect.Maps) Subject(javax.security.auth.Subject) ACLPermissionHandler(org.dcache.namespace.ACLPermissionHandler) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) PoolMonitor(org.dcache.poolmanager.PoolMonitor) Ordering(com.google.common.collect.Ordering) CopyManagerMessage(diskCacheV111.vehicles.CopyManagerMessage) GetFileSpaceTokensMessage(diskCacheV111.services.space.message.GetFileSpaceTokensMessage) Origin(org.dcache.auth.Origin) AccessMask(org.dcache.acl.enums.AccessMask) Required(org.springframework.beans.factory.annotation.Required) Comparator(java.util.Comparator) UnknownHostException(java.net.UnknownHostException) InetAddress(java.net.InetAddress) NetworkUtils.isInetAddress(org.dcache.util.NetworkUtils.isInetAddress) LoginBrokerInfo(dmg.cells.services.login.LoginBrokerInfo)

Example 5 with LoginBrokerInfo

use of dmg.cells.services.login.LoginBrokerInfo in project dcache by dCache.

the class Storage method findDoor.

/**
 * Attempts to locate the door referred to in the given uri.
 */
private LoginBrokerInfo findDoor(Map<String, Collection<LoginBrokerInfo>> doorsByProtocol, URI uri) {
    try {
        String protocol = uri.getScheme();
        String host = uri.getHost();
        int port = uri.getPort();
        InetAddress address = InetAddress.getByName(host);
        for (LoginBrokerInfo door : doorsByProtocol.get(protocol)) {
            if (door.getAddresses().contains(address) && door.getPort() == port) {
                return door;
            }
        }
    } catch (UnknownHostException ignored) {
    }
    return null;
}
Also used : UnknownHostException(java.net.UnknownHostException) InetAddress(java.net.InetAddress) NetworkUtils.isInetAddress(org.dcache.util.NetworkUtils.isInetAddress) LoginBrokerInfo(dmg.cells.services.login.LoginBrokerInfo)

Aggregations

LoginBrokerInfo (dmg.cells.services.login.LoginBrokerInfo)8 InetAddress (java.net.InetAddress)5 CellPath (dmg.cells.nucleus.CellPath)4 Joiner (com.google.common.base.Joiner)3 Throwables (com.google.common.base.Throwables)3 HashMap (java.util.HashMap)3 ExecutionException (java.util.concurrent.ExecutionException)3 CharMatcher (com.google.common.base.CharMatcher)2 Function (com.google.common.base.Function)2 Predicate (com.google.common.base.Predicate)2 CacheBuilder (com.google.common.cache.CacheBuilder)2 CacheLoader (com.google.common.cache.CacheLoader)2 LoadingCache (com.google.common.cache.LoadingCache)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 Iterables.filter (com.google.common.collect.Iterables.filter)2 Iterables.isEmpty (com.google.common.collect.Iterables.isEmpty)2 Maps (com.google.common.collect.Maps)2 Maps.filterKeys (com.google.common.collect.Maps.filterKeys)2 Ordering (com.google.common.collect.Ordering)2 TransferInfo (diskCacheV111.util.TransferInfo)2