CompletableFuture < Void > createSegment ( String segmentName , Collection < AttributeUpdate > attributes , Duration timeout ) { long traceId = LoggerHelpers . traceEnterWithContext ( log , traceObjectId , "createSegment" , segmentName ) ; long segmentId = this . connector . containerMetadata . getStreamSegmentId ( segmentName , true ) ; if ( isValidSegmentId ( segmentId ) ) { // Quick fail: see if this is an active Segment, and if so, don't bother with anything else. return Futures . failedFuture ( new StreamSegmentExistsException ( segmentName ) ) ; } ArrayView segmentInfo = SegmentInfo . serialize ( SegmentInfo . newSegment ( segmentName , attributes ) ) ; CompletableFuture < Void > result = createSegment ( segmentName , segmentInfo , new TimeoutTimer ( timeout ) ) ; if ( log . isTraceEnabled ( ) ) { result . thenAccept ( v -> LoggerHelpers . traceLeave ( log , traceObjectId , "createSegment" , traceId , segmentName ) ) ; } return result ; }
Creates a new Segment with given name .