From edd05291604cfff96df897382395120256771003 Mon Sep 17 00:00:00 2001 From: Paul Dix Date: Thu, 3 Oct 2013 18:07:59 -0400 Subject: [PATCH] WIP: so much stuff on the coordinator and protocol --- README.md | 8 ++++++ src/coordinator/client.go | 0 src/coordinator/client_test.go | 0 src/coordinator/coordinator_test.go | 21 ++++++++++++++++ src/coordinator/interface.go | 38 ++++++++++++++++++++++++++++- src/coordinator/server.go | 1 + src/coordinator/server_test.go | 0 src/datastore/interface.go | 11 +++++++++ src/protocol/protocol.proto | 21 ++++++++++++++++ 9 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 src/coordinator/client.go create mode 100644 src/coordinator/client_test.go create mode 100644 src/coordinator/coordinator_test.go create mode 100644 src/coordinator/server.go create mode 100644 src/coordinator/server_test.go create mode 100644 src/datastore/interface.go diff --git a/README.md b/README.md index dcf8928c87..8f4b67cd85 100644 --- a/README.md +++ b/README.md @@ -66,3 +66,11 @@ Modules | Storage Engine | | Storage Engine | | | | | +--------+-----------+ +-------+------------+ + +Concensus Notes +--------------- + +Two state machines: +* 1 for the entire cluster of which machines are taking which portions of the ring +* 1 for each portion of the ring to replicate the operations +sequence number per ring location? that's the concensus, if they don't agree then request a replay from the last known sequence number diff --git a/src/coordinator/client.go b/src/coordinator/client.go new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/coordinator/client_test.go b/src/coordinator/client_test.go new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/coordinator/coordinator_test.go b/src/coordinator/coordinator_test.go new file mode 100644 index 0000000000..445d73812c --- /dev/null +++ b/src/coordinator/coordinator_test.go @@ -0,0 +1,21 @@ +package coordinator + +import ( + . "launchpad.net/gocheck" + "testing" +) + +// Hook up gocheck into the gotest runner. +func Test(t *testing.T) { + TestingT(t) +} + +type CoordinatorSuite struct{} + +var _ = Suite(&CoordinatorSuite{}) + +func (self *CoordinatorSuite) TestCanCreateCoordinatorWithNoSeed(c *C) { +} + +func (self *CoordinatorSuite) TestCanCreateCoordinatorWithSeedThatIsNotRunning(c *C) { +} diff --git a/src/coordinator/interface.go b/src/coordinator/interface.go index c2404bc312..5c37c63c9f 100644 --- a/src/coordinator/interface.go +++ b/src/coordinator/interface.go @@ -1,9 +1,45 @@ package coordinator import ( + "datastore" "protocol" + "query" ) type Coordinator interface { - DistributeQuery(query *protocol.Query, yield func(*protocol.Series) error) error + DistributeQuery(query *query.Query, yield func(*protocol.Series) error) error + WriteSeriesData(series *protocol.Series) error +} + +type ClusterServer interface { + Datastore + RingLocations() []*RingLocation + AddRingLocation(ringLocation *RingLocation) error + RemoveRingLocation(ringLocation *RingLocation) error +} + +type ClusterConfiguration interface { + JoinServer(seedServers []string, server string) error + RemoveServer(server string) + GetClusterServersForRingLocation(ringLocation int64) []*ClusterServer + GetRingLocationsForQuery(query *query.Query) []int64 + + getServers() []*ClusterServer + splitSeriesIntoLocations(series *protocol.Series) []*SeriesAndRing +} + +type ClusterServerImpl struct { + host string + ringLocations []*RingLocation +} + +type RingLocation struct { + location int64 + totalData int64 + averageVolume int64 +} + +type SeriesAndRing struct { + series *protocol.Series + ringLocation int64 } diff --git a/src/coordinator/server.go b/src/coordinator/server.go new file mode 100644 index 0000000000..f2f4440fd7 --- /dev/null +++ b/src/coordinator/server.go @@ -0,0 +1 @@ +package coordinator diff --git a/src/coordinator/server_test.go b/src/coordinator/server_test.go new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/datastore/interface.go b/src/datastore/interface.go new file mode 100644 index 0000000000..5acc00dd8e --- /dev/null +++ b/src/datastore/interface.go @@ -0,0 +1,11 @@ +package datastore + +import ( + "protocol" + "query" +) + +type Datastore interface { + ExecuteQuery(ringLocation int64, query *query.Query, yield func(*protocol.Series) error) error + WriteSeriesData(ringLocation int64, series *protocol.Series) error +} diff --git a/src/protocol/protocol.proto b/src/protocol/protocol.proto index 95805fee26..bb642b950e 100644 --- a/src/protocol/protocol.proto +++ b/src/protocol/protocol.proto @@ -28,4 +28,25 @@ message Series { repeated Point points = 1; required string name = 2; repeated FieldDefinition fields = 3; +} + +message Request { + enum Type { + QUERY = 1; + WRITE = 2; + GET_SERVERS = 3; + } + required int32 id = 1; + required Type type = 2; +} + +message Response { + enum Type { + QUERY = 1; + WRITE_OK = 2; + END_STREAM = 3; + } + required int32 id = 1; + optional Series series = 2; + repeated string servers = 3; } \ No newline at end of file