use of io.joynr.messaging.info.PerformanceMeasures in project joynr by bmwcarit.
the class MonitoringServiceImplTest method testUpdatePerformanceMeasures.
@Test
public void testUpdatePerformanceMeasures() {
Mockito.when(bpDirectoryMock.containsBounceProxy("X.Y")).thenReturn(true);
Mockito.when(bpDirectoryMock.getBounceProxy("X.Y")).thenReturn(new BounceProxyRecord(new ControlledBounceProxyInformation("X.Y", null)));
PerformanceMeasures performanceMeasures = new PerformanceMeasures();
performanceMeasures.addMeasure(Key.ACTIVE_LONGPOLL_COUNT, 5);
monitoringService.updatePerformanceMeasures("X.Y", performanceMeasures);
ArgumentCaptor<BounceProxyRecord> argument = ArgumentCaptor.forClass(BounceProxyRecord.class);
Mockito.verify(bpDirectoryMock).updateBounceProxy(argument.capture());
Assert.assertEquals("X.Y", argument.getValue().getBounceProxyId());
Assert.assertEquals(5, argument.getValue().getPerformanceMeasures().getMeasure(Key.ACTIVE_LONGPOLL_COUNT));
Assert.assertEquals(BounceProxyStatus.ACTIVE, argument.getValue().getStatus());
}
use of io.joynr.messaging.info.PerformanceMeasures 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());
}
use of io.joynr.messaging.info.PerformanceMeasures in project joynr by bmwcarit.
the class MonitoringServiceRestAdapter method reportPerformance.
/**
* Refreshes the performance measures of a bounce proxy instance, e.g.
* active long polls.
*
* @param bpId
* the identifier of the bounce proxy
* @param performanceMap
* key-value pairs of performance measures
* @return empty response
*/
@POST
@Path("/{bpid: ([A-Z,a-z,0-9,_,\\-]+)(\\.)([A-Z,a-z,0-9,_,\\-]+)}/performance")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.TEXT_PLAIN })
public Response reportPerformance(@PathParam("bpid") String bpId, Map<String, Integer> performanceMap) {
if (!monitoringService.isRegistered(bpId)) {
throw new JoynrHttpException(Status.BAD_REQUEST, JoynrBounceProxyControlErrorCode.BOUNCEPROXY_UNKNOWN, "bounce proxy '" + bpId + "'");
}
PerformanceMeasures performanceMeasures = new PerformanceMeasures();
performanceMeasures.addMeasures(performanceMap);
monitoringService.updatePerformanceMeasures(bpId, performanceMeasures);
return Response.noContent().build();
}
use of io.joynr.messaging.info.PerformanceMeasures in project joynr by bmwcarit.
the class BounceProxyInstanceLifeCycleTest method testReportPerformanceWithUnknownMeasureName.
@Test
public void testReportPerformanceWithUnknownMeasureName() {
Mockito.when(mock.isRegistered("0.0")).thenReturn(true);
//
Response response = //
given().when().contentType(ContentType.JSON).body("{ \"active\" : 5 }").post(serverUrl + "0.0/performance");
assertEquals(204, /* No Content */
response.getStatusCode());
Mockito.verify(mock).updatePerformanceMeasures("0.0", new PerformanceMeasures());
Mockito.verify(mock).isRegistered("0.0");
Mockito.verifyNoMoreInteractions(mock);
}
Aggregations