Tabnine Logo
Configuration.get
Code IndexAdd Tabnine to your IDE (free)

How to use
get
method
in
com.hotels.styx.api.configuration.Configuration

Best Java code snippets using com.hotels.styx.api.configuration.Configuration.get (Showing top 19 results out of 315)

origin: com.hotels.styx/styx-api

/**
 * Returns the value to which the specified key is mapped, converted to String
 * or {@code Optional.absent} if this configuration source contains no mapping for the key.
 *
 * @param key the key whose associated value is to be returned
 * @return the value to which the specified key is mapped, or
 * {@code Optional.absent} if this map contains no mapping for the key
 */
default Optional<String> get(String key) {
  return get(key, String.class);
}
origin: HotelsDotCom/styx

private Optional<PluginsMetadata> readPluginsConfig() {
  return configuration.get("plugins", PluginsMetadata.class);
}
origin: HotelsDotCom/styx

/**
 * Returns the value to which the specified key is mapped, converted to String
 * or {@code Optional.absent} if this configuration source contains no mapping for the key.
 *
 * @param key the key whose associated value is to be returned
 * @return the value to which the specified key is mapped, or
 * {@code Optional.absent} if this map contains no mapping for the key
 */
default Optional<String> get(String key) {
  return get(key, String.class);
}
origin: HotelsDotCom/styx

@Override
public <T> Optional<T> get(String key, Class<T> tClass) {
  return configuration.get(key, tClass);
}
origin: HotelsDotCom/styx

@Override
public LoadBalancerFactory get() {
  return configurations.get(LOAD_BALANCING_STRATEGY_KEY)
      .map(this::newFactoryInstance)
      .orElseGet(this::busyConnectionBalancer);
}
origin: com.hotels.styx/styx-api

@Override
public <X> Optional<X> get(String key, Class<X> type) {
  Optional<X> found = Optional.ofNullable(config.get(key)).map(type::cast);
  if (!found.isPresent()) {
    return parent.get(key, type);
  }
  return found;
}
origin: HotelsDotCom/styx

@Override
public <X> Optional<X> get(String key, Class<X> type) {
  Optional<X> found = Optional.ofNullable(config.get(key)).map(type::cast);
  if (!found.isPresent()) {
    return parent.get(key, type);
  }
  return found;
}
origin: com.hotels.styx/styx-client

  @Override
  public RetryPolicy create(Environment environment, Configuration retryPolicyConfiguration) {
    int retriesCount = retryPolicyConfiguration.get("count", Integer.class)
        .orElse(1);
    return new RetryNTimes(retriesCount);
  }
}
origin: HotelsDotCom/styx

@Override
public Registry<BackendService> create(Environment environment, Configuration registryConfiguration) {
  String originsFile = registryConfiguration.get("originsFile", String.class)
      .map(Factory::requireNonEmpty)
      .orElseThrow(() -> new ConfigurationException(
          "missing [services.registry.factory.config.originsFile] config value for factory class FileBackedBackendServicesRegistry.Factory"));
  FileMonitorSettings monitorSettings = registryConfiguration.get("monitor", FileMonitorSettings.class)
      .orElseGet(FileMonitorSettings::new);
  return registry(originsFile, monitorSettings);
}
origin: HotelsDotCom/styx

  private String factoryClassName(String strategyName) {
    String key = format("loadBalancing.strategies.%s.factory.class", strategyName);

    return configurations.get(key).orElseThrow(() -> new MissingConfigurationException(key));
  }
}
origin: HotelsDotCom/styx

  @Override
  public RetryPolicy create(Environment environment, Configuration retryPolicyConfiguration) {
    int retriesCount = retryPolicyConfiguration.get("count", Integer.class)
        .orElse(1);
    return new RetryNTimes(retriesCount);
  }
}
origin: HotelsDotCom/styx

/**
 * Creates the services whose configuration has the specified key.
 *
 * @param <T>           service type
 * @param configuration Styx configuration
 * @param key           Factory configuration attribute
 * @param serviceClass  Service class
 * @return services, if such a configuration key exists
 */
