当前位置: 首页>>代码示例>>Java>>正文


Java BlobStore类代码示例

本文整理汇总了Java中org.elasticsearch.common.blobstore.BlobStore的典型用法代码示例。如果您正苦于以下问题:Java BlobStore类的具体用法?Java BlobStore怎么用?Java BlobStore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BlobStore类属于org.elasticsearch.common.blobstore包,在下文中一共展示了BlobStore类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testContainerCreationAndDeletion

import org.elasticsearch.common.blobstore.BlobStore; //导入依赖的package包/类
public void testContainerCreationAndDeletion() throws IOException {
    try(BlobStore store = newBlobStore()) {
        final BlobContainer containerFoo = store.blobContainer(new BlobPath().add("foo"));
        final BlobContainer containerBar = store.blobContainer(new BlobPath().add("bar"));
        byte[] data1 = randomBytes(randomIntBetween(10, scaledRandomIntBetween(1024, 1 << 16)));
        byte[] data2 = randomBytes(randomIntBetween(10, scaledRandomIntBetween(1024, 1 << 16)));
        writeBlob(containerFoo, "test", new BytesArray(data1));
        writeBlob(containerBar, "test", new BytesArray(data2));

        assertArrayEquals(readBlobFully(containerFoo, "test", data1.length), data1);
        assertArrayEquals(readBlobFully(containerBar, "test", data2.length), data2);

        assertTrue(containerFoo.blobExists("test"));
        assertTrue(containerBar.blobExists("test"));
        store.delete(new BlobPath());
        assertFalse(containerFoo.blobExists("test"));
        assertFalse(containerBar.blobExists("test"));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:ESBlobStoreTestCase.java

示例2: testWriteRead

import org.elasticsearch.common.blobstore.BlobStore; //导入依赖的package包/类
public void testWriteRead() throws IOException {
    try(BlobStore store = newBlobStore()) {
        final BlobContainer container = store.blobContainer(new BlobPath());
        byte[] data = randomBytes(randomIntBetween(10, scaledRandomIntBetween(1024, 1 << 16)));
        writeBlob(container, "foobar", new BytesArray(data));
        try (InputStream stream = container.readBlob("foobar")) {
            BytesRefBuilder target = new BytesRefBuilder();
            while (target.length() < data.length) {
                byte[] buffer = new byte[scaledRandomIntBetween(1, data.length - target.length())];
                int offset = scaledRandomIntBetween(0, buffer.length - 1);
                int read = stream.read(buffer, offset, buffer.length - offset);
                target.append(new BytesRef(buffer, offset, read));
            }
            assertEquals(data.length, target.length());
            assertArrayEquals(data, Arrays.copyOfRange(target.bytes(), 0, target.length()));
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:ESBlobStoreContainerTestCase.java

示例3: testBlobStoreOperations

import org.elasticsearch.common.blobstore.BlobStore; //导入依赖的package包/类
public void testBlobStoreOperations() throws IOException {
    BlobStore blobStore = createTestBlobStore();
    BlobContainer blobContainer = blobStore.blobContainer(BlobPath.cleanPath());
    ChecksumBlobStoreFormat<BlobObj> checksumJSON = new ChecksumBlobStoreFormat<>(BLOB_CODEC, "%s", BlobObj::fromXContent,
        xContentRegistry(), false, XContentType.JSON);
    ChecksumBlobStoreFormat<BlobObj> checksumSMILE = new ChecksumBlobStoreFormat<>(BLOB_CODEC, "%s", BlobObj::fromXContent,
        xContentRegistry(), false, XContentType.SMILE);
    ChecksumBlobStoreFormat<BlobObj> checksumSMILECompressed = new ChecksumBlobStoreFormat<>(BLOB_CODEC, "%s", BlobObj::fromXContent,
        xContentRegistry(), true, XContentType.SMILE);

    // Write blobs in different formats
    checksumJSON.write(new BlobObj("checksum json"), blobContainer, "check-json");
    checksumSMILE.write(new BlobObj("checksum smile"), blobContainer, "check-smile");
    checksumSMILECompressed.write(new BlobObj("checksum smile compressed"), blobContainer, "check-smile-comp");

    // Assert that all checksum blobs can be read by all formats
    assertEquals(checksumJSON.read(blobContainer, "check-json").getText(), "checksum json");
    assertEquals(checksumSMILE.read(blobContainer, "check-json").getText(), "checksum json");
    assertEquals(checksumJSON.read(blobContainer, "check-smile").getText(), "checksum smile");
    assertEquals(checksumSMILE.read(blobContainer, "check-smile").getText(), "checksum smile");
    assertEquals(checksumJSON.read(blobContainer, "check-smile-comp").getText(), "checksum smile compressed");
    assertEquals(checksumSMILE.read(blobContainer, "check-smile-comp").getText(), "checksum smile compressed");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:BlobStoreFormatIT.java

示例4: testCompressionIsApplied

import org.elasticsearch.common.blobstore.BlobStore; //导入依赖的package包/类
public void testCompressionIsApplied() throws IOException {
    BlobStore blobStore = createTestBlobStore();
    BlobContainer blobContainer = blobStore.blobContainer(BlobPath.cleanPath());
    StringBuilder veryRedundantText = new StringBuilder();
    for (int i = 0; i < randomIntBetween(100, 300); i++) {
        veryRedundantText.append("Blah ");
    }
    ChecksumBlobStoreFormat<BlobObj> checksumFormat = new ChecksumBlobStoreFormat<>(BLOB_CODEC, "%s", BlobObj::fromXContent,
        xContentRegistry(), false, randomBoolean() ? XContentType.SMILE : XContentType.JSON);
    ChecksumBlobStoreFormat<BlobObj> checksumFormatComp = new ChecksumBlobStoreFormat<>(BLOB_CODEC, "%s", BlobObj::fromXContent,
        xContentRegistry(), true, randomBoolean() ? XContentType.SMILE : XContentType.JSON);
    BlobObj blobObj = new BlobObj(veryRedundantText.toString());
    checksumFormatComp.write(blobObj, blobContainer, "blob-comp");
    checksumFormat.write(blobObj, blobContainer, "blob-not-comp");
    Map<String, BlobMetaData> blobs = blobContainer.listBlobsByPrefix("blob-");
    assertEquals(blobs.size(), 2);
    assertThat(blobs.get("blob-not-comp").length(), greaterThan(blobs.get("blob-comp").length()));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:BlobStoreFormatIT.java

示例5: testDeleteBlob

import org.elasticsearch.common.blobstore.BlobStore; //导入依赖的package包/类
public void testDeleteBlob() throws IOException {
    try (BlobStore store = newBlobStore()) {
        final String blobName = "foobar";
        final BlobContainer container = store.blobContainer(new BlobPath());
        expectThrows(IOException.class, () -> container.deleteBlob(blobName));

        byte[] data = randomBytes(randomIntBetween(10, scaledRandomIntBetween(1024, 1 << 16)));
        final BytesArray bytesArray = new BytesArray(data);
        writeBlob(container, blobName, bytesArray);
        container.deleteBlob(blobName); // should not raise

        // blob deleted, so should raise again
        expectThrows(IOException.class, () -> container.deleteBlob(blobName));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:ESBlobStoreContainerTestCase.java

示例6: testVerifyOverwriteFails

import org.elasticsearch.common.blobstore.BlobStore; //导入依赖的package包/类
public void testVerifyOverwriteFails() throws IOException {
    try (BlobStore store = newBlobStore()) {
        final String blobName = "foobar";
        final BlobContainer container = store.blobContainer(new BlobPath());
        byte[] data = randomBytes(randomIntBetween(10, scaledRandomIntBetween(1024, 1 << 16)));
        final BytesArray bytesArray = new BytesArray(data);
        writeBlob(container, blobName, bytesArray);
        // should not be able to overwrite existing blob
        expectThrows(IOException.class, () -> writeBlob(container, blobName, bytesArray));
        container.deleteBlob(blobName);
        writeBlob(container, blobName, bytesArray); // after deleting the previous blob, we should be able to write to it again
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:ESBlobStoreContainerTestCase.java

示例7: testAtomicWrite

import org.elasticsearch.common.blobstore.BlobStore; //导入依赖的package包/类
public void testAtomicWrite() throws Exception {
    final BlobStore blobStore = createTestBlobStore();
    final BlobContainer blobContainer = blobStore.blobContainer(BlobPath.cleanPath());
    String testString = randomAsciiOfLength(randomInt(10000));
    final CountDownLatch block = new CountDownLatch(1);
    final CountDownLatch unblock = new CountDownLatch(1);
    final BlobObj blobObj = new BlobObj(testString) {
        @Override
        public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException {
            super.toXContent(builder, params);
            // Block before finishing writing
            try {
                block.countDown();
                unblock.await(5, TimeUnit.SECONDS);
            } catch (InterruptedException ex) {
                Thread.currentThread().interrupt();
            }
            return builder;
        }
    };
    final ChecksumBlobStoreFormat<BlobObj> checksumFormat = new ChecksumBlobStoreFormat<>(BLOB_CODEC, "%s", BlobObj::fromXContent,
        xContentRegistry(), randomBoolean(), randomBoolean() ? XContentType.SMILE : XContentType.JSON);
    ExecutorService threadPool = Executors.newFixedThreadPool(1);
    try {
        Future<Void> future = threadPool.submit(new Callable<Void>() {
            @Override
            public Void call() throws Exception {
                checksumFormat.writeAtomic(blobObj, blobContainer, "test-blob");
                return null;
            }
        });
        block.await(5, TimeUnit.SECONDS);
        assertFalse(blobContainer.blobExists("test-blob"));
        unblock.countDown();
        future.get();
        assertTrue(blobContainer.blobExists("test-blob"));
    } finally {
        threadPool.shutdown();
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:41,代码来源:BlobStoreFormatIT.java

示例8: newBlobStore

import org.elasticsearch.common.blobstore.BlobStore; //导入依赖的package包/类
@Override
protected BlobStore newBlobStore() throws IOException {
    try {
        RepositoryMetaData repositoryMetaData = new RepositoryMetaData("azure", "ittest", Settings.EMPTY);
        AzureStorageServiceMock client = new AzureStorageServiceMock();
        return new AzureBlobStore(repositoryMetaData, Settings.EMPTY, client);
    } catch (URISyntaxException | StorageException e) {
        throw new IOException(e);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:AzureBlobStoreContainerTests.java

示例9: newBlobStore

import org.elasticsearch.common.blobstore.BlobStore; //导入依赖的package包/类
protected BlobStore newBlobStore() throws IOException {
    MockAmazonS3 client = new MockAmazonS3();
    String bucket = randomAsciiOfLength(randomIntBetween(1, 10)).toLowerCase(Locale.ROOT);

    return new S3BlobStore(Settings.EMPTY, client, bucket, false,
        new ByteSizeValue(10, ByteSizeUnit.MB), 5, "public-read-write", "standard");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:S3BlobStoreContainerTests.java

示例10: newBlobStore

import org.elasticsearch.common.blobstore.BlobStore; //导入依赖的package包/类
@Override
protected BlobStore newBlobStore() throws IOException {
    FileContext fileContext;
    try {
        fileContext = AccessController.doPrivileged((PrivilegedExceptionAction<FileContext>)
            () -> createContext(new URI("hdfs:///")));
    } catch (PrivilegedActionException e) {
        throw new RuntimeException(e.getCause());
    }
    return new HdfsBlobStore(fileContext, "temp", 1024);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:HdfsBlobStoreContainerTests.java

示例11: initialize

import org.elasticsearch.common.blobstore.BlobStore; //导入依赖的package包/类
/**
 * Called by {@link org.elasticsearch.repositories.blobstore.BlobStoreRepository} on repository startup
 *
 * @param blobStore blob store
 * @param basePath  base path to blob store
 * @param chunkSize chunk size
 */
public void initialize(BlobStore blobStore, BlobPath basePath, ByteSizeValue chunkSize,
                       RateLimiter snapshotRateLimiter, RateLimiter restoreRateLimiter,
                       final RateLimiterListener rateLimiterListener, boolean compress) {
    this.blobStore = blobStore;
    this.basePath = basePath;
    this.chunkSize = chunkSize;
    this.snapshotRateLimiter = snapshotRateLimiter;
    this.restoreRateLimiter = restoreRateLimiter;
    this.rateLimiterListener = rateLimiterListener;
    this.snapshotThrottleListener = new RateLimitingInputStream.Listener() {
        @Override
        public void onPause(long nanos) {
            rateLimiterListener.onSnapshotPause(nanos);
        }
    };
    this.restoreThrottleListener = new RateLimitingInputStream.Listener() {
        @Override
        public void onPause(long nanos) {
            rateLimiterListener.onRestorePause(nanos);
        }
    };
    this.compress = compress;
    indexShardSnapshotFormat = new ChecksumBlobStoreFormat<>(SNAPSHOT_CODEC, SNAPSHOT_NAME_FORMAT, BlobStoreIndexShardSnapshot.PROTO, parseFieldMatcher, isCompress());
    indexShardSnapshotLegacyFormat = new LegacyBlobStoreFormat<>(LEGACY_SNAPSHOT_NAME_FORMAT, BlobStoreIndexShardSnapshot.PROTO, parseFieldMatcher);
    indexShardSnapshotsFormat = new ChecksumBlobStoreFormat<>(SNAPSHOT_INDEX_CODEC, SNAPSHOT_INDEX_NAME_FORMAT, BlobStoreIndexShardSnapshots.PROTO, parseFieldMatcher, isCompress());
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:34,代码来源:BlobStoreIndexShardRepository.java

示例12: CloudFilesBlobStore

import org.elasticsearch.common.blobstore.BlobStore; //导入依赖的package包/类
public CloudFilesBlobStore(Settings settings, RegionScopedBlobStoreContext context, String container, Location location, Executor executor) {
    super(settings);
    this.blobStoreContext = context;
    this.container = container;
    this.executor = executor;
    this.location = location;

    this.bufferSizeInBytes = (int) settings.getAsBytesSize("buffer_size", new ByteSizeValue(100, ByteSizeUnit.KB)).bytes();

    // create the cloud files container if it does not already exist
    org.jclouds.blobstore.BlobStore blobStore = blobStoreContext.getBlobStore(location.getId());
    blobStore.createContainerInLocation(getOnlyElement(blobStore.listAssignableLocations()), container);
}
 
开发者ID:jlinn,项目名称:elasticsearch-cloud-rackspace,代码行数:14,代码来源:CloudFilesBlobStore.java

示例13: blobStore

import org.elasticsearch.common.blobstore.BlobStore; //导入依赖的package包/类
@Override
protected BlobStore blobStore() {
    return blobStore;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:URLRepository.java

示例14: createTestBlobStore

import org.elasticsearch.common.blobstore.BlobStore; //导入依赖的package包/类
protected BlobStore createTestBlobStore() throws IOException {
    Settings settings = Settings.builder().build();
    return new FsBlobStore(settings, randomRepoPath());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:BlobStoreFormatIT.java

示例15: BlobStoreWrapper

import org.elasticsearch.common.blobstore.BlobStore; //导入依赖的package包/类
public BlobStoreWrapper(BlobStore delegate) {
    this.delegate = delegate;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:4,代码来源:BlobStoreWrapper.java


注:本文中的org.elasticsearch.common.blobstore.BlobStore类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。