org.apache.storm.utils

## Class NimbusClient

- java.lang.Object
- - org.apache.storm.security.auth.ThriftClient
  - - org.apache.storm.utils.NimbusClient

- All Implemented Interfaces:
    AutoCloseable

      public class NimbusClient
      extends ThriftClient

  Client used for connecting to nimbus. Typically you want to use a variant of the `getConfiguredClient` static method to get a client to use, as directly putting in a host and port does not support nimbus high availability.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `NimbusClient.LocalOverride`
    `static interface` | `NimbusClient.WithNimbus` An interface to allow callbacks with a thrift nimbus client.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `boolean` | `isLocal` Indicates if this is a special client that is overwritten for local mode.

    - ### Fields inherited from class org.apache.storm.security.auth.ThriftClient

      `protocol, retryForever`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `NimbusClient(Map<String,Object> conf, String host)` Constructor, Please try to use `getConfiguredClient` instead of calling this directly.
    `NimbusClient(Map<String,Object> conf, String host, int port)` Deprecated.
    `NimbusClient(Map<String,Object> conf, String host, Integer port, Integer timeout, String asUser)` Constructor, Please try to use `getConfiguredClientAs` instead of calling this directly.
    `NimbusClient(Map<String,Object> conf, String host, int port, Integer timeout)` Constructor, Please try to use `getConfiguredClient` instead of calling this directly.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Nimbus.Iface` | `getClient()` Get the underlying thrift client.
    `static NimbusClient` | `getConfiguredClient(Map<String,Object> conf)` Get a nimbus client as configured by conf.
    `static NimbusClient` | `getConfiguredClient(Map<String,Object> conf, Integer timeout)` Get a nimbus client as configured by conf.
    `static NimbusClient` | `getConfiguredClientAs(Map<String,Object> conf, String asUser)` Get a nimbus client as configured by conf.
    `static NimbusClient` | `getConfiguredClientAs(Map<String,Object> conf, String asUser, Integer timeout)` Get a nimbus client as configured by conf.
    `static boolean` | `isLocalOverride()` Is the local override set or not.
    `static void` | `withConfiguredClient(NimbusClient.WithNimbus cb)` Execute cb with a configured nimbus client that will be closed once cb returns.
    `static void` | `withConfiguredClient(NimbusClient.WithNimbus cb, Map<String,Object> conf)` Execute cb with a configured nimbus client that will be closed once cb returns.

    - ### Methods inherited from class org.apache.storm.security.auth.ThriftClient

      `close, reconnect, transport`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### isLocal

          public final boolean isLocal

      Indicates if this is a special client that is overwritten for local mode.

  - ### Constructor Detail

    - #### NimbusClient

          @Deprecated
          public NimbusClient(Map<String,Object> conf,
                                          String host,
                                          int port)
                                   throws org.apache.storm.thrift.transport.TTransportException

      Deprecated.

      Constructor, Please try to use `getConfiguredClient` instead of calling this directly.

      Parameters:
        `conf` - the conf for the client.
        `host` - the host the client is to talk to.
        `port` - the port the client is to talk to.
      Throws:
        `org.apache.storm.thrift.transport.TTransportException` - on any error.

    - #### NimbusClient

          public NimbusClient(Map<String,Object> conf,
                              String host,
                              int port,
                              Integer timeout)
                       throws org.apache.storm.thrift.transport.TTransportException

      Constructor, Please try to use `getConfiguredClient` instead of calling this directly.

      Parameters:
        `conf` - the conf for the client.
        `host` - the host the client is to talk to.
        `port` - the port the client is to talk to.
        `timeout` - the timeout to use when connecting.
      Throws:
        `org.apache.storm.thrift.transport.TTransportException` - on any error.

    - #### NimbusClient

          public NimbusClient(Map<String,Object> conf,
                              String host,
                              Integer port,
                              Integer timeout,
                              String asUser)
                       throws org.apache.storm.thrift.transport.TTransportException

      Constructor, Please try to use `getConfiguredClientAs` instead of calling this directly.

      Parameters:
        `conf` - the conf for the client.
        `host` - the host the client is to talk to.
        `port` - the port the client is to talk to.
        `timeout` - the timeout to use when connecting.
        `asUser` - the name of the user you want to impersonate (use with caution as it is not always supported).
      Throws:
        `org.apache.storm.thrift.transport.TTransportException` - on any error.

    - #### NimbusClient

          public NimbusClient(Map<String,Object> conf,
                              String host)
                       throws org.apache.storm.thrift.transport.TTransportException

      Constructor, Please try to use `getConfiguredClient` instead of calling this directly.

      Parameters:
        `conf` - the conf for the client.
        `host` - the host the client is to talk to.
      Throws:
        `org.apache.storm.thrift.transport.TTransportException` - on any error.

  - ### Method Detail

    - #### isLocalOverride

          public static boolean isLocalOverride()

      Is the local override set or not.

      Returns:
        true of new clients will be overridden to connect to a local cluster and not the configured remote cluster.

    - #### withConfiguredClient

          public static void withConfiguredClient(NimbusClient.WithNimbus cb)
                                           throws Exception

      Execute cb with a configured nimbus client that will be closed once cb returns.

      Parameters:
        `cb` - the callback to send to nimbus.
      Throws:
        `Exception` - on any kind of error.

    - #### withConfiguredClient

          public static void withConfiguredClient(NimbusClient.WithNimbus cb,
                                                  Map<String,Object> conf)
                                           throws Exception

      Execute cb with a configured nimbus client that will be closed once cb returns.

      Parameters:
        `cb` - the callback to send to nimbus.
        `conf` - the conf to use instead of reading the global storm conf.
      Throws:
        `Exception` - on any kind of error.

    - #### getConfiguredClient

          public static NimbusClient getConfiguredClient(Map<String,Object> conf)

      Get a nimbus client as configured by conf.

      Parameters:
        `conf` - the configuration to use.
      Returns:
        the client, don’t forget to close it when done.

    - #### getConfiguredClient

          public static NimbusClient getConfiguredClient(Map<String,Object> conf,
                                                         Integer timeout)

      Get a nimbus client as configured by conf.

      Parameters:
        `conf` - the configuration to use.
        `timeout` - the timeout to use when connecting.
      Returns:
        the client, don’t forget to close it when done.

    - #### getConfiguredClientAs

          public static NimbusClient getConfiguredClientAs(Map<String,Object> conf,
                                                           String asUser)

      Get a nimbus client as configured by conf.

      Parameters:
        `conf` - the configuration to use.
        `asUser` - the user to impersonate (this does not always work).
      Returns:
        the client, don’t forget to close it when done.

    - #### getConfiguredClientAs

          public static NimbusClient getConfiguredClientAs(Map<String,Object> conf,
                                                           String asUser,
                                                           Integer timeout)

      Get a nimbus client as configured by conf.

      Parameters:
        `conf` - the configuration to use.
        `asUser` - the user to impersonate (this does not always work).
        `timeout` - the timeout to use when connecting.
      Returns:
        the client, don’t forget to close it when done.

    - #### getClient

          public Nimbus.Iface getClient()

      Get the underlying thrift client.

      Returns:
        the underlying thrift client.

Copyright © 2021 The Apache Software Foundation. All rights reserved.