Skip to content

Commit

Permalink
Merge T52 to default.
Browse files Browse the repository at this point in the history
Ref T52.
  • Loading branch information
msackman committed Nov 18, 2016
2 parents b7cba53 + b4fa9ab commit 6153af6
Show file tree
Hide file tree
Showing 54 changed files with 4,046 additions and 1,889 deletions.
11 changes: 11 additions & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,14 @@ This file lists all individuals having contributed content to the
repository.

Matthew Sackman <matthew@goshawkdb.io>
Ashley Hewson <ash@lshift.net>

By default, code in this repository is:
Copyright (C) 2015-2016 Matthew Sackman <matthew@goshawkdb.io>

The following files are:

Copyright (C) 2015-2016 Matthew Sackman <matthew@goshawkdb.io>
Copyright (C) 2016 LShift Ltd <opensource@lshift.net>

client/clienttxnsubmitter.go
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
GoshawkDB Server
Copyright 2015 Matthew Sackman <matthew@goshawkdb.io>
Copyright 2015-2016 Matthew Sackman <matthew@goshawkdb.io>
13 changes: 5 additions & 8 deletions capnp/acceptor.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,22 @@ $Go.import("goshawkdb.io/server/capnp");

@0xefa5a1e88b6da9e3;

using Ballot = import "ballot.capnp";
using Txn = import "transaction.capnp";
using Outcome = import "outcome.capnp";

struct AcceptorState {
txn @0: Txn.Txn;
outcome @1: Outcome.Outcome;
sendToAll @2: Bool;
instances @3: List(InstancesForVar);
outcome @0: Outcome.Outcome;
sendToAll @1: Bool;
instances @2: List(InstancesForVar);
}

struct InstancesForVar {
varId @0: Data;
instances @1: List(AcceptedInstance);
result @2: Ballot.Ballot;
result @2: Data;
}

