Search in sources :

Example 6 with BounceProxyStatusInformation

use of io.joynr.messaging.info.BounceProxyStatusInformation in project joynr by bmwcarit.

the class BounceProxyEhcacheAdapterTest method testUpdateChannelAssignmentForAlreadyAssignedChannel.

@Test
public void testUpdateChannelAssignmentForAlreadyAssignedChannel() {
    ControlledBounceProxyInformation bpInfo1 = new ControlledBounceProxyInformation("bp1.0", URI.create("http://www.joynr1.de/bp1/"));
    cache.addBounceProxy(bpInfo1);
    cache.updateChannelAssignment("channel-123", bpInfo1);
    List<BounceProxyStatusInformation> assignableBounceProxies = cache.getBounceProxyStatusInformation();
    assertEquals(1, assignableBounceProxies.size());
    BounceProxyRecord bpRecord1 = cache.getBounceProxy("bp1.0");
    assertEquals("bp1.0", bpRecord1.getBounceProxyId());
    assertEquals(1, bpRecord1.getNumberOfAssignedChannels());
    cache.updateChannelAssignment("channel-123", bpInfo1);
    bpRecord1 = cache.getBounceProxy("bp1.0");
    assertEquals("bp1.0", bpRecord1.getBounceProxyId());
    assertEquals(1, bpRecord1.getNumberOfAssignedChannels());
}
Also used : BounceProxyRecord(io.joynr.messaging.bounceproxy.controller.directory.BounceProxyRecord) BounceProxyStatusInformation(io.joynr.messaging.info.BounceProxyStatusInformation) ControlledBounceProxyInformation(io.joynr.messaging.info.ControlledBounceProxyInformation) Test(org.junit.Test)

Example 7 with BounceProxyStatusInformation

use of io.joynr.messaging.info.BounceProxyStatusInformation in project joynr by bmwcarit.

the class BounceProxyEhcacheAdapter method getBounceProxyStatusInformation.

@Override
public List<BounceProxyStatusInformation> getBounceProxyStatusInformation() {
    if (log.isTraceEnabled()) {
        log.trace("getBounceProxyStatusInformation from cache {}", cacheName);
        tracePeers();
    }
    List<BounceProxyStatusInformation> result = new LinkedList<BounceProxyStatusInformation>();
    Cache cache = manager.getCache(cacheName);
    @SuppressWarnings("rawtypes") List keys = cache.getKeys();
    Map<Object, Element> elements = cache.getAll(keys);
    for (Element element : elements.values()) {
        result.add(getBounceProxyRecordFromElement(element));
    }
    return result;
}
Also used : Element(net.sf.ehcache.Element) BounceProxyStatusInformation(io.joynr.messaging.info.BounceProxyStatusInformation) List(java.util.List) LinkedList(java.util.LinkedList) LinkedList(java.util.LinkedList) Cache(net.sf.ehcache.Cache)

Aggregations

BounceProxyStatusInformation (io.joynr.messaging.info.BounceProxyStatusInformation)7 ControlledBounceProxyInformation (io.joynr.messaging.info.ControlledBounceProxyInformation)5 Test (org.junit.Test)5 BounceProxyRecord (io.joynr.messaging.bounceproxy.controller.directory.BounceProxyRecord)4 LinkedList (java.util.LinkedList)2 BounceProxyEntity (io.joynr.messaging.bounceproxy.controller.directory.jdbc.entities.BounceProxyEntity)1 List (java.util.List)1 Cache (net.sf.ehcache.Cache)1 Element (net.sf.ehcache.Element)1