GithubHelp home page GithubHelp logo

skphilipp / hectorauxiliaryroutines Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 156 KB

Utilities for talking to Cassandra through Hector for when you've never used Cassandra or Hector.

Java 100.00%

hectorauxiliaryroutines's Introduction

HectorAuxiliaryRoutines

This project is no longer maintained and part of my source code "attic". You probably should not use this repository. It is functional, but fairly untested.

Utilities for talking to Cassandra through Hector for when you've never used Cassandra or Hector.

The test describes how to use it, project is mavenized as well so you can just import it into your IDE. It's only one class under Java sources.

In case you missed it, here's the test:

HectorAuxiliaryRoutines hectorAuxiliaryRoutines = HectorAuxiliaryRoutines.getInstance();
hectorAuxiliaryRoutines.addColumnFamilyIfNotExists(Server.class.getSimpleName());
// note that me.prettyprint.hom.EntityManagerImpl is not even remotely an implementation of a JPA EntityManager
EntityManagerImpl entityManager = hectorAuxiliaryRoutines.getEntityManager();

try {

    // create something and save it
    Server server = new Server();
    server.setHostname("hello");
    server.setId(UUID.randomUUID());
    server.setIpAddress("127.0.0.1");
    server.setPort(80);
    entityManager.persist(server);
        
    // get it back out
    Server server1 = entityManager.find(Server.class, server.getId());
    System.out.println("IpAddress = " + server1.getIpAddress());

    // reaching this point is worth a celebration

} finally {
    hectorAuxiliaryRoutines.getCluster().getConnectionManager().shutdown();
}

When you use it you'll either want to just copy paste the source to your project, if for some reason you want to use this project as a maven dependency you'll want to keep this in mind:

public static final String CASSANDRA_HOST = System.getProperty("CASSANDRA_HOST", "localhost:9160");
public static final String CASSANDRA_KEYSPACE = System.getProperty("CASSANDRA_KEYSPACE", "ExampleKeyspace");
public static final int CASSANDRA_KEYSPACE_REPLICATION_FACTOR = Ints.tryParse(System.getProperty("CASSANDRA_KEYSPACE_REPLICATION_FACTOR", "1"));
public static final String CASSANDRA_COLUMN_FAMILY_NAME = System.getProperty("CASSANDRA_COLUMN_FAMILY_NAME", "ExampleColumnFamily");
public static final String HECTOR_CLUSTER_NAME = System.getProperty("HECTOR_CLUSTER_NAME", "ExamplePool");
public static final String HECTOR_SCAN_CLASSPATH_PREFIX = System.getProperty("HECTOR_SCAN_CLASSPATH_PREFIX", "com.hileco.model");

Also keep in mind that @Column must have its name property set, otherwise Hector ORM will throw exceptions. Make sure to set it all up as in the test and your code should run smoothly.

hectorauxiliaryroutines's People

Contributors

skphilipp avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.