Search in sources :

Example 16 with ControlledBounceProxyInformation

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

the class DatabasesTest method testGetBounceProxyStatusInformation.

@Test
public void testGetBounceProxyStatusInformation() {
    ControlledBounceProxyInformation bpInfo1 = new ControlledBounceProxyInformation("bp1.0", URI.create("http://www.joynr1.de/bp1/"));
    Mockito.when(mockTimestampProvider.getCurrentTime()).thenReturn(1000l);
    bounceProxyDb.addBounceProxy(bpInfo1);
    List<BounceProxyStatusInformation> bpList = bounceProxyDb.getBounceProxyStatusInformation();
    Assert.assertEquals(1, bpList.size());
    BounceProxyStatusInformation bpInfo = bpList.get(0);
    Assert.assertEquals("bp1.0", bpInfo.getBounceProxyId());
    Assert.assertEquals(1000l, bpInfo.getFreshness().getTime());
    Assert.assertEquals(BounceProxyStatus.ALIVE, bpInfo.getStatus());
}
Also used : BounceProxyStatusInformation(io.joynr.messaging.info.BounceProxyStatusInformation) ControlledBounceProxyInformation(io.joynr.messaging.info.ControlledBounceProxyInformation) Test(org.junit.Test)

Example 17 with ControlledBounceProxyInformation

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

the class BounceProxyRecordTest method testCreation.

@Test
public void testCreation() {
    ControlledBounceProxyInformation info = new ControlledBounceProxyInformation("X.Y", URI.create("http://www.testuri.com/test"));
    BounceProxyRecord record = new BounceProxyRecord(info);
    assertEquals(info, record.getInfo());
    assertEquals(0, record.getNumberOfAssignedChannels());
    assertEquals(BounceProxyRecord.ASSIGNMENT_TIMESTAMP_NEVER, record.getLastAssignedTimestamp());
    assertEquals(BounceProxyStatus.ALIVE, record.getStatus());
}
Also used : ControlledBounceProxyInformation(io.joynr.messaging.info.ControlledBounceProxyInformation) Test(org.junit.Test)

Example 18 with ControlledBounceProxyInformation

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

the class ChannelServiceImpl method createChannel.

/*
     * (non-Javadoc)
     * 
     * @see
     * io.joynr.messaging.service.ChannelServiceDelegate#createChannel(java.
     * lang.String, java.lang.String)
     */
@Override
public Channel createChannel(String ccid, String trackingId) {
    try {
        // The controller has to assign the channel to a bounce proxy
        // instance.
        ControlledBounceProxyInformation bpInfo = strategy.calculateBounceProxy(ccid);
        URI channelLocation = bpFacade.createChannel(bpInfo, ccid, trackingId);
        Channel channel = new Channel(bpInfo, ccid, channelLocation);
        channelDirectory.addChannel(channel);
        bounceProxyDirectory.updateChannelAssignment(ccid, bpInfo);
        return channel;
    } catch (Exception e) {
        log.error("Could not create channel on bounce proxy: channel {}, error: {}", ccid, e.getMessage());
        throw new JoynrRuntimeException("Error creating channel on bounce proxy", e);
    }
}
Also used : Channel(io.joynr.messaging.info.Channel) ControlledBounceProxyInformation(io.joynr.messaging.info.ControlledBounceProxyInformation) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) URI(java.net.URI) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) JoynrCommunicationException(io.joynr.exceptions.JoynrCommunicationException)

Example 19 with ControlledBounceProxyInformation

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

the class InMemoryBounceProxyDirectoryTest method testUpdateFreshness.

@Test
public void testUpdateFreshness() {
    Mockito.when(mockTimestampProvider.getCurrentTime()).thenReturn(150l);
    directory.addBounceProxy(new ControlledBounceProxyInformation("X.Y", URI.create("http://www.location.de")));
    assertEquals(150, directory.getBounceProxy("X.Y").getFreshness().getTime());
}
Also used : ControlledBounceProxyInformation(io.joynr.messaging.info.ControlledBounceProxyInformation) Test(org.junit.Test)

Example 20 with ControlledBounceProxyInformation

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

the class InMemoryBounceProxyDirectoryTest method testUpdateBounceProxyPerformance.

@Test
public void testUpdateBounceProxyPerformance() {
    Mockito.when(mockTimestampProvider.getCurrentTime()).thenReturn(100l);
    directory.addBounceProxy(new ControlledBounceProxyInformation("X.Y", URI.create("http://www.location.de")));
    BounceProxyRecord bounceProxyRecord = directory.getBounceProxy("X.Y");
    PerformanceMeasures performanceMeasures = new PerformanceMeasures();
    performanceMeasures.addMeasure(Key.ACTIVE_LONGPOLL_COUNT, 5);
    performanceMeasures.addMeasure(Key.ASSIGNED_CHANNELS_COUNT, 13);
    bounceProxyRecord.setPerformanceMeasures(performanceMeasures);
    Mockito.when(mockTimestampProvider.getCurrentTime()).thenReturn(200l);
    directory.updateBounceProxy(bounceProxyRecord);
    PerformanceMeasures result = directory.getBounceProxy("X.Y").getPerformanceMeasures();
    assertEquals(5, result.getMeasure(Key.ACTIVE_LONGPOLL_COUNT));
    assertEquals(13, result.getMeasure(Key.ASSIGNED_CHANNELS_COUNT));
    assertEquals(200, directory.getBounceProxy("X.Y").getFreshness().getTime());
}
Also used : PerformanceMeasures(io.joynr.messaging.info.PerformanceMeasures) ControlledBounceProxyInformation(io.joynr.messaging.info.ControlledBounceProxyInformation) Test(org.junit.Test)

Aggregations

ControlledBounceProxyInformation (io.joynr.messaging.info.ControlledBounceProxyInformation)47 Test (org.junit.Test)44 BounceProxyRecord (io.joynr.messaging.bounceproxy.controller.directory.BounceProxyRecord)13 IsCreateChannelHttpRequest (io.joynr.messaging.bounceproxy.IsCreateChannelHttpRequest)5 JoynrProtocolException (io.joynr.messaging.bounceproxy.controller.exception.JoynrProtocolException)5 BounceProxyStatusInformation (io.joynr.messaging.info.BounceProxyStatusInformation)5 Channel (io.joynr.messaging.info.Channel)5 HttpResponse (org.apache.http.HttpResponse)5 HttpContext (org.apache.http.protocol.HttpContext)5 URI (java.net.URI)4 BounceProxyInformation (io.joynr.messaging.info.BounceProxyInformation)2 BounceProxyStatus (io.joynr.messaging.info.BounceProxyStatus)2 PerformanceMeasures (io.joynr.messaging.info.PerformanceMeasures)2 JoynrCommunicationException (io.joynr.exceptions.JoynrCommunicationException)1 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)1 IOException (java.io.IOException)1 EntityManager (javax.persistence.EntityManager)1 EntityTransaction (javax.persistence.EntityTransaction)1 Query (javax.persistence.Query)1 HttpException (org.apache.http.HttpException)1