/** * Cancels the current job. */ public synchronized void cancel() { for (int taskId : mJobInfo.getTaskIdList()) { mCommandManager.submitCancelTaskCommand(mJobInfo.getId(), taskId, mTaskIdToWorkerInfo.get(taskId).getId()); } }
return workerInfoList.get(index).getId();
/** * 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(); }
@Test public void detectLostWorkers() throws Exception { // Register a worker. long worker1 = mBlockMaster.getWorkerId(NET_ADDRESS_1); mBlockMaster.workerRegister(worker1, ImmutableList.of("MEM"), ImmutableMap.of("MEM", 100L), ImmutableMap.of("MEM", 10L), NO_BLOCKS_ON_TIERS, RegisterWorkerPOptions.getDefaultInstance()); // Advance the block master's clock by an hour so that worker appears lost. mClock.setTimeMs(System.currentTimeMillis() + Constants.HOUR_MS); // Run the lost worker detector. HeartbeatScheduler.execute(HeartbeatContext.MASTER_LOST_WORKER_DETECTION); // Make sure the worker is detected as lost. List<WorkerInfo> info = mBlockMaster.getLostWorkersInfoList(); assertEquals(worker1, Iterables.getOnlyElement(info).getId()); }
@Test public void getWorkerInfoList() { long worker1 = mBlockMaster.getWorkerId(NET_ADDRESS_1); long worker2 = mBlockMaster.getWorkerId(NET_ADDRESS_2); Set<Long> expected = new HashSet<>(); expected.add(worker1); expected.add(worker2); Response response = mHandler.getWorkerInfoList(); try { assertNotNull("Response must be not null!", response); assertNotNull("Response must have a entry!", response.getEntity()); assertTrue("Entry must be a List!", (response.getEntity() instanceof List)); @SuppressWarnings("unchecked") List<WorkerInfo> entry = (List<WorkerInfo>) response.getEntity(); Set<Long> actual = new HashSet<>(); for (WorkerInfo info : entry) { actual.add(info.getId()); } assertEquals(expected, actual); } finally { response.close(); } } }
@Test public void createJobCoordinator() throws Exception { mockSelectExecutors(mWorkerInfo); JobCoordinator.create(mCommandManager, mUfsManager, mWorkerInfoList, mJobId, mJobconfig, null); List<JobCommand> commands = mCommandManager.pollAllPendingCommands(mWorkerInfo.getId()); Assert.assertEquals(1, commands.size()); Assert.assertEquals(mJobId, commands.get(0).getRunTaskCommand().getJobId()); Assert.assertEquals(0, commands.get(0).getRunTaskCommand().getTaskId()); }
@Test public void failWorker() throws Exception { mockSelectExecutors(mWorkerInfo); JobCoordinator jobCoordinator = JobCoordinator.create(mCommandManager, mUfsManager, mWorkerInfoList, mJobId, mJobconfig, null); jobCoordinator.failTasksForWorker(mWorkerInfo.getId()); Assert.assertEquals(Status.FAILED, jobCoordinator.getJobInfoWire().getStatus()); }
/** * 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()); }
return workerInfoList.get(index).getId();
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(); }