Search in sources :

Example 31 with WorkerInfo

use of alluxio.wire.WorkerInfo in project alluxio by Alluxio.

the class AlluxioMasterRestServiceHandlerTest method getWorkerInfoList.

@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();
    }
}
Also used : Response(javax.ws.rs.core.Response) WorkerInfo(alluxio.wire.WorkerInfo) List(java.util.List) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 32 with WorkerInfo

use of alluxio.wire.WorkerInfo in project alluxio by Alluxio.

the class AlluxioMasterRestApiTest method getWorkers.

@Test
public void getWorkers() throws Exception {
    List<WorkerInfo> workerInfos = getInfo(NO_PARAMS).getWorkers();
    Assert.assertEquals(1, workerInfos.size());
    WorkerInfo workerInfo = workerInfos.get(0);
    Assert.assertEquals(0, workerInfo.getUsedBytes());
    long bytes = Configuration.getBytes(PropertyKey.WORKER_MEMORY_SIZE);
    Assert.assertEquals(bytes, workerInfo.getCapacityBytes());
}
Also used : WorkerInfo(alluxio.wire.WorkerInfo) Test(org.junit.Test) RestApiTest(alluxio.rest.RestApiTest)

Example 33 with WorkerInfo

use of alluxio.wire.WorkerInfo in project alluxio by Alluxio.

the class CompactDefinitionSelectExecutorsTest method testExecutorsParallel.

@Test
public void testExecutorsParallel() throws Exception {
    int tasksPerWorker = 10;
    int numCompactedFiles = 100;
    int totalFiles = 5000;
    PartitionInfo mockPartitionInfo = mock(PartitionInfo.class);
    when(mockPartitionInfo.getFormat(any())).thenReturn(Format.CSV);
    CompactConfig config = new CompactConfig(mockPartitionInfo, INPUT_DIR, mockPartitionInfo, OUTPUT_DIR, numCompactedFiles, 2 * FileUtils.ONE_GB);
    List<URIStatus> inputFiles = new ArrayList<>();
    for (int i = 0; i < totalFiles; i++) {
        inputFiles.add(newFile(Integer.toString(i)));
    }
    when(mMockFileSystem.listStatus(new AlluxioURI(INPUT_DIR))).thenReturn(inputFiles);
    Set<Pair<WorkerInfo, ArrayList<CompactTask>>> result = new CompactDefinition().selectExecutors(config, SelectExecutorsTest.JOB_WORKERS, new SelectExecutorsContext(1, new JobServerContext(mMockFileSystem, mMockFileSystemContext, mMockUfsManager)));
    assertEquals(JOB_WORKERS.size() * tasksPerWorker, result.size());
    int allCompactTasks = 0;
    for (Pair<WorkerInfo, ArrayList<CompactTask>> tasks : result) {
        allCompactTasks += tasks.getSecond().size();
    }
    assertEquals(numCompactedFiles, allCompactTasks);
}
Also used : JobServerContext(alluxio.job.JobServerContext) ArrayList(java.util.ArrayList) WorkerInfo(alluxio.wire.WorkerInfo) URIStatus(alluxio.client.file.URIStatus) SelectExecutorsContext(alluxio.job.SelectExecutorsContext) AlluxioURI(alluxio.AlluxioURI) Pair(alluxio.collections.Pair) Test(org.junit.Test) SelectExecutorsTest(alluxio.job.plan.SelectExecutorsTest)

Example 34 with WorkerInfo

use of alluxio.wire.WorkerInfo in project alluxio by Alluxio.

the class PlanCoordinatorTest method mockSelectExecutors.

/**
 * @param workerInfos the worker infos to return from the mocked selectExecutors method
 */
private void mockSelectExecutors(WorkerInfo... workerInfos) throws Exception {
    Set<Pair<WorkerInfo, Serializable>> taskAddressToArgs = Sets.newHashSet();
    for (WorkerInfo workerInfo : workerInfos) {
        taskAddressToArgs.add(new Pair<>(workerInfo, null));
    }
    Mockito.when(mPlanDefinition.selectExecutors(Mockito.eq(mJobconfig), Mockito.eq(Lists.newArrayList(mWorkerInfo)), Mockito.any(SelectExecutorsContext.class))).thenReturn(taskAddressToArgs);
}
Also used : WorkerInfo(alluxio.wire.WorkerInfo) SelectExecutorsContext(alluxio.job.SelectExecutorsContext) Pair(alluxio.collections.Pair)

Example 35 with WorkerInfo

use of alluxio.wire.WorkerInfo in project alluxio by Alluxio.

the class WorkflowTrackerTest method before.

@Before
public void before() throws Exception {
    mMockJobMaster = mock(JobMaster.class);
    mWorkflowTracker = new WorkflowTracker(mMockJobMaster);
    mPlanTracker = new PlanTracker(CAPACITY, RETENTION_TIME, PURGE_CONUT, mWorkflowTracker);
    mJobIdCounter = 100;
    when(mMockJobMaster.getNewJobId()).thenAnswer(invocation -> mJobIdCounter++);
    mWorkers = Lists.newArrayList(new WorkerInfo());
    mCommandManager = new CommandManager();
    mMockJobServerContext = mock(JobServerContext.class);
}
Also used : JobMaster(alluxio.master.job.JobMaster) JobServerContext(alluxio.job.JobServerContext) PlanTracker(alluxio.master.job.plan.PlanTracker) CommandManager(alluxio.master.job.command.CommandManager) WorkerInfo(alluxio.wire.WorkerInfo) Before(org.junit.Before)

Aggregations

WorkerInfo (alluxio.wire.WorkerInfo)66 Test (org.junit.Test)31 ArrayList (java.util.ArrayList)18 Pair (alluxio.collections.Pair)17 BlockMasterTestUtils.findWorkerInfo (alluxio.master.block.BlockMasterTestUtils.findWorkerInfo)14 CountDownLatch (java.util.concurrent.CountDownLatch)14 SelectExecutorsContext (alluxio.job.SelectExecutorsContext)12 BlockWorkerInfo (alluxio.client.block.BlockWorkerInfo)11 Command (alluxio.grpc.Command)11 AlluxioURI (alluxio.AlluxioURI)9 Map (java.util.Map)9 BlockInfo (alluxio.wire.BlockInfo)8 BlockLocation (alluxio.wire.BlockLocation)8 WorkerNetAddress (alluxio.wire.WorkerNetAddress)8 URIStatus (alluxio.client.file.URIStatus)7 HashMap (java.util.HashMap)7 List (java.util.List)7 HashSet (java.util.HashSet)6 UnavailableException (alluxio.exception.status.UnavailableException)5 FileBlockInfo (alluxio.wire.FileBlockInfo)5