Search in sources :

Example 1 with Joblet

use of org.apache.hyracks.control.nc.Joblet in project asterixdb by apache.

the class AbortTasksWork method run.

@Override
public void run() {
    if (LOGGER.isLoggable(Level.INFO)) {
        LOGGER.info("Aborting Tasks: " + jobId + ":" + tasks);
    }
    IDatasetPartitionManager dpm = ncs.getDatasetPartitionManager();
    if (dpm != null) {
        ncs.getDatasetPartitionManager().abortReader(jobId);
    }
    Joblet ji = ncs.getJobletMap().get(jobId);
    if (ji != null) {
        Map<TaskAttemptId, Task> taskMap = ji.getTaskMap();
        for (TaskAttemptId taId : tasks) {
            Task task = taskMap.get(taId);
            if (task != null) {
                task.abort();
            }
        }
    } else {
        LOGGER.log(Level.WARNING, "Joblet couldn't be found. Tasks of job " + jobId + " have all either completed or failed");
    }
}
Also used : IDatasetPartitionManager(org.apache.hyracks.api.dataset.IDatasetPartitionManager) Task(org.apache.hyracks.control.nc.Task) TaskAttemptId(org.apache.hyracks.api.dataflow.TaskAttemptId) Joblet(org.apache.hyracks.control.nc.Joblet)

Example 2 with Joblet

use of org.apache.hyracks.control.nc.Joblet in project asterixdb by apache.

the class BuildJobProfilesWork method doRun.

@Override
protected void doRun() throws Exception {
    List<JobProfile> profiles = new ArrayList<JobProfile>();
    Map<JobId, Joblet> jobletMap = ncs.getJobletMap();
    for (Joblet ji : jobletMap.values()) {
        profiles.add(new JobProfile(ji.getJobId()));
    }
    for (JobProfile jProfile : profiles) {
        Joblet ji;
        JobletProfile jobletProfile = new JobletProfile(ncs.getId());
        ji = jobletMap.get(jProfile.getJobId());
        if (ji != null) {
            ji.dumpProfile(jobletProfile);
            jProfile.getJobletProfiles().put(ncs.getId(), jobletProfile);
        }
    }
    fv.setValue(profiles);
}
Also used : JobletProfile(org.apache.hyracks.control.common.job.profiling.om.JobletProfile) ArrayList(java.util.ArrayList) JobProfile(org.apache.hyracks.control.common.job.profiling.om.JobProfile) JobId(org.apache.hyracks.api.job.JobId) Joblet(org.apache.hyracks.control.nc.Joblet)

Example 3 with Joblet

use of org.apache.hyracks.control.nc.Joblet in project asterixdb by apache.

the class ReportPartitionAvailabilityWork method run.

