public DriverRemoteConnection(final Configuration conf) {
    if (conf.containsKey(GREMLIN_REMOTE_GRAPH_DRIVER_CLUSTERFILE)
        && conf.containsKey("clusterConfiguration"))
      throw new IllegalStateException(
          String.format(
              "A configuration should not contain both '%s' and 'clusterConfiguration'",
              GREMLIN_REMOTE_GRAPH_DRIVER_CLUSTERFILE));

    connectionGraphName = conf.getString(GREMLIN_REMOTE_GRAPH_DRIVER_GRAPHNAME, DEFAULT_GRAPH);

    try {
      final Cluster cluster;
      if (!conf.containsKey(GREMLIN_REMOTE_GRAPH_DRIVER_CLUSTERFILE)
          && !conf.containsKey("clusterConfiguration")) cluster = Cluster.open();
      else
        cluster =
            conf.containsKey(GREMLIN_REMOTE_GRAPH_DRIVER_CLUSTERFILE)
                ? Cluster.open(conf.getString(GREMLIN_REMOTE_GRAPH_DRIVER_CLUSTERFILE))
                : Cluster.open(conf.subset("clusterConfiguration"));

      client =
          cluster
              .connect(Client.Settings.build().unrollTraversers(false).create())
              .alias(connectionGraphName);
    } catch (Exception ex) {
      throw new IllegalStateException(ex);
    }

    tryCloseCluster = true;
    this.conf = Optional.of(conf);
  }
 private DriverRemoteConnection(
     final Cluster cluster, final boolean tryCloseCluster, final String connectionGraphName) {
   client =
       cluster
           .connect(Client.Settings.build().unrollTraversers(false).create())
           .alias(connectionGraphName);
   this.connectionGraphName = connectionGraphName;
   this.tryCloseCluster = tryCloseCluster;
 }
 /**
  * This constructor is largely just for unit testing purposes and should not typically be used
  * externally.
  */
 DriverRemoteConnection(final Cluster cluster, final Configuration conf) {
   connectionGraphName = conf.getString(GREMLIN_REMOTE_GRAPH_DRIVER_GRAPHNAME, DEFAULT_GRAPH);
   client =
       cluster
           .connect(Client.Settings.build().unrollTraversers(false).create())
           .alias(connectionGraphName);
   tryCloseCluster = false;
   this.conf = Optional.of(conf);
 }