use of com.yammer.metrics.core.MetricsRegistry in project pinot by linkedin.
the class ScatterGatherPerfClient method sendRequestAndGetResponse.
/**
* Helper to send request to server and get back response
* @param request
* @return
* @throws InterruptedException
* @throws ExecutionException
* @throws IOException
* @throws ClassNotFoundException
*/
private String sendRequestAndGetResponse(SimpleScatterGatherRequest request, final ScatterGatherStats scatterGatherStats) throws InterruptedException, ExecutionException, IOException, ClassNotFoundException {
BrokerMetrics brokerMetrics = new BrokerMetrics(new MetricsRegistry());
CompositeFuture<ServerInstance, ByteBuf> future = _scatterGather.scatterGather(request, scatterGatherStats, brokerMetrics);
ByteBuf b = future.getOne();
String r = null;
if (null != b) {
byte[] b2 = new byte[b.readableBytes()];
b.readBytes(b2);
r = new String(b2);
}
return r;
}
use of com.yammer.metrics.core.MetricsRegistry in project pinot by linkedin.
the class MetricsHelperTest method testMetricsHelperRegistration.
@Test
public void testMetricsHelperRegistration() {
listenerOneOkay = false;
listenerTwoOkay = false;
Map<String, String> configKeys = new HashMap<String, String>();
configKeys.put("pinot.broker.metrics.metricsRegistryRegistrationListeners", ListenerOne.class.getName() + "," + ListenerTwo.class.getName());
Configuration configuration = new MapConfiguration(configKeys);
MetricsRegistry registry = new MetricsRegistry();
// Initialize the MetricsHelper and create a new timer
MetricsHelper.initializeMetrics(configuration.subset("pinot.broker.metrics"));
MetricsHelper.registerMetricsRegistry(registry);
MetricsHelper.newTimer(registry, new MetricName(MetricsHelperTest.class, "dummy"), TimeUnit.MILLISECONDS, TimeUnit.MILLISECONDS);
// Check that the two listeners fired
assertTrue(listenerOneOkay);
assertTrue(listenerTwoOkay);
}
use of com.yammer.metrics.core.MetricsRegistry in project pinot by linkedin.
the class RoutingTableTest method testTimeBoundaryRegression.
@Test
public void testTimeBoundaryRegression() throws Exception {
final FakePropertyStore propertyStore = new FakePropertyStore();
final OfflineSegmentZKMetadata offlineSegmentZKMetadata = new OfflineSegmentZKMetadata();
offlineSegmentZKMetadata.setTimeUnit(TimeUnit.DAYS);
offlineSegmentZKMetadata.setEndTime(1234L);
propertyStore.setContents(ZKMetadataProvider.constructPropertyStorePathForSegment("myTable_OFFLINE", "someSegment_0"), offlineSegmentZKMetadata.toZNRecord());
final ExternalView offlineExternalView = new ExternalView("myTable_OFFLINE");
offlineExternalView.setState("someSegment_0", "Server_1.2.3.4_1234", "ONLINE");
final MutableBoolean timeBoundaryUpdated = new MutableBoolean(false);
HelixExternalViewBasedRouting routingTable = new HelixExternalViewBasedRouting(propertyStore, NO_LLC_ROUTING, null, new BaseConfiguration()) {
@Override
protected ExternalView fetchExternalView(String table) {
return offlineExternalView;
}
@Override
protected void updateTimeBoundary(String tableName, ExternalView externalView) {
if (tableName.equals("myTable_OFFLINE")) {
timeBoundaryUpdated.setValue(true);
}
}
};
routingTable.setBrokerMetrics(new BrokerMetrics(new MetricsRegistry()));
Assert.assertFalse(timeBoundaryUpdated.booleanValue());
final ArrayList<InstanceConfig> instanceConfigList = new ArrayList<>();
instanceConfigList.add(new InstanceConfig("Server_1.2.3.4_1234"));
routingTable.markDataResourceOnline("myTable_OFFLINE", offlineExternalView, instanceConfigList);
routingTable.markDataResourceOnline("myTable_REALTIME", new ExternalView("myTable_REALTIME"), null);
Assert.assertTrue(timeBoundaryUpdated.booleanValue());
}
use of com.yammer.metrics.core.MetricsRegistry in project pinot by linkedin.
the class SegmentStatusCheckerTest method basicTest.
@Test
public void basicTest() throws Exception {
final String tableName = "myTable_OFFLINE";
List<String> allTableNames = new ArrayList<String>();
allTableNames.add(tableName);
IdealState idealState = new IdealState(tableName);
idealState.setPartitionState("myTable_0", "pinot1", "ONLINE");
idealState.setPartitionState("myTable_0", "pinot2", "ONLINE");
idealState.setPartitionState("myTable_0", "pinot3", "ONLINE");
idealState.setPartitionState("myTable_1", "pinot1", "ONLINE");
idealState.setPartitionState("myTable_1", "pinot2", "ONLINE");
idealState.setPartitionState("myTable_1", "pinot3", "ONLINE");
idealState.setPartitionState("myTable_2", "pinot3", "OFFLINE");
idealState.setReplicas("2");
idealState.setRebalanceMode(IdealState.RebalanceMode.CUSTOMIZED);
ExternalView externalView = new ExternalView(tableName);
externalView.setState("myTable_0", "pinot1", "ONLINE");
externalView.setState("myTable_0", "pinot2", "ONLINE");
externalView.setState("myTable_1", "pinot1", "ERROR");
externalView.setState("myTable_1", "pinot2", "ONLINE");
HelixAdmin helixAdmin;
{
helixAdmin = mock(HelixAdmin.class);
when(helixAdmin.getResourceIdealState("StatusChecker", tableName)).thenReturn(idealState);
when(helixAdmin.getResourceExternalView("StatusChecker", tableName)).thenReturn(externalView);
}
{
helixResourceManager = mock(PinotHelixResourceManager.class);
when(helixResourceManager.isLeader()).thenReturn(true);
when(helixResourceManager.getAllPinotTableNames()).thenReturn(allTableNames);
when(helixResourceManager.getHelixClusterName()).thenReturn("StatusChecker");
when(helixResourceManager.getHelixAdmin()).thenReturn(helixAdmin);
}
{
config = mock(ControllerConf.class);
when(config.getStatusCheckerFrequencyInSeconds()).thenReturn(300);
when(config.getStatusCheckerWaitForPushTimeInSeconds()).thenReturn(300);
}
metricsRegistry = new MetricsRegistry();
controllerMetrics = new ControllerMetrics(metricsRegistry);
segmentStatusChecker = new SegmentStatusChecker(helixResourceManager, config);
segmentStatusChecker.setMetricsRegistry(controllerMetrics);
segmentStatusChecker.runSegmentMetrics();
Assert.assertEquals(controllerMetrics.getValueOfTableGauge(externalView.getId(), ControllerGauge.SEGMENTS_IN_ERROR_STATE), 1);
Assert.assertEquals(controllerMetrics.getValueOfTableGauge(externalView.getId(), ControllerGauge.NUMBER_OF_REPLICAS), 1);
Assert.assertEquals(controllerMetrics.getValueOfTableGauge(externalView.getId(), ControllerGauge.PERCENT_OF_REPLICAS), 33);
Assert.assertEquals(controllerMetrics.getValueOfTableGauge(externalView.getId(), ControllerGauge.PERCENT_SEGMENTS_AVAILABLE), 100);
segmentStatusChecker.stop();
}
use of com.yammer.metrics.core.MetricsRegistry in project pinot by linkedin.
the class SegmentStatusCheckerTest method missingEVTest.
@Test
public void missingEVTest() throws Exception {
final String tableName = "myTable_REALTIME";
List<String> allTableNames = new ArrayList<String>();
allTableNames.add(tableName);
IdealState idealState = new IdealState(tableName);
idealState.setPartitionState("myTable_0", "pinot1", "ONLINE");
idealState.setPartitionState("myTable_0", "pinot2", "ONLINE");
idealState.setPartitionState("myTable_0", "pinot3", "ONLINE");
idealState.setPartitionState("myTable_1", "pinot1", "ONLINE");
idealState.setPartitionState("myTable_1", "pinot2", "ONLINE");
idealState.setPartitionState("myTable_1", "pinot3", "ONLINE");
idealState.setPartitionState("myTable_2", "pinot3", "OFFLINE");
idealState.setReplicas("2");
idealState.setRebalanceMode(IdealState.RebalanceMode.CUSTOMIZED);
HelixAdmin helixAdmin;
{
helixAdmin = mock(HelixAdmin.class);
when(helixAdmin.getResourceIdealState("StatusChecker", tableName)).thenReturn(idealState);
when(helixAdmin.getResourceExternalView("StatusChecker", tableName)).thenReturn(null);
}
{
helixResourceManager = mock(PinotHelixResourceManager.class);
when(helixResourceManager.isLeader()).thenReturn(true);
when(helixResourceManager.getAllPinotTableNames()).thenReturn(allTableNames);
when(helixResourceManager.getHelixClusterName()).thenReturn("StatusChecker");
when(helixResourceManager.getHelixAdmin()).thenReturn(helixAdmin);
}
{
config = mock(ControllerConf.class);
when(config.getStatusCheckerFrequencyInSeconds()).thenReturn(300);
when(config.getStatusCheckerWaitForPushTimeInSeconds()).thenReturn(300);
}
metricsRegistry = new MetricsRegistry();
controllerMetrics = new ControllerMetrics(metricsRegistry);
segmentStatusChecker = new SegmentStatusChecker(helixResourceManager, config);
segmentStatusChecker.setMetricsRegistry(controllerMetrics);
segmentStatusChecker.runSegmentMetrics();
Assert.assertEquals(controllerMetrics.getValueOfTableGauge(tableName, ControllerGauge.SEGMENTS_IN_ERROR_STATE), 0);
Assert.assertEquals(controllerMetrics.getValueOfTableGauge(tableName, ControllerGauge.NUMBER_OF_REPLICAS), 0);
segmentStatusChecker.stop();
}
Aggregations