Search in sources :

Example 1 with ActivitiesManager

use of org.apache.hadoop.yarn.server.resourcemanager.scheduler.activities.ActivitiesManager in project hadoop by apache.

the class RMWebServices method getAppActivities.

@GET
@Path("/scheduler/app-activities")
@Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 })
public AppActivitiesInfo getAppActivities(@Context HttpServletRequest hsr, @QueryParam("appId") String appId, @QueryParam("maxTime") String time) {
    YarnScheduler scheduler = rm.getRMContext().getScheduler();
    if (scheduler instanceof AbstractYarnScheduler) {
        AbstractYarnScheduler abstractYarnScheduler = (AbstractYarnScheduler) scheduler;
        ActivitiesManager activitiesManager = abstractYarnScheduler.getActivitiesManager();
        if (null == activitiesManager) {
            String errMessage = "Not Capacity Scheduler";
            return new AppActivitiesInfo(errMessage, appId);
        }
        if (appId == null) {
            String errMessage = "Must provide an application Id";
            return new AppActivitiesInfo(errMessage, null);
        }
        double maxTime = 3.0;
        if (time != null) {
            if (time.contains(".")) {
                maxTime = Double.parseDouble(time);
            } else {
                maxTime = Double.parseDouble(time + ".0");
            }
        }
        ApplicationId applicationId;
        try {
            applicationId = ApplicationId.fromString(appId);
            activitiesManager.turnOnAppActivitiesRecording(applicationId, maxTime);
            AppActivitiesInfo appActivitiesInfo = activitiesManager.getAppActivitiesInfo(applicationId);
            return appActivitiesInfo;
        } catch (Exception e) {
            String errMessage = "Cannot find application with given appId";
            return new AppActivitiesInfo(errMessage, appId);
        }
    }
    return null;
}
Also used : AbstractYarnScheduler(org.apache.hadoop.yarn.server.resourcemanager.scheduler.AbstractYarnScheduler) YarnScheduler(org.apache.hadoop.yarn.server.resourcemanager.scheduler.YarnScheduler) AbstractYarnScheduler(org.apache.hadoop.yarn.server.resourcemanager.scheduler.AbstractYarnScheduler) ActivitiesManager(org.apache.hadoop.yarn.server.resourcemanager.scheduler.activities.ActivitiesManager) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) ForbiddenException(org.apache.hadoop.yarn.webapp.ForbiddenException) NotFoundException(org.apache.hadoop.yarn.webapp.NotFoundException) IOException(java.io.IOException) YarnRuntimeException(org.apache.hadoop.yarn.exceptions.YarnRuntimeException) AuthorizationException(org.apache.hadoop.security.authorize.AuthorizationException) ParseException(java.text.ParseException) AccessControlException(java.security.AccessControlException) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) BadRequestException(org.apache.hadoop.yarn.webapp.BadRequestException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with ActivitiesManager

use of org.apache.hadoop.yarn.server.resourcemanager.scheduler.activities.ActivitiesManager in project hadoop by apache.

the class RMWebServices method getActivities.

@GET
@Path("/scheduler/activities")
@Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 })
public ActivitiesInfo getActivities(@Context HttpServletRequest hsr, @QueryParam("nodeId") String nodeId) {
    YarnScheduler scheduler = rm.getRMContext().getScheduler();
    if (scheduler instanceof AbstractYarnScheduler) {
        String errMessage = "";
        AbstractYarnScheduler abstractYarnScheduler = (AbstractYarnScheduler) scheduler;
        ActivitiesManager activitiesManager = abstractYarnScheduler.getActivitiesManager();
        if (null == activitiesManager) {
            errMessage = "Not Capacity Scheduler";
            return new ActivitiesInfo(errMessage, nodeId);
        }
        List<FiCaSchedulerNode> nodeList = abstractYarnScheduler.getNodeTracker().getAllNodes();
        boolean illegalInput = false;
        if (nodeList.size() == 0) {
            illegalInput = true;
            errMessage = "No node manager running in the cluster";
        } else {
            if (nodeId != null) {
                String hostName = nodeId;
                String portName = "";
                if (nodeId.contains(":")) {
                    int index = nodeId.indexOf(":");
                    hostName = nodeId.substring(0, index);
                    portName = nodeId.substring(index + 1);
                }
                boolean correctNodeId = false;
                for (FiCaSchedulerNode node : nodeList) {
                    if ((portName.equals("") && node.getRMNode().getHostName().equals(hostName)) || (!portName.equals("") && node.getRMNode().getHostName().equals(hostName) && String.valueOf(node.getRMNode().getCommandPort()).equals(portName))) {
                        correctNodeId = true;
                        nodeId = node.getNodeID().toString();
                        break;
                    }
                }
                if (!correctNodeId) {
                    illegalInput = true;
                    errMessage = "Cannot find node manager with given node id";
                }
            }
        }
        if (!illegalInput) {
            activitiesManager.recordNextNodeUpdateActivities(nodeId);
            return activitiesManager.getActivitiesInfo(nodeId);
        }
        // Return a activities info with error message
        return new ActivitiesInfo(errMessage, nodeId);
    }
    return null;
}
Also used : FiCaSchedulerNode(org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode) AbstractYarnScheduler(org.apache.hadoop.yarn.server.resourcemanager.scheduler.AbstractYarnScheduler) YarnScheduler(org.apache.hadoop.yarn.server.resourcemanager.scheduler.YarnScheduler) AbstractYarnScheduler(org.apache.hadoop.yarn.server.resourcemanager.scheduler.AbstractYarnScheduler) ActivitiesManager(org.apache.hadoop.yarn.server.resourcemanager.scheduler.activities.ActivitiesManager) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 3 with ActivitiesManager

