Source:
<code><START> public String commitSegmentFile(String realtimeTableName, CommittingSegmentDescriptor committingSegmentDescriptor) <END> throws Exception { Preconditions.checkState(!_isStopping, "Segment manager is stopping"); String rawTableName = TableNameBuilder.extractRawTableName(realtimeTableName); String segmentName = committingSegmentDescriptor.getSegmentName(); LOGGER.info("Committing segment file for segment: {}", segmentName); String segmentLocation = committingSegmentDescriptor.getSegmentLocation(); URI segmentFileURI = URIUtils.getUri(segmentLocation); URI tableDirURI = URIUtils.getUri(_controllerConf.getDataDir(), rawTableName); URI uriToMoveTo = URIUtils.getUri(_controllerConf.getDataDir(), rawTableName, URIUtils.encode(segmentName)); PinotFS pinotFS = PinotFSFactory.create(tableDirURI.getScheme()); Preconditions.checkState(pinotFS.move(segmentFileURI, uriToMoveTo, true), "Failed to move segment file for segment: %s from: %s to: %s", segmentName, segmentLocation, uriToMoveTo); try { for (String uri : pinotFS.listFiles(tableDirURI, false)) { if (uri.contains(SegmentCompletionUtils.getSegmentNamePrefix(segmentName))) { LOGGER.warn("Deleting temporary segment file: {}", uri); Preconditions.checkState(pinotFS.delete(new URI(uri), true), "Failed to delete file: %s", uri); } } } catch (Exception e) { LOGGER.warn("Caught exception while deleting temporary segment files for segment: {}", segmentName, e); } return uriToMoveTo.toString(); }</code><technical_language>check descriptor for peer scheme in this method, move if is peer scheme. leave descriptor.location is if is peer scheme. If not, update location final location in this method. return void</technical_language>

Target:
public void commitSegmentFile(String realtimeTableName, CommittingSegmentDescriptor committingSegmentDescriptor) throws Exception { Preconditions.checkState(!_isStopping, "Segment manager is stopping"); if (isPeerSegmentDownloadScheme(committingSegmentDescriptor)) { LOGGER.info("No moving needed for segment on peer servers: {}", committingSegmentDescriptor.getSegmentLocation()); return; } String rawTableName = TableNameBuilder.extractRawTableName(realtimeTableName); String segmentName = committingSegmentDescriptor.getSegmentName(); LOGGER.info("Committing segment file for segment: {}", segmentName); String segmentLocation = committingSegmentDescriptor.getSegmentLocation(); URI segmentFileURI = URIUtils.getUri(segmentLocation); URI tableDirURI = URIUtils.getUri(_controllerConf.getDataDir(), rawTableName); URI uriToMoveTo = URIUtils.getUri(_controllerConf.getDataDir(), rawTableName, URIUtils.encode(segmentName)); PinotFS pinotFS = PinotFSFactory.create(tableDirURI.getScheme()); Preconditions.checkState(pinotFS.move(segmentFileURI, uriToMoveTo, true), "Failed to move segment file for segment: %s from: %s to: %s", segmentName, segmentLocation, uriToMoveTo); try { for (String uri : pinotFS.listFiles(tableDirURI, false)) { if (uri.contains(SegmentCompletionUtils.getSegmentNamePrefix(segmentName))) { LOGGER.warn("Deleting temporary segment file: {}", uri); Preconditions.checkState(pinotFS.delete(new URI(uri), true), "Failed to delete file: %s", uri); } } } catch (Exception e) { LOGGER.warn("Caught exception while deleting temporary segment files for segment: {}", segmentName, e); } committingSegmentDescriptor.setSegmentLocation(uriToMoveTo.toString()); }