@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);
  }
 @Inject
 public AssertingLocalTransport(
     Settings settings,
     ThreadPool threadPool,
     Version version,
     NamedWriteableRegistry namedWriteableRegistry) {
   super(settings, threadPool, version, namedWriteableRegistry);
   final long seed = settings.getAsLong(ESIntegTestCase.SETTING_INDEX_SEED, 0l);
   random = new Random(seed);
   minVersion = settings.getAsVersion(ASSERTING_TRANSPORT_MIN_VERSION_KEY, Version.V_0_18_0);
   maxVersion = settings.getAsVersion(ASSERTING_TRANSPORT_MAX_VERSION_KEY, Version.CURRENT);
 }
예제 #3
0
 /**
  * Adds human readable version and creation date settings. This method is used to display the
  * settings in a human readable format in REST API
  */
 public static Settings addHumanReadableSettings(Settings settings) {
   Settings.Builder builder = Settings.builder().put(settings);
   Version version = settings.getAsVersion(SETTING_VERSION_CREATED, null);
   if (version != null) {
     builder.put(SETTING_VERSION_CREATED_STRING, version.toString());
   }
   Version versionUpgraded = settings.getAsVersion(SETTING_VERSION_UPGRADED, null);
   if (versionUpgraded != null) {
     builder.put(SETTING_VERSION_UPGRADED_STRING, versionUpgraded.toString());
   }
   Long creationDate = settings.getAsLong(SETTING_CREATION_DATE, null);
   if (creationDate != null) {
     DateTime creationDateTime = new DateTime(creationDate, DateTimeZone.UTC);
     builder.put(SETTING_CREATION_DATE_STRING, creationDateTime.toString());
   }
   return builder.build();
 }