use of org.apache.hadoop.yarn.server.resourcemanager.scheduler.activities.ActivitiesManager in project hadoop by apache.

the class CapacityScheduler method initScheduler.

@VisibleForTesting
void initScheduler(Configuration configuration) throws IOException {
    try {
        writeLock.lock();
        this.conf = loadCapacitySchedulerConfiguration(configuration);
        validateConf(this.conf);
        this.minimumAllocation = this.conf.getMinimumAllocation();
        initMaximumResourceCapability(this.conf.getMaximumAllocation());
        this.calculator = this.conf.getResourceCalculator();
        this.usePortForNodeName = this.conf.getUsePortForNodeName();
        this.applications = new ConcurrentHashMap<>();
        this.labelManager = rmContext.getNodeLabelManager();
        this.appPriorityACLManager = new AppPriorityACLsManager(conf);
        this.queueManager = new CapacitySchedulerQueueManager(yarnConf, this.labelManager, this.appPriorityACLManager);
        this.queueManager.setCapacitySchedulerContext(this);
        this.activitiesManager = new ActivitiesManager(rmContext);
        activitiesManager.init(conf);
        initializeQueues(this.conf);
        this.isLazyPreemptionEnabled = conf.getLazyPreemptionEnabled();
        scheduleAsynchronously = this.conf.getScheduleAynschronously();
        asyncScheduleInterval = this.conf.getLong(ASYNC_SCHEDULER_INTERVAL, DEFAULT_ASYNC_SCHEDULER_INTERVAL);
        // number of threads for async scheduling
        int maxAsyncSchedulingThreads = this.conf.getInt(CapacitySchedulerConfiguration.SCHEDULE_ASYNCHRONOUSLY_MAXIMUM_THREAD, 1);
        maxAsyncSchedulingThreads = Math.max(maxAsyncSchedulingThreads, 1);
        if (scheduleAsynchronously) {
            asyncSchedulerThreads = new ArrayList<>();
            for (int i = 0; i < maxAsyncSchedulingThreads; i++) {
                asyncSchedulerThreads.add(new AsyncScheduleThread(this));
            }
            resourceCommitterService = new ResourceCommitterService(this);
        }
        // Setup how many containers we can allocate for each round
        offswitchPerHeartbeatLimit = this.conf.getOffSwitchPerHeartbeatLimit();
        LOG.info("Initialized CapacityScheduler with " + "calculator=" + getResourceCalculator().getClass() + ", " + "minimumAllocation=<" + getMinimumResourceCapability() + ">, " + "maximumAllocation=<" + getMaximumResourceCapability() + ">, " + "asynchronousScheduling=" + scheduleAsynchronously + ", " + "asyncScheduleInterval=" + asyncScheduleInterval + "ms");
    } finally {
        writeLock.unlock();
    }
}
Also used : ActivitiesManager(org.apache.hadoop.yarn.server.resourcemanager.scheduler.activities.ActivitiesManager) AppPriorityACLsManager(org.apache.hadoop.yarn.server.resourcemanager.security.AppPriorityACLsManager) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

ActivitiesManager (org.apache.hadoop.yarn.server.resourcemanager.scheduler.activities.ActivitiesManager)3 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 AbstractYarnScheduler (org.apache.hadoop.yarn.server.resourcemanager.scheduler.AbstractYarnScheduler)2 YarnScheduler (org.apache.hadoop.yarn.server.resourcemanager.scheduler.YarnScheduler)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 IOException (java.io.IOException)1 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)1 AccessControlException (java.security.AccessControlException)1 ParseException (java.text.ParseException)1 AuthorizationException (org.apache.hadoop.security.authorize.AuthorizationException)1 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)1 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)1 YarnRuntimeException (org.apache.hadoop.yarn.exceptions.YarnRuntimeException)1 FiCaSchedulerNode (org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode)1 AppPriorityACLsManager (org.apache.hadoop.yarn.server.resourcemanager.security.AppPriorityACLsManager)1 BadRequestException (org.apache.hadoop.yarn.webapp.BadRequestException)1 ForbiddenException (org.apache.hadoop.yarn.webapp.ForbiddenException)1 NotFoundException (org.apache.hadoop.yarn.webapp.NotFoundException)1