Search in sources :

Example 6 with CompositeConfig

use of alluxio.job.workflow.composite.CompositeConfig in project alluxio by Alluxio.

the class WorkflowExecutionRegistryTest method getExecutionFactoryTest.

@Test
public void getExecutionFactoryTest() throws Exception {
    WorkflowExecution execution = WorkflowExecutionRegistry.INSTANCE.getExecution(new CompositeConfig(Lists.newArrayList(), true));
    assertTrue(execution instanceof CompositeExecution);
}
Also used : CompositeExecution(alluxio.job.workflow.composite.CompositeExecution) CompositeConfig(alluxio.job.workflow.composite.CompositeConfig) Test(org.junit.Test)

Example 7 with CompositeConfig

use of alluxio.job.workflow.composite.CompositeConfig in project alluxio by Alluxio.

the class TransformManager method execute.

/**
 * Executes the plans for the table transformation.
 *
 * This method executes a transformation job with type{@link CompositeConfig},
 * the transformation job concurrently executes the plans,
 * each plan has a list of jobs to be executed sequentially.
 *
 * This method triggers the execution of the transformation job asynchronously without waiting
 * for it to finish. The returned job ID can be used to poll the job service for the status of
 * this transformation.
 *
 * @param dbName the database name
 * @param tableName the table name
 * @param definition the parsed transformation definition
 * @return the job ID for the transformation job
 * @throws IOException when there is an ongoing transformation on the table, or the transformation
 *    job fails to be started, or all partitions of the table have been transformed with the same
 *    definition
 */
public long execute(String dbName, String tableName, TransformDefinition definition) throws IOException {
    List<TransformPlan> plans = mCatalog.getTransformPlan(dbName, tableName, definition);
    if (plans.isEmpty()) {
        throw new IOException(ExceptionMessage.TABLE_ALREADY_TRANSFORMED.getMessage(dbName, tableName, definition.getDefinition()));
    }
    Pair<String, String> dbTable = new Pair<>(dbName, tableName);
    // Atomically try to acquire the permit to execute the transformation job.
    // This PUT does not need to be journaled, because if this PUT succeeds and master crashes,
    // when master restarts, this temporary placeholder entry will not exist, which is correct
    // behavior.
    Long existingJobId = mState.acquireJobPermit(dbTable);
    if (existingJobId != null) {
        if (existingJobId == INVALID_JOB_ID) {
            throw new IOException("A concurrent transformation request is going to be executed");
        } else {
            throw new IOException(ExceptionMessage.TABLE_BEING_TRANSFORMED.getMessage(existingJobId.toString(), tableName, dbName));
        }
    }
    ArrayList<JobConfig> concurrentJobs = new ArrayList<>(plans.size());
    for (TransformPlan plan : plans) {
        concurrentJobs.add(new CompositeConfig(plan.getJobConfigs(), true));
    }
    CompositeConfig transformJob = new CompositeConfig(concurrentJobs, false);
    long jobId;
    try {
        jobId = mJobMasterClient.run(transformJob);
    } catch (IOException e) {
        // The job fails to start, clear the acquired permit for execution.
        // No need to journal this REMOVE, if master crashes, when it restarts, the permit placeholder
        // entry will not exist any more, which is correct behavior.
        mState.releaseJobPermit(dbTable);
        String error = String.format("Fails to start job to transform table %s in database %s", tableName, dbName);
        LOG.error(error, e);
        throw new IOException(error, e);
    }
    Map<String, Layout> transformedLayouts = new HashMap<>(plans.size());
    for (TransformPlan plan : plans) {
        transformedLayouts.put(plan.getBaseLayout().getSpec(), plan.getTransformedLayout());
    }
    AddTransformJobInfoEntry journalEntry = AddTransformJobInfoEntry.newBuilder().setDbName(dbName).setTableName(tableName).setDefinition(definition.getDefinition()).setJobId(jobId).putAllTransformedLayouts(Maps.transformValues(transformedLayouts, Layout::toProto)).build();
    try (JournalContext journalContext = mCreateJournalContext.apply()) {
        applyAndJournal(journalContext, Journal.JournalEntry.newBuilder().setAddTransformJobInfo(journalEntry).build());
    }
    return jobId;
}
Also used : HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) JournalContext(alluxio.master.journal.JournalContext) ArrayList(java.util.ArrayList) IOException(java.io.IOException) JobConfig(alluxio.job.JobConfig) Layout(alluxio.table.common.Layout) AddTransformJobInfoEntry(alluxio.proto.journal.Table.AddTransformJobInfoEntry) TransformPlan(alluxio.table.common.transform.TransformPlan) CompositeConfig(alluxio.job.workflow.composite.CompositeConfig) Pair(alluxio.collections.Pair)

Aggregations

CompositeConfig (alluxio.job.workflow.composite.CompositeConfig)7 Test (org.junit.Test)6 JobConfig (alluxio.job.JobConfig)5 SleepJobConfig (alluxio.job.SleepJobConfig)5 WorkflowInfo (alluxio.job.wire.WorkflowInfo)3 TestPlanConfig (alluxio.job.TestPlanConfig)2 PlanInfo (alluxio.job.plan.meta.PlanInfo)2 JobInfo (alluxio.job.wire.JobInfo)2 ArrayList (java.util.ArrayList)2 Pair (alluxio.collections.Pair)1 ResourceExhaustedException (alluxio.exception.status.ResourceExhaustedException)1 JobServerContext (alluxio.job.JobServerContext)1 PlanConfig (alluxio.job.plan.PlanConfig)1 Status (alluxio.job.wire.Status)1 CompositeExecution (alluxio.job.workflow.composite.CompositeExecution)1 JobMaster (alluxio.master.job.JobMaster)1 CommandManager (alluxio.master.job.command.CommandManager)1 PlanTracker (alluxio.master.job.plan.PlanTracker)1 JournalContext (alluxio.master.journal.JournalContext)1 AddTransformJobInfoEntry (alluxio.proto.journal.Table.AddTransformJobInfoEntry)1