use of java.nio.file.Path in project crate by crate.
the class BlobPathITest method testDataStorageWithMultipleDataPaths.
@Test
public void testDataStorageWithMultipleDataPaths() throws Exception {
Path data1 = createTempDir("data1");
Path data2 = createTempDir("data2");
Settings settings = Settings.builder().put(nodeSettings(0)).put("path.data", data1.toString() + "," + data2.toString()).build();
launchNodeAndInitClient(settings);
Settings indexSettings = Settings.builder().put(SETTING_NUMBER_OF_REPLICAS, 0).put(SETTING_NUMBER_OF_SHARDS, 2).build();
blobAdminClient.createBlobTable("test", indexSettings).get();
for (int i = 0; i < 10; i++) {
client.put("test", "body" + i);
}
List<String> data1Files = gatherDigests(data1);
List<String> data2Files = gatherDigests(data2);
assertThat(data1Files.size(), Matchers.allOf(lessThan(10), greaterThan(0)));
assertThat(data2Files.size(), Matchers.allOf(lessThan(10), greaterThan(0)));
assertThat(data1Files.size() + data2Files.size(), is(10));
}
use of java.nio.file.Path in project crate by crate.
the class BlobIndicesService method getGlobalBlobPath.
@Nullable
public static Path getGlobalBlobPath(Settings settings) {
String customGlobalBlobPathSetting = settings.get(SETTING_BLOBS_PATH);
if (customGlobalBlobPathSetting == null) {
return null;
}
Path globalBlobPath = PathUtils.get(customGlobalBlobPathSetting);
ensureExistsAndWritable(globalBlobPath);
return globalBlobPath;
}
use of java.nio.file.Path in project crate by crate.
the class LuceneQueryBuilderTest method prepare.
@Before
public void prepare() throws Exception {
DocTableInfo users = TestingTableInfo.builder(new TableIdent(null, "users"), null).add("name", DataTypes.STRING).add("x", DataTypes.INTEGER).add("d", DataTypes.DOUBLE).add("d_array", new ArrayType(DataTypes.DOUBLE)).add("y_array", new ArrayType(DataTypes.LONG)).add("shape", DataTypes.GEO_SHAPE).add("point", DataTypes.GEO_POINT).build();
TableRelation usersTr = new TableRelation(users);
sources = ImmutableMap.of(new QualifiedName("users"), usersTr);
expressions = new SqlExpressions(sources, usersTr);
builder = new LuceneQueryBuilder(expressions.getInstance(Functions.class));
indexCache = mock(IndexCache.class, Answers.RETURNS_MOCKS.get());
Path tempDir = createTempDir();
Settings indexSettings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).put("path.home", tempDir).build();
Index index = new Index(users.ident().indexName());
when(indexCache.indexSettings()).thenReturn(indexSettings);
AnalysisService analysisService = createAnalysisService(indexSettings, index);
mapperService = createMapperService(index, indexSettings, analysisService);
// @formatter:off
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("default").startObject("properties").startObject("name").field("type", "string").endObject().startObject("x").field("type", "integer").endObject().startObject("d").field("type", "double").endObject().startObject("point").field("type", "geo_point").endObject().startObject("shape").field("type", "geo_shape").endObject().startObject("d_array").field("type", "array").startObject("inner").field("type", "double").endObject().endObject().startObject("y_array").field("type", "array").startObject("inner").field("type", "integer").endObject().endObject().endObject().endObject().endObject();
// @formatter:on
mapperService.merge("default", new CompressedXContent(xContentBuilder.bytes()), MapperService.MergeReason.MAPPING_UPDATE, true);
indexFieldDataService = mock(IndexFieldDataService.class);
IndexFieldData geoFieldData = mock(IndexGeoPointFieldData.class);
when(geoFieldData.getFieldNames()).thenReturn(new MappedFieldType.Names("point"));
when(indexFieldDataService.getForField(mapperService.smartNameFieldType("point"))).thenReturn(geoFieldData);
}
use of java.nio.file.Path in project crate by crate.
the class FileWriterProjectorTest method testWriteRawToFile.
@Test
public void testWriteRawToFile() throws Exception {
Path file = createTempFile("out", "json");
FileWriterProjector fileWriterProjector = new FileWriterProjector(executorService, file.toUri().toString(), null, null, ImmutableSet.of(), new HashMap<>(), null, WriterProjection.OutputFormat.JSON_OBJECT);
new TestingBatchConsumer().accept(fileWriterProjector.apply(sourceSupplier.get()), null);
assertEquals("input line 00\n" + "input line 01\n" + "input line 02\n" + "input line 03\n" + "input line 04\n", TestingHelpers.readFile(file.toAbsolutePath().toString()));
}
use of java.nio.file.Path in project crate by crate.
the class SysShardsExpressionsTest method mockIndexShard.
private IndexShard mockIndexShard() {
IndexService indexService = mock(IndexService.class);
Index index = new Index(indexName);
ShardId shardId = new ShardId(indexName, 1);
IndexShard indexShard = mock(IndexShard.class);
when(indexService.index()).thenReturn(index);
when(indexShard.indexService()).thenReturn(indexService);
when(indexShard.shardId()).thenReturn(shardId);
when(indexShard.state()).thenReturn(IndexShardState.STARTED);
StoreStats storeStats = mock(StoreStats.class);
when(storeStats.getSizeInBytes()).thenReturn(123456L);
when(indexShard.storeStats()).thenReturn(storeStats);
Path dataPath = Paths.get("/dummy/" + indexName + "/1");
when(indexShard.shardPath()).thenReturn(new ShardPath(false, dataPath, dataPath, "123", shardId));
DocsStats docsStats = new DocsStats(654321L, 0L);
when(indexShard.docStats()).thenReturn(docsStats).thenThrow(IllegalIndexShardStateException.class);
ShardRouting shardRouting = ShardRouting.newUnassigned(index.name(), shardId.id(), null, true, new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, "foo"));
ShardRoutingHelper.initialize(shardRouting, "node1");
ShardRoutingHelper.moveToStarted(shardRouting);
ShardRoutingHelper.relocate(shardRouting, "node_X");
when(indexShard.routingEntry()).thenReturn(shardRouting);
when(indexShard.minimumCompatibleVersion()).thenReturn(Version.LATEST);
RecoveryState recoveryState = mock(RecoveryState.class);
when(indexShard.recoveryState()).thenReturn(recoveryState);
RecoveryState.Index recoveryStateIndex = mock(RecoveryState.Index.class);
RecoveryState.Timer recoveryStateTimer = mock(RecoveryState.Timer.class);
when(recoveryState.getIndex()).thenReturn(recoveryStateIndex);
when(recoveryState.getStage()).thenReturn(RecoveryState.Stage.DONE);
when(recoveryState.getTimer()).thenReturn(recoveryStateTimer);
when(recoveryState.getType()).thenReturn(RecoveryState.Type.REPLICA);
when(recoveryStateIndex.totalBytes()).thenReturn(2048L);
when(recoveryStateIndex.reusedBytes()).thenReturn(1024L);
when(recoveryStateIndex.recoveredBytes()).thenReturn(1024L);
when(recoveryStateIndex.totalFileCount()).thenReturn(2);
when(recoveryStateIndex.reusedFileCount()).thenReturn(1);
when(recoveryStateIndex.recoveredFileCount()).thenReturn(1);
when(recoveryStateTimer.time()).thenReturn(10000L);
return indexShard;
}
Aggregations