Package io.crate.blob

Examples of io.crate.blob.BlobEnvironment


    }

    @Test
    public void testGlobalBlobPath() 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()));

        Settings indexSettings = ImmutableSettings.builder()
                .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)
                .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 2)
                .build();
        blobIndices.createBlobTable("test", indexSettings).get();
        ensureGreen();
        assertTrue(blobEnvironment.shardLocation(new ShardId(".blob_test", 0)).exists()
         || blobEnvironment.shardLocation(new ShardId(".blob_test", 1)).exists());
        assertTrue(blobEnvironment2.shardLocation(new ShardId(".blob_test", 0)).exists()
                || blobEnvironment2.shardLocation(new ShardId(".blob_test", 1)).exists());

        blobIndices.dropBlobTable("test").get();
        assertFalse(blobEnvironment.indexLocation(new Index(".blob_test")).exists());
        assertFalse(blobEnvironment2.indexLocation(new Index(".blob_test")).exists());
    }
View Full Code Here


    }

    @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();
View Full Code Here

        dataPath = Files.createTempDirectory(null);
        Settings settings = ImmutableSettings.builder()
                .put("path.data", dataPath.toAbsolutePath()).build();
        Environment environment = new Environment(settings);
        nodeEnvironment = new NodeEnvironment(settings, environment);
        blobEnvironment = new BlobEnvironment(settings, nodeEnvironment, new ClusterName("test"));
    }
View Full Code Here

TOP

Related Classes of io.crate.blob.BlobEnvironment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.