@Override
public void run() {
    try {
        Map<JobId, Joblet> jobletMap = ncs.getJobletMap();
        Joblet ji = jobletMap.get(pid.getJobId());
        if (ji != null) {
            PartitionChannel channel = new PartitionChannel(pid, new NetworkInputChannel(ncs.getNetworkManager(), new InetSocketAddress(InetAddress.getByAddress(networkAddress.lookupIpAddress()), networkAddress.getPort()), pid, 5));
            ji.reportPartitionAvailability(channel);
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : PartitionChannel(org.apache.hyracks.api.comm.PartitionChannel) InetSocketAddress(java.net.InetSocketAddress) NetworkInputChannel(org.apache.hyracks.comm.channels.NetworkInputChannel) JobId(org.apache.hyracks.api.job.JobId) Joblet(org.apache.hyracks.control.nc.Joblet)

Example 4 with Joblet

use of org.apache.hyracks.control.nc.Joblet in project asterixdb by apache.

the class StartTasksWork method run.

@Override
public void run() {
    Task task = null;
    try {
        NCServiceContext serviceCtx = ncs.getContext();
        Joblet joblet = getOrCreateLocalJoblet(deploymentId, jobId, serviceCtx, acgBytes);
        final ActivityClusterGraph acg = joblet.getActivityClusterGraph();
        IRecordDescriptorProvider rdp = new IRecordDescriptorProvider() {

            @Override
            public RecordDescriptor getOutputRecordDescriptor(ActivityId aid, int outputIndex) {
                ActivityCluster ac = acg.getActivityMap().get(aid);
                IConnectorDescriptor conn = ac.getActivityOutputMap().get(aid).get(outputIndex);
                return ac.getConnectorRecordDescriptorMap().get(conn.getConnectorId());
            }

            @Override
            public RecordDescriptor getInputRecordDescriptor(ActivityId aid, int inputIndex) {
                ActivityCluster ac = acg.getActivityMap().get(aid);
                IConnectorDescriptor conn = ac.getActivityInputMap().get(aid).get(inputIndex);
                return ac.getConnectorRecordDescriptorMap().get(conn.getConnectorId());
            }
        };
        for (TaskAttemptDescriptor td : taskDescriptors) {
            TaskAttemptId taId = td.getTaskAttemptId();
            TaskId tid = taId.getTaskId();
            ActivityId aid = tid.getActivityId();
            ActivityCluster ac = acg.getActivityMap().get(aid);
            IActivity han = ac.getActivityMap().get(aid);
            if (LOGGER.isLoggable(Level.INFO)) {
                LOGGER.info("Initializing " + taId + " -> " + han);
            }
            final int partition = tid.getPartition();
            List<IConnectorDescriptor> inputs = ac.getActivityInputMap().get(aid);
            task = new Task(joblet, taId, han.getClass().getName(), ncs.getExecutor(), ncs, createInputChannels(td, inputs));
            IOperatorNodePushable operator = han.createPushRuntime(task, rdp, partition, td.getPartitionCount());
            List<IPartitionCollector> collectors = new ArrayList<>();
            if (inputs != null) {
                for (int i = 0; i < inputs.size(); ++i) {
                    IConnectorDescriptor conn = inputs.get(i);
                    IConnectorPolicy cPolicy = connectorPoliciesMap.get(conn.getConnectorId());
                    if (LOGGER.isLoggable(Level.INFO)) {
                        LOGGER.info("input: " + i + ": " + conn.getConnectorId());
                    }
                    RecordDescriptor recordDesc = ac.getConnectorRecordDescriptorMap().get(conn.getConnectorId());
                    IPartitionCollector collector = createPartitionCollector(td, partition, task, i, conn, recordDesc, cPolicy);
                    collectors.add(collector);
                }
            }
            List<IConnectorDescriptor> outputs = ac.getActivityOutputMap().get(aid);
            if (outputs != null) {
                for (int i = 0; i < outputs.size(); ++i) {
                    final IConnectorDescriptor conn = outputs.get(i);
                    RecordDescriptor recordDesc = ac.getConnectorRecordDescriptorMap().get(conn.getConnectorId());
                    IConnectorPolicy cPolicy = connectorPoliciesMap.get(conn.getConnectorId());
                    IPartitionWriterFactory pwFactory = createPartitionWriterFactory(task, cPolicy, jobId, conn, partition, taId, flags);
                    if (LOGGER.isLoggable(Level.INFO)) {
                        LOGGER.info("output: " + i + ": " + conn.getConnectorId());
                    }
                    IFrameWriter writer = conn.createPartitioner(task, recordDesc, pwFactory, partition, td.getPartitionCount(), td.getOutputPartitionCounts()[i]);
                    operator.setOutputFrameWriter(i, writer, recordDesc);
                }
            }
            task.setTaskRuntime(collectors.toArray(new IPartitionCollector[collectors.size()]), operator);
            joblet.addTask(task);
            task.start();
        }
    } catch (Exception e) {
        LOGGER.log(Level.WARNING, "Failure starting a task", e);
        // notify cc of start task failure
        List<Exception> exceptions = new ArrayList<>();
        ExceptionUtils.setNodeIds(exceptions, ncs.getId());
        ncs.getWorkQueue().schedule(new NotifyTaskFailureWork(ncs, task, exceptions));
    }
}
Also used : IFrameWriter(org.apache.hyracks.api.comm.IFrameWriter) Task(org.apache.hyracks.control.nc.Task) TaskId(org.apache.hyracks.api.dataflow.TaskId) RecordDescriptor(org.apache.hyracks.api.dataflow.value.RecordDescriptor) ActivityId(org.apache.hyracks.api.dataflow.ActivityId) ArrayList(java.util.ArrayList) IRecordDescriptorProvider(org.apache.hyracks.api.dataflow.value.IRecordDescriptorProvider) Joblet(org.apache.hyracks.control.nc.Joblet) IActivity(org.apache.hyracks.api.dataflow.IActivity) NCServiceContext(org.apache.hyracks.control.nc.application.NCServiceContext) INCServiceContext(org.apache.hyracks.api.application.INCServiceContext) List(java.util.List) ArrayList(java.util.ArrayList) IConnectorDescriptor(org.apache.hyracks.api.dataflow.IConnectorDescriptor) IPartitionCollector(org.apache.hyracks.api.comm.IPartitionCollector) TaskAttemptId(org.apache.hyracks.api.dataflow.TaskAttemptId) IConnectorPolicy(org.apache.hyracks.api.dataflow.connectors.IConnectorPolicy) IPartitionWriterFactory(org.apache.hyracks.api.comm.IPartitionWriterFactory) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) UnknownHostException(java.net.UnknownHostException) HyracksException(org.apache.hyracks.api.exceptions.HyracksException) ActivityCluster(org.apache.hyracks.api.job.ActivityCluster) TaskAttemptDescriptor(org.apache.hyracks.control.common.job.TaskAttemptDescriptor) ActivityClusterGraph(org.apache.hyracks.api.job.ActivityClusterGraph) IOperatorNodePushable(org.apache.hyracks.api.dataflow.IOperatorNodePushable)

Example 5 with Joblet

use of org.apache.hyracks.control.nc.Joblet in project asterixdb by apache.

the class StartTasksWork method getOrCreateLocalJoblet.

private Joblet getOrCreateLocalJoblet(DeploymentId deploymentId, JobId jobId, INCServiceContext appCtx, byte[] acgBytes) throws HyracksException {
    Map<JobId, Joblet> jobletMap = ncs.getJobletMap();
    Joblet ji = jobletMap.get(jobId);
    if (ji == null) {
        ActivityClusterGraph acg = ncs.getActivityClusterGraph(jobId);
        if (acg == null) {
            if (acgBytes == null) {
                throw HyracksException.create(ErrorCode.ERROR_FINDING_DISTRIBUTED_JOB, jobId);
            }
            acg = (ActivityClusterGraph) DeploymentUtils.deserialize(acgBytes, deploymentId, appCtx);
        }
        ji = new Joblet(ncs, deploymentId, jobId, appCtx, acg);
        jobletMap.put(jobId, ji);
    }
    return ji;
}
Also used : ActivityClusterGraph(org.apache.hyracks.api.job.ActivityClusterGraph) JobId(org.apache.hyracks.api.job.JobId) Joblet(org.apache.hyracks.control.nc.Joblet)

Aggregations

Joblet (org.apache.hyracks.control.nc.Joblet)6 JobId (org.apache.hyracks.api.job.JobId)4 ArrayList (java.util.ArrayList)3 TaskAttemptId (org.apache.hyracks.api.dataflow.TaskAttemptId)2 ActivityClusterGraph (org.apache.hyracks.api.job.ActivityClusterGraph)2 Task (org.apache.hyracks.control.nc.Task)2 InetSocketAddress (java.net.InetSocketAddress)1 UnknownHostException (java.net.UnknownHostException)1 List (java.util.List)1 INCServiceContext (org.apache.hyracks.api.application.INCServiceContext)1 IFrameWriter (org.apache.hyracks.api.comm.IFrameWriter)1 IPartitionCollector (org.apache.hyracks.api.comm.IPartitionCollector)1 IPartitionWriterFactory (org.apache.hyracks.api.comm.IPartitionWriterFactory)1 PartitionChannel (org.apache.hyracks.api.comm.PartitionChannel)1 ActivityId (org.apache.hyracks.api.dataflow.ActivityId)1 IActivity (org.apache.hyracks.api.dataflow.IActivity)1 IConnectorDescriptor (org.apache.hyracks.api.dataflow.IConnectorDescriptor)1 IOperatorNodePushable (org.apache.hyracks.api.dataflow.IOperatorNodePushable)1 TaskId (org.apache.hyracks.api.dataflow.TaskId)1 IConnectorPolicy (org.apache.hyracks.api.dataflow.connectors.IConnectorPolicy)1