Search in sources :

Example 66 with DiscoveryEntryWithMetaInfo

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);
}
Also used : DiscoveryEntryWithMetaInfo(joynr.types.DiscoveryEntryWithMetaInfo)

Aggregations

DiscoveryEntryWithMetaInfo (joynr.types.DiscoveryEntryWithMetaInfo)66 Test (org.junit.Test)32 Version (joynr.types.Version)29 ProviderQos (joynr.types.ProviderQos)24 DiscoveryEntry (joynr.types.DiscoveryEntry)16 HashSet (java.util.HashSet)14 GlobalDiscoveryEntry (joynr.types.GlobalDiscoveryEntry)13 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)11 Matchers.anyString (org.mockito.Matchers.anyString)10 InvocationOnMock (org.mockito.invocation.InvocationOnMock)10 ChannelAddress (joynr.system.RoutingTypes.ChannelAddress)9 Before (org.junit.Before)9 DiscoveryException (io.joynr.exceptions.DiscoveryException)7 MessagingQos (io.joynr.messaging.MessagingQos)7 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)7 Set (java.util.Set)7 Callback (io.joynr.proxy.Callback)6 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)5 Collection (java.util.Collection)5