예제 #4
0
 public MockEngineSupport(EngineConfig config, Class<? extends FilterDirectoryReader> wrapper) {
   Settings indexSettings = config.getIndexSettings();
   shardId = config.getShardId();
   filterCache = config.getQueryCache();
   filterCachingPolicy = config.getQueryCachingPolicy();
   final long seed = indexSettings.getAsLong(ESIntegTestCase.SETTING_INDEX_SEED, 0l);
   Random random = new Random(seed);
   final double ratio =
       indexSettings.getAsDouble(
           WRAP_READER_RATIO, 0.0d); // DISABLED by default - AssertingDR is crazy slow
   boolean wrapReader = random.nextDouble() < ratio;
   if (logger.isTraceEnabled()) {
     logger.trace(
         "Using [{}] for shard [{}] seed: [{}] wrapReader: [{}]",
         this.getClass().getName(),
         shardId,
         seed,
         wrapReader);
   }
   mockContext = new MockContext(random, wrapReader, wrapper, indexSettings);
   this.searcherCloseable = new SearcherCloseable();
   LuceneTestCase.closeAfterSuite(searcherCloseable); // only one suite closeable per Engine
 }
  @Inject
  public CouchbaseCAPITransportImpl(
      Settings settings,
      RestController restController,
      NetworkService networkService,
      IndicesService indicesService,
      MetaDataMappingService metaDataMappingService,
      Client client) {
    super(settings);
    this.networkService = networkService;
    this.indicesService = indicesService;
    this.metaDataMappingService = metaDataMappingService;
    this.client = client;
    this.port = settings.get("couchbase.port", "9091-10091");
    this.bindHost = componentSettings.get("bind_host");
    this.publishHost = componentSettings.get("publish_host");
    this.username = settings.get("couchbase.username", "Administrator");
    this.password = settings.get("couchbase.password", "");

    this.bucketUUIDCacheEvictMs = settings.getAsLong("couchbase.bucketUUIDCacheEvictMs", 300000L);
    this.bucketUUIDCache =
        CacheBuilder.newBuilder()
            .expireAfterWrite(this.bucketUUIDCacheEvictMs, TimeUnit.MILLISECONDS)
            .build();

    int defaultNumVbuckets = 1024;
    if (System.getProperty("os.name").toLowerCase().contains("mac")) {
      logger.info("Detected platform is Mac, changing default num_vbuckets to 64");
      defaultNumVbuckets = 64;
    }
    this.numVbuckets = settings.getAsInt("couchbase.num_vbuckets", defaultNumVbuckets);

    pluginSettings = new PluginSettings();
    pluginSettings.setCheckpointDocumentType(
        settings.get(
            "couchbase.typeSelector.checkpointDocumentType",
            PluginSettings.DEFAULT_DOCUMENT_TYPE_CHECKPOINT));
    pluginSettings.setDynamicTypePath(settings.get("couchbase.dynamicTypePath"));
    pluginSettings.setResolveConflicts(settings.getAsBoolean("couchbase.resolveConflicts", true));
    pluginSettings.setWrapCounters(settings.getAsBoolean("couchbase.wrapCounters", false));
    pluginSettings.setMaxConcurrentRequests(
        settings.getAsLong("couchbase.maxConcurrentRequests", 1024L));
    pluginSettings.setBulkIndexRetries(settings.getAsLong("couchbase.bulkIndexRetries", 10L));
    pluginSettings.setBulkIndexRetryWaitMs(
        settings.getAsLong("couchbase.bulkIndexRetryWaitMs", 1000L));
    pluginSettings.setIgnoreDeletes(
        new ArrayList<String>(
            Arrays.asList(settings.get("couchbase.ignoreDeletes", "").split("[:,;\\s]"))));
    pluginSettings.getIgnoreDeletes().removeAll(Arrays.asList("", null));
    pluginSettings.setIgnoreFailures(settings.getAsBoolean("couchbase.ignoreFailures", false));
    pluginSettings.setDocumentTypeRoutingFields(
        settings.getByPrefix("couchbase.documentTypeRoutingFields.").getAsMap());
    pluginSettings.setIgnoreDotIndexes(settings.getAsBoolean("couchbase.ignoreDotIndexes", true));
    pluginSettings.setIncludeIndexes(
        new ArrayList<String>(
            Arrays.asList(settings.get("couchbase.includeIndexes", "").split("[:,;\\s]"))));
    pluginSettings.getIncludeIndexes().removeAll(Arrays.asList("", null));

    TypeSelector typeSelector;
    Class<? extends TypeSelector> typeSelectorClass =
        settings.<TypeSelector>getAsClass("couchbase.typeSelector", DefaultTypeSelector.class);
    try {
      typeSelector = typeSelectorClass.newInstance();
    } catch (Exception e) {
      throw new ElasticsearchException("couchbase.typeSelector", e);
    }
    typeSelector.configure(settings);
    pluginSettings.setTypeSelector(typeSelector);

    ParentSelector parentSelector;
    Class<? extends ParentSelector> parentSelectorClass =
        settings.<ParentSelector>getAsClass(
            "couchbase.parentSelector", DefaultParentSelector.class);
    try {
      parentSelector = parentSelectorClass.newInstance();
    } catch (Exception e) {
      throw new ElasticsearchException("couchbase.parentSelector", e);
    }
    parentSelector.configure(settings);
    pluginSettings.setParentSelector(parentSelector);

    KeyFilter keyFilter;
    Class<? extends KeyFilter> keyFilterClass =
        settings.<KeyFilter>getAsClass("couchbase.keyFilter", DefaultKeyFilter.class);
    try {
      keyFilter = keyFilterClass.newInstance();
    } catch (Exception e) {
      throw new ElasticsearchException("couchbase.keyFilter", e);
    }
    keyFilter.configure(settings);
    pluginSettings.setKeyFilter(keyFilter);

    // Log settings info
    logger.info(
        "Couchbase transport will ignore delete/expiration operations for these buckets: {}",
        pluginSettings.getIgnoreDeletes());
    logger.info(
        "Couchbase transport will ignore indexing failures and not throw exception to Couchbase: {}",
        pluginSettings.getIgnoreFailures());
    logger.info(
        "Couchbase transport is using type selector: {}",
        typeSelector.getClass().getCanonicalName());
    logger.info(
        "Couchbase transport is using parent selector: {}",
        parentSelector.getClass().getCanonicalName());
    logger.info(
        "Couchbase transport is using key filter: {}", keyFilter.getClass().getCanonicalName());
    for (String key : pluginSettings.getDocumentTypeRoutingFields().keySet()) {
      String routingField = pluginSettings.getDocumentTypeRoutingFields().get(key);
      logger.info("Using field {} as routing for type {}", routingField, key);
    }
    logger.info("Plugin Settings: {}", pluginSettings.toString());
  }
예제 #6
0
 public long getCreationDate() {
   return settings.getAsLong(SETTING_CREATION_DATE, -1l);
 }