• Stars
    star
    54
  • Rank 525,866 (Top 11 %)
  • Language
    Go
  • License
    MIT License
  • Created over 8 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Go(lang) client library for accessing information of an Apache Mesos cluster.

megos

GoDoc Build Status Go Report Card Coverage Status

Go(lang) client library for accessing an Apache Mesos cluster.

Features

  • Determine the Mesos leader
  • Get the current state of every mesos node (master or slave)
  • Retrieve stdout and stderr of tasks
  • Covered with unit tests

Installation

It is go gettable

$ go get github.com/andygrunwald/megos

(optional) to run unit / example tests:

$ cd $GOPATH/src/github.com/andygrunwald/megos
$ go test -v ./...

API

Please have a look at the GoDoc documentation for a detailed API description.

Examples / use cases

A (small) list of usecases how this library can be used:

  • Determine the leader of a Mesos cluster
  • Get a list of all completed Mesos tasks
  • Get the stdout and stderr of a failed mesos task
  • Get the statistics and push it to a different backend

Further more a few examples how the API can be used and the code looks like.

Determine the leader node

node1, _ := url.Parse("http://192.168.1.120:5050/")
node2, _ := url.Parse("http://192.168.1.122:5050/")

mesos := megos.NewClient([]*url.URL{node1, node2}, nil)
leader, err := mesos.DetermineLeader()
if err != nil {
	panic(err)
}

fmt.Println(leader)
// Output:
// [email protected]:5050

Get the version of Mesos

node1, _ := url.Parse("http://192.168.1.120:5050/")
node2, _ := url.Parse("http://192.168.1.122:5050/")

mesos := megos.NewClient([]*url.URL{node1, node2}, nil)
state, err := mesos.GetStateFromCluster()
if err != nil {
	panic(err)
}

fmt.Printf("Mesos v%s", state.Version)
// Output:
// Mesos v0.26.0

Get stdout and stderr of a task

Get stdout and stderr from a task of the chronos framework. Error checks are dropped for simplicity.

node1, _ := url.Parse("http://192.168.1.120:5050/")
node2, _ := url.Parse("http://192.168.1.122:5050/")
mesos := megos.NewClient([]*url.URL{node1, node2}, nil)

frameworkPrefix := "chronos"
taskID := "ct:1444578480000:0:example-chronos-task:"

mesos.DetermineLeader()
state, _ := mesos.GetStateFromLeader()

framework, _ := mesos.GetFrameworkByPrefix(state.Frameworks, frameworkPrefix)
task, _ := mesos.GetTaskByID(framework.CompletedTasks, taskID)

slave, _ := mesos.GetSlaveByID(state.Slaves, task.SlaveID)

pid, _ := mesos.ParsePidInformation(slave.PID)
slaveState, _ := mesos.GetStateFromPid(pid)

framework, _ = mesos.GetFrameworkByPrefix(slaveState.CompletedFrameworks, frameworkPrefix)
executor, _ := mesos.GetExecutorByID(framework.CompletedExecutors, taskID)

stdOut, _ := mesos.GetStdOutOfTask(pid, executor.Directory)
stdErr, _ := mesos.GetStdErrOfTask(pid, executor.Directory)

fmt.Println(string(stdOut))
fmt.Println("================")
fmt.Println(string(stdErr))
// Output:
// Registered executor on 192.168.1.123
// Starting task ct:1444578480000:0:example-chronos-task:
// sh -c 'MY COMMAND'
// Forked command at 10629
// ...
// ================
// I1011 17:48:00.390614 10602 exec.cpp:132] Version: 0.22.1
// I1011 17:48:00.532158 10618 exec.cpp:206] Executor registered on slave 20150603-103119-2046951690-5050-24382-S1

Version compatibility

This library was tested with Apache Mesos in version 0.26.0. In theory this should work with versions >= v0.25.x.

In version 0.25.x they renamed various API endpoints (like state.json to /state). See Upgrading Mesos - Upgrading from 0.24.x to 0.25.x for details. This is the reason why we support no lower versions of Mesos.

