use of org.apache.servicecomb.inspector.internal.model.DynamicPropertyView in project java-chassis by ServiceComb.
the class InspectorImpl method dynamicProperties.
@Path("/dynamicProperties")
@GET
public List<DynamicPropertyView> dynamicProperties() {
List<DynamicPropertyView> views = new ArrayList<>();
for (DynamicProperty property : ConfigUtil.getAllDynamicProperties().values()) {
views.add(createDynamicPropertyView(property));
}
// show more callback first, because maybe there is memory leak problem
// show recently changed second
// and sort by key
views.sort(Comparator.comparing(DynamicPropertyView::getCallbackCount).thenComparing(DynamicPropertyView::getChangedTime).reversed().thenComparing(DynamicPropertyView::getKey));
return views;
}
use of org.apache.servicecomb.inspector.internal.model.DynamicPropertyView in project java-chassis by ServiceComb.
the class InspectorImpl method createDynamicPropertyView.
private DynamicPropertyView createDynamicPropertyView(DynamicProperty property) {
DynamicPropertyView view = new DynamicPropertyView();
view.setKey(property.getName());
view.setValue(property.getString());
if (property.getChangedTimestamp() != 0) {
LocalDateTime localDatetime = LocalDateTime.ofInstant(Instant.ofEpochMilli(property.getChangedTimestamp()), ZoneId.systemDefault());
view.setChangedTime(localDatetime.format(FORMATTER));
}
view.setCallbackCount(ConfigUtil.getCallbacks(property).size());
return view;
}
use of org.apache.servicecomb.inspector.internal.model.DynamicPropertyView in project java-chassis by ServiceComb.
the class TestInspectorImpl method priorityProperties.
@Test
public void priorityProperties() {
PriorityPropertyFactory propertyFactory = new PriorityPropertyFactory();
inspector.setPropertyFactory(propertyFactory);
propertyFactory.getOrCreate(int.class, 0, 0, "high", "low");
List<PriorityPropertyView> views = inspector.priorityProperties();
Assert.assertEquals(1, views.size());
Assert.assertThat(views.get(0).getDynamicProperties().stream().map(DynamicPropertyView::getKey).collect(Collectors.toList()), Matchers.contains("high", "low"));
}
Aggregations