protected void initialize(
     BlobStore blobStore, ClusterName clusterName, @Nullable ByteSizeValue defaultChunkSize)
     throws IOException {
   this.blobStore = blobStore;
   this.chunkSize = componentSettings.getAsBytesSize("chunk_size", defaultChunkSize);
   this.basePath = BlobPath.cleanPath().add(clusterName.value());
   this.metaDataBlobContainer = blobStore.immutableBlobContainer(basePath.add("metadata"));
   this.currentIndex = findLatestIndex();
   this.compress = componentSettings.getAsBoolean("compress", true);
   logger.debug("Latest metadata found at index [" + currentIndex + "]");
 }
 public CommitPoint findCommitPoint(String index, int shardId) throws IOException {
   BlobPath path = BlobStoreIndexGateway.shardPath(basePath, index, shardId);
   ImmutableBlobContainer container = blobStore.immutableBlobContainer(path);
   ImmutableMap<String, BlobMetaData> blobs = container.listBlobs();
   List<CommitPoint> commitPointsList = Lists.newArrayList();
   for (BlobMetaData md : blobs.values()) {
     if (md.length() == 0) { // a commit point that was not flushed yet...
       continue;
     }
     if (md.name().startsWith("commit-")) {
       try {
         commitPointsList.add(CommitPoints.fromXContent(container.readBlobFully(md.name())));
       } catch (Exception e) {
         logger.warn("failed to read commit point at path {} with name [{}]", e, path, md.name());
       }
     }
   }
   CommitPoints commitPoints = new CommitPoints(commitPointsList);
   if (commitPoints.commits().isEmpty()) {
     return null;
   }
   return commitPoints.commits().get(0);
 }
  protected BlobStoreIndexShardGateway(
      ShardId shardId,
      @IndexSettings Settings indexSettings,
      ThreadPool threadPool,
      IndexGateway indexGateway,
      IndexShard indexShard,
      Store store) {
    super(shardId, indexSettings);

    this.threadPool = threadPool;
    this.indexShard = (InternalIndexShard) indexShard;
    this.store = store;

    BlobStoreIndexGateway blobStoreIndexGateway = (BlobStoreIndexGateway) indexGateway;

    this.chunkSize = blobStoreIndexGateway.chunkSize(); // can be null -> no chunking
    this.blobStore = blobStoreIndexGateway.blobStore();
    this.shardPath = blobStoreIndexGateway.shardPath(shardId.id());

    this.blobContainer = blobStore.immutableBlobContainer(shardPath);

    this.recoveryStatus = new RecoveryStatus();
  }
 public ImmutableMap<String, BlobMetaData> listIndexBlobs(int shardId) throws IOException {
   ImmutableBlobContainer indexContainer =
       blobStore.immutableBlobContainer(shardIndexPath(shardId));
   return BlobStoreIndexShardGateway.buildVirtualBlobs(
       indexContainer, indexContainer.listBlobs(), null);
 }
 @Override
 public void close(boolean delete) throws ElasticSearchException {
   if (delete) {
     blobStore.delete(indexPath);
   }
 }
 @Override
 public void reset() throws Exception {
   blobStore.delete(BlobPath.cleanPath());
 }
 @Override
 protected void delete(IndexMetaData indexMetaData) throws ElasticSearchException {
   BlobPath indexPath = basePath().add("indices").add(indexMetaData.index());
   blobStore.delete(indexPath);
 }