use of org.apache.ignite.spi.systemview.view.BaselineNodeAttributeView in project ignite by apache.
the class SystemViewSelfTest method testBaselineNodeAttributes.
/**
*/
@Test
public void testBaselineNodeAttributes() throws Exception {
cleanPersistenceDir();
try (IgniteEx ignite = startGrid(getConfiguration().setDataStorageConfiguration(new DataStorageConfiguration().setDefaultDataRegionConfiguration(new DataRegionConfiguration().setName("pds").setPersistenceEnabled(true))).setUserAttributes(F.asMap("name", "val")).setConsistentId("consId"))) {
ignite.cluster().state(ClusterState.ACTIVE);
SystemView<BaselineNodeAttributeView> view = ignite.context().systemView().view(BASELINE_NODE_ATTRIBUTES_SYS_VIEW);
assertEquals(ignite.cluster().localNode().attributes().size(), view.size());
assertEquals(1, F.size(view.iterator(), row -> "consId".equals(row.nodeConsistentId()) && "name".equals(row.name()) && "val".equals(row.value())));
// Test filtering.
assertTrue(view instanceof FiltrableSystemView);
Iterator<BaselineNodeAttributeView> iter = ((FiltrableSystemView<BaselineNodeAttributeView>) view).iterator(F.asMap(BaselineNodeAttributeViewWalker.NODE_CONSISTENT_ID_FILTER, "consId", BaselineNodeAttributeViewWalker.NAME_FILTER, "name"));
assertEquals(1, F.size(iter));
iter = ((FiltrableSystemView<BaselineNodeAttributeView>) view).iterator(F.asMap(BaselineNodeAttributeViewWalker.NODE_CONSISTENT_ID_FILTER, "consId"));
assertEquals(1, F.size(iter, row -> "name".equals(row.name())));
iter = ((FiltrableSystemView<BaselineNodeAttributeView>) view).iterator(F.asMap(BaselineNodeAttributeViewWalker.NAME_FILTER, "name"));
assertEquals(1, F.size(iter));
}
}
Aggregations