}
@Test
public void testPerTableBlobPath() throws Exception {
BlobIndices blobIndices = cluster().getInstance(BlobIndices.class, "node_0");
BlobEnvironment blobEnvironment = cluster().getInstance(BlobEnvironment.class, "node_0");
BlobEnvironment blobEnvironment2 = cluster().getInstance(BlobEnvironment.class, "node_1");
assertThat(blobEnvironment.blobsPath().getAbsolutePath(), is(globalBlobPath.getAbsolutePath()));
File tempBlobPath = Files.createTempDirectory(null).toFile();
Settings indexSettings = ImmutableSettings.builder()
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 2)
.put(BlobIndices.SETTING_INDEX_BLOBS_PATH, tempBlobPath.getAbsolutePath())
.build();
blobIndices.createBlobTable("test", indexSettings).get();
ensureGreen();
assertTrue(blobEnvironment.shardLocation(new ShardId(".blob_test", 0), tempBlobPath).exists()
|| blobEnvironment.shardLocation(new ShardId(".blob_test", 1), tempBlobPath).exists());
assertTrue(blobEnvironment2.shardLocation(new ShardId(".blob_test", 0), tempBlobPath).exists()
|| blobEnvironment2.shardLocation(new ShardId(".blob_test", 1), tempBlobPath).exists());
blobIndices.createBlobTable("test2", indexSettings).get();
ensureGreen();
assertTrue(blobEnvironment.shardLocation(new ShardId(".blob_test2", 0), tempBlobPath).exists()
|| blobEnvironment.shardLocation(new ShardId(".blob_test2", 1), tempBlobPath).exists());
assertTrue(blobEnvironment2.shardLocation(new ShardId(".blob_test2", 0), tempBlobPath).exists()
|| blobEnvironment2.shardLocation(new ShardId(".blob_test2", 1), tempBlobPath).exists());
blobIndices.dropBlobTable("test").get();
assertFalse(blobEnvironment.indexLocation(new Index(".blob_test"), tempBlobPath).exists());
assertFalse(blobEnvironment2.indexLocation(new Index(".blob_test"), tempBlobPath).exists());
// blobs path still exists because other index is using it
assertTrue(tempBlobPath.exists());
blobIndices.dropBlobTable("test2").get();
assertFalse(blobEnvironment.indexLocation(new Index(".blob_test2"), tempBlobPath).exists());
assertFalse(blobEnvironment2.indexLocation(new Index(".blob_test2"), tempBlobPath).exists());
// no index using the blobs path anymore, should be deleted
assertFalse(tempBlobPath.exists());
blobIndices.createBlobTable("test", indexSettings).get();