use of io.joynr.messaging.bounceproxy.controller.directory.BounceProxyRecord in project joynr by bmwcarit.
the class BounceProxyEhcacheAdapter method getBounceProxyRecordFromElement.
protected BounceProxyRecord getBounceProxyRecordFromElement(Element element) {
BounceProxyRecord bpRecord = (BounceProxyRecord) element.getObjectValue();
bpRecord.setFreshness(element.getLatestOfCreationAndUpdateTime());
return bpRecord;
}
use of io.joynr.messaging.bounceproxy.controller.directory.BounceProxyRecord in project joynr by bmwcarit.
the class BounceProxyEhcacheAdapter method updateChannelAssignment.
@Override
public void updateChannelAssignment(String ccid, BounceProxyInformation bpInfo) throws IllegalArgumentException {
if (log.isTraceEnabled()) {
log.trace("Update channel assignment for bounce proxy {} in cache {}", bpInfo.getId(), cacheName);
tracePeers();
}
Cache cache = manager.getCache(cacheName);
Element element = cache.get(bpInfo.getId());
if (element == null) {
throw new IllegalArgumentException("No bounce proxy with ID '" + bpInfo.getId() + "' exists");
}
BounceProxyRecord bpRecord = getBounceProxyRecordFromElement(element);
bpRecord.addAssignedChannel(ccid);
Element updatedElement = new Element(bpInfo.getId(), bpRecord);
cache.put(updatedElement);
}
use of io.joynr.messaging.bounceproxy.controller.directory.BounceProxyRecord in project joynr by bmwcarit.
the class RoundRobinAssignmentTest method testAssignmentToUnassignedBounceProxySmallTimestamps.
@Test
public void testAssignmentToUnassignedBounceProxySmallTimestamps() {
LinkedList<BounceProxyRecord> bpList = new LinkedList<BounceProxyRecord>();
bpList.add(createBounceProxyRecordWithChannels("X1.Y1", 2, 2l));
bpList.add(createBounceProxyRecordWithChannels("X2.Y2", 3, 3l));
bpList.add(createBounceProxyRecord("X3.Y3"));
Mockito.when(directoryMock.getAssignableBounceProxies()).thenReturn(bpList);
BounceProxyInformation bounceProxy = assignmentStrategy.calculateBounceProxy("channel-123");
Assert.assertEquals("X3.Y3", bounceProxy.getId());
Mockito.verify(directoryMock, Mockito.never()).updateChannelAssignment("channel-123", bounceProxy);
}
use of io.joynr.messaging.bounceproxy.controller.directory.BounceProxyRecord in project joynr by bmwcarit.
the class RoundRobinAssignmentTest method testAssignmentToUnassignedBounceProxy.
@Test
public void testAssignmentToUnassignedBounceProxy() {
LinkedList<BounceProxyRecord> bpList = new LinkedList<BounceProxyRecord>();
bpList.add(createBounceProxyRecordWithChannels("X1.Y1", 2, 23456456456l));
bpList.add(createBounceProxyRecordWithChannels("X2.Y2", 3, 19837453453l));
bpList.add(createBounceProxyRecord("X3.Y3"));
Mockito.when(directoryMock.getAssignableBounceProxies()).thenReturn(bpList);
BounceProxyInformation bounceProxy = assignmentStrategy.calculateBounceProxy("channel-123");
Assert.assertEquals("X3.Y3", bounceProxy.getId());
Mockito.verify(directoryMock, Mockito.never()).updateChannelAssignment("channel-123", bounceProxy);
}
use of io.joynr.messaging.bounceproxy.controller.directory.BounceProxyRecord in project joynr by bmwcarit.
the class RoundRobinAssignmentTest method createBounceProxyRecordWithChannels.
private BounceProxyRecord createBounceProxyRecordWithChannels(String bpId, int noOfAssignedChannels, long lastAssignedTimestamp) {
BounceProxyRecord record = createBounceProxyRecord(bpId);
for (int i = 0; i < noOfAssignedChannels; i++) {
record.addAssignedChannel("channel-" + bpId + "-" + 1);
}
record.setLastAssignedTimestamp(lastAssignedTimestamp);
return record;
}
Aggregations