Class GremlinClient

java.lang.Object
com.Lomikel.Januser.GremlinClient
Direct Known Subclasses:
DirectGremlinClient, StringGremlinClient

public abstract class GremlinClient extends Object
Shared remote Gremlin connection and cleanup lifecycle.

Subclasses select a serializer and either expose a typed remote traversal source or script-submission results.

Author:
J.Hrivnac
  • Field Details

    • _cluster

      private Cluster _cluster
    • log

      private static org.apache.logging.log4j.Logger log
      Logging .
  • Constructor Details

    • GremlinClient

      public GremlinClient(String hostname, int port)
      Create with connection parameters.
      Parameters:
      hostname - The Gremlin hostname.
      port - The Gremlin port.
    • GremlinClient

      protected GremlinClient(String hostname, int port, boolean deferInitialization)
      Create with optional deferred initialization for subclasses that need their own state initialized before open(java.lang.String, int) and connect().
      Parameters:
      hostname - The Gremlin hostname.
      port - The Gremlin port.
      deferInitialization - Whether the subclass will call initialize(java.lang.String, int) explicitly.
  • Method Details

    • initialize

      protected final void initialize(String hostname, int port)
      Open and connect, closing partial resources if initialization fails.
      Parameters:
      hostname - The Gremlin hostname.
      port - The Gremlin port.
    • collectCleanupFailure

      protected static RuntimeException collectCleanupFailure(RuntimeException failure, String resource, Exception cause)
      Accumulate cleanup failures without preventing later resources from closing.
      Parameters:
      failure - The previously collected failure, or null.
      resource - The resource whose close failed.
      cause - The close failure.
      Returns:
      The first failure with later failures suppressed.
    • open

      public abstract void open(String hostname, int port)
      Open.
      Parameters:
      hostname - The Gremlin hostname.
      port - The Gremlin port.
    • connect

      public abstract void connect()
      Connect client.
    • close

      public abstract void close()
      Close client.
    • createCluster

      public void createCluster(String hostname, int port, MessageSerializer serializer)
      Create Cluster.
      Parameters:
      hostname - The Gremlin hostname.
      port - The Gremlin port.
      serializer - The used MessageSerializer.
    • cluster

      public Cluster cluster()
      Give the Cluster.
      Returns:
      The attached Cluster.