struct AcceptedInstance {
rmId @0: UInt32;
roundNumber @1: UInt64;
ballot @2: Ballot.Ballot;
ballot @2: Data;
}
80 changes: 32 additions & 48 deletions capnp/acceptor.capnp.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,18 @@ import (

type AcceptorState C.Struct

func NewAcceptorState(s *C.Segment) AcceptorState { return AcceptorState(s.NewStruct(8, 3)) }
func NewRootAcceptorState(s *C.Segment) AcceptorState { return AcceptorState(s.NewRootStruct(8, 3)) }
func AutoNewAcceptorState(s *C.Segment) AcceptorState { return AcceptorState(s.NewStructAR(8, 3)) }
func NewAcceptorState(s *C.Segment) AcceptorState { return AcceptorState(s.NewStruct(8, 2)) }
func NewRootAcceptorState(s *C.Segment) AcceptorState { return AcceptorState(s.NewRootStruct(8, 2)) }
func AutoNewAcceptorState(s *C.Segment) AcceptorState { return AcceptorState(s.NewStructAR(8, 2)) }
func ReadRootAcceptorState(s *C.Segment) AcceptorState { return AcceptorState(s.Root(0).ToStruct()) }
func (s AcceptorState) Txn() Txn { return Txn(C.Struct(s).GetObject(0).ToStruct()) }
func (s AcceptorState) SetTxn(v Txn) { C.Struct(s).SetObject(0, C.Object(v)) }
func (s AcceptorState) Outcome() Outcome { return Outcome(C.Struct(s).GetObject(1).ToStruct()) }
func (s AcceptorState) SetOutcome(v Outcome) { C.Struct(s).SetObject(1, C.Object(v)) }
func (s AcceptorState) Outcome() Outcome { return Outcome(C.Struct(s).GetObject(0).ToStruct()) }
func (s AcceptorState) SetOutcome(v Outcome) { C.Struct(s).SetObject(0, C.Object(v)) }
func (s AcceptorState) SendToAll() bool { return C.Struct(s).Get1(0) }
func (s AcceptorState) SetSendToAll(v bool) { C.Struct(s).Set1(0, v) }
func (s AcceptorState) Instances() InstancesForVar_List {
return InstancesForVar_List(C.Struct(s).GetObject(2))
return InstancesForVar_List(C.Struct(s).GetObject(1))
}
func (s AcceptorState) SetInstances(v InstancesForVar_List) { C.Struct(s).SetObject(2, C.Object(v)) }
func (s AcceptorState) SetInstances(v InstancesForVar_List) { C.Struct(s).SetObject(1, C.Object(v)) }
func (s AcceptorState) WriteJSON(w io.Writer) error {
b := bufio.NewWriter(w)
var err error
Expand All @@ -35,21 +33,6 @@ func (s AcceptorState) WriteJSON(w io.Writer) error {
if err != nil {
return err
}
_, err = b.WriteString("\"txn\":")
if err != nil {
return err
}
{
s := s.Txn()
err = s.WriteJSON(b)
if err != nil {
return err
}
}
err = b.WriteByte(',')
if err != nil {
return err
}
_, err = b.WriteString("\"outcome\":")
if err != nil {
return err
Expand Down Expand Up @@ -134,21 +117,6 @@ func (s AcceptorState) WriteCapLit(w io.Writer) error {
if err != nil {
return err
}
_, err = b.WriteString("txn = ")
if err != nil {
return err
}
{
s := s.Txn()
err = s.WriteCapLit(b)
if err != nil {
return err
}
}
_, err = b.WriteString(", ")
if err != nil {
return err
}
_, err = b.WriteString("outcome = ")
if err != nil {
return err
Expand Down Expand Up @@ -228,7 +196,7 @@ func (s AcceptorState) MarshalCapLit() ([]byte, error) {
type AcceptorState_List C.PointerList

func NewAcceptorStateList(s *C.Segment, sz int) AcceptorState_List {
return AcceptorState_List(s.NewCompositeList(8, 3, sz))
return AcceptorState_List(s.NewCompositeList(8, 2, sz))
}
func (s AcceptorState_List) Len() int { return C.PointerList(s).Len() }
func (s AcceptorState_List) At(i int) AcceptorState {
Expand Down Expand Up @@ -260,8 +228,8 @@ func (s InstancesForVar) Instances() AcceptedInstance_List {
return AcceptedInstance_List(C.Struct(s).GetObject(1))
}
func (s InstancesForVar) SetInstances(v AcceptedInstance_List) { C.Struct(s).SetObject(1, C.Object(v)) }
func (s InstancesForVar) Result() Ballot { return Ballot(C.Struct(s).GetObject(2).ToStruct()) }
func (s InstancesForVar) SetResult(v Ballot) { C.Struct(s).SetObject(2, C.Object(v)) }
func (s InstancesForVar) Result() []byte { return C.Struct(s).GetObject(2).ToData() }
func (s InstancesForVar) SetResult(v []byte) { C.Struct(s).SetObject(2, s.Segment.NewData(v)) }
func (s InstancesForVar) WriteJSON(w io.Writer) error {
b := bufio.NewWriter(w)
var err error
Expand Down Expand Up @@ -329,7 +297,11 @@ func (s InstancesForVar) WriteJSON(w io.Writer) error {
}
{
s := s.Result()
err = s.WriteJSON(b)
buf, err = json.Marshal(s)
if err != nil {
return err
}
_, err = b.Write(buf)
if err != nil {
return err
}
Expand Down Expand Up @@ -413,7 +385,11 @@ func (s InstancesForVar) WriteCapLit(w io.Writer) error {
}
{
s := s.Result()
err = s.WriteCapLit(b)
buf, err = json.Marshal(s)
if err != nil {
return err
}
_, err = b.Write(buf)
if err != nil {
return err
}
Expand Down Expand Up @@ -468,8 +444,8 @@ func (s AcceptedInstance) RmId() uint32 { return C.Struct(s).Get32(0)
func (s AcceptedInstance) SetRmId(v uint32) { C.Struct(s).Set32(0, v) }
func (s AcceptedInstance) RoundNumber() uint64 { return C.Struct(s).Get64(8) }
func (s AcceptedInstance) SetRoundNumber(v uint64) { C.Struct(s).Set64(8, v) }
func (s AcceptedInstance) Ballot() Ballot { return Ballot(C.Struct(s).GetObject(0).ToStruct()) }
func (s AcceptedInstance) SetBallot(v Ballot) { C.Struct(s).SetObject(0, C.Object(v)) }
func (s AcceptedInstance) Ballot() []byte { return C.Struct(s).GetObject(0).ToData() }
func (s AcceptedInstance) SetBallot(v []byte) { C.Struct(s).SetObject(0, s.Segment.NewData(v)) }
func (s AcceptedInstance) WriteJSON(w io.Writer) error {
b := bufio.NewWriter(w)
var err error
Expand Down Expand Up @@ -523,7 +499,11 @@ func (s AcceptedInstance) WriteJSON(w io.Writer) error {
}
{
s := s.Ballot()
err = s.WriteJSON(b)
buf, err = json.Marshal(s)
if err != nil {
return err
}
_, err = b.Write(buf)
if err != nil {
return err
}
Expand Down Expand Up @@ -593,7 +573,11 @@ func (s AcceptedInstance) WriteCapLit(w io.Writer) error {
}
{
s := s.Ballot()
err = s.WriteCapLit(b)
buf, err = json.Marshal(s)
if err != nil {
return err
}
_, err = b.Write(buf)
if err != nil {
return err
}
Expand Down
5 changes: 2 additions & 3 deletions capnp/ballot.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ $Go.import("goshawkdb.io/server/capnp");

@0x960e5f709149380d;

using VC = import "vectorclock.capnp";
using Txn = import "transaction.capnp";

struct Ballot {
varId @0: Data;
clock @1: VC.VectorClock;
clock @1: Data;
vote @2: Vote;
}

Expand All @@ -19,7 +18,7 @@ struct Vote {
commit @0: Void;
abortBadRead :group {
txnId @1: Data;
txnActions @2: List(Txn.Action);
txnActions @2: Data;
}
abortDeadlock @3: Void;
}
Expand Down
86 changes: 33 additions & 53 deletions capnp/ballot.capnp.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ func AutoNewBallot(s *C.Segment) Ballot { return Ballot(s.NewStructAR(0, 3)) }
func ReadRootBallot(s *C.Segment) Ballot { return Ballot(s.Root(0).ToStruct()) }
func (s Ballot) VarId() []byte { return C.Struct(s).GetObject(0).ToData() }
func (s Ballot) SetVarId(v []byte) { C.Struct(s).SetObject(0, s.Segment.NewData(v)) }
func (s Ballot) Clock() VectorClock { return VectorClock(C.Struct(s).GetObject(1).ToStruct()) }
func (s Ballot) SetClock(v VectorClock) { C.Struct(s).SetObject(1, C.Object(v)) }
func (s Ballot) Clock() []byte { return C.Struct(s).GetObject(1).ToData() }
func (s Ballot) SetClock(v []byte) { C.Struct(s).SetObject(1, s.Segment.NewData(v)) }
func (s Ballot) Vote() Vote { return Vote(C.Struct(s).GetObject(2).ToStruct()) }
func (s Ballot) SetVote(v Vote) { C.Struct(s).SetObject(2, C.Object(v)) }
func (s Ballot) WriteJSON(w io.Writer) error {
Expand Down Expand Up @@ -56,7 +56,11 @@ func (s Ballot) WriteJSON(w io.Writer) error {
}
{
s := s.Clock()
err = s.WriteJSON(b)
buf, err = json.Marshal(s)
if err != nil {
return err
}
_, err = b.Write(buf)
if err != nil {
return err
}
Expand Down Expand Up @@ -122,7 +126,11 @@ func (s Ballot) WriteCapLit(w io.Writer) error {
}
{
s := s.Clock()
err = s.WriteCapLit(b)
buf, err = json.Marshal(s)
if err != nil {
return err
}
_, err = b.Write(buf)
if err != nil {
return err
}
Expand Down Expand Up @@ -180,19 +188,19 @@ const (
VOTE_ABORTDEADLOCK Vote_Which = 2
)

func NewVote(s *C.Segment) Vote { return Vote(s.NewStruct(8, 2)) }
func NewRootVote(s *C.Segment) Vote { return Vote(s.NewRootStruct(8, 2)) }
func AutoNewVote(s *C.Segment) Vote { return Vote(s.NewStructAR(8, 2)) }
func ReadRootVote(s *C.Segment) Vote { return Vote(s.Root(0).ToStruct()) }
func (s Vote) Which() Vote_Which { return Vote_Which(C.Struct(s).Get16(0)) }
func (s Vote) SetCommit() { C.Struct(s).Set16(0, 0) }
func (s Vote) AbortBadRead() VoteAbortBadRead { return VoteAbortBadRead(s) }
func (s Vote) SetAbortBadRead() { C.Struct(s).Set16(0, 1) }
func (s VoteAbortBadRead) TxnId() []byte { return C.Struct(s).GetObject(0).ToData() }
func (s VoteAbortBadRead) SetTxnId(v []byte) { C.Struct(s).SetObject(0, s.Segment.NewData(v)) }
func (s VoteAbortBadRead) TxnActions() Action_List { return Action_List(C.Struct(s).GetObject(1)) }
func (s VoteAbortBadRead) SetTxnActions(v Action_List) { C.Struct(s).SetObject(1, C.Object(v)) }
func (s Vote) SetAbortDeadlock() { C.Struct(s).Set16(0, 2) }
func NewVote(s *C.Segment) Vote { return Vote(s.NewStruct(8, 2)) }
func NewRootVote(s *C.Segment) Vote { return Vote(s.NewRootStruct(8, 2)) }
func AutoNewVote(s *C.Segment) Vote { return Vote(s.NewStructAR(8, 2)) }
func ReadRootVote(s *C.Segment) Vote { return Vote(s.Root(0).ToStruct()) }
func (s Vote) Which() Vote_Which { return Vote_Which(C.Struct(s).Get16(0)) }
func (s Vote) SetCommit() { C.Struct(s).Set16(0, 0) }
func (s Vote) AbortBadRead() VoteAbortBadRead { return VoteAbortBadRead(s) }
func (s Vote) SetAbortBadRead() { C.Struct(s).Set16(0, 1) }
func (s VoteAbortBadRead) TxnId() []byte { return C.Struct(s).GetObject(0).ToData() }
func (s VoteAbortBadRead) SetTxnId(v []byte) { C.Struct(s).SetObject(0, s.Segment.NewData(v)) }
func (s VoteAbortBadRead) TxnActions() []byte { return C.Struct(s).GetObject(1).ToData() }
func (s VoteAbortBadRead) SetTxnActions(v []byte) { C.Struct(s).SetObject(1, s.Segment.NewData(v)) }
func (s Vote) SetAbortDeadlock() { C.Struct(s).Set16(0, 2) }
func (s Vote) WriteJSON(w io.Writer) error {
b := bufio.NewWriter(w)
var err error
Expand Down Expand Up @@ -249,25 +257,11 @@ func (s Vote) WriteJSON(w io.Writer) error {
}
{
s := s.TxnActions()
{
err = b.WriteByte('[')
if err != nil {
return err
}
for i, s := range s.ToArray() {
if i != 0 {
_, err = b.WriteString(", ")
}
if err != nil {
return err
}
err = s.WriteJSON(b)
if err != nil {
return err
}
}
err = b.WriteByte(']')
buf, err = json.Marshal(s)
if err != nil {
return err
}
_, err = b.Write(buf)
if err != nil {
return err
}
Expand Down Expand Up @@ -357,25 +351,11 @@ func (s Vote) WriteCapLit(w io.Writer) error {
}
{
s := s.TxnActions()
{
err = b.WriteByte('[')
if err != nil {
return err
}
for i, s := range s.ToArray() {
if i != 0 {
_, err = b.WriteString(", ")
}
if err != nil {
return err
}
err = s.WriteCapLit(b)
if err != nil {
return err
}
}
err = b.WriteByte(']')
buf, err = json.Marshal(s)
if err != nil {
return err
}
_, err = b.Write(buf)
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit 6153af6

Please sign in to comment.