congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
Configuration
Code IndexAdd Tabnine to your IDE (free)

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

Best Java code snippets using com.hotels.styx.api.configuration.Configuration (Showing top 20 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

@Override
public <X> X as(Class<X> type) {
  return configuration.as(type);
}
origin: HotelsDotCom/styx

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

  @Override
  public StyxService create(Environment environment, Configuration serviceConfiguration) {
    GraphiteConfig graphiteConfig = serviceConfiguration.as(GraphiteConfig.class);

    String host = graphiteConfig.host();
    int port = graphiteConfig.port();

    return new GraphiteReporterService.Builder()
        .serviceName(format("Graphite-Reporter-%s:%d", host, port))
        .prefix(graphiteConfig.prefix())
        .graphiteSender(new NonSanitizingGraphiteSender(host, port))
        .reportingInterval(graphiteConfig.intervalMillis(), MILLISECONDS)
        .metricRegistry(codaHaleMetricRegistry(environment))
        .build();
  }
}
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);
}
com.hotels.styx.api.configurationConfiguration

Javadoc

Static configuration.

Most used methods

  • get
  • as

Popular in Java

  • Reactive rest calls using spring rest template
  • onCreateOptionsMenu (Activity)
  • notifyDataSetChanged (ArrayAdapter)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • PhpStorm for WordPress
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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