use of org.opensearch.ml.stats.suppliers.SettableSupplier in project ml-commons by opensearch-project.
the class MLStatsNodesTransportActionTests method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
clusterStatName1 = "clusterStat1";
nodeStatName1 = "nodeStat1";
statsMap = new HashMap<String, MLStat<?>>() {
{
put(nodeStatName1, new MLStat<>(false, new CounterSupplier()));
put(clusterStatName1, new MLStat<>(true, new CounterSupplier()));
put(InternalStatNames.JVM_HEAP_USAGE.getName(), new MLStat<>(true, new SettableSupplier()));
}
};
mlStats = new MLStats(statsMap);
Environment environment = mock(Environment.class);
Settings settings = Settings.builder().build();
when(environment.settings()).thenReturn(settings);
action = new MLStatsNodesTransportAction(client().threadPool(), clusterService(), mock(TransportService.class), mock(ActionFilters.class), mlStats, environment);
}
use of org.opensearch.ml.stats.suppliers.SettableSupplier in project ml-commons by opensearch-project.
the class MLStatTests method testSetGetValue.
public void testSetGetValue() {
MLStat<Long> stat1 = new MLStat<>(false, new CounterSupplier());
Assert.assertEquals("GetValue returns the incorrect value", 0L, (long) (stat1.getValue()));
stat1.setValue(1L);
Assert.assertEquals("GetValue returns the incorrect value", 0L, (long) (stat1.getValue()));
MLStat<String> stat2 = new MLStat<>(false, new TestSupplier());
Assert.assertEquals("GetValue returns the incorrect value", "test", stat2.getValue());
stat2.setValue(1L);
Assert.assertEquals("GetValue returns the incorrect value", "test", stat2.getValue());
MLStat<Long> stat3 = new MLStat<>(false, new SettableSupplier());
Assert.assertEquals("GetValue returns the incorrect value", 0L, (long) stat3.getValue());
stat3.setValue(1L);
Assert.assertEquals("GetValue returns the incorrect value", 1L, (long) stat3.getValue());
}
Aggregations