public static <T> Map<String, T> loadServices(Configuration configuration, Environment environment, String key, Class<? extends T> serviceClass) {
  return configuration.get(key, JsonNode.class)
      .<Map<String, T>>map(node -> servicesMap(node, environment, serviceClass))
      .orElse(emptyMap());
}
origin: HotelsDotCom/styx

  @Override
  public Registry<BackendService> create(Environment environment, Configuration registryConfiguration) {
    BackendService service = registryConfiguration.get("backendService", BackendService.class)
        .orElseThrow(() -> new ConfigurationException(
            "missing [services.registry.factory.config.backendService] config value for factory class TestBackendProvider.Factory"));
    return new TestBackendProvider(service);
  }
}
origin: HotelsDotCom/styx

  @Override
  public StyxService create(Environment environment, Configuration serviceConfiguration) {
    String domain = serviceConfiguration.get("domain").orElse("com.hotels.styx");

    return new JmxReporterService(domain, codaHaleMetricRegistry(environment));
  }
}
origin: HotelsDotCom/styx

  @Test
  public void doesNotContainConfigurationsValue() {
    assertThat(emptyConfiguration.get("any value"), is(isAbsent()));
    assertThat(emptyConfiguration.get("xsfsd", Integer.class), is(isAbsent()));
  }
}
origin: HotelsDotCom/styx

/**
 * Create factory configured with a particular key, then uses the factory's create method
 * to create its product.
 *
 * @param <E>           service type
 * @param configuration Styx configuration
 * @param key           Factory configuration attribute
 * @param serviceClass  Service class
 * @return service, if such a configuration key exists
 */
public static <E extends RetryPolicy> Optional<E> loadRetryPolicy(
    Configuration configuration,
    Environment environment,
    String key,
    Class<? extends E> serviceClass) {
  return configuration
      .get(key, ServiceFactoryConfig.class)
      .map(factoryConfig -> {
        RetryPolicyFactory factory = newInstance(factoryConfig.factory(), RetryPolicyFactory.class);
        JsonNodeConfig config = factoryConfig.config();
        return serviceClass.cast(factory.create(environment, config));
      });
}
origin: HotelsDotCom/styx

/**
 * Create a {@link com.hotels.styx.client.StyxBackendServiceClient} related factory configured with a particular key,
 * then uses the factory's create method to create its product.
 *
 * @param <E>           service type
 * @param configuration Styx configuration
 * @param key           Factory configuration attribute
 * @param serviceClass  Service class
 * @param activeOrigins source of active connections for purpose of load balancing
 * @return service, if such a configuration key exists
 */
public static <E extends LoadBalancer> Optional<E> loadLoadBalancer(
    Configuration configuration,
    Environment environment,
    String key,
    Class<? extends E> serviceClass,
    ActiveOrigins activeOrigins) {
  return configuration
      .get(key, ServiceFactoryConfig.class)
      .map(factoryConfig -> {
        try {
          LoadBalancerFactory factory = newInstance(factoryConfig.factory(), LoadBalancerFactory.class);
          return serviceClass.cast(factory.create(environment, factoryConfig.config(), activeOrigins));
        } catch (Exception e) {
          throw new ConfigurationException("Error creating service", e);
        }
      });
}
origin: HotelsDotCom/styx

@Override
public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) {
  String header = xHcomPluginsHeader(request);
  final String configPath = environment.pluginConfig(String.class);
  String pluginsList = environment.configuration().get("plugins.active").get();
  LiveHttpRequest newRequest = request.newBuilder()
      .header(X_HCOM_PLUGINS_HEADER, header)
      .header(X_HCOM_PLUGINS_CONFIGURATION_PATH, configPath)
      .header(X_HCOM_PLUGINS_LIST, pluginsList)
      .header("X-Hcom-Styx-Started", styxStarted)
      .header("X-Hcom-Styx-Stopped", styxStopped)
      .build();
  Function<ByteBuf, String> byteBufStringFunction = byteBuf -> byteBuf.toString(Charsets.UTF_8);
  return chain.proceed(newRequest)
      .flatMap(response -> response.aggregate(1 * 1024 * 1024))
      .map(response ->
          response.newBuilder()
              .header(X_HCOM_PLUGINS_HEADER, header)
              .header(X_HCOM_PLUGINS_CONFIGURATION_PATH, configPath)
              .header(X_HCOM_PLUGINS_LIST, pluginsList)
              .header("X-Hcom-Styx-Started", styxStarted)
              .header("X-Hcom-Styx-Stopped", styxStopped)
              .build())
      .map(HttpResponse::stream);
}
origin: HotelsDotCom/styx

Configuration styxConfig = environment.configuration();
String originRestrictionCookie = styxConfig.get("originRestrictionCookie").orElse(null);
boolean stickySessionEnabled = backendService.stickySessionConfig().stickySessionEnabled();
com.hotels.styx.api.configurationConfigurationget

Javadoc

Returns the value to which the specified key is mapped, converted to String or Optional.absent if this configuration source contains no mapping for the key.

Popular methods of Configuration

  • as

Popular in Java

  • Making http requests using okhttp
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • requestLocationUpdates (LocationManager)
  • getApplicationContext (Context)
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • JCheckBox (javax.swing)
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now