Book Image

Storm Blueprints: Patterns for Distributed Real-time Computation

Book Image

Storm Blueprints: Patterns for Distributed Real-time Computation

Overview of this book

Table of Contents (17 chapters)
Storm Blueprints: Patterns for Distributed Real-time Computation
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Implementing GraphFactory


The GraphFactory interface we defined earlier creates a TinkerPop Graph implementation, where a Map object represents a Storm configuration. The following code illustrates how to create TitanGraph backed by Cassandra:

TitanGraphFactory.java
public class TitanGraphFactory implements GraphFactory {
   
    public static final String STORAGE_BACKEND = "titan.storage.backend";
    public static final String STORAGE_HOSTNAME = "titan.storage.hostname";

    public Graph makeGraph(Map conf) {
        Configuration graphConf = new BaseConfiguration();
        graphConf.setProperty("storage.backend", conf.get(STORAGE_BACKEND));
        graphConf.setProperty("storage.hostname", conf.get(STORAGE_HOSTNAME));
       
        return TitanFactory.open(graphConf);
    }
}