Source:
<code>SegmentIdWithShardSpec allocateNewSegment(DateTime timestamp) throws IOException { final String dataSource = getDataSource(); final GranularitySpec granularitySpec = getIngestionSchema().getDataSchema().getGranularitySpec(); final Optional<SortedSet<Interval>> bucketIntervals = granularitySpec.bucketIntervals(); final Map<Interval, String> versions = toolbox .getTaskActionClient() .submit(new LockListAction()) .stream() .filter(taskLock -> !taskLock.isRevoked()) .collect(Collectors.toMap(TaskLock::getInterval, TaskLock::getVersion)); Interval interval; String version; if (bucketIntervals.isPresent()) { final Optional<Interval> maybeInterval = granularitySpec.bucketInterval(timestamp); if (!maybeInterval.isPresent()) { throw new IAE("Could not find interval for timestamp [%s]", timestamp); } interval = maybeInterval.get(); if (!bucketIntervals.get().contains(interval)) { throw new ISE("Unspecified interval[%s] in granularitySpec[%s]", interval, granularitySpec); } version = findVersion(versions, interval); if (version == null) { throw new ISE("Cannot find a version for interval[%s]", interval); } } else { interval = granularitySpec.getSegmentGranularity().bucket(timestamp); version = findVersion(versions, interval); if (version == null) { final TaskLock lock = Preconditions.checkNotNull( toolbox.getTaskActionClient().submit(new LockTryAcquireAction(TaskLockType.EXCLUSIVE, interval)), "Cannot acquire a lock for interval[%s]", interval ); <START> if (!interval.equals(lock.getInterval())) { <END> throw new ISE("Lock is for the wrong interval: expected [%s], got [%s]", interval, lock.getInterval()); } version = lock.getVersion(); } } final int partitionNum = Counters.incrementAndGetInt(partitionNumCountersPerInterval, interval); return new SegmentIdWithShardSpec( dataSource, interval, version, new NumberedShardSpec(partitionNum, 0) ); }</code><technical_language>I fine skip this check. lock is created interval, this happen</technical_language>

Target:
SegmentIdWithShardSpec allocateNewSegment(DateTime timestamp) throws IOException { final String dataSource = getDataSource(); final GranularitySpec granularitySpec = getIngestionSchema().getDataSchema().getGranularitySpec(); final Optional<SortedSet<Interval>> bucketIntervals = granularitySpec.bucketIntervals(); final List<TaskLock> locks = toolbox .getTaskActionClient() .submit(new LockListAction()); final TaskLock revokedLock = locks.stream().filter(TaskLock::isRevoked).findAny().orElse(null); if (revokedLock != null) { throw new ISE("Lock revoked: [%s]", revokedLock); } final Map<Interval, String> versions = locks .stream() .collect(Collectors.toMap(TaskLock::getInterval, TaskLock::getVersion)); Interval interval; String version; boolean justLockedInterval = false; if (bucketIntervals.isPresent()) { final Optional<Interval> maybeInterval = granularitySpec.bucketInterval(timestamp); if (!maybeInterval.isPresent()) { throw new IAE("Could not find interval for timestamp [%s]", timestamp); } interval = maybeInterval.get(); if (!bucketIntervals.get().contains(interval)) { throw new ISE("Unspecified interval[%s] in granularitySpec[%s]", interval, granularitySpec); } version = findVersion(versions, interval); if (version == null) { throw new ISE("Cannot find a version for interval[%s]", interval); } } else { interval = granularitySpec.getSegmentGranularity().bucket(timestamp); version = findVersion(versions, interval); if (version == null) { final TaskLock lock = Preconditions.checkNotNull( toolbox.getTaskActionClient().submit(new LockTryAcquireAction(TaskLockType.EXCLUSIVE, interval)), "Cannot acquire a lock for interval[%s]", interval ); version = lock.getVersion(); justLockedInterval = true; } } final int partitionNum = Counters.getAndIncrementInt(partitionNumCountersPerInterval, interval); if (justLockedInterval && partitionNum != 0) { throw new ISE( "Expected partitionNum to be 0 for interval [%s] right after locking, but got [%s]", interval, partitionNum ); } return new SegmentIdWithShardSpec( dataSource, interval, version, new NumberedShardSpec(partitionNum, 0) ); }