Search in sources :

Example 6 with INodeManager

use of org.apache.hyracks.control.cc.cluster.INodeManager in project asterixdb by apache.

the class CliDeployBinaryWork method doRun.

@Override
public void doRun() {
    try {
        if (deploymentId == null) {
            deploymentId = new DeploymentId(UUID.randomUUID().toString());
        }
        /**
             * Deploy for the cluster controller
             */
        DeploymentUtils.deploy(deploymentId, binaryURLs, ccs.getContext().getJobSerializerDeserializerContainer(), ccs.getServerContext(), false);
        /**
             * Deploy for the node controllers
             */
        INodeManager nodeManager = ccs.getNodeManager();
        Collection<String> nodeIds = nodeManager.getAllNodeIds();
        final DeploymentRun dRun = new DeploymentRun(nodeIds);
        /** The following call prevents a user to deploy with the same deployment id simultaneously. */
        ccs.addDeploymentRun(deploymentId, dRun);
        /***
             * deploy binaries to each node controller
             */
        for (NodeControllerState ncs : nodeManager.getAllNodeControllerStates()) {
            ncs.getNodeController().deployBinary(deploymentId, binaryURLs);
        }
        ccs.getExecutor().execute(new Runnable() {

            @Override
            public void run() {
                try {
                    /**
                         * wait for completion
                         */
                    dRun.waitForCompletion();
                    ccs.removeDeploymentRun(deploymentId);
                    callback.setValue(deploymentId);
                } catch (Exception e) {
                    callback.setException(e);
                }
            }
        });
    } catch (Exception e) {
        callback.setException(e);
    }
}
Also used : INodeManager(org.apache.hyracks.control.cc.cluster.INodeManager) DeploymentId(org.apache.hyracks.api.deployment.DeploymentId) DeploymentRun(org.apache.hyracks.control.common.deployment.DeploymentRun) NodeControllerState(org.apache.hyracks.control.cc.NodeControllerState)

Example 7 with INodeManager

use of org.apache.hyracks.control.cc.cluster.INodeManager in project asterixdb by apache.

the class CliUnDeployBinaryWork method doRun.

