Source:
public TaskStatus run(TaskToolbox toolbox) throws Exception { final GranularitySpec granularitySpec = ingestionSchema.getDataSchema().getGranularitySpec(); final int targetPartitionSize = ingestionSchema.getTuningConfig().getTargetPartitionSize(); final TaskLock myLock; try { myLock = Iterables.getOnlyElement(getTaskLocks(toolbox)); } catch (NoSuchElementException e) { log.error("No valid lock found, looks like the lock has been revoked by a higher priority task, dying now !!"); return TaskStatus.failure(getId()); } final Set<DataSegment> segments = Sets.newHashSet(); final Set<Interval> validIntervals = Sets.intersection(granularitySpec.bucketIntervals().get(), getDataIntervals()); if (validIntervals.isEmpty()) { throw new ISE("No valid data intervals found. Check your configs!"); } for (final Interval bucket : validIntervals) { final List<ShardSpec> shardSpecs; if (targetPartitionSize > 0) { shardSpecs = determinePartitions(bucket, targetPartitionSize, granularitySpec.getQueryGranularity()); } else { int numShards = ingestionSchema.getTuningConfig().getNumShards(); if (numShards > 0) { shardSpecs = Lists.newArrayList(); for (int i = 0; i < numShards; i++) { shardSpecs.add(new HashBasedNumberedShardSpec(i, numShards, jsonMapper)); } } else { shardSpecs = ImmutableList.<ShardSpec>of(new NoneShardSpec()); } } for (final ShardSpec shardSpec : shardSpecs) { final DataSegment segment = generateSegment( toolbox, ingestionSchema.getDataSchema(), shardSpec, bucket, myLock.getVersion() ); segments.add(segment); } } if (toolbox.getTaskActionClient().submit(new LockUpgradeAction(getInterval()))) { toolbox.pushSegments(segments); return TaskStatus.success(getId()); } return TaskStatus.failure(getId()); }

Target:
public TaskStatus run(TaskToolbox toolbox) throws Exception { final GranularitySpec granularitySpec = ingestionSchema.getDataSchema().getGranularitySpec(); final int targetPartitionSize = ingestionSchema.getTuningConfig().getTargetPartitionSize(); final TaskLock myLock; try { myLock = Iterables.getOnlyElement(getTaskLocks(toolbox)); } catch (NoSuchElementException e) { throw new ISE("No valid lock found, dying now !! Is there a higher priority task running that may have revoked this lock ?"); } final Set<DataSegment> segments = Sets.newHashSet(); final Set<Interval> validIntervals = Sets.intersection(granularitySpec.bucketIntervals().get(), getDataIntervals()); if (validIntervals.isEmpty()) { throw new ISE("No valid data intervals found. Check your configs!"); } for (final Interval bucket : validIntervals) { final List<ShardSpec> shardSpecs; if (targetPartitionSize > 0) { shardSpecs = determinePartitions(bucket, targetPartitionSize, granularitySpec.getQueryGranularity()); } else { int numShards = ingestionSchema.getTuningConfig().getNumShards(); if (numShards > 0) { shardSpecs = Lists.newArrayList(); for (int i = 0; i < numShards; i++) { shardSpecs.add(new HashBasedNumberedShardSpec(i, numShards, null, jsonMapper)); } } else { shardSpecs = ImmutableList.<ShardSpec>of(NoneShardSpec.instance()); } } for (final ShardSpec shardSpec : shardSpecs) { final DataSegment segment = generateSegment( toolbox, ingestionSchema.getDataSchema(), shardSpec, bucket, myLock.getVersion() ); segments.add(segment); } } if (toolbox.getTaskActionClient().submit(new SetLockCriticalStateAction(getInterval(), TaskLockCriticalState.UPGRADE))) { toolbox.publishSegments(segments); return TaskStatus.success(getId()); } else { throw new ISE("Lock upgrade failed for interval [%s] !!", getInterval()); } }