@Inject
  public MockFSDirectoryService(
      IndexSettings idxSettings,
      IndexStore indexStore,
      final IndicesService service,
      final ShardPath path) {
    super(idxSettings, indexStore, path);
    Settings indexSettings = idxSettings.getSettings();
    final long seed = indexSettings.getAsLong(ESIntegTestCase.SETTING_INDEX_SEED, 0l);
    this.random = new Random(seed);

    randomIOExceptionRate = indexSettings.getAsDouble(RANDOM_IO_EXCEPTION_RATE, 0.0d);
    randomIOExceptionRateOnOpen = indexSettings.getAsDouble(RANDOM_IO_EXCEPTION_RATE_ON_OPEN, 0.0d);
    preventDoubleWrite =
        indexSettings.getAsBoolean(RANDOM_PREVENT_DOUBLE_WRITE, true); // true is default in MDW
    noDeleteOpenFile =
        indexSettings.getAsBoolean(
            RANDOM_NO_DELETE_OPEN_FILE, random.nextBoolean()); // true is default in MDW
    random.nextInt(shardId.getId() + 1); // some randomness per shard
    throttle = MockDirectoryWrapper.Throttling.NEVER;
    crashIndex = indexSettings.getAsBoolean(CRASH_INDEX, true);

    if (logger.isDebugEnabled()) {
      logger.debug(
          "Using MockDirWrapper with seed [{}] throttle: [{}] crashIndex: [{}]",
          SeedUtils.formatSeed(seed),
          throttle,
          crashIndex);
    }
    this.indexSettings = indexSettings;
    delegateService = randomDirectorService(indexStore, path);
  }
示例#2
0
 public static String clusterName(String prefix, String childVMId, long clusterSeed) {
   StringBuilder builder = new StringBuilder(prefix);
   builder.append('-').append(NetworkUtils.getLocalAddress().getHostName());
   builder.append("-CHILD_VM=[").append(childVMId).append(']');
   builder.append("-CLUSTER_SEED=[").append(clusterSeed).append(']');
   // if multiple maven task run on a single host we better have an identifier that doesn't rely on
   // input params
   builder.append("-HASH=[").append(SeedUtils.formatSeed(System.nanoTime())).append(']');
   return builder.toString();
 }
示例#3
0
 TestCluster(
     long clusterSeed, int numNodes, String clusterName, NodeSettingsSource nodeSettingsSource) {
   this.clusterName = clusterName;
   Random random = new Random(clusterSeed);
   numSharedNodes =
       numNodes == -1 ? 2 + random.nextInt(4) : numNodes; // at least 2 nodes if randomized
   assert numSharedNodes >= 0;
   /*
    *  TODO
    *  - we might want start some master only nodes?
    *  - we could add a flag that returns a client to the master all the time?
    *  - we could add a flag that never returns a client to the master
    *  - along those lines use a dedicated node that is master eligible and let all other nodes be only data nodes
    */
   sharedNodesSeeds = new long[numSharedNodes];
   for (int i = 0; i < sharedNodesSeeds.length; i++) {
     sharedNodesSeeds[i] = random.nextLong();
   }
   logger.info(
       "Setup TestCluster [{}] with seed [{}] using [{}] nodes",
       clusterName,
       SeedUtils.formatSeed(clusterSeed),
       numSharedNodes);
   Builder builder =
       ImmutableSettings.settingsBuilder()
           /* use RAM directories in 10% of the runs */
           //        .put("index.store.type", random.nextInt(10) == 0 ?
           // MockRamIndexStoreModule.class.getName() : MockFSIndexStoreModule.class.getName())
           .put("index.store.type", MockFSIndexStoreModule.class.getName()) // no RAM dir for now!
           .put(IndexEngineModule.EngineSettings.ENGINE_TYPE, MockEngineModule.class.getName())
           .put("cluster.name", clusterName)
           // decrease the routing schedule so new nodes will be added quickly - some random value
           // between 30 and 80 ms
           .put("cluster.routing.schedule", (30 + random.nextInt(50)) + "ms")
           // default to non gateway
           .put("gateway.type", "none");
   if (isLocalTransportConfigured()) {
     builder.put(
         TransportModule.TRANSPORT_TYPE_KEY, AssertingLocalTransportModule.class.getName());
   } else {
     builder.put(Transport.TransportSettings.TRANSPORT_TCP_COMPRESS, random.nextInt(10) == 0);
   }
   this.defaultSettings = builder.build();
   this.nodeSettingsSource = nodeSettingsSource;
 }
示例#4
0
 protected void appendClusterSeed(ReproduceErrorMessageBuilder builder) {
   builder.appendOpt(TESTS_CLUSTER_SEED, SeedUtils.formatSeed(SHARED_CLUSTER_SEED));
 }