use of joynr.types.DiscoveryEntryWithMetaInfo in project joynr by bmwcarit.
the class LastSeenArbitrationStrategyFunction method select.
@Override
public final Set<DiscoveryEntryWithMetaInfo> select(Map<String, String> parameters, final Collection<DiscoveryEntryWithMetaInfo> capabilities) {
logger.trace("starting select Provider by lastSeenDateMs");
DiscoveryEntryWithMetaInfo latestSeenCapability = null;
long latestSeenDateMs = -1L;
for (DiscoveryEntryWithMetaInfo discoveryEntry : capabilities) {
// Search for the provider with the highest lastSeenDateMs
Long lastSeenDateMs = discoveryEntry.getLastSeenDateMs();
logger.trace("Looking at capability with lastSeenDateMs " + lastSeenDateMs);
if (latestSeenDateMs < lastSeenDateMs) {
latestSeenDateMs = lastSeenDateMs;
latestSeenCapability = discoveryEntry;
}
}
logger.trace("capability with lastSeenMs: " + latestSeenDateMs + "\r\n" + latestSeenCapability);
return latestSeenCapability == null ? null : Sets.newHashSet(latestSeenCapability);
}
Aggregations