use of alluxio.wire.AlluxioMasterInfo in project alluxio by Alluxio.
the class AlluxioMasterRestApiTest method getInfo.
private AlluxioMasterInfo getInfo(Map<String, String> params) throws Exception {
String result = new TestCase(mHostname, mPort, getEndpoint(AlluxioMasterRestServiceHandler.GET_INFO), params, HttpMethod.GET, null).call();
AlluxioMasterInfo info = new ObjectMapper().readValue(result, AlluxioMasterInfo.class);
return info;
}
use of alluxio.wire.AlluxioMasterInfo in project alluxio by Alluxio.
the class AlluxioMasterRestServiceHandlerTest method getMasterInfo.
@Test
public void getMasterInfo() {
// Mock for rpc address
when(mMasterProcess.getRpcAddress()).thenReturn(new InetSocketAddress("localhost", 8080));
// Mock for metrics
final int FILES_PINNED_TEST_VALUE = 100;
String filesPinnedProperty = MetricKey.MASTER_FILES_PINNED.getName();
Gauge<Integer> filesPinnedGauge = () -> FILES_PINNED_TEST_VALUE;
MetricSet mockMetricsSet = mock(MetricSet.class);
Map<String, Metric> map = new HashMap<>();
map.put(filesPinnedProperty, filesPinnedGauge);
when(mockMetricsSet.getMetrics()).thenReturn(map);
MetricsSystem.METRIC_REGISTRY.registerAll(mockMetricsSet);
// Mock for start time
when(mMasterProcess.getStartTimeMs()).thenReturn(101L);
// Mock for up time
when(mMasterProcess.getUptimeMs()).thenReturn(102L);
Response response = mHandler.getInfo(false);
try {
assertNotNull("Response must be not null!", response);
assertNotNull("Response must have a entry!", response.getEntity());
assertTrue("Entry must be an AlluxioMasterInfo!", (response.getEntity() instanceof AlluxioMasterInfo));
AlluxioMasterInfo info = (AlluxioMasterInfo) response.getEntity();
// Validate configuration
assertNotNull("Configuration must be not null", info.getConfiguration());
assertFalse("Properties Map must be not empty!", (info.getConfiguration().isEmpty()));
// Validate rpc address
assertEquals("localhost/127.0.0.1:8080", info.getRpcAddress());
// Validate metrics
Map<String, Long> metricsMap = info.getMetrics();
assertFalse("Metrics Map must be not empty!", (metricsMap.isEmpty()));
assertTrue("Map must contain key " + filesPinnedProperty + "!", metricsMap.containsKey(filesPinnedProperty));
assertEquals(FILES_PINNED_TEST_VALUE, metricsMap.get(filesPinnedProperty).longValue());
// Validate StartTimeMs
assertEquals(101L, info.getStartTimeMs());
// Validate UptimeMs
assertEquals(102L, info.getUptimeMs());
// Validate version
assertEquals(RuntimeConstants.VERSION, info.getVersion());
// Validate capacity bytes
Capacity cap = info.getCapacity();
long sumCapacityBytes = 0;
for (Map.Entry<String, Long> entry1 : WORKER1_TOTAL_BYTES_ON_TIERS.entrySet()) {
Long totalBytes = entry1.getValue();
sumCapacityBytes += totalBytes;
}
for (Map.Entry<String, Long> entry1 : WORKER2_TOTAL_BYTES_ON_TIERS.entrySet()) {
Long totalBytes = entry1.getValue();
sumCapacityBytes += totalBytes;
}
assertEquals(sumCapacityBytes, cap.getTotal());
// Validate used bytes
long sumUsedBytes = 0;
for (Map.Entry<String, Long> entry1 : WORKER1_USED_BYTES_ON_TIERS.entrySet()) {
Long totalBytes = entry1.getValue();
sumUsedBytes += totalBytes;
}
for (Map.Entry<String, Long> entry1 : WORKER2_USED_BYTES_ON_TIERS.entrySet()) {
Long totalBytes = entry1.getValue();
sumUsedBytes += totalBytes;
}
assertEquals(sumUsedBytes, cap.getUsed());
// Validate UFS capacity
Capacity ufsCapacity = info.getUfsCapacity();
assertEquals(UFS_SPACE_TOTAL, ufsCapacity.getTotal());
assertEquals(UFS_SPACE_USED, ufsCapacity.getUsed());
// Validate workers
List<WorkerInfo> workers = info.getWorkers();
assertEquals(2, workers.size());
long worker1 = mBlockMaster.getWorkerId(NET_ADDRESS_1);
long worker2 = mBlockMaster.getWorkerId(NET_ADDRESS_2);
Set<Long> expectedWorkers = new HashSet<>();
expectedWorkers.add(worker1);
expectedWorkers.add(worker2);
Set<Long> actualWorkers = new HashSet<>();
for (WorkerInfo w : workers) {
actualWorkers.add(w.getId());
}
assertEquals(expectedWorkers, actualWorkers);
} finally {
response.close();
}
}
use of alluxio.wire.AlluxioMasterInfo in project alluxio by Alluxio.
the class AlluxioMasterRestApiTest method getInfo.
private AlluxioMasterInfo getInfo(Map<String, String> params) throws Exception {
String result = new TestCase(mHostname, mPort, getEndpoint(AlluxioMasterRestServiceHandler.GET_INFO), params, HttpMethod.GET, null).call();
AlluxioMasterInfo info = new ObjectMapper().readValue(result, AlluxioMasterInfo.class);
return info;
}
Aggregations