Search in sources :

Example 16 with WorkerInfo

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

the class PlanCoordinator method join.

/**
 * Joins the task results and produces a final result.
 *
 * @param taskInfoList the list of task information
 * @return the aggregated result as a String
 * @throws Exception if any error occurs
 */
private String join(List<TaskInfo> taskInfoList) throws Exception {
    // get the job definition
    PlanDefinition<JobConfig, Serializable, Serializable> definition = PlanDefinitionRegistry.INSTANCE.getJobDefinition(mPlanInfo.getJobConfig());
    Map<WorkerInfo, Serializable> taskResults = Maps.newHashMap();
    for (TaskInfo taskInfo : taskInfoList) {
        taskResults.put(mTaskIdToWorkerInfo.get(taskInfo.getTaskId()), taskInfo.getResult());
    }
    return definition.join(mPlanInfo.getJobConfig(), taskResults);
}
Also used : TaskInfo(alluxio.job.wire.TaskInfo) Serializable(java.io.Serializable) WorkerInfo(alluxio.wire.WorkerInfo) BatchedJobConfig(alluxio.job.plan.BatchedJobConfig) JobConfig(alluxio.job.JobConfig)

Example 17 with WorkerInfo

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

the class PlanTrackerTest method before.

@Before
public void before() {
    mMockWorkflowTracker = mock(WorkflowTracker.class);
    mTracker = new PlanTracker(CAPACITY, RETENTION_TIME, PURGE_CONUT, mMockWorkflowTracker);
    mCommandManager = new CommandManager();
    mMockJobServerContext = mock(JobServerContext.class);
    mWorkers = Lists.newArrayList(new WorkerInfo());
    mJobIdGenerator = new JobIdGenerator();
}
Also used : JobServerContext(alluxio.job.JobServerContext) CommandManager(alluxio.master.job.command.CommandManager) WorkflowTracker(alluxio.master.job.workflow.WorkflowTracker) WorkerInfo(alluxio.wire.WorkerInfo) JobIdGenerator(alluxio.job.meta.JobIdGenerator) Before(org.junit.Before)

Example 18 with WorkerInfo

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

the class CapacityCommand method collectWorkerInfo.

/**
 * Collects worker capacity information.
 *
 * @param workerInfoList the worker info list to collect info from
 */
private void collectWorkerInfo(List<WorkerInfo> workerInfoList) {
    initVariables();
    for (WorkerInfo workerInfo : workerInfoList) {
        long usedBytes = workerInfo.getUsedBytes();
        long capacityBytes = workerInfo.getCapacityBytes();
        mSumCapacityBytes += capacityBytes;
        mSumUsedBytes += usedBytes;
        String workerName = workerInfo.getAddress().getHost();
        Map<String, Long> totalBytesOnTiers = workerInfo.getCapacityBytesOnTiers();
        for (Map.Entry<String, Long> totalBytesTier : totalBytesOnTiers.entrySet()) {
            String tier = totalBytesTier.getKey();
            long value = totalBytesTier.getValue();
            mSumCapacityBytesOnTierMap.put(tier, value + mSumCapacityBytesOnTierMap.getOrDefault(tier, 0L));
            Map<String, String> map = mCapacityTierInfoMap.getOrDefault(tier, new HashMap<>());
            map.put(workerName, FormatUtils.getSizeFromBytes(value));
            mCapacityTierInfoMap.put(tier, map);
        }
        Map<String, Long> usedBytesOnTiers = workerInfo.getUsedBytesOnTiers();
        for (Map.Entry<String, Long> usedBytesTier : usedBytesOnTiers.entrySet()) {
            String tier = usedBytesTier.getKey();
            long value = usedBytesTier.getValue();
            mSumUsedBytesOnTierMap.put(tier, value + mSumUsedBytesOnTierMap.getOrDefault(tier, 0L));
            Map<String, String> map = mUsedTierInfoMap.getOrDefault(tier, new HashMap<>());
            map.put(workerName, FormatUtils.getSizeFromBytes(value));
            mUsedTierInfoMap.put(tier, map);
        }
    }
}
Also used : WorkerInfo(alluxio.wire.WorkerInfo) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) Map(java.util.Map)

