/** * Instantiates a new Node info. * * @param workerInfo the worker info */ public NodeInfo(WorkerInfo workerInfo) { mHost = workerInfo.getAddress().getHost(); mWebPort = workerInfo.getAddress().getWebPort(); mLastContactSec = Integer.toString(workerInfo.getLastContactSec()); mWorkerState = workerInfo.getState(); mCapacityBytes = workerInfo.getCapacityBytes(); mUsedBytes = workerInfo.getUsedBytes(); if (mCapacityBytes != 0) { mUsedPercent = (int) (100L * mUsedBytes / mCapacityBytes); } else { mUsedPercent = 0; } mFreePercent = 100 - mUsedPercent; mUptimeClockTime = WebUtils.convertMsToShortClockTime( System.currentTimeMillis() - workerInfo.getStartTimeMs()); mWorkerId = workerInfo.getId(); }
/** * Converts wire type to proto type. * * @param workerInfo the wire representation to convert * @return the converted proto representation */ public static alluxio.grpc.WorkerInfo toProto(WorkerInfo workerInfo) { return alluxio.grpc.WorkerInfo.newBuilder().setId(workerInfo.getId()) .setAddress(toProto(workerInfo.getAddress())) .setLastContactSec(workerInfo.getLastContactSec()).setState(workerInfo.getState()) .setCapacityBytes(workerInfo.getCapacityBytes()).setUsedBytes(workerInfo.getUsedBytes()) .setStartTimeMs(workerInfo.getStartTimeMs()) .putAllCapacityBytesOnTiers(workerInfo.getCapacityBytesOnTiers()) .putAllUsedBytesOnTiers(workerInfo.getUsedBytesOnTiers()).build(); }
public void checkEquality(WorkerInfo a, WorkerInfo b) { Assert.assertEquals(a.getId(), b.getId()); Assert.assertEquals(a.getAddress(), b.getAddress()); Assert.assertEquals(a.getLastContactSec(), b.getLastContactSec()); Assert.assertEquals(a.getCapacityBytes(), b.getCapacityBytes()); Assert.assertEquals(a.getUsedBytes(), b.getUsedBytes()); Assert.assertEquals(a.getStartTimeMs(), b.getStartTimeMs()); Assert.assertEquals(a.getState(), b.getState()); Assert.assertEquals(a.getCapacityBytesOnTiers(), b.getCapacityBytesOnTiers()); Assert.assertEquals(a.getUsedBytesOnTiers(), b.getUsedBytesOnTiers()); Assert.assertEquals(a, b); }
/** * Tests the {@link MasterWorkerInfo#generateWorkerInfo} method. */ @Test public void workerInfoGeneration() { WorkerInfo workerInfo = mInfo.generateWorkerInfo(null, true); assertEquals(mInfo.getId(), workerInfo.getId()); assertEquals(mInfo.getWorkerAddress(), workerInfo.getAddress()); assertEquals("In Service", workerInfo.getState()); assertEquals(mInfo.getCapacityBytes(), workerInfo.getCapacityBytes()); assertEquals(mInfo.getUsedBytes(), workerInfo.getUsedBytes()); assertEquals(mInfo.getStartTime(), workerInfo.getStartTimeMs()); }
private NodeInfo(WorkerInfo workerInfo) { mHost = workerInfo.getAddress().getHost(); mWebPort = workerInfo.getAddress().getWebPort(); mLastContactSec = Integer.toString(workerInfo.getLastContactSec()); mWorkerState = workerInfo.getState(); mCapacityBytes = workerInfo.getCapacityBytes(); mUsedBytes = workerInfo.getUsedBytes(); if (mCapacityBytes != 0) { mUsedPercent = (int) (100L * mUsedBytes / mCapacityBytes); } else { mUsedPercent = 0; } mFreePercent = 100 - mUsedPercent; mUptimeClockTime = WebUtils.convertMsToShortClockTime( System.currentTimeMillis() - workerInfo.getStartTimeMs()); mWorkerId = workerInfo.getId(); }