Tabnine Logo
com.palantir.remoting3.clients
Code IndexAdd Tabnine to your IDE (free)

How to use com.palantir.remoting3.clients

Best Java code snippets using com.palantir.remoting3.clients (Showing top 20 results out of 315)

origin: com.palantir.remoting3/http-clients

  static Agent of(String name, String version) {
    return ImmutableAgent.builder()
        .name(name)
        .version(UserAgents.isValidVersion(version) ? version : DEFAULT_VERSION)
        .build();
  }
}
origin: com.palantir.remoting3/http-clients

/**
 * Returns a new {@link UserAgent} instance whose {@link #informational} agents are this instance's agents plus the
 * given agent.
 */
default UserAgent addAgent(Agent agent) {
  return ImmutableUserAgent.builder()
      .from(this)
      .addInformational(agent)
      .build();
}
origin: com.palantir.remoting3/http-clients

/** Creates a new {@link UserAgent} with the given {@link #primary} agent and originating node id. */
static UserAgent of(Agent agent, String nodeId) {
  return ImmutableUserAgent.builder()
      .nodeId(nodeId)
      .primary(agent)
      .build();
}
origin: com.palantir.remoting3/http-clients

/**
 * Creates a new {@link ClientConfiguration} instance from the given {@link ServiceConfiguration}, filling in
 * empty/absent configuration with the defaults specified as constants in this class.
 */
public static ClientConfiguration of(ServiceConfiguration config) {
  return ClientConfiguration.builder()
      .sslSocketFactory(SslSocketFactories.createSslSocketFactory(config.security()))
      .trustManager(SslSocketFactories.createX509TrustManager(config.security()))
      .uris(config.uris())
      .connectTimeout(config.connectTimeout().orElse(DEFAULT_CONNECT_TIMEOUT))
      .readTimeout(config.readTimeout().orElse(DEFAULT_READ_TIMEOUT))
      .writeTimeout(config.writeTimeout().orElse(DEFAULT_WRITE_TIMEOUT))
      .enableGcmCipherSuites(config.enableGcmCipherSuites().orElse(DEFAULT_ENABLE_GCM_CIPHERS))
      .proxy(config.proxy().map(ClientConfigurations::createProxySelector).orElse(ProxySelector.getDefault()))
      .proxyCredentials(config.proxy().flatMap(ProxyConfiguration::credentials))
      .meshProxy(meshProxy(config.proxy()))
      .maxNumRetries(config.maxNumRetries().orElse(DEFAULT_MAX_NUM_RETRIES))
      .nodeSelectionStrategy(DEFAULT_NODE_SELECTION_STRATEGY)
      .failedUrlCooldown(DEFAULT_FAILED_URL_COOLDOWN)
      .backoffSlotSize(config.backoffSlotSize().orElse(DEFAULT_BACKOFF_SLOT_SIZE))
      .build();
}
origin: com.palantir.remoting3/http-clients

@Value.Check
default void check() {
  if (meshProxy().isPresent()) {
    checkArgument(maxNumRetries() == 0, "If meshProxy is configured then maxNumRetries must be 0");
    checkArgument(uris().size() == 1, "If meshProxy is configured then uris must contain exactly 1 URI");
  }
  if (nodeSelectionStrategy().equals(NodeSelectionStrategy.ROUND_ROBIN)) {
    checkArgument(!failedUrlCooldown().isNegative() && !failedUrlCooldown().isZero(),
        "If nodeSelectionStrategy is ROUND_ROBIN then failedUrlCooldown must be positive");
  }
}
origin: com.palantir.remoting3/http-clients

@Value.Check
default void check() {
  checkArgument(UserAgents.isValidName(name()), "Illegal agent name format: %s", name());
  // Should never hit the following.
  checkArgument(UserAgents.isValidVersion(version()), "Illegal version format: %s. This is a bug", version());
}
origin: com.palantir.remoting3/http-clients

/**
 * Like {@link #of(Agent, String)}, but with an empty/unknown node id. Users should generally prefer the version
 * with explicit node in order to facilitate server-side client trackingb
 */
static UserAgent of(Agent agent) {
  return ImmutableUserAgent.builder().primary(agent).build();
}
origin: com.palantir.remoting3/okhttp-clients

/**
 * Adds informational {@link com.palantir.remoting3.clients.UserAgent.Agent}s to the given {@link UserAgent}, one
 * for the http-remoting library and one for the given service class. Version strings are extracted from the
 * packages' {@link Package#getImplementationVersion implementation version}, defaulting to 0.0.0 if no version can
 * be found.
 */
private static UserAgent augmentUserAgent(UserAgent agent, Class<?> serviceClass) {
  UserAgent augmentedAgent = agent;
  String maybeServiceVersion = serviceClass.getPackage().getImplementationVersion();
  augmentedAgent = augmentedAgent.addAgent(UserAgent.Agent.of(
      serviceClass.getSimpleName(),
      maybeServiceVersion != null ? maybeServiceVersion : "0.0.0"));
  String maybeRemotingVersion = OkHttpClients.class.getPackage().getImplementationVersion();
  augmentedAgent = augmentedAgent.addAgent(UserAgent.Agent.of(
      UserAgents.REMOTING_AGENT_NAME,
      maybeRemotingVersion != null ? maybeRemotingVersion : "0.0.0"));
  return augmentedAgent;
}
origin: com.palantir.remoting3/jaxrs-clients

