• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java RandomPicks类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: setRandomIndexTranslogSettings

import com.carrotsearch.randomizedtesting.generators.RandomPicks; //导入依赖的package包/类
private static Settings.Builder setRandomIndexTranslogSettings(Random random, Settings.Builder builder) {
    if (random.nextBoolean()) {
        builder.put(IndexSettings.INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE_SETTING.getKey(), new ByteSizeValue(RandomNumbers.randomIntBetween(random, 1, 300), ByteSizeUnit.MB));
    }
    if (random.nextBoolean()) {
        builder.put(IndexSettings.INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE_SETTING.getKey(), new ByteSizeValue(1, ByteSizeUnit.PB)); // just don't flush
    }
    if (random.nextBoolean()) {
        builder.put(IndexSettings.INDEX_TRANSLOG_DURABILITY_SETTING.getKey(), RandomPicks.randomFrom(random, Translog.Durability.values()));
    }

    if (random.nextBoolean()) {
        builder.put(IndexSettings.INDEX_TRANSLOG_SYNC_INTERVAL_SETTING.getKey(), RandomNumbers.randomIntBetween(random, 100, 5000), TimeUnit.MILLISECONDS);
    }

    return builder;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:ESIntegTestCase.java


示例2: RandomizingClient

import com.carrotsearch.randomizedtesting.generators.RandomPicks; //导入依赖的package包/类
public RandomizingClient(Client client, Random random) {
    super(client);
    // we don't use the QUERY_AND_FETCH types that break quite a lot of tests
    // given that they return `size*num_shards` hits instead of `size`
    defaultSearchType = RandomPicks.randomFrom(random, Arrays.asList(
            SearchType.DFS_QUERY_THEN_FETCH,
            SearchType.QUERY_THEN_FETCH));
    if (random.nextInt(10) == 0) {
        defaultPreference = RandomPicks.randomFrom(random, EnumSet.of(Preference.PRIMARY_FIRST, Preference.LOCAL)).type();
    } else if (random.nextInt(10) == 0) {
        String s = TestUtil.randomRealisticUnicodeString(random, 1, 10);
        defaultPreference = s.startsWith("_") ? null : s; // '_' is a reserved character
    } else {
        defaultPreference = null;
    }
    this.batchedReduceSize = 2 + random.nextInt(10);

}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:RandomizingClient.java


示例3: doCreateTestQueryBuilder

import com.carrotsearch.randomizedtesting.generators.RandomPicks; //导入依赖的package包/类
/**
 * @return a {@link HasChildQueryBuilder} with random values all over the place
 */
@Override
protected HasChildQueryBuilder doCreateTestQueryBuilder() {
    int min = randomIntBetween(0, Integer.MAX_VALUE / 2);
    int max = randomIntBetween(min, Integer.MAX_VALUE);

    QueryBuilder innerQueryBuilder = RandomQueryBuilder.createQuery(random());
    if (randomBoolean()) {
        requiresRewrite = true;
        innerQueryBuilder = new WrapperQueryBuilder(innerQueryBuilder.toString());
    }

    HasChildQueryBuilder hqb = new HasChildQueryBuilder(CHILD_TYPE, innerQueryBuilder,
            RandomPicks.randomFrom(random(), ScoreMode.values()));
    hqb.minMaxChildren(min, max);
    hqb.ignoreUnmapped(randomBoolean());
    if (randomBoolean()) {
        hqb.innerHit(new InnerHitBuilder()
                .setName(randomAsciiOfLengthBetween(1, 10))
                .setSize(randomIntBetween(0, 100))
                .addSort(new FieldSortBuilder(STRING_FIELD_NAME_2).order(SortOrder.ASC)), hqb.ignoreUnmapped());
    }
    return hqb;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:HasChildQueryBuilderTests.java


示例4: doCreateTestQueryBuilder

import com.carrotsearch.randomizedtesting.generators.RandomPicks; //导入依赖的package包/类
/**
 * @return a {@link HasChildQueryBuilder} with random values all over the place
 */
@Override
protected NestedQueryBuilder doCreateTestQueryBuilder() {
    QueryBuilder innerQueryBuilder = RandomQueryBuilder.createQuery(random());
    if (randomBoolean()) {
        requiresRewrite = true;
        innerQueryBuilder = new WrapperQueryBuilder(innerQueryBuilder.toString());
    }
    NestedQueryBuilder nqb = new NestedQueryBuilder("nested1", innerQueryBuilder,
            RandomPicks.randomFrom(random(), ScoreMode.values()));
    nqb.ignoreUnmapped(randomBoolean());
    if (randomBoolean()) {
        nqb.innerHit(new InnerHitBuilder()
                .setName(randomAsciiOfLengthBetween(1, 10))
                .setSize(randomIntBetween(0, 100))
                .addSort(new FieldSortBuilder(INT_FIELD_NAME).order(SortOrder.ASC)), nqb.ignoreUnmapped());
    }
    return nqb;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:NestedQueryBuilderTests.java


示例5: testBuiltInAnalyzersAreCached

import com.carrotsearch.randomizedtesting.generators.RandomPicks; //导入依赖的package包/类
public void testBuiltInAnalyzersAreCached() throws IOException {
    Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).build();
    Settings indexSettings = Settings.builder()
            .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build();
    IndexSettings idxSettings = IndexSettingsModule.newIndexSettings("index", indexSettings);
    IndexAnalyzers indexAnalyzers = new AnalysisRegistry(new Environment(settings),
            emptyMap(), emptyMap(), emptyMap(), emptyMap(), emptyMap())
            .build(idxSettings);
    IndexAnalyzers otherIndexAnalyzers = new AnalysisRegistry(new Environment(settings), emptyMap(), emptyMap(), emptyMap(),
            emptyMap(), emptyMap()).build(idxSettings);
    final int numIters = randomIntBetween(5, 20);
    for (int i = 0; i < numIters; i++) {
        PreBuiltAnalyzers preBuiltAnalyzers = RandomPicks.randomFrom(random(), PreBuiltAnalyzers.values());
        assertSame(indexAnalyzers.get(preBuiltAnalyzers.name()), otherIndexAnalyzers.get(preBuiltAnalyzers.name()));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:AnalysisRegistryTests.java


示例6: getTranslogDirs

import com.carrotsearch.randomizedtesting.generators.RandomPicks; //导入依赖的package包/类
private Set<Path> getTranslogDirs(String indexName) throws IOException {
    ClusterState state = client().admin().cluster().prepareState().get().getState();
    GroupShardsIterator shardIterators = state.getRoutingTable().activePrimaryShardsGrouped(new String[]{indexName}, false);
    final Index idx = state.metaData().index(indexName).getIndex();
    List<ShardIterator> iterators = iterableAsArrayList(shardIterators);
    ShardIterator shardIterator = RandomPicks.randomFrom(random(), iterators);
    ShardRouting shardRouting = shardIterator.nextOrNull();
    assertNotNull(shardRouting);
    assertTrue(shardRouting.primary());
    assertTrue(shardRouting.assignedToNode());
    String nodeId = shardRouting.currentNodeId();
    NodesStatsResponse nodeStatses = client().admin().cluster().prepareNodesStats(nodeId).setFs(true).get();
    Set<Path> translogDirs = new TreeSet<>(); // treeset makes sure iteration order is deterministic
    for (FsInfo.Path fsPath : nodeStatses.getNodes().get(0).getFs()) {
        String path = fsPath.getPath();
        final String relativeDataLocationPath =  "indices/"+ idx.getUUID() +"/" + Integer.toString(shardRouting.getId()) + "/translog";
        Path translogPath = PathUtils.get(path).resolve(relativeDataLocationPath);
        if (Files.isDirectory(translogPath)) {
            translogDirs.add(translogPath);
        }
    }
    return translogDirs;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:TruncateTranslogIT.java


示例7: testRangeQuery

import com.carrotsearch.randomizedtesting.generators.RandomPicks; //导入依赖的package包/类
public void testRangeQuery() throws Exception {
    Settings indexSettings = Settings.builder()
        .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build();
    IndexSettings idxSettings = IndexSettingsModule.newIndexSettings(randomAsciiOfLengthBetween(1, 10), indexSettings);
    QueryShardContext context = new QueryShardContext(0, idxSettings, null, null, null, null, null, xContentRegistry(),
            null, null, () -> nowInMillis);
    RangeFieldMapper.RangeFieldType ft = new RangeFieldMapper.RangeFieldType(type);
    ft.setName(FIELDNAME);
    ft.setIndexOptions(IndexOptions.DOCS);

    ShapeRelation relation = RandomPicks.randomFrom(random(), ShapeRelation.values());
    boolean includeLower = random().nextBoolean();
    boolean includeUpper = random().nextBoolean();
    Object from = nextFrom();
    Object to = nextTo(from);

    assertEquals(getExpectedRangeQuery(relation, from, to, includeLower, includeUpper),
        ft.rangeQuery(from, to, includeLower, includeUpper, relation, context));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:RangeFieldTypeTests.java


示例8: testSerialization

import com.carrotsearch.randomizedtesting.generators.RandomPicks; //导入依赖的package包/类
public void testSerialization() throws Exception {
    UnassignedInfo.Reason reason = RandomPicks.randomFrom(random(), UnassignedInfo.Reason.values());
    UnassignedInfo meta = reason == UnassignedInfo.Reason.ALLOCATION_FAILED ?
        new UnassignedInfo(reason, randomBoolean() ? randomAsciiOfLength(4) : null, null, randomIntBetween(1, 100), System.nanoTime(),
                           System.currentTimeMillis(), false, AllocationStatus.NO_ATTEMPT):
        new UnassignedInfo(reason, randomBoolean() ? randomAsciiOfLength(4) : null);
    BytesStreamOutput out = new BytesStreamOutput();
    meta.writeTo(out);
    out.close();

    UnassignedInfo read = new UnassignedInfo(out.bytes().streamInput());
    assertThat(read.getReason(), equalTo(meta.getReason()));
    assertThat(read.getUnassignedTimeInMillis(), equalTo(meta.getUnassignedTimeInMillis()));
    assertThat(read.getMessage(), equalTo(meta.getMessage()));
    assertThat(read.getDetails(), equalTo(meta.getDetails()));
    assertThat(read.getNumFailedAllocations(), equalTo(meta.getNumFailedAllocations()));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:UnassignedInfoTests.java


示例9: testBuildWithCountryDbAndCityFields

import com.carrotsearch.randomizedtesting.generators.RandomPicks; //导入依赖的package包/类
public void testBuildWithCountryDbAndCityFields() throws Exception {
    GeoIpProcessor.Factory factory = new GeoIpProcessor.Factory(databaseReaders);
    Map<String, Object> config = new HashMap<>();
    config.put("field", "_field");
    config.put("database_file", "GeoLite2-Country.mmdb.gz");
    EnumSet<GeoIpProcessor.Property> cityOnlyProperties = EnumSet.complementOf(GeoIpProcessor.Property.ALL_COUNTRY_PROPERTIES);
    String cityProperty = RandomPicks.randomFrom(Randomness.get(), cityOnlyProperties).toString();
    config.put("properties", Collections.singletonList(cityProperty));
    try {
        factory.create(null, null, config);
        fail("Exception expected");
    } catch (ElasticsearchParseException e) {
        assertThat(e.getMessage(), equalTo("[properties] illegal property value [" + cityProperty +
                "]. valid values are [IP, COUNTRY_ISO_CODE, COUNTRY_NAME, CONTINENT_NAME]"));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:GeoIpProcessorFactoryTests.java


示例10: RandomDocument

import com.carrotsearch.randomizedtesting.generators.RandomPicks; //导入依赖的package包/类
protected RandomDocument(int fieldCount, int maxTermCount, Options options, String[] fieldNames, String[] sampleTerms, BytesRef[] sampleTermBytes) {
  if (fieldCount > fieldNames.length) {
    throw new IllegalArgumentException();
  }
  this.fieldNames = new String[fieldCount];
  fieldTypes = new FieldType[fieldCount];
  tokenStreams = new RandomTokenStream[fieldCount];
  Arrays.fill(fieldTypes, fieldType(options));
  final Set<String> usedFileNames = new HashSet<>();
  for (int i = 0; i < fieldCount; ++i) {
    do {
      this.fieldNames[i] = RandomPicks.randomFrom(random(), fieldNames);
    } while (usedFileNames.contains(this.fieldNames[i]));
    usedFileNames.add(this.fieldNames[i]);
    tokenStreams[i] = new RandomTokenStream(TestUtil.nextInt(random(), 1, maxTermCount), sampleTerms, sampleTermBytes);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:18,代码来源:BaseTermVectorsFormatTestCase.java


示例11: randomLong

import com.carrotsearch.randomizedtesting.generators.RandomPicks; //导入依赖的package包/类
static long randomLong() {
  if (random().nextBoolean()) {
    long l = 1;
    if (random().nextBoolean()) {
      l *= -1;
    }
    for (long i : PRIMES) {
      final int m = random().nextInt(3);
      for (int j = 0; j < m; ++j) {
        l *= i;
      }
    }
    return l;
  } else if (random().nextBoolean()) {
    return random().nextLong();
  } else {
    return RandomPicks.randomFrom(random(), Arrays.asList(Long.MIN_VALUE, Long.MAX_VALUE, 0L, -1L, 1L));
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:TestMathUtil.java


示例12: RandomDocument

import com.carrotsearch.randomizedtesting.generators.RandomPicks; //导入依赖的package包/类
protected RandomDocument(int fieldCount, int maxTermCount, Options options, String[] fieldNames, String[] sampleTerms, BytesRef[] sampleTermBytes) {
  if (fieldCount > fieldNames.length) {
    throw new IllegalArgumentException();
  }
  this.fieldNames = new String[fieldCount];
  fieldTypes = new FieldType[fieldCount];
  tokenStreams = new RandomTokenStream[fieldCount];
  Arrays.fill(fieldTypes, fieldType(options));
  final Set<String> usedFileNames = new HashSet<String>();
  for (int i = 0; i < fieldCount; ++i) {
    do {
      this.fieldNames[i] = RandomPicks.randomFrom(random(), fieldNames);
    } while (usedFileNames.contains(this.fieldNames[i]));
    usedFileNames.add(this.fieldNames[i]);
    tokenStreams[i] = new RandomTokenStream(_TestUtil.nextInt(random(), 1, maxTermCount), sampleTerms, sampleTermBytes);
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:18,代码来源:BaseTermVectorsFormatTestCase.java


示例13: newDirectoryImpl

import com.carrotsearch.randomizedtesting.generators.RandomPicks; //导入依赖的package包/类
static Directory newDirectoryImpl(Random random, String clazzName) {
  if (clazzName.equals("random")) {
    if (rarely(random)) {
      clazzName = RandomPicks.randomFrom(random, CORE_DIRECTORIES);
    } else {
      clazzName = "RAMDirectory";
    }
  }

  try {
    final Class<? extends Directory> clazz = CommandLineUtil.loadDirectoryClass(clazzName);
    // If it is a FSDirectory type, try its ctor(File)
    if (FSDirectory.class.isAssignableFrom(clazz)) {
      final File dir = _TestUtil.getTempDir("index");
      dir.mkdirs(); // ensure it's created so we 'have' it.
      return newFSDirectoryImpl(clazz.asSubclass(FSDirectory.class), dir);
    }

    // try empty ctor
    return clazz.newInstance();
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:25,代码来源:LuceneTestCase.java


示例14: createRandomIndexes

import com.carrotsearch.randomizedtesting.generators.RandomPicks; //导入依赖的package包/类
private void createRandomIndexes(int maxSegments) throws IOException {
  dir = newDirectory();
  numDocs = atLeast(150);
  final int numTerms = _TestUtil.nextInt(random(), 1, numDocs / 5);
  Set<String> randomTerms = new HashSet<String>();
  while (randomTerms.size() < numTerms) {
    randomTerms.add(_TestUtil.randomSimpleString(random()));
  }
  terms = new ArrayList<String>(randomTerms);
  final long seed = random().nextLong();
  final IndexWriterConfig iwc = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(new Random(seed)));
  iwc.setMergePolicy(TestSortingMergePolicy.newSortingMergePolicy(sorter));
  iw = new RandomIndexWriter(new Random(seed), dir, iwc);
  for (int i = 0; i < numDocs; ++i) {
    final Document doc = randomDocument();
    iw.addDocument(doc);
    if (i == numDocs / 2 || (i != numDocs - 1 && random().nextInt(8) == 0)) {
      iw.commit();
    }
    if (random().nextInt(15) == 0) {
      final String term = RandomPicks.randomFrom(random(), terms);
      iw.deleteDocuments(new Term("s", term));
    }
  }
  reader = iw.getReader();
}
 
开发者ID:jimaguere,项目名称:Maskana-Gestor-de-Conocimiento,代码行数:27,代码来源:TestEarlyTermination.java


示例15: testEarlyTermination

import com.carrotsearch.randomizedtesting.generators.RandomPicks; //导入依赖的package包/类
public void testEarlyTermination() throws IOException {
  createRandomIndexes(5);
  final int numHits = _TestUtil.nextInt(random(), 1, numDocs / 10);
  final Sort sort = new Sort(new SortField("ndv1", SortField.Type.LONG, false));
  final boolean fillFields = random().nextBoolean();
  final boolean trackDocScores = random().nextBoolean();
  final boolean trackMaxScore = random().nextBoolean();
  final boolean inOrder = random().nextBoolean();
  final TopFieldCollector collector1 = TopFieldCollector.create(sort, numHits, fillFields, trackDocScores, trackMaxScore, inOrder);
  final TopFieldCollector collector2 = TopFieldCollector.create(sort, numHits, fillFields, trackDocScores, trackMaxScore, inOrder);

  final IndexSearcher searcher = newSearcher(reader);
  final int iters = atLeast(5);
  for (int i = 0; i < iters; ++i) {
    final TermQuery query = new TermQuery(new Term("s", RandomPicks.randomFrom(random(), terms)));
    searcher.search(query, collector1);
    searcher.search(query, new EarlyTerminatingSortingCollector(collector2, sorter, numHits));
  }
  assertTrue(collector1.getTotalHits() >= collector2.getTotalHits());
  assertTopDocsEquals(collector1.topDocs().scoreDocs, collector2.topDocs().scoreDocs);
}
 
开发者ID:jimaguere,项目名称:Maskana-Gestor-de-Conocimiento,代码行数:22,代码来源:TestEarlyTermination.java


示例16: startHttpServer

import com.carrotsearch.randomizedtesting.generators.RandomPicks; //导入依赖的package包/类
@Before
public void startHttpServer() throws IOException {
    this.sniffRequestTimeout = RandomNumbers.randomIntBetween(getRandom(), 1000, 10000);
    this.scheme = RandomPicks.randomFrom(getRandom(), ElasticsearchHostsSniffer.Scheme.values());
    if (rarely()) {
        this.sniffResponse = SniffResponse.buildFailure();
    } else {
        this.sniffResponse = buildSniffResponse(scheme);
    }
    this.httpServer = createHttpServer(sniffResponse, sniffRequestTimeout);
    this.httpServer.start();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:ElasticsearchHostsSnifferTests.java


示例17: randomPickExcept

import com.carrotsearch.randomizedtesting.generators.RandomPicks; //导入依赖的package包/类
private static <T> T randomPickExcept(List<T> fromList, T butNot) {
    while (true) {
        T t = RandomPicks.randomFrom(random(), fromList);
        if (t.equals(butNot)) {
            continue;
        }
        return t;
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:MultiMatchQueryIT.java


示例18: testDuelIndexOrderQueryThenFetch

import com.carrotsearch.randomizedtesting.generators.RandomPicks; //导入依赖的package包/类
public void testDuelIndexOrderQueryThenFetch() throws Exception {
    final SearchType searchType = RandomPicks.randomFrom(random(), Arrays.asList(SearchType.QUERY_THEN_FETCH,
        SearchType.DFS_QUERY_THEN_FETCH));
    final int numDocs = createIndex(false);
    testDuelIndexOrder(searchType, false, numDocs);
    testDuelIndexOrder(searchType, true, numDocs);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:DuelScrollIT.java


示例19: testLocationHashCodeEquals

import com.carrotsearch.randomizedtesting.generators.RandomPicks; //导入依赖的package包/类
public void testLocationHashCodeEquals() throws IOException {
    List<Translog.Location> locations = new ArrayList<>();
    List<Translog.Location> locations2 = new ArrayList<>();
    int translogOperations = randomIntBetween(10, 100);
    try (Translog translog2 = create(createTempDir())) {
        for (int op = 0; op < translogOperations; op++) {
            locations.add(translog.add(new Translog.Index("test", "" + op, Integer.toString(op).getBytes(Charset.forName("UTF-8")))));
            locations2.add(translog2.add(new Translog.Index("test", "" + op, Integer.toString(op).getBytes(Charset.forName("UTF-8")))));
        }
        int iters = randomIntBetween(10, 100);
        for (int i = 0; i < iters; i++) {
            Translog.Location location = RandomPicks.randomFrom(random(), locations);
            for (Translog.Location loc : locations) {
                if (loc == location) {
                    assertTrue(loc.equals(location));
                    assertEquals(loc.hashCode(), location.hashCode());
                } else {
                    assertFalse(loc.equals(location));
                }
            }
            for (int j = 0; j < translogOperations; j++) {
                assertTrue(locations.get(j).equals(locations2.get(j)));
                assertEquals(locations.get(j).hashCode(), locations2.get(j).hashCode());
            }
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:28,代码来源:TranslogTests.java


示例20: corruptRandomPrimaryFile

import com.carrotsearch.randomizedtesting.generators.RandomPicks; //导入依赖的package包/类
private ShardRouting corruptRandomPrimaryFile(final boolean includePerCommitFiles) throws IOException {
    ClusterState state = client().admin().cluster().prepareState().get().getState();
    Index test = state.metaData().index("test").getIndex();
    GroupShardsIterator shardIterators = state.getRoutingTable().activePrimaryShardsGrouped(new String[]{"test"}, false);
    List<ShardIterator> iterators = iterableAsArrayList(shardIterators);
    ShardIterator shardIterator = RandomPicks.randomFrom(random(), iterators);
    ShardRouting shardRouting = shardIterator.nextOrNull();
    assertNotNull(shardRouting);
    assertTrue(shardRouting.primary());
    assertTrue(shardRouting.assignedToNode());
    String nodeId = shardRouting.currentNodeId();
    NodesStatsResponse nodeStatses = client().admin().cluster().prepareNodesStats(nodeId).setFs(true).get();
    Set<Path> files = new TreeSet<>(); // treeset makes sure iteration order is deterministic
    for (FsInfo.Path info : nodeStatses.getNodes().get(0).getFs()) {
        String path = info.getPath();
        Path file = PathUtils.get(path).resolve("indices").resolve(test.getUUID()).resolve(Integer.toString(shardRouting.getId())).resolve("index");
        if (Files.exists(file)) { // multi data path might only have one path in use
            try (DirectoryStream<Path> stream = Files.newDirectoryStream(file)) {
                for (Path item : stream) {
                    if (Files.isRegularFile(item) && "write.lock".equals(item.getFileName().toString()) == false) {
                        if (includePerCommitFiles || isPerSegmentFile(item.getFileName().toString())) {
                            files.add(item);
                        }
                    }
                }
            }
        }
    }
    pruneOldDeleteGenerations(files);
    CorruptionUtils.corruptFile(random(), files.toArray(new Path[0]));
    return shardRouting;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:33,代码来源:CorruptedFileIT.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MassIndexer类代码示例发布时间:2022-05-22
下一篇:
Java RubyNil类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap