Giter Site home page Giter Site logo

zu's Introduction

Zu - A simple cluster management system based on Twitter's ServerSets api

What is it?

A simple cluster management system for partitioned data. E.g. a distributed search engine.

Zu is built on top of Twitter's Zookeeper based server management api called ServerSets.

Where does the name mean?

Zu comes from the Chinese character: ็ป„, which means a group or a set.

What are some of Zu's features?

  • Simple api
  • Manages partitioned data
  • Integration with Twitter's Finagle
  • Multi-tenancy for Finagle
  • Custom serialization
  • Scatter-gather support
  • Customizable requesting routing algorithm

Build it:

mvn clean package

2 artifacts:

  • zu-core - core library
  • zu-finagle - Finagle support

Maven:

Core:
<groupid>com.senseidb.zu</groupid>
<artifactId>zu-core</artifactId>
Finagle extension:
<groupid>com.senseidb.zu</groupid>
<artifactId>zu-finagle</artifactId>

Zu Core:

  • Cluster management
  • Routing algorithm API

Code snippet:

// Zookeepr location
String zkHost = ...
int zkPort = ...

ZuCluster cluster = new ZuCluster(new InetSocketAddress(zkHost,zkPort), "mycluster");

cluster.addClusterEventListener(new ZuClusterEventListener() {

      @Override
      public void clusterChanged(Map<Integer, ArrayList<InetSocketAddress>> clusterView) {
	    // a shard -> host mapping
	    System.out.println("cluster changed");
      }
 });

// join a cluster
List<EndPointStatus> endpoints = cluster.join(new InetSocketAddress(host,port), new HashSet<Integer>)(Arrays.asList(1,2)));

// leaving a cluster
cluster.leave(endpoints);

For more details, checkout the unit tests here.

Zu Finagle

Zu finagle is an extension to Twitter's Finagle with the following enhancements:

(To learn more about Finagle, checkout this great example)

  • Multi-tenancy - add handlers for different APIs without rebuilding the service IDL
  • Custom serializer - define different rpc serializer for each handler
  • Scatter-gather support

Example 1:

This example defines an API that returns the length of a string and is then deployed as a server.

See code listing here.

Example 2:

This example defines a set of 3 finagle servers, each handles different shards. They all join a cluster with scatter-gather logic defined.

We construct a broker based on the provided scatter-gather logic with random request routing logic for each shard.

See code listing here.

Example 3:

We have the same setup as example 2, but instead of starting the finagle servers as finagle services, we wrap them up as ZuFinagleServers.

We then create the broker both as a finagle service as well a ZuFinagleServer in different tests.

See code listing here.

Example 4:

Same as example 3, but instead of starting the ZuFinagleServers the wraps finagle services, we register our API as a ZuTransportService. This allows us to add different handlers while abstracting finagle's inner details as well as without having to re-compile the underlying thrift IDLs.

See code listing here.

zu's People

Contributors

javasoze avatar yozhao avatar msavchuk avatar

Watchers

James Cloos avatar Jacob 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.