├── project ├── build.properties └── plugins.sbt ├── bin ├── get ├── put ├── disable_offload.sh └── docker_cleanup.sh ├── src └── main │ ├── resources │ ├── application.conf │ └── logback.xml │ ├── java │ └── ru │ │ └── jpoint │ │ └── distdb │ │ └── RaftServer.java │ └── scala │ └── ru │ └── jpoint │ └── distdb │ ├── Server.scala │ ├── ms │ ├── MasterSlaveSync.scala │ └── MasterSlave.scala │ ├── HttpUtils.scala │ ├── Quorum.scala │ └── RestfulServer.scala ├── .gitignore ├── docker ├── distdb.sh ├── common.yml ├── authorized_keys ├── Dockerfile └── docker-compose.yml ├── jepsen.distdb ├── doc │ └── intro.md ├── .gitignore ├── README.md ├── test │ └── jepsen │ │ └── distdb_test.clj ├── project.clj ├── CHANGELOG.md ├── src │ └── jepsen │ │ ├── distdb.clj │ │ └── os │ │ └── ubuntu.clj └── LICENSE ├── deploy.sh └── resolv.sh /project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version = 0.13.8 -------------------------------------------------------------------------------- /bin/get: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | curl -4 -v http://$1:8000/db 4 | echo -------------------------------------------------------------------------------- /bin/put: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | curl -4 -v http://$1:8000/db -d $2 4 | echo -------------------------------------------------------------------------------- /src/main/resources/application.conf: -------------------------------------------------------------------------------- 1 | akka { 2 | loglevel = "INFO" 3 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | project/project 2 | project/target 3 | target 4 | .idea 5 | docker/*.jar 6 | *.iml -------------------------------------------------------------------------------- /docker/distdb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | java -Djava.net.preferIPv4Stack=true -jar /app/distdb-assembly-1.0.jar -------------------------------------------------------------------------------- /jepsen.distdb/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to jepsen.distdb 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | sbt assembly 4 | cd docker 5 | cp ../target/scala-2.11/distdb-assembly-1.0.jar . 6 | docker build -t shutty/distdb . 7 | docker-compose up -------------------------------------------------------------------------------- /src/main/java/ru/jpoint/distdb/RaftServer.java: -------------------------------------------------------------------------------- 1 | package ru.jpoint.distdb; 2 | 3 | /** 4 | * Created by shutty on 2/25/16. 5 | */ 6 | public class RaftServer { 7 | } 8 | -------------------------------------------------------------------------------- /bin/disable_offload.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for i in `cat /proc/net/dev|grep eth|sed s/://g|awk '{print $1}'`; do ethtool -K $i tx off tso off gso off gro off; echo done $i; done -------------------------------------------------------------------------------- /project/plugins.sbt: -------------------------------------------------------------------------------- 1 | logLevel := Level.Warn 2 | 3 | addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.1.10") 4 | 5 | addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.1") -------------------------------------------------------------------------------- /docker/common.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | services: 3 | node: 4 | image: shutty/distdb 5 | dns: 172.18.0.1 6 | privileged: true 7 | environment: 8 | NODES: "n1,n2,n3,n4,n5" -------------------------------------------------------------------------------- /jepsen.distdb/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | /store -------------------------------------------------------------------------------- /resolv.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | prev=`cat /etc/resolv.conf` 4 | echo "domain distdb.docker_default.docker" > /etc/resolv.conf 5 | echo "nameserver 172.18.0.1" >> /etc/resolv.conf 6 | echo "nameserver 8.8.8.8" >> /etc/resolv.conf -------------------------------------------------------------------------------- /bin/docker_cleanup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Cleaning up dead containers" 4 | docker ps --filter status=dead --filter status=exited -aq | xargs docker rm -v 5 | 6 | echo "Cleaning up non-tagged images" 7 | docker images --no-trunc | grep '' | awk '{ print $3 }' | xargs -r docker rmi -------------------------------------------------------------------------------- /jepsen.distdb/README.md: -------------------------------------------------------------------------------- 1 | # jepsen.distdb 2 | 3 | A Clojure library designed to ... well, that part is up to you. 4 | 5 | ## Usage 6 | 7 | FIXME 8 | 9 | ## License 10 | 11 | Copyright © 2016 FIXME 12 | 13 | Distributed under the Eclipse Public License either version 1.0 or (at 14 | your option) any later version. 15 | -------------------------------------------------------------------------------- /jepsen.distdb/test/jepsen/distdb_test.clj: -------------------------------------------------------------------------------- 1 | (ns jepsen.distdb-test 2 | (:require [clojure.test :refer :all] 3 | [jepsen.core :as jepsen] 4 | [jepsen.distdb :refer :all])) 5 | 6 | 7 | (deftest distdb-test 8 | (is (:valid? 9 | (:results (jepsen/run! (jepsen.distdb/distsb-test)))))) 10 | -------------------------------------------------------------------------------- /src/main/scala/ru/jpoint/distdb/Server.scala: -------------------------------------------------------------------------------- 1 | package ru.jpoint.distdb 2 | 3 | import ru.jpoint.distdb.ms.MasterSlave 4 | 5 | /** 6 | * Created by shutty on 11/16/15. 7 | */ 8 | object Server { 9 | def main(args: Array[String]): Unit = { 10 | val dsys = new MasterSlave() 11 | dsys.start 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /docker/authorized_keys: -------------------------------------------------------------------------------- 1 | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDfj62ICRG1KBFQxKev7exGqwyaSSvdByygt1XYPWRdx10cpB2Q1Sr1YI9K5x2h8vLXiSQ+6NuP1IYe1f/v9ZqiZ0YmtxcieK5Pe3hXCMnJ8/3HCuk+B3LoXBbLiLF6FcWNA2Ttil+GIYBosPtteh87l3Crq5eF3VIRr6MNIwBbzIBAIIaT0ZnBAzzMO32R9Cx3BNAwnL1aQtX981kaUXMbtg8LrfJ/Gi8dgGDebRmdSjwzE7C3yvuuYR7vJMg8IEU3SXEyFC5UlEs4rESZV90yjpuXfyTSrI3Y2mhyBrucCPd3FMrvOtoMzBY7YrPUonM8GgRWVQ4AMVcDwJrDpErB shutty@lappy 2 | -------------------------------------------------------------------------------- /jepsen.distdb/project.clj: -------------------------------------------------------------------------------- 1 | (defproject jepsen.distdb "0.1.0-SNAPSHOT" 2 | :description "A jepsen test for sample distributed database" 3 | :url "http://github.com/shuttie/distdb" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.7.0"] 7 | [jepsen "0.1.0"] 8 | [clj-http "2.0.1"]]) 9 | -------------------------------------------------------------------------------- /src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | %d [%-5level] - %logger: %msg%n 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/main/scala/ru/jpoint/distdb/ms/MasterSlaveSync.scala: -------------------------------------------------------------------------------- 1 | package ru.jpoint.distdb.ms 2 | 3 | import akka.http.scaladsl.model._ 4 | 5 | import scala.concurrent.Future 6 | 7 | /** 8 | * Created by shutty on 2/19/16. 9 | */ 10 | class MasterSlaveSync extends MasterSlave { 11 | override def write(data: String) = { 12 | logger.info(s"write, before=$value, after=$data") 13 | value = data 14 | 15 | logger.info(s"replicating write to slaves: $slaves") 16 | Future.sequence(slaves 17 | .map(node => httpWrite(node, data))) 18 | .map(responses => responses 19 | .find(_.status != StatusCodes.OK) 20 | .getOrElse(HttpResponse(StatusCodes.OK, entity = value))) 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM phusion/baseimage:latest 2 | MAINTAINER grv@dfdx.me 3 | 4 | RUN apt-get -y -q update && \ 5 | apt-get -y -q install software-properties-common && \ 6 | add-apt-repository ppa:openjdk-r/ppa && \ 7 | apt-get -y -q update && \ 8 | apt-get install -qqy \ 9 | openjdk-8-jdk \ 10 | libjna-java 11 | 12 | ADD authorized_keys /root/.ssh/ 13 | RUN chmod 600 /root/.ssh/authorized_keys 14 | RUN rm -f /etc/service/sshd/down 15 | RUN /etc/my_init.d/00_regen_ssh_host_keys.sh 16 | 17 | RUN apt-get -y -q install curl iptables iputils-ping inetutils-telnet dnsutils 18 | EXPOSE 8000 19 | RUN mkdir /app 20 | RUN mkdir /etc/service/distdb 21 | ADD distdb.sh /etc/service/distdb/run 22 | ADD distdb-assembly-1.0.jar /app/ 23 | CMD ["/sbin/my_init"] -------------------------------------------------------------------------------- /src/main/scala/ru/jpoint/distdb/ms/MasterSlave.scala: -------------------------------------------------------------------------------- 1 | package ru.jpoint.distdb.ms 2 | 3 | import akka.http.scaladsl.model._ 4 | import ru.jpoint.distdb.RestfulServer 5 | 6 | import scala.concurrent.Future 7 | 8 | /** 9 | * Created by shutty on 2/18/16. 10 | */ 11 | class MasterSlave extends RestfulServer { 12 | def read = { 13 | logger.info(s"read, result=$value") 14 | Future.successful(HttpResponse(StatusCodes.OK, entity = value)) 15 | } 16 | 17 | def write(data: String) = { 18 | logger.info(s"write, before=$value, after=$data") 19 | value = data 20 | logger.info(s"replicating write to slaves: $slaves") 21 | slaves.foreach(node => httpWrite(node, data)) 22 | Future.successful(HttpResponse(StatusCodes.OK, entity = value)) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /jepsen.distdb/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased][unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - 2016-02-17 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - 2016-02-17 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [unreleased]: https://github.com/your-name/jepsen.distdb/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/jepsen.distdb/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /docker/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | services: 3 | n1: 4 | container_name: n1 5 | hostname: n1 6 | environment: 7 | DNSDOCK_ALIAS: n1 8 | extends: 9 | file: common.yml 10 | service: node 11 | n2: 12 | container_name: n2 13 | hostname: n2 14 | environment: 15 | DNSDOCK_ALIAS: n2 16 | extends: 17 | file: common.yml 18 | service: node 19 | n3: 20 | container_name: n3 21 | hostname: n3 22 | environment: 23 | DNSDOCK_ALIAS: n3 24 | extends: 25 | file: common.yml 26 | service: node 27 | n4: 28 | container_name: n4 29 | hostname: n4 30 | environment: 31 | DNSDOCK_ALIAS: n4 32 | extends: 33 | file: common.yml 34 | service: node 35 | n5: 36 | container_name: n5 37 | hostname: n5 38 | environment: 39 | DNSDOCK_ALIAS: n5 40 | extends: 41 | file: common.yml 42 | service: node 43 | 44 | dnsdock: 45 | container_name: dnsdock 46 | hostname: dnsdock 47 | image: tjamet/dnsdock 48 | volumes: 49 | - /var/run/docker.sock:/var/run/docker.sock 50 | ports: 51 | - "172.18.0.1:53:53/udp" 52 | -------------------------------------------------------------------------------- /src/main/scala/ru/jpoint/distdb/HttpUtils.scala: -------------------------------------------------------------------------------- 1 | package ru.jpoint.distdb 2 | 3 | import akka.actor.ActorSystem 4 | import akka.http.scaladsl.Http 5 | import akka.http.scaladsl.model.{HttpMethods, HttpRequest, HttpResponse} 6 | import akka.stream.ActorMaterializer 7 | import akka.util.ByteString 8 | import com.typesafe.scalalogging.LazyLogging 9 | import org.slf4j.LoggerFactory 10 | 11 | trait HttpUtils extends LazyLogging { 12 | implicit val system = ActorSystem.create("distdb") 13 | implicit val executor = system.dispatcher 14 | implicit val mat = ActorMaterializer() 15 | val http = Http(system) 16 | 17 | def httpWrite(node: String, data: String) = 18 | http.singleRequest(HttpRequest( 19 | uri = s"http://$node:8000/local", 20 | method = HttpMethods.POST, 21 | entity = data)) 22 | 23 | def httpRead(node: String) = 24 | http.singleRequest( 25 | HttpRequest( 26 | uri = s"http://$node:8000/local", 27 | method = HttpMethods.GET)) 28 | 29 | def parseResponse(response: HttpResponse) = response 30 | .entity 31 | .dataBytes 32 | .runFold(ByteString(""))(_ ++ _) 33 | .map(_.utf8String) 34 | 35 | } 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/main/scala/ru/jpoint/distdb/Quorum.scala: -------------------------------------------------------------------------------- 1 | package ru.jpoint.distdb 2 | 3 | import akka.http.scaladsl.model.{StatusCodes, HttpResponse} 4 | import scala.concurrent.Future 5 | 6 | class Quorum extends RestfulServer { 7 | def quorumSize = Math.ceil(nodes.size / 2.0) 8 | 9 | def handleQuorum(responses: List[HttpResponse]) = 10 | Future.sequence(responses.map(parseResponse)).map(_ 11 | .groupBy(x => x) 12 | .toList 13 | .map(item => item._1 -> item._2.size) 14 | .sortBy(_._2) 15 | .lastOption) 16 | 17 | def buildResponse(quorumResponse: Option[(String, Int)]) = quorumResponse match { 18 | case Some((quorumValue, numberVotes)) if numberVotes >= quorumSize => 19 | logger.info(s"quorum: $quorumValue with $numberVotes votes (of $quorumSize)") 20 | HttpResponse(StatusCodes.OK, entity = quorumValue) 21 | case other => 22 | HttpResponse(StatusCodes.Conflict, entity = s"quorum response: $other") 23 | } 24 | 25 | 26 | def read = 27 | Future.sequence(nodes.map(node => httpRead(node))) 28 | .flatMap(handleQuorum) 29 | .map(buildResponse) 30 | 31 | def write(data: String) = { 32 | Future.sequence(nodes.map(node => httpWrite(node, data))) 33 | .flatMap(handleQuorum) 34 | .map(buildResponse) 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/scala/ru/jpoint/distdb/RestfulServer.scala: -------------------------------------------------------------------------------- 1 | package ru.jpoint.distdb 2 | 3 | import akka.http.scaladsl.model._ 4 | import akka.http.scaladsl.server.Directives._ 5 | import scala.concurrent.duration.Duration 6 | import scala.concurrent.{Await, Future} 7 | 8 | trait RestfulServer extends HttpUtils { 9 | var value: String = "0" 10 | val hostname = sys.env("HOSTNAME") 11 | val nodes = sys.env("NODES") 12 | .split(",") 13 | .toList 14 | .filter(_.nonEmpty) 15 | val slaves = nodes.filter(_ != hostname) 16 | 17 | def read: Future[HttpResponse] 18 | 19 | def write(value: String): Future[HttpResponse] 20 | 21 | def start = { 22 | 23 | val route = path("db") { 24 | get { 25 | complete { 26 | read 27 | } 28 | } ~ post { 29 | entity(as[String]) { data => 30 | complete { 31 | write(data) 32 | } 33 | } 34 | } 35 | } ~ path("local") { 36 | get { 37 | complete { 38 | logger.info(s"local read: $value") 39 | HttpResponse(StatusCodes.OK, entity = value) 40 | } 41 | } ~ post { 42 | entity(as[String]) { data => 43 | complete { 44 | value = data 45 | logger.info(s"local commit: $data") 46 | HttpResponse(StatusCodes.OK, entity = value) 47 | } 48 | } 49 | } 50 | } 51 | 52 | http.bindAndHandle(route, "0.0.0.0", 8000) 53 | logger.info("Service started") 54 | Await.result(system.whenTerminated, Duration.Inf) 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /jepsen.distdb/src/jepsen/distdb.clj: -------------------------------------------------------------------------------- 1 | (ns jepsen.distdb 2 | (:require [clojure.tools.logging :refer :all :as log] 3 | [clojure.string :refer :all] 4 | [clj-http.client :as http] 5 | [knossos [model :as model] 6 | [op :as op] 7 | [linear :as linear] 8 | [history :as history]] 9 | [jepsen 10 | [db :as db] 11 | [checker :as checker] 12 | [control :as c] 13 | [client :as client] 14 | [generator :as gen] 15 | [nemesis :as nemesis] 16 | [util :refer [timeout]] 17 | [tests :as tests]] 18 | [jepsen.os.ubuntu :as ubuntu])) 19 | 20 | (defn db 21 | "Node bootstrap" 22 | [version] 23 | (reify db/DB 24 | (setup! [_ test node] 25 | (log/info node "setting up distdb" version)) 26 | (teardown! [_ test node] 27 | (log/info node "tearing down distdb")))) 28 | 29 | 30 | 31 | (defn r [_ _] {:type :invoke, :f :read, :value nil}) 32 | (defn w [_ _] {:type :invoke, :f :write, :value (rand-int 5)}) 33 | 34 | (defn process-response [response op] 35 | (case (:status response) 36 | 200 (assoc op :type :ok :value (read-string (:body response))) 37 | 409 (assoc op :type :fail))) 38 | 39 | (defn http-write [host op] 40 | (process-response (http/post (join ["http://" host ":8000/db"]) { :body (str (:value op)) :throw-exceptions false }) op)) 41 | 42 | (defn http-read [host op] 43 | (process-response (http/get (join ["http://" host ":8000/db"]) { :throw-exceptions false }) op)) 44 | 45 | (defn client 46 | "A simple http client" 47 | [host] 48 | (reify client/Client 49 | (setup! [_ test node] 50 | (client (name node))) 51 | (invoke! [this test op] 52 | (timeout 5000 (assoc op 53 | :type :info, 54 | :error :timeout) 55 | (case (:f op) 56 | :read (http-read host op) 57 | :write (http-write "n1" op)))) 58 | (teardown! [_ test]))) 59 | 60 | (def distdb-checker 61 | (reify checker/Checker 62 | (check [this test model history opts] 63 | (let [a (linear/analysis model history)] 64 | (assoc a 65 | :final-paths (take 100 (:final-paths a)) 66 | :configs (take 100 (:configs a))))))) 67 | 68 | (defn distsb-test 69 | [] 70 | (assoc tests/noop-test 71 | :name "distdb" 72 | :os ubuntu/os 73 | :db (db "1.0") 74 | :client (client nil) 75 | :checker distdb-checker 76 | :model (model/register 5) 77 | :generator (->> (gen/mix [r w]) 78 | (gen/stagger 0.01) 79 | (gen/clients) 80 | (gen/time-limit 30)) 81 | :ssh { 82 | :strict-host-key-checking false 83 | :private-key-path "~/.ssh/grebennikov_roman.pem" 84 | :username "root"})) -------------------------------------------------------------------------------- /jepsen.distdb/src/jepsen/os/ubuntu.clj: -------------------------------------------------------------------------------- 1 | (ns jepsen.os.ubuntu 2 | "Common tasks for Debian boxes." 3 | (:use clojure.tools.logging) 4 | (:require [clojure.set :as set] 5 | [jepsen.util :refer [meh]] 6 | [jepsen.os :as os] 7 | [jepsen.control :as c] 8 | [jepsen.control.util :as cu] 9 | [jepsen.control.net :as net] 10 | [clojure.string :as str])) 11 | 12 | (defn time-since-last-update 13 | "When did we last run an apt-get update, in seconds ago" 14 | [] 15 | (- (Long/parseLong (c/exec :date "+%s")) 16 | (Long/parseLong (c/exec :stat :-c "%Y" "/var/cache/apt/pkgcache.bin")))) 17 | 18 | (defn update! 19 | "Apt-get update." 20 | [] 21 | (c/su (c/exec :apt-get :update))) 22 | 23 | (defn maybe-update! 24 | "Apt-get update if we haven't done so recently." 25 | [] 26 | (when (< 86400 (time-since-last-update)) 27 | (update!))) 28 | 29 | (defn installed 30 | "Given a list of debian packages (strings, symbols, keywords, etc), returns 31 | the set of packages which are installed, as strings." 32 | [pkgs] 33 | (let [pkgs (->> pkgs (map name) set)] 34 | (->> (apply c/exec :dpkg :--get-selections pkgs) 35 | str/split-lines 36 | (map (fn [line] (str/split line #"\s+"))) 37 | (filter #(= "install" (second %))) 38 | (map first) 39 | set))) 40 | 41 | (defn uninstall! 42 | "Removes a package or packages." 43 | [pkg-or-pkgs] 44 | (let [pkgs (if (coll? pkg-or-pkgs) pkg-or-pkgs (list pkg-or-pkgs)) 45 | pkgs (installed pkgs)] 46 | (c/su (apply c/exec :apt-get :remove :--purge :-y pkgs)))) 47 | 48 | (defn installed? 49 | "Are the given debian packages, or singular package, installed on the current 50 | system?" 51 | [pkg-or-pkgs] 52 | (let [pkgs (if (coll? pkg-or-pkgs) pkg-or-pkgs (list pkg-or-pkgs))] 53 | (every? (installed pkgs) (map name pkgs)))) 54 | 55 | (defn installed-version 56 | "Given a package name, determines the installed version of that package, or 57 | nil if it is not installed." 58 | [pkg] 59 | (->> (c/exec :apt-cache :policy (name pkg)) 60 | (re-find #"Installed: ([^\s]+)") 61 | second)) 62 | 63 | (defn install 64 | "Ensure the given packages are installed. Can take a flat collection of 65 | packages, passed as symbols, strings, or keywords, or, alternatively, a map 66 | of packages to version strings." 67 | [pkgs] 68 | (if (map? pkgs) 69 | ; Install specific versions 70 | (dorun 71 | (for [[pkg version] pkgs] 72 | (when (not= version (installed-version pkg)) 73 | (info "Installing" pkg version) 74 | (c/exec :apt-get :install :-y :--force-yes 75 | (str (name pkg) "=" version))))) 76 | 77 | ; Install any version 78 | (let [pkgs (set (map name pkgs)) 79 | missing (set/difference pkgs (installed pkgs))] 80 | (when-not (empty? missing) 81 | (c/su 82 | (info "Installing" missing) 83 | (apply c/exec :apt-get :install :-y missing)))))) 84 | 85 | (defn add-key! 86 | "Receives an apt key from the given keyserver." 87 | [keyserver key] 88 | (c/su 89 | (c/exec :apt-key :adv 90 | :--keyserver keyserver 91 | :--recv key))) 92 | 93 | (defn add-repo! 94 | "Adds an apt repo (and optionally a key from the given keyserver)." 95 | ([repo-name apt-line] 96 | (add-repo! repo-name apt-line nil nil)) 97 | ([repo-name apt-line keyserver key] 98 | (let [list-file (str "/etc/apt/sources.list.d/" (name repo-name) ".list")] 99 | (when-not (cu/file? list-file) 100 | (info "setting up" repo-name "apt repo") 101 | (when (or keyserver key) 102 | (add-key! keyserver key)) 103 | (c/exec :echo apt-line :> list-file) 104 | (update!))))) 105 | 106 | (def os 107 | (reify os/OS 108 | (setup! [_ test node] 109 | (info node "setting up ubuntu") 110 | 111 | ;(meh (net/heal)) 112 | ;(net/heal) 113 | ) 114 | 115 | (teardown! [_ test node]))) 116 | -------------------------------------------------------------------------------- /jepsen.distdb/LICENSE: -------------------------------------------------------------------------------- 1 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC 2 | LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM 3 | CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 4 | 5 | 1. DEFINITIONS 6 | 7 | "Contribution" means: 8 | 9 | a) in the case of the initial Contributor, the initial code and 10 | documentation distributed under this Agreement, and 11 | 12 | b) in the case of each subsequent Contributor: 13 | 14 | i) changes to the Program, and 15 | 16 | ii) additions to the Program; 17 | 18 | where such changes and/or additions to the Program originate from and are 19 | distributed by that particular Contributor. A Contribution 'originates' from 20 | a Contributor if it was added to the Program by such Contributor itself or 21 | anyone acting on such Contributor's behalf. Contributions do not include 22 | additions to the Program which: (i) are separate modules of software 23 | distributed in conjunction with the Program under their own license 24 | agreement, and (ii) are not derivative works of the Program. 25 | 26 | "Contributor" means any person or entity that distributes the Program. 27 | 28 | "Licensed Patents" mean patent claims licensable by a Contributor which are 29 | necessarily infringed by the use or sale of its Contribution alone or when 30 | combined with the Program. 31 | 32 | "Program" means the Contributions distributed in accordance with this 33 | Agreement. 34 | 35 | "Recipient" means anyone who receives the Program under this Agreement, 36 | including all Contributors. 37 | 38 | 2. GRANT OF RIGHTS 39 | 40 | a) Subject to the terms of this Agreement, each Contributor hereby grants 41 | Recipient a non-exclusive, worldwide, royalty-free copyright license to 42 | reproduce, prepare derivative works of, publicly display, publicly perform, 43 | distribute and sublicense the Contribution of such Contributor, if any, and 44 | such derivative works, in source code and object code form. 45 | 46 | b) Subject to the terms of this Agreement, each Contributor hereby grants 47 | Recipient a non-exclusive, worldwide, royalty-free patent license under 48 | Licensed Patents to make, use, sell, offer to sell, import and otherwise 49 | transfer the Contribution of such Contributor, if any, in source code and 50 | object code form. This patent license shall apply to the combination of the 51 | Contribution and the Program if, at the time the Contribution is added by the 52 | Contributor, such addition of the Contribution causes such combination to be 53 | covered by the Licensed Patents. The patent license shall not apply to any 54 | other combinations which include the Contribution. No hardware per se is 55 | licensed hereunder. 56 | 57 | c) Recipient understands that although each Contributor grants the licenses 58 | to its Contributions set forth herein, no assurances are provided by any 59 | Contributor that the Program does not infringe the patent or other 60 | intellectual property rights of any other entity. Each Contributor disclaims 61 | any liability to Recipient for claims brought by any other entity based on 62 | infringement of intellectual property rights or otherwise. As a condition to 63 | exercising the rights and licenses granted hereunder, each Recipient hereby 64 | assumes sole responsibility to secure any other intellectual property rights 65 | needed, if any. For example, if a third party patent license is required to 66 | allow Recipient to distribute the Program, it is Recipient's responsibility 67 | to acquire that license before distributing the Program. 68 | 69 | d) Each Contributor represents that to its knowledge it has sufficient 70 | copyright rights in its Contribution, if any, to grant the copyright license 71 | set forth in this Agreement. 72 | 73 | 3. REQUIREMENTS 74 | 75 | A Contributor may choose to distribute the Program in object code form under 76 | its own license agreement, provided that: 77 | 78 | a) it complies with the terms and conditions of this Agreement; and 79 | 80 | b) its license agreement: 81 | 82 | i) effectively disclaims on behalf of all Contributors all warranties and 83 | conditions, express and implied, including warranties or conditions of title 84 | and non-infringement, and implied warranties or conditions of merchantability 85 | and fitness for a particular purpose; 86 | 87 | ii) effectively excludes on behalf of all Contributors all liability for 88 | damages, including direct, indirect, special, incidental and consequential 89 | damages, such as lost profits; 90 | 91 | iii) states that any provisions which differ from this Agreement are offered 92 | by that Contributor alone and not by any other party; and 93 | 94 | iv) states that source code for the Program is available from such 95 | Contributor, and informs licensees how to obtain it in a reasonable manner on 96 | or through a medium customarily used for software exchange. 97 | 98 | When the Program is made available in source code form: 99 | 100 | a) it must be made available under this Agreement; and 101 | 102 | b) a copy of this Agreement must be included with each copy of the Program. 103 | 104 | Contributors may not remove or alter any copyright notices contained within 105 | the Program. 106 | 107 | Each Contributor must identify itself as the originator of its Contribution, 108 | if any, in a manner that reasonably allows subsequent Recipients to identify 109 | the originator of the Contribution. 110 | 111 | 4. COMMERCIAL DISTRIBUTION 112 | 113 | Commercial distributors of software may accept certain responsibilities with 114 | respect to end users, business partners and the like. While this license is 115 | intended to facilitate the commercial use of the Program, the Contributor who 116 | includes the Program in a commercial product offering should do so in a 117 | manner which does not create potential liability for other Contributors. 118 | Therefore, if a Contributor includes the Program in a commercial product 119 | offering, such Contributor ("Commercial Contributor") hereby agrees to defend 120 | and indemnify every other Contributor ("Indemnified Contributor") against any 121 | losses, damages and costs (collectively "Losses") arising from claims, 122 | lawsuits and other legal actions brought by a third party against the 123 | Indemnified Contributor to the extent caused by the acts or omissions of such 124 | Commercial Contributor in connection with its distribution of the Program in 125 | a commercial product offering. The obligations in this section do not apply 126 | to any claims or Losses relating to any actual or alleged intellectual 127 | property infringement. In order to qualify, an Indemnified Contributor must: 128 | a) promptly notify the Commercial Contributor in writing of such claim, and 129 | b) allow the Commercial Contributor tocontrol, and cooperate with the 130 | Commercial Contributor in, the defense and any related settlement 131 | negotiations. The Indemnified Contributor may participate in any such claim 132 | at its own expense. 133 | 134 | For example, a Contributor might include the Program in a commercial product 135 | offering, Product X. That Contributor is then a Commercial Contributor. If 136 | that Commercial Contributor then makes performance claims, or offers 137 | warranties related to Product X, those performance claims and warranties are 138 | such Commercial Contributor's responsibility alone. Under this section, the 139 | Commercial Contributor would have to defend claims against the other 140 | Contributors related to those performance claims and warranties, and if a 141 | court requires any other Contributor to pay any damages as a result, the 142 | Commercial Contributor must pay those damages. 143 | 144 | 5. NO WARRANTY 145 | 146 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON 147 | AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER 148 | EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR 149 | CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A 150 | PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the 151 | appropriateness of using and distributing the Program and assumes all risks 152 | associated with its exercise of rights under this Agreement , including but 153 | not limited to the risks and costs of program errors, compliance with 154 | applicable laws, damage to or loss of data, programs or equipment, and 155 | unavailability or interruption of operations. 156 | 157 | 6. DISCLAIMER OF LIABILITY 158 | 159 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY 160 | CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, 161 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION 162 | LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 163 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 164 | ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE 165 | EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY 166 | OF SUCH DAMAGES. 167 | 168 | 7. GENERAL 169 | 170 | If any provision of this Agreement is invalid or unenforceable under 171 | applicable law, it shall not affect the validity or enforceability of the 172 | remainder of the terms of this Agreement, and without further action by the 173 | parties hereto, such provision shall be reformed to the minimum extent 174 | necessary to make such provision valid and enforceable. 175 | 176 | If Recipient institutes patent litigation against any entity (including a 177 | cross-claim or counterclaim in a lawsuit) alleging that the Program itself 178 | (excluding combinations of the Program with other software or hardware) 179 | infringes such Recipient's patent(s), then such Recipient's rights granted 180 | under Section 2(b) shall terminate as of the date such litigation is filed. 181 | 182 | All Recipient's rights under this Agreement shall terminate if it fails to 183 | comply with any of the material terms or conditions of this Agreement and 184 | does not cure such failure in a reasonable period of time after becoming 185 | aware of such noncompliance. If all Recipient's rights under this Agreement 186 | terminate, Recipient agrees to cease use and distribution of the Program as 187 | soon as reasonably practicable. However, Recipient's obligations under this 188 | Agreement and any licenses granted by Recipient relating to the Program shall 189 | continue and survive. 190 | 191 | Everyone is permitted to copy and distribute copies of this Agreement, but in 192 | order to avoid inconsistency the Agreement is copyrighted and may only be 193 | modified in the following manner. The Agreement Steward reserves the right to 194 | publish new versions (including revisions) of this Agreement from time to 195 | time. No one other than the Agreement Steward has the right to modify this 196 | Agreement. The Eclipse Foundation is the initial Agreement Steward. The 197 | Eclipse Foundation may assign the responsibility to serve as the Agreement 198 | Steward to a suitable separate entity. Each new version of the Agreement will 199 | be given a distinguishing version number. The Program (including 200 | Contributions) may always be distributed subject to the version of the 201 | Agreement under which it was received. In addition, after a new version of 202 | the Agreement is published, Contributor may elect to distribute the Program 203 | (including its Contributions) under the new version. Except as expressly 204 | stated in Sections 2(a) and 2(b) above, Recipient receives no rights or 205 | licenses to the intellectual property of any Contributor under this 206 | Agreement, whether expressly, by implication, estoppel or otherwise. All 207 | rights in the Program not expressly granted under this Agreement are 208 | reserved. 209 | 210 | This Agreement is governed by the laws of the State of New York and the 211 | intellectual property laws of the United States of America. No party to this 212 | Agreement will bring a legal action under this Agreement more than one year 213 | after the cause of action arose. Each party waives its rights to a jury trial 214 | in any resulting litigation. 215 | --------------------------------------------------------------------------------