Package org.kiji.schema.cassandra

Examples of org.kiji.schema.cassandra.CassandraKijiURI$CassandraKijiURIParser


   * @param kijiURI The KijiURI specifying the Kiji instance for the CassandraAdmin.
   *                Note: Must be an instance of CassandraKijiURI.
   * @return A CassandraAdmin for the given Kiji instance.
   */
  public static DefaultCassandraAdmin makeFromKijiURI(KijiURI kijiURI) {
    CassandraKijiURI cassandraKijiURI;
    if (kijiURI instanceof CassandraKijiURI) {
       cassandraKijiURI = (CassandraKijiURI) kijiURI;
    } else {
      throw new KijiIOException("Need a Cassandra URI for a CassandraAdmin.");
    }
    final List<String> hosts = cassandraKijiURI.getContactPoints();
    final String[] hostStrings = hosts.toArray(new String[hosts.size()]);
    int port = cassandraKijiURI.getContactPort();
    final Cluster.Builder clusterBuilder = Cluster
        .builder()
        .addContactPoints(hostStrings)
        .withPort(port);

    if (null != cassandraKijiURI.getUsername()) {
      clusterBuilder.withAuthProvider(
          new PlainTextAuthProvider(cassandraKijiURI.getUsername(), cassandraKijiURI.getPassword())
      );
    }

    final Cluster cluster = clusterBuilder.build();
    final Session cassandraSession = cluster.connect();
View Full Code Here

TOP

Related Classes of org.kiji.schema.cassandra.CassandraKijiURI$CassandraKijiURIParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.