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();
}
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);
}
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));
}
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;
}
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;
}
Aggregations