zu-core

zu core library

License

License

GroupId

GroupId

com.senseidb.zu
ArtifactId

ArtifactId

zu-core
Last Version

Last Version

0.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

zu-core
zu core library

Download zu-core

How to add to project

<!-- https://jarcasting.com/artifacts/com.senseidb.zu/zu-core/ -->
<dependency>
    <groupId>com.senseidb.zu</groupId>
    <artifactId>zu-core</artifactId>
    <version>0.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/com.senseidb.zu/zu-core/
implementation 'com.senseidb.zu:zu-core:0.0.2'
// https://jarcasting.com/artifacts/com.senseidb.zu/zu-core/
implementation ("com.senseidb.zu:zu-core:0.0.2")
'com.senseidb.zu:zu-core:jar:0.0.2'
<dependency org="com.senseidb.zu" name="zu-core" rev="0.0.2">
  <artifact name="zu-core" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.senseidb.zu', module='zu-core', version='0.0.2')
)
libraryDependencies += "com.senseidb.zu" % "zu-core" % "0.0.2"
[com.senseidb.zu/zu-core "0.0.2"]

Dependencies

compile (1)

Group / Artifact Type Version
com.twitter.common.zookeeper : server-set jar 1.0.31

test (2)

Group / Artifact Type Version
com.twitter.common : zookeeper-testing jar 0.0.30
junit : junit jar 4.5

Project Modules

There are no modules declared in this project.

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.

com.senseidb.zu

SenseiDB

Versions

Version
0.0.2
0.0.1