Other/Similar projects

  • boldfield/go-mesos: A client for discovering information about a Mesos exposed via HTTP API
  • antonlindstrom/mesos_stats: Statistics definition for Mesos /monitor/statistics.json
  • Clever/marathon-stats: A simple container which queries marathon and mesos for stats about their current state, and logs these stats to stderr
  • bolcom/mesos_metrics: Go definitions for the Mesos {master}:5050/metrics/snapshot and {slave}:5051/metrics/snapshot endpoints

Contribution

  • You have a question?
  • Don`t know if a feature is supported?
  • Want to implement a new feature, but don`t know how?
  • You like the library and use it for your implementation / use case?
  • You found a bug or incompatibility?
  • Something is not working as expected?

Feel free to open a new issue. I will be happy to answer them and try to help you. It might be useful to add as much information as possible into the issue like Mesos version, example URL, (parts) of your code and the expected and current behaviour.

License

This project is released under the terms of the MIT license.

More Repositories

1

go-jira

Go client library for Atlassian Jira
Go
1,401
star
2

FOM-LaTeX-Template

A LaTeX template for term paper, bachelor or master thesis for "FOM University of Applied Sciences"
TeX
164
star
3

go-trending

Go library for accessing trending repositories and developers at Github.
Go
137
star
4

TrendingGithub

A twitter bot (@TrendingGithub) to tweet trending repositories and developers from GitHub
Go
112
star
5

go-gerrit

Go(lang) client/library for Gerrit Code Review
Go
94
star
6

cachet

Go(lang) client library for Cachet (open source status page system).
Go
90
star
7

DigitalKanban

A small digital Kanban board based on Symfony2. This application was developed during a small university project.
PHP
55
star
8

jitic

The JIRA Ticket Checker - Checks the existence of one or more ticket in the JIRA issue tracker
Go
33
star
9

vdf

A Lexer and Parser for Valves Data Format (known as vdf) written in Go
Go
30
star
10

your-connection-deserves-a-name

Examples and code to assign a name to your MongoDB, MySQL, NATS, Oracle, PostgreSQL, RabbitMQ, and redis connection.
Go
26
star
11

things-with-buzzers-jeopardy

A Jeopardy! game frontend for things with buzzers with support for three buzzers πŸš€
JavaScript
24
star
12

simple-webserver

A small webserver for testing various technologies, techniques and concepts written in Go.
Go
23
star
13

things-with-buzzers-hardware

Everything you need to build hardware game show buzzers (and to do awesome things with it!) πŸš€
Python
12
star
14

Jacobine

A framework to analyze your software development cycle and the community around your software product to discover hidden information.
PHP
11
star
15

gotrap

A Gerrit <=> Github <=> TravisCI bridge written in Go
Go
11
star
16

Gerrie

A crawler for Googles code review system "Gerrit"
PHP
9
star
17

things-with-buzzers-websocket

A WebSocket server to publish messages when someone pushed a hardware game show buzzer πŸš€
Go
7
star
18

sico

A Sitemap Comparison that helps you to not fuck up your website migration.
Go
4
star
19

perseus

Local git mirror for your PHP (composer) project dependencies that works together with Satis.
Go
4
star
20

watson

A crawler for Googles code review system "Gerrit"
Go
4
star
21

go-incident

Go client library for accessing the Incident.io API
Go
4
star
22

Jacobine-Vagrant

Vagrant setup for a project to analyze different data sources of various open source projects (source code, ecosystem, community) to detect new information about your community and your contribution. See Jacobine.
Python
2
star
23

Jacobine-Web-Frontend

Website for a project to analyze different data sources of the open source project TYPO3. See TYPO3-Analytics
PHP
1
star
24

Vagrant-MetricsGrimoire

Vagrant setup to play with the MetricsGrimoire toolset
Python
1
star
25

dotfiles

My .files
Shell
1
star