AbstractFeignJaxRsClientBuilder(ClientConfiguration config) {
  Preconditions.checkArgument(!config.uris().isEmpty(), "Must provide at least one service URI");
  this.config = config;
  this.primaryUri = config.uris().get(0);
}
origin: com.palantir.remoting3/okhttp-clients

private UserAgentInterceptor(UserAgent userAgent) {
  this.userAgent = UserAgents.format(userAgent);
}
origin: com.palantir.remoting3/okhttp-clients

/**
 * Deprecated variant of {@link #create(ClientConfiguration, UserAgent, Class)}.
 *
 * @deprecated Use {@link #create(ClientConfiguration, UserAgent, Class)}
 */
@Deprecated
public static OkHttpClient create(ClientConfiguration config, String userAgent, Class<?> serviceClass) {
  return create(config, UserAgents.tryParse(userAgent), serviceClass);
}
origin: com.palantir.remoting3/okhttp-clients

  @Value.Immutable
  @ImmutablesStyle
  interface ServiceHostAndPort {
    @Value.Parameter String serviceName();
    @Value.Parameter String hostname();
    @Value.Parameter int port();
  }
}
origin: com.palantir.remoting3/http-clients

@Value.Check
default void check() {
  if (nodeId().isPresent()) {
    checkArgument(UserAgents.isValidNodeId(nodeId().get()),
        "Illegal node id format: %s", nodeId().get());
  }
}
origin: com.palantir.remoting3/okhttp-clients

private static ImmutableList<ConnectionSpec> createConnectionSpecs(boolean enableGcmCipherSuites) {
  return ImmutableList.of(
      new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
          .tlsVersions(TlsVersion.TLS_1_2)
          .cipherSuites(enableGcmCipherSuites
              ? CipherSuites.allCipherSuites()
              : CipherSuites.fastCipherSuites())
          .build(),
      ConnectionSpec.CLEARTEXT);
}
origin: com.palantir.remoting3/http-clients

/**
 * Like {@link #parse}, but never fails and returns the primary agent {@code unknown/0.0.0} if no valid primary
 * agent can be parsed.
 */
public static UserAgent tryParse(String userAgent) {
  return parseInternal(Strings.nullToEmpty(userAgent), true /* lenient */);
}
origin: com.palantir.remoting3/http-clients

static Builder builder() {
  return new Builder();
}
origin: palantir/atlasdb

  private static ClientConfiguration createTestConfig(String... uris) {
    SslConfiguration sslConfiguration = SslConfiguration.of(
        Paths.get(ResourceHelpers.resourceFilePath("trustStore.jks")));
    return ClientConfigurations.of(
        ImmutableList.copyOf(uris),
        SslSocketFactories.createSslSocketFactory(sslConfiguration),
        SslSocketFactories.createX509TrustManager(sslConfiguration));
  }
}
origin: com.palantir.remoting3/jaxrs-clients

/**
 * Similar to {@link #create(Class, UserAgent, ClientConfiguration)}, but creates a mutable client that updates its
 * configuration transparently whenever the given {@link Refreshable refreshable} {@link ClientConfiguration}
 * changes.
 */
public static <T> T create(Class<T> serviceClass, UserAgent userAgent, Refreshable<ClientConfiguration> config) {
  // TODO(rfink): Add http-remoting agent as informational
  return create(serviceClass, UserAgents.format(userAgent), config);
}
origin: com.palantir.remoting3/jaxrs-clients

/**
 * @deprecated Use {@link #build(Class, UserAgent)}.
 */
@Deprecated
public final <T> T build(Class<T> serviceClass, String userAgent) {
  return build(serviceClass, UserAgents.tryParse(userAgent));
}
origin: com.palantir.remoting3/http-clients

/**
 * Parses the given string into a {@link UserAgent} or throws an {@link IllegalArgumentException} if no correctly
 * formatted primary user agent can be found. Incorrectly formatted informational agents are omitted.
 * <p>
 * Valid user agent strings loosely follow RFC 7230 (https://tools.ietf.org/html/rfc7230#section-3.2.6).
 */
public static UserAgent parse(String userAgent) {
  Preconditions.checkNotNull(userAgent, "userAgent must not be null");
  return parseInternal(userAgent, false /* strict */);
}
com.palantir.remoting3.clients

Most used classes

  • ClientConfiguration
    A context-independent (i.e., does not depend on configuration files or on-disk entities like JKS key
  • UserAgents
  • ClientConfigurations
    Utilities for creating ClientConfiguration instances.
  • ImmutablesStyle
  • UserAgent$Agent
    Specifies an agent that participates (client-side) in an RPC call in terms of its name and version.
  • CipherSuites,
  • ClientConfiguration$Builder,
  • ImmutableAgent$Builder,
  • ImmutableAgent,
  • ImmutableUserAgent$Builder,
  • ImmutableUserAgent,
  • NodeSelectionStrategy
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