GithubHelp home page GithubHelp logo

talalmahmood / scoop Goto Github PK

View Code? Open in Web Editor NEW

This project forked from akauppi/scoop

0.0 1.0 0.0 82 KB

simple library based on Akka Cluster to partition work between multiple instances (belonging to same cluster)

License: MIT License

Java 100.00%

scoop's Introduction

Scoop

Simple library based on Akka Cluster to partition work between multiple instances (belonging to same cluster).

Prerequisites

  • Java >= 1.8
  • Maven >= 3.x

Semantics

Scoop was implemented to partition work among all cluster members. It does so by assigning each cluster member a partition id. If one the members wants to perform an operation where other cluster members might be involved, it hashes the item of interest with MurmurHash3 and performs a modulo operation over all available partitions in order to determine the partition id. If the member sees that the item of interest belongs to its partition, it processes it and ignores it otherwise.

One possible use case is an application subscribing with all of its instances to a pub sub system. In this scenario, the application`s instances run a Scoop cluster in order to avoid multiple consumptions by instances of the same application.

Tutorial

        Scoop scoop = new Scoop();
        scoop = scoop.withAwsConfig() // STUPS sepcific logic gathering seed nodes, current IP etc. for Scoop setup
                     .withBindHostName("my-hostname") // host name to bind to (this is usually the docker host name (see '-h'))
                     .withClusterPort(25551) // port of the Scoop cluster -> all cluster nodes must be accessible via this port
                     .withPort(25551); // local node port
                     
        ActorSystem system = ActorSystem("scoop-nakadi-client", ConfigFactory.defaultApplication()
                                                                              .withFallback(scoop.buildConfiguration()))
        ActorRef scoopActor = scoop.startScoopActor(system)

        ScoopClient scoopClient = scoop.defaultClient()
        
        // ...
        boolean shouldIprocessIt scoopClient.isHandledByMe(id);
        
        // add ScoopListener when ScoopActor is already running
        ScoopListener listener = ...
        system.eventStream().publish(new NewScoopListener(listener))

AWS Support

NOTE: This logic is Zalando STUPS specific and might not fit other kind of deployments.

Scoop reads AWS meta data in order to perform its AWS specific configuration. The logic is as follows:

Important: Make sure the role of your instances have following policy assigned:

 {
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Stmt1450176974000",
            "Effect": "Allow",
            "Action": [
                "ec2:DescribeInstances"
            ],
            "Resource": [
                "*"
            ]
        },
        {
            "Sid": "Stmt1450177255000",
            "Effect": "Allow",
            "Action": [
                "autoscaling:DescribeAutoScalingGroups",
                "autoscaling:DescribeAutoScalingInstances"
            ],
            "Resource": [
                "*"
            ]
        }
    ]
}

Important: Make sure your Senza definition contains the cluster port defnition and the host name to which it should bind to:

...
     TaupageConfig:
        application_version: "{{Arguments.ImageVersion}}"
        runtime: Docker
        source: "my-image:{{Arguments.ImageVersion}}"
        health_check_path: /heartbeat
        ports:
          8080: 8080
          25551: 25551 # <-- cluster port
        hostname: my-hostname # <-- host name to bind to
...

TODO

  • automated tests

License

http://opensource.org/licenses/MIT

scoop's People

Contributors

codechimp avatar

Watchers

 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.