Search in sources :

Example 1 with DynamicPropertyView

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;
}
Also used : DynamicProperty(com.netflix.config.DynamicProperty) DynamicPropertyView(org.apache.servicecomb.inspector.internal.model.DynamicPropertyView) ArrayList(java.util.ArrayList) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 2 with DynamicPropertyView

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;
}
Also used : LocalDateTime(java.time.LocalDateTime) DynamicPropertyView(org.apache.servicecomb.inspector.internal.model.DynamicPropertyView)

Example 3 with DynamicPropertyView

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"));
}
Also used : PriorityPropertyFactory(org.apache.servicecomb.config.priority.PriorityPropertyFactory) DynamicPropertyView(org.apache.servicecomb.inspector.internal.model.DynamicPropertyView) PriorityPropertyView(org.apache.servicecomb.inspector.internal.model.PriorityPropertyView) Test(org.junit.Test)

Aggregations

DynamicPropertyView (org.apache.servicecomb.inspector.internal.model.DynamicPropertyView)3 DynamicProperty (com.netflix.config.DynamicProperty)1 LocalDateTime (java.time.LocalDateTime)1 ArrayList (java.util.ArrayList)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 PriorityPropertyFactory (org.apache.servicecomb.config.priority.PriorityPropertyFactory)1 PriorityPropertyView (org.apache.servicecomb.inspector.internal.model.PriorityPropertyView)1 Test (org.junit.Test)1