code: public ListenableFuture<SegmentsAndMetadata> publishAll(final TransactionalSegmentPublisher publisher)
    {
      final Map<String, SegmentsForSequence> snapshot;
      synchronized (segments) {
        snapshot = ImmutableMap.copyOf(segments);
      }
  
      return publishInBackground(
          new SegmentsAndMetadata(
              snapshot
                  .values()
                  .stream()
                  .flatMap(SegmentsForSequence::allSegmentStateStream)
                  .map(segmentWithState -> Preconditions
                      .checkNotNull(
                          segmentWithState.getDataSegment(),
                          "dataSegment for segmentId[%s]",
                          segmentWithState.getSegmentIdentifier()
                      )
                  )
                  .collect(Collectors.toList()),
              null
          ),
          publisher
      );
    }
docs: Publish all segments.
  
  @param publisher segment publisher
  
  @return a {@link ListenableFuture} for the publish task