@Override
public void doRun() {
    try {
        if (deploymentId == null) {
            deploymentId = new DeploymentId(UUID.randomUUID().toString());
        }
        /**
             * Deploy for the cluster controller
             */
        DeploymentUtils.undeploy(deploymentId, ccs.getContext().getJobSerializerDeserializerContainer(), ccs.getServerContext());
        /**
             * Deploy for the node controllers
             */
        INodeManager nodeManager = ccs.getNodeManager();
        Collection<String> nodeIds = nodeManager.getAllNodeIds();
        final DeploymentRun dRun = new DeploymentRun(nodeIds);
        /** The following call prevents a user to undeploy with the same deployment id simultaneously. */
        ccs.addDeploymentRun(deploymentId, dRun);
        /***
             * deploy binaries to each node controller
             */
        for (NodeControllerState ncs : nodeManager.getAllNodeControllerStates()) {
            ncs.getNodeController().undeployBinary(deploymentId);
        }
        ccs.getExecutor().execute(new Runnable() {

            @Override
            public void run() {
                try {
                    /**
                         * wait for completion
                         */
                    dRun.waitForCompletion();
                    ccs.removeDeploymentRun(deploymentId);
                    callback.setValue(null);
                } catch (Exception e) {
                    callback.setException(e);
                }
            }
        });
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : INodeManager(org.apache.hyracks.control.cc.cluster.INodeManager) DeploymentId(org.apache.hyracks.api.deployment.DeploymentId) DeploymentRun(org.apache.hyracks.control.common.deployment.DeploymentRun) NodeControllerState(org.apache.hyracks.control.cc.NodeControllerState)

Example 8 with INodeManager

use of org.apache.hyracks.control.cc.cluster.INodeManager in project asterixdb by apache.

the class DestroyJobWork method doRun.

@Override
protected void doRun() throws Exception {
    try {
        ccs.getPreDistributedJobStore().removeDistributedJobDescriptor(jobId);
        INodeManager nodeManager = ccs.getNodeManager();
        for (NodeControllerState node : nodeManager.getAllNodeControllerStates()) {
            node.getNodeController().destroyJob(jobId);
        }
        callback.setValue(jobId);
    } catch (Exception e) {
        callback.setException(e);
    }
}
Also used : INodeManager(org.apache.hyracks.control.cc.cluster.INodeManager) NodeControllerState(org.apache.hyracks.control.cc.NodeControllerState)

Example 9 with INodeManager

use of org.apache.hyracks.control.cc.cluster.INodeManager in project asterixdb by apache.

the class JobExecutor method abortTaskCluster.

private void abortTaskCluster(TaskClusterAttempt tcAttempt, TaskClusterAttempt.TaskClusterStatus failedOrAbortedStatus) {
    LOGGER.fine("Aborting task cluster: " + tcAttempt.getAttempt());
    Set<TaskAttemptId> abortTaskIds = new HashSet<>();
    Map<String, List<TaskAttemptId>> abortTaskAttemptMap = new HashMap<>();
    for (TaskAttempt ta : tcAttempt.getTaskAttempts().values()) {
        TaskAttemptId taId = ta.getTaskAttemptId();
        TaskAttempt.TaskStatus status = ta.getStatus();
        abortTaskIds.add(taId);
        LOGGER.fine("Checking " + taId + ": " + ta.getStatus());
        if (status == TaskAttempt.TaskStatus.RUNNING || status == TaskAttempt.TaskStatus.COMPLETED) {
            ta.setStatus(TaskAttempt.TaskStatus.ABORTED, null);
            ta.setEndTime(System.currentTimeMillis());
            List<TaskAttemptId> abortTaskAttempts = abortTaskAttemptMap.get(ta.getNodeId());
            if (status == TaskAttempt.TaskStatus.RUNNING && abortTaskAttempts == null) {
                abortTaskAttempts = new ArrayList<>();
                abortTaskAttemptMap.put(ta.getNodeId(), abortTaskAttempts);
            }
            if (status == TaskAttempt.TaskStatus.RUNNING) {
                abortTaskAttempts.add(taId);
            }
        }
    }
    final JobId jobId = jobRun.getJobId();
    LOGGER.fine("Abort map for job: " + jobId + ": " + abortTaskAttemptMap);
    INodeManager nodeManager = ccs.getNodeManager();
    for (Map.Entry<String, List<TaskAttemptId>> entry : abortTaskAttemptMap.entrySet()) {
        final NodeControllerState node = nodeManager.getNodeControllerState(entry.getKey());
        final List<TaskAttemptId> abortTaskAttempts = entry.getValue();
        if (node != null) {
            if (LOGGER.isLoggable(Level.FINE)) {
                LOGGER.fine("Aborting: " + abortTaskAttempts + " at " + entry.getKey());
            }
            try {
                node.getNodeController().abortTasks(jobId, abortTaskAttempts);
            } catch (Exception e) {
                LOGGER.log(Level.SEVERE, e.getMessage(), e);
            }
        }
    }
    inProgressTaskClusters.remove(tcAttempt.getTaskCluster());
    TaskCluster tc = tcAttempt.getTaskCluster();
    PartitionMatchMaker pmm = jobRun.getPartitionMatchMaker();
    pmm.removeUncommittedPartitions(tc.getProducedPartitions(), abortTaskIds);
    pmm.removePartitionRequests(tc.getRequiredPartitions(), abortTaskIds);
    tcAttempt.setStatus(failedOrAbortedStatus);
    tcAttempt.setEndTime(System.currentTimeMillis());
}
Also used : INodeManager(org.apache.hyracks.control.cc.cluster.INodeManager) HashMap(java.util.HashMap) TaskAttemptId(org.apache.hyracks.api.dataflow.TaskAttemptId) PartitionMatchMaker(org.apache.hyracks.control.cc.partitions.PartitionMatchMaker) HyracksException(org.apache.hyracks.api.exceptions.HyracksException) TaskCluster(org.apache.hyracks.control.cc.job.TaskCluster) ArrayList(java.util.ArrayList) List(java.util.List) TaskAttempt(org.apache.hyracks.control.cc.job.TaskAttempt) NodeControllerState(org.apache.hyracks.control.cc.NodeControllerState) HashMap(java.util.HashMap) Map(java.util.Map) JobId(org.apache.hyracks.api.job.JobId) HashSet(java.util.HashSet)

Example 10 with INodeManager

use of org.apache.hyracks.control.cc.cluster.INodeManager in project asterixdb by apache.

the class JobExecutor method assignLocation.

private String assignLocation(ActivityClusterGraph acg, Map<TaskId, LValueConstraintExpression> locationMap, TaskId tid, TaskAttempt taskAttempt) throws HyracksException {
    ActivityId aid = tid.getActivityId();
    ActivityCluster ac = acg.getActivityMap().get(aid);
    Set<ActivityId> blockers = ac.getBlocked2BlockerMap().get(aid);
    String nodeId = null;
    if (blockers != null) {
        for (ActivityId blocker : blockers) {
            nodeId = findTaskLocation(new TaskId(blocker, tid.getPartition()));
            if (nodeId != null) {
                break;
            }
        }
    }
    INodeManager nodeManager = ccs.getNodeManager();
    Collection<String> liveNodes = nodeManager.getAllNodeIds();
    if (nodeId == null) {
        LValueConstraintExpression pLocationExpr = locationMap.get(tid);
        Object location = solver.getValue(pLocationExpr);
        if (location == null) {
            // pick any
            nodeId = liveNodes.toArray(new String[liveNodes.size()])[random.nextInt(1) % liveNodes.size()];
        } else if (location instanceof String) {
            nodeId = (String) location;
        } else if (location instanceof String[]) {
            for (String choice : (String[]) location) {
                if (liveNodes.contains(choice)) {
                    nodeId = choice;
                    break;
                }
            }
            if (nodeId == null) {
                throw new HyracksException("No satisfiable location found for " + taskAttempt.getTaskAttemptId());
            }
        } else {
            throw new HyracksException("Unknown type of value for " + pLocationExpr + ": " + location + "(" + location.getClass() + ")");
        }
    }
    if (nodeId == null) {
        throw new HyracksException("No satisfiable location found for " + taskAttempt.getTaskAttemptId());
    }
    if (!liveNodes.contains(nodeId)) {
        throw new HyracksException("Node " + nodeId + " not live");
    }
    return nodeId;
}
Also used : INodeManager(org.apache.hyracks.control.cc.cluster.INodeManager) LValueConstraintExpression(org.apache.hyracks.api.constraints.expressions.LValueConstraintExpression) TaskId(org.apache.hyracks.api.dataflow.TaskId) ActivityId(org.apache.hyracks.api.dataflow.ActivityId) HyracksException(org.apache.hyracks.api.exceptions.HyracksException) ActivityCluster(org.apache.hyracks.api.job.ActivityCluster)

Aggregations

INodeManager (org.apache.hyracks.control.cc.cluster.INodeManager)21 NodeControllerState (org.apache.hyracks.control.cc.NodeControllerState)15 HyracksException (org.apache.hyracks.api.exceptions.HyracksException)6 HashMap (java.util.HashMap)4 JobId (org.apache.hyracks.api.job.JobId)4 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 List (java.util.List)3 Map (java.util.Map)3 DeploymentId (org.apache.hyracks.api.deployment.DeploymentId)3 ActivityClusterGraph (org.apache.hyracks.api.job.ActivityClusterGraph)3 INodeController (org.apache.hyracks.control.common.base.INodeController)3 NetworkAddress (org.apache.hyracks.api.comm.NetworkAddress)2 LValueConstraintExpression (org.apache.hyracks.api.constraints.expressions.LValueConstraintExpression)2 ActivityId (org.apache.hyracks.api.dataflow.ActivityId)2 ConnectorDescriptorId (org.apache.hyracks.api.dataflow.ConnectorDescriptorId)2 TaskAttemptId (org.apache.hyracks.api.dataflow.TaskAttemptId)2 TaskId (org.apache.hyracks.api.dataflow.TaskId)2 IConnectorPolicy (org.apache.hyracks.api.dataflow.connectors.IConnectorPolicy)2 ClusterControllerService (org.apache.hyracks.control.cc.ClusterControllerService)2