use of org.apache.hadoop.hdds.scm.container.ReplicationManagerReport in project ozone by apache.
the class StorageContainerLocationProtocolClientSideTranslatorPB method getReplicationManagerReport.
@Override
public ReplicationManagerReport getReplicationManagerReport() throws IOException {
ReplicationManagerReportRequestProto request = ReplicationManagerReportRequestProto.newBuilder().setTraceID(TracingUtil.exportCurrentSpan()).build();
ReplicationManagerReportResponseProto response = submitRequest(Type.GetReplicationManagerReport, builder -> builder.setReplicationManagerReportRequest(request)).getGetReplicationManagerReportResponse();
return ReplicationManagerReport.fromProtobuf(response.getReport());
}
use of org.apache.hadoop.hdds.scm.container.ReplicationManagerReport in project ozone by apache.
the class TestReportSubCommand method testCorrectValuesAppearInEmptyReport.
@Test
public void testCorrectValuesAppearInEmptyReport() throws IOException {
ScmClient scmClient = mock(ScmClient.class);
Mockito.when(scmClient.getReplicationManagerReport()).thenAnswer(invocation -> new ReplicationManagerReport());
cmd.execute(scmClient);
for (HddsProtos.LifeCycleState state : HddsProtos.LifeCycleState.values()) {
Pattern p = Pattern.compile("^" + state.toString() + ": 0$", Pattern.MULTILINE);
Matcher m = p.matcher(outContent.toString(DEFAULT_ENCODING));
assertTrue(m.find());
}
for (ReplicationManagerReport.HealthState state : ReplicationManagerReport.HealthState.values()) {
Pattern p = Pattern.compile("^" + state.toString() + ": 0$", Pattern.MULTILINE);
Matcher m = p.matcher(outContent.toString(DEFAULT_ENCODING));
assertTrue(m.find());
}
}
use of org.apache.hadoop.hdds.scm.container.ReplicationManagerReport in project ozone by apache.
the class TestReportSubCommand method createReport.
private ReplicationManagerReport createReport() {
ReplicationManagerReport report = new ReplicationManagerReport();
int counter = SEED;
for (HddsProtos.LifeCycleState state : HddsProtos.LifeCycleState.values()) {
for (int i = 0; i < counter; i++) {
report.increment(state);
}
counter++;
}
// Add samples
counter = SEED;
for (ReplicationManagerReport.HealthState state : ReplicationManagerReport.HealthState.values()) {
for (int i = 0; i < counter; i++) {
report.incrementAndSample(state, ContainerID.valueOf(i));
}
counter++;
}
return report;
}
use of org.apache.hadoop.hdds.scm.container.ReplicationManagerReport in project ozone by apache.
the class ReplicationManagerMetrics method getMetrics.
@Override
public void getMetrics(MetricsCollector collector, boolean all) {
MetricsRecordBuilder builder = collector.addRecord(METRICS_SOURCE_NAME).addGauge(INFLIGHT_REPLICATION, getInflightReplication()).addGauge(INFLIGHT_DELETION, getInflightDeletion()).addGauge(INFLIGHT_MOVE, getInflightMove());
ReplicationManagerReport report = replicationManager.getContainerReport();
for (Map.Entry<HddsProtos.LifeCycleState, MetricsInfo> e : LIFECYCLE_STATE_METRICS.entrySet()) {
builder.addGauge(e.getValue(), report.getStat(e.getKey()));
}
for (Map.Entry<ReplicationManagerReport.HealthState, MetricsInfo> e : CONTAINER_HEALTH_STATE_METRICS.entrySet()) {
builder.addGauge(e.getValue(), report.getStat(e.getKey()));
}
numReplicationCmdsSent.snapshot(builder, all);
numReplicationCmdsCompleted.snapshot(builder, all);
numReplicationCmdsTimeout.snapshot(builder, all);
numDeletionCmdsSent.snapshot(builder, all);
numDeletionCmdsCompleted.snapshot(builder, all);
numDeletionCmdsTimeout.snapshot(builder, all);
numReplicationBytesTotal.snapshot(builder, all);
numReplicationBytesCompleted.snapshot(builder, all);
numDeletionBytesTotal.snapshot(builder, all);
numDeletionBytesCompleted.snapshot(builder, all);
replicationTime.snapshot(builder, all);
deletionTime.snapshot(builder, all);
}
use of org.apache.hadoop.hdds.scm.container.ReplicationManagerReport in project ozone by apache.
the class TestReplicationManagerMetrics method setup.
@Before
public void setup() {
ReplicationManagerReport report = new ReplicationManagerReport();
// to the value by incrementing the counter that number of times.
for (HddsProtos.LifeCycleState s : HddsProtos.LifeCycleState.values()) {
for (int i = 0; i < s.getNumber(); i++) {
report.increment(s);
}
}
// The ordinal starts from 0, so each state will have a value of its ordinal
for (ReplicationManagerReport.HealthState s : ReplicationManagerReport.HealthState.values()) {
for (int i = 0; i < s.ordinal(); i++) {
report.increment(s);
}
}
replicationManager = Mockito.mock(ReplicationManager.class);
Mockito.when(replicationManager.getContainerReport()).thenReturn(report);
metrics = ReplicationManagerMetrics.create(replicationManager);
}
Aggregations