Example 19 with WorkerInfo

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

the class CapacityCommand method printWorkerInfo.

/**
 * Prints worker capacity information.
 *
 * @param workerInfoList the worker info list to get info from
 */
private void printWorkerInfo(List<WorkerInfo> workerInfoList) {
    mIndentationLevel = 0;
    if (mCapacityTierInfoMap.size() == 0) {
        return;
    } else if (mCapacityTierInfoMap.size() == 1) {
        // Do not print Total value when only one tier exists
        printShortWorkerInfo(workerInfoList);
        return;
    }
    Set<String> tiers = mCapacityTierInfoMap.keySet();
    String tiersInfo = String.format(Strings.repeat("%-14s", tiers.size()), tiers.toArray());
    String longInfoFormat = getInfoFormat(workerInfoList, false);
    print(String.format("%n" + longInfoFormat, "Worker Name", "Last Heartbeat", "Storage", "Total", tiersInfo));
    for (WorkerInfo info : workerInfoList) {
        String workerName = info.getAddress().getHost();
        long usedBytes = info.getUsedBytes();
        long capacityBytes = info.getCapacityBytes();
        String usedPercentageInfo = "";
        if (capacityBytes != 0) {
            int usedPercentage = (int) (100L * usedBytes / capacityBytes);
            usedPercentageInfo = String.format(" (%s%%)", usedPercentage);
        }
        String capacityTierInfo = getWorkerFormattedTierValues(mCapacityTierInfoMap, workerName);
        String usedTierInfo = getWorkerFormattedTierValues(mUsedTierInfoMap, workerName);
        print(String.format(longInfoFormat, workerName, info.getLastContactSec(), "capacity", FormatUtils.getSizeFromBytes(capacityBytes), capacityTierInfo));
        print(String.format(longInfoFormat, "", "", "used", FormatUtils.getSizeFromBytes(usedBytes) + usedPercentageInfo, usedTierInfo));
    }
}
Also used : WorkerInfo(alluxio.wire.WorkerInfo)

Example 20 with WorkerInfo

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

the class CapacityCommandTest method prepareShortInfoList.

/**
 * @return short worker info list that only one tier exists
 */
private List<WorkerInfo> prepareShortInfoList() {
    List<WorkerInfo> infoList = new ArrayList<>();
    Map<String, Long> capacityBytesOnTiersOne = new HashMap<>();
    capacityBytesOnTiersOne.put("RAM", 6000000000L);
    Map<String, Long> usedBytesOnTiersOne = new HashMap<>();
    usedBytesOnTiersOne.put("RAM", 5000000000L);
    WorkerInfo firstInfo = new WorkerInfo().setAddress(new WorkerNetAddress().setHost("29.53.5.124")).setCapacityBytes(6000000000L).setCapacityBytesOnTiers(capacityBytesOnTiersOne).setId(1).setLastContactSec(6424122).setStartTimeMs(19365332L).setState("Out of Service").setUsedBytes(5000000000L).setUsedBytesOnTiers(usedBytesOnTiersOne);
    Map<String, Long> capacityBytesOnTiersSec = new HashMap<>();
    capacityBytesOnTiersSec.put("RAM", 10000000000L);
    Map<String, Long> usedBytesOnTiersSec = new HashMap<>();
    usedBytesOnTiersSec.put("RAM", 500000000L);
    WorkerInfo secondInfo = new WorkerInfo().setAddress(new WorkerNetAddress().setHost("215.42.95.24")).setCapacityBytes(10000000000L).setCapacityBytesOnTiers(capacityBytesOnTiersSec).setId(2).setLastContactSec(953).setStartTimeMs(112495222L).setState("In Service").setUsedBytes(500000000L).setUsedBytesOnTiers(usedBytesOnTiersSec);
    infoList.add(firstInfo);
    infoList.add(secondInfo);
    return infoList;
}
Also used : HashMap(java.util.HashMap) WorkerNetAddress(alluxio.wire.WorkerNetAddress) ArrayList(java.util.ArrayList) WorkerInfo(alluxio.wire.WorkerInfo)

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