mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-09 12:27:52 +00:00
Merge branch 'master' into cluster-resize
Refactored LocalID/ClusterID for use with Topology and Coordinator.
This commit is contained in:
commit
6b3f4d1a64
18 changed files with 397 additions and 196 deletions
11
.travis.yml
11
.travis.yml
|
|
@ -6,11 +6,14 @@ env:
|
|||
global: # AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
|
||||
- secure: "VnBFmFfBOrrf7ONLN9WpAFCcV8SEt5G5VPnnHv97TP7PlJG8LWR6k6O+vRJOvf8V4vDMfKCTDonwWLgbssVf3yygo3C8ZoftY2phehEkWGffCgsd9ML/YBNbGq4LYLSE5HKvBqrZjQaOrVby71BAsP8W7RhC6hqzFQ00M/z8dZVfwaQQFwew2eEcSxLEaaDFS8Wgc3/UuwxDRPBq6u3cCN5RxfB+q70HvGVq4TT+0dqS4eCvz688+Z0GIGYx9olNjh0F2Kc8R2Po0lnUNa0GiHrZ21zeQ1DxIK04QABrWWmjL4h+bx3VHNKPFR4GYSKDf+pj1kfaqbfrAg6rMAJdGejgoS+QyjhgCoN4d3qRp8s+1nrxtp0TvezEdjwyxt4quGHbP5TxWUszssbGhWqf4mx6OeJ8MmdTaJjfu0f3NWJXMycqT6J73WKORk4rHeIqF9CIdxdmcpkwYj8rk0TEMTPTsd7WA8w2HIDsCz/jQnRmEgLUiNnTAofYc/uUi/Wg/T2hllkp+oBDTzxk9NTelkqx8TJ0bDmYYL9JWUi1siFHTHiVYTJgyirSfGNpe61u8OLmT0Hak/D399IfL7qgFLlMXk8q92typfO2xEduq6G+8KygeqiOMSsOY+xcDvZf5xtcEihYd21vjtrxRSqFsup/o8DIxEurQnfXBx1B+WA="
|
||||
- secure: "U4fpHWDVOG4viqZsiVgUDW7OW1JW60uPOZy0q9pfbs86iHvmZq0PaScsZ+YdlYaN2GETVr7endDf6DCcZs1PWfg0F6VQfkOXcShX8HVS9O58lUZA5tyvbDVql9DQs4PbnkZo+ktz+Z0YaXqq2RdtMDOUz4bgZwspLPMA14if+N6w0tqCFpB7bEtpptTGsdbIQPG1n07yvSeNmK4mvrEEs77tWmhulN5iilpOqhpIvD39bJvtCYVALuJpzLd/OjLTPV9l/fl+hJkMXSj+X5ilO1DHINAcCM648iEX2phXAIWmi0O0Rbg2cI4kV9T5ysOIw8ux+YCm9bZDGTCt+VGBW5Fg+Z5iaXXexyKYCGiHleOJ7kCj9kXxh2u8NiYVNgb19dGJV5/HgQ6pcGWjeVEqr8yY1546zMjpTX+SYGQF+XZe+uggEjeAsk53ueXa0pyZTrlrqSvR7BBtWPx47s/dTg2L19FQYv3XpGMxEXLw92RplExQKi1h7QgihRxFpjGgURHhrt7d9eiNiNqBt3ZsHjmh2AkXZHnaDjlgSnFFWaMqP3UtDBWIuO+2BMbZUJVfP+gpQGBZ4gtpUSmV2JDCHgZgX5OAnLD4usxh+ATQ4rvUXF/tf8nMqEKHlGKd8hxpYSyMX21BoqfSfY4/IA0ejVE9BITqlrvqewqkP1yxe7o="
|
||||
addons:
|
||||
before_install:
|
||||
- go get github.com/mattn/goveralls
|
||||
install:
|
||||
- make vendor
|
||||
script:
|
||||
- make vendor && $HOME/gopath/bin/goveralls -service=travis-ci -ignore "internal/internal.go,internal/public.pb.go,internal/private.pb.go"
|
||||
- make test
|
||||
# TODO: When we drop support for Go <1.10, we should use `-coverprofile=` on both `go test` and `goveralls` so the test suite doesn't run twice. See https://github.com/pilosa/pilosa/issues/1009
|
||||
after_success:
|
||||
- go get github.com/mattn/goveralls
|
||||
- $HOME/gopath/bin/goveralls -service=travis-ci -ignore "internal/internal.go,internal/public.pb.go,internal/private.pb.go"
|
||||
before_deploy:
|
||||
- pip install awscli --user `whoami`
|
||||
deploy:
|
||||
|
|
|
|||
25
CHANGELOG.md
25
CHANGELOG.md
|
|
@ -5,6 +5,31 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## [0.8.3] - 2017-12-12
|
||||
|
||||
This version contains 1 contribution from 1 contributor. There are 2 files changed, 59 insertions, and 42 deletions.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Protect against accessing pointers to memory which was unmapped ([#1000](https://github.com/pilosa/pilosa/pull/1000))
|
||||
|
||||
## [0.8.2] - 2017-12-05
|
||||
|
||||
This version contains 1 contribution from 1 contributor. There are 15 files changed, 127 insertions, and 98 deletions.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Modify initialization of HTTP client so only one instance is created ([#994](https://github.com/pilosa/pilosa/pull/994))
|
||||
|
||||
## [0.8.1] - 2017-11-15
|
||||
|
||||
This version contains 2 contributions from 2 contributors. There are 4 files changed, 27 insertions, and 14 deletions.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix CountOpenFiles() fatal crash ([#969](https://github.com/pilosa/pilosa/pull/969))
|
||||
- Fix version check when local is greater than pilosa.com ([#968](https://github.com/pilosa/pilosa/pull/968))
|
||||
|
||||
## [0.8.0] - 2017-11-15
|
||||
|
||||
This version contains 31 contributions from 8 contributors. There are 84 files changed, 3,732 insertions, and 1,428 deletions.
|
||||
|
|
|
|||
8
Gopkg.lock
generated
8
Gopkg.lock
generated
|
|
@ -157,6 +157,12 @@
|
|||
revision = "fd36b3595eb2ec8da4b8153b107f7ea08504899d"
|
||||
version = "v0.1.1"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/satori/go.uuid"
|
||||
packages = ["."]
|
||||
revision = "879c5887cd475cd7864858769793b2ceb0d44feb"
|
||||
version = "v1.1.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/sean-/seed"
|
||||
|
|
@ -238,6 +244,6 @@
|
|||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-digest = "2a604b59afbfef0e6d4ad5e2eaf63f5fff19e767234e44974cf7aead0510e0fb"
|
||||
inputs-digest = "210f654a7a072d5751f0814e4d71ef0758dd53b3dc59ed462619396ef8621d81"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
# This file intentionally left blank as all needed dependencies are imported by
|
||||
# the project and thus tracked by `dep`.
|
||||
# See https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md for details.
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/satori/go.uuid"
|
||||
version = "1.1.0"
|
||||
|
|
|
|||
25
client.go
25
client.go
|
|
@ -1096,6 +1096,30 @@ func (c *InternalHTTPClient) clientURI(ctx context.Context) *URI {
|
|||
return clientURI
|
||||
}
|
||||
|
||||
func (c *InternalHTTPClient) NodeID(uri *URI) (string, error) {
|
||||
u := uriPathToURL(uri, "/id")
|
||||
req, err := http.NewRequest("GET", u.String(), nil)
|
||||
resp, err := c.HTTPClient.Do(req)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("executing http request: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
// Read body.
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("reading response body: %v", err)
|
||||
}
|
||||
|
||||
// Return error if status is not OK.
|
||||
switch resp.StatusCode {
|
||||
case http.StatusOK: // ok
|
||||
default:
|
||||
return "", fmt.Errorf("unexpected response status code: %d: %s", resp.StatusCode, body)
|
||||
}
|
||||
return string(body), nil
|
||||
}
|
||||
|
||||
// Bit represents the location of a single bit.
|
||||
type Bit struct {
|
||||
RowID uint64
|
||||
|
|
@ -1271,4 +1295,5 @@ type InternalClient interface {
|
|||
ColumnAttrDiff(ctx context.Context, index string, blks []AttrBlock) (map[uint64]map[string]interface{}, error)
|
||||
RowAttrDiff(ctx context.Context, index, frame string, blks []AttrBlock) (map[uint64]map[string]interface{}, error)
|
||||
SendMessage(ctx context.Context, pb proto.Message) error
|
||||
NodeID(uri *URI) (string, error)
|
||||
}
|
||||
|
|
|
|||
44
cluster.go
44
cluster.go
|
|
@ -35,6 +35,7 @@ import (
|
|||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/pilosa/pilosa/internal"
|
||||
uuid "github.com/satori/go.uuid"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -145,6 +146,7 @@ type nodeAction struct {
|
|||
|
||||
// Cluster represents a collection of nodes.
|
||||
type Cluster struct {
|
||||
ID string
|
||||
URI URI
|
||||
Nodes []*Node // TODO phase this out?
|
||||
MemberSet MemberSet
|
||||
|
|
@ -289,6 +291,17 @@ func (c *Cluster) NodeSet() []URI {
|
|||
return Nodes(c.Nodes).URIs()
|
||||
}
|
||||
|
||||
func (c *Cluster) setID(id string) {
|
||||
// Don't overwrite ClusterID.
|
||||
if c.ID != "" {
|
||||
return
|
||||
}
|
||||
c.ID = id
|
||||
|
||||
// Make sure the Topology is updated.
|
||||
c.Topology.ClusterID = c.ID
|
||||
}
|
||||
|
||||
func (c *Cluster) setState(state string) {
|
||||
// Ignore cases where the state hasn't changed.
|
||||
if state == c.State {
|
||||
|
|
@ -351,7 +364,7 @@ func (c *Cluster) SetNodeState(state string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// ReceiveNodeState set node state in Topology in order for the
|
||||
// ReceiveNodeState sets node state in Topology in order for the
|
||||
// Coordinator to keep track of, during startup, which nodes have
|
||||
// finished opening their Holder.
|
||||
func (c *Cluster) ReceiveNodeState(uri URI, state string) error {
|
||||
|
|
@ -383,8 +396,9 @@ func (c *Cluster) ReceiveNodeState(uri URI, state string) error {
|
|||
// Status returns the internal ClusterStatus representation.
|
||||
func (c *Cluster) Status() *internal.ClusterStatus {
|
||||
return &internal.ClusterStatus{
|
||||
State: c.State,
|
||||
NodeSet: encodeURIs(c.NodeSet()),
|
||||
ClusterID: c.ID,
|
||||
State: c.State,
|
||||
NodeSet: encodeURIs(c.NodeSet()),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -756,6 +770,8 @@ func (c *Cluster) Open() error {
|
|||
return fmt.Errorf("load topology: %v", err)
|
||||
}
|
||||
|
||||
c.ID = c.Topology.ClusterID
|
||||
|
||||
// Only the coordinator needs to consider the .topology file.
|
||||
if c.IsCoordinator() {
|
||||
err := c.considerTopology()
|
||||
|
|
@ -765,10 +781,7 @@ func (c *Cluster) Open() error {
|
|||
}
|
||||
|
||||
// Add the local node to the cluster.
|
||||
//NEXT
|
||||
//if c.URI.Port() != 0 {
|
||||
c.AddNode(c.URI)
|
||||
//}
|
||||
|
||||
// Start the EventReceiver.
|
||||
if err := c.EventReceiver.Start(c); err != nil {
|
||||
|
|
@ -1346,6 +1359,8 @@ type Topology struct {
|
|||
mu sync.RWMutex
|
||||
NodeSet []URI
|
||||
|
||||
ClusterID string
|
||||
|
||||
// nodeStates holds the state of each node according to
|
||||
// the coordinator. Used during startup and data load.
|
||||
nodeStates map[URI]string
|
||||
|
|
@ -1459,7 +1474,8 @@ func encodeTopology(topology *Topology) *internal.Topology {
|
|||
return nil
|
||||
}
|
||||
return &internal.Topology{
|
||||
NodeSet: encodeURIs(topology.NodeSet),
|
||||
ClusterID: topology.ClusterID,
|
||||
NodeSet: encodeURIs(topology.NodeSet),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1469,6 +1485,7 @@ func decodeTopology(topology *internal.Topology) (*Topology, error) {
|
|||
}
|
||||
|
||||
t := NewTopology()
|
||||
t.ClusterID = topology.ClusterID
|
||||
t.NodeSet = decodeURIs(topology.NodeSet)
|
||||
sort.Slice(t.NodeSet,
|
||||
func(i, j int) bool {
|
||||
|
|
@ -1479,6 +1496,16 @@ func decodeTopology(topology *internal.Topology) (*Topology, error) {
|
|||
}
|
||||
|
||||
func (c *Cluster) considerTopology() error {
|
||||
|
||||
c.ID = c.Topology.ClusterID
|
||||
|
||||
// Create ClusterID if one does not already exist.
|
||||
if c.ID == "" {
|
||||
u := uuid.NewV4()
|
||||
c.ID = u.String()
|
||||
c.Topology.ClusterID = c.ID
|
||||
}
|
||||
|
||||
if c.Static {
|
||||
return nil
|
||||
}
|
||||
|
|
@ -1631,6 +1658,9 @@ func (c *Cluster) MergeClusterStatus(cs *internal.ClusterStatus) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Set ClusterID.
|
||||
c.setID(cs.ClusterID)
|
||||
|
||||
officialURIs := decodeURIs(cs.NodeSet)
|
||||
|
||||
// Add all nodes from the coordinator.
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ omitted. If it is present then its format should be YYYY-MM-DDTHH:MM.
|
|||
flags.IntVarP(&Importer.BufferSize, "buffer-size", "s", 10000000, "Number of bits to buffer/sort before importing.")
|
||||
flags.BoolVarP(&Importer.Sort, "sort", "", false, "Enables sorting before import.")
|
||||
flags.BoolVarP(&Importer.CreateSchema, "create", "e", false, "Create the schema if it does not exist before import.")
|
||||
flags.Var(&Importer.IndexOptions.TimeQuantum, "index-time-quantum", "Time quantum for the index")
|
||||
flags.Var(&Importer.IndexOptions.TimeQuantum, "index-time-quantum", "Time quantum for the index (DEPRECATED. This feature will be removed in a future version. Set time quantum of each frame instead.)")
|
||||
flags.Var(&Importer.FrameOptions.TimeQuantum, "frame-time-quantum", "Time quantum for the frame")
|
||||
flags.BoolVar(&Importer.FrameOptions.InverseEnabled, "frame-inverse-enabled", false, "Enable inverse frame")
|
||||
flags.BoolVar(&Importer.FrameOptions.RangeEnabled, "frame-range-enabled", false, "Enabled range encoded frame")
|
||||
|
|
|
|||
|
|
@ -45,15 +45,9 @@ Response:
|
|||
|
||||
Creates an index with the given name.
|
||||
|
||||
The request payload is in JSON, and may contain the `options` field. The `options` field is a JSON object which may contain the following fields:
|
||||
|
||||
* `timeQuantum` (string): time quantum of the index.
|
||||
|
||||
Request:
|
||||
```
|
||||
curl localhost:10101/index/user \
|
||||
-X POST \
|
||||
-d '{"options": {"timeQuantum": "YMDH"}}'
|
||||
curl -XPOST localhost:10101/index/user
|
||||
```
|
||||
|
||||
Response:
|
||||
|
|
@ -117,38 +111,6 @@ Response:
|
|||
|
||||
By default, all bits and attributes (*for `Bitmap` queries only*) are returned. In order to suppress returning bits, set `excludeBits` query argument to `true`; to suppress returning attributes, set `excludeAttrs` query argument to `true`.
|
||||
|
||||
### Change index time quantum
|
||||
|
||||
`PATCH /index/<index-name>/time-quantum`
|
||||
|
||||
Changes the time quantum for the given index. This endpoint should be called at most once right after creating a database.
|
||||
|
||||
The payload is in JSON with the format: `{"timeQuantum": "${TIME_QUANTUM}"}`. Valid time quantum values are:
|
||||
|
||||
* (Empty string)
|
||||
* Y: year
|
||||
* M: month
|
||||
* D: day
|
||||
* H: hour
|
||||
* YM: year and month
|
||||
* MD: month and day
|
||||
* DH: day and hour
|
||||
* YMD: year, month and day
|
||||
* MDH: month, day and hour
|
||||
* YMDH: year, month, day and hour
|
||||
|
||||
Request:
|
||||
```
|
||||
curl localhost:10101/index/user/time-quantum \
|
||||
-X POST \
|
||||
-d '{"timeQuantum": "YM"}'
|
||||
```
|
||||
|
||||
Response:
|
||||
```
|
||||
{}
|
||||
```
|
||||
|
||||
### Create frame
|
||||
|
||||
`POST /index/<index-name>/frame/<frame-name>`
|
||||
|
|
|
|||
|
|
@ -59,21 +59,12 @@ curl localhost:10101/index/repository -X POST
|
|||
|
||||
Let's create the `stargazer` frame which has user IDs of stargazers as its rows:
|
||||
```
|
||||
curl localhost:10101/index/repository/frame/stargazer \
|
||||
-X POST \
|
||||
-d '{"options": {"timeQuantum": "YMD",
|
||||
"inverseEnabled": true}}'
|
||||
curl localhost:10101/index/repository/frame/stargazer -X POST
|
||||
```
|
||||
|
||||
Since our data contains time stamps for the time users starred repos, we set the *time quantum* for the `stargazer` frame in the options as well. Time quantum is the resolution of the time we want to use, and we set it to `YMD` (year, month, day) for `stargazer`.
|
||||
|
||||
We set `inverseEnabled` to `true` in order to allow queries over columns as well as rows.
|
||||
|
||||
Next up is the `language` frame, which will contain IDs for programming languages:
|
||||
```
|
||||
curl localhost:10101/index/repository/frame/language \
|
||||
-X POST \
|
||||
-d '{"options": {"inverseEnabled": true}}'
|
||||
curl localhost:10101/index/repository/frame/language -X POST
|
||||
```
|
||||
|
||||
#### Import Data From CSV Files
|
||||
|
|
|
|||
|
|
@ -74,19 +74,19 @@ There are four ways to install Pilosa on MacOS: Use [Homebrew](https://brew.sh/)
|
|||
|
||||
1. Download the latest release:
|
||||
```
|
||||
curl -L -O https://github.com/pilosa/pilosa/releases/download/v0.8.0/pilosa-v0.8.0-darwin-amd64.tar.gz
|
||||
curl -L -O https://github.com/pilosa/pilosa/releases/download/v0.8.3/pilosa-v0.8.3-darwin-amd64.tar.gz
|
||||
```
|
||||
|
||||
Other releases can be downloaded from our Releases page on Github.
|
||||
|
||||
2. Extract the binary:
|
||||
```
|
||||
tar xfz pilosa-v0.8.0-darwin-amd64.tar.gz
|
||||
tar xfz pilosa-v0.8.3-darwin-amd64.tar.gz
|
||||
```
|
||||
|
||||
3. Move the binary into your PATH so you can run `pilosa` from any shell:
|
||||
```
|
||||
cp -i pilosa-v0.8.0-darwin-amd64/pilosa /usr/local/bin
|
||||
cp -i pilosa-v0.8.3-darwin-amd64/pilosa /usr/local/bin
|
||||
```
|
||||
|
||||
4. Make sure Pilosa is installed successfully:
|
||||
|
|
@ -228,19 +228,19 @@ There are three ways to install Pilosa on Linux: download the binary (recommende
|
|||
|
||||
1. To install the latest version of Pilosa, download the latest release:
|
||||
```
|
||||
curl -L -O https://github.com/pilosa/pilosa/releases/download/v0.8.0/pilosa-v0.8.0-linux-amd64.tar.gz
|
||||
curl -L -O https://github.com/pilosa/pilosa/releases/download/v0.8.3/pilosa-v0.8.3-linux-amd64.tar.gz
|
||||
```
|
||||
|
||||
Note: This assumes you are using an `amd64` compatible architecture. Other releases can be downloaded from our Releases page on Github.
|
||||
|
||||
2. Extract the binary:
|
||||
```
|
||||
tar xfz pilosa-v0.8.0-linux-amd64.tar.gz
|
||||
tar xfz pilosa-v0.8.3-linux-amd64.tar.gz
|
||||
```
|
||||
|
||||
3. Move the binary into your PATH so you can run `pilosa` from any shell:
|
||||
```
|
||||
cp -i pilosa-v0.8.0-linux-amd64/pilosa /usr/local/bin
|
||||
cp -i pilosa-v0.8.3-linux-amd64/pilosa /usr/local/bin
|
||||
```
|
||||
|
||||
4. Make sure Pilosa is installed successfully:
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ In addition to standard PQL, the console supports a few special commands, prefix
|
|||
- `:create frame <framename>`
|
||||
- `:delete frame <framename>`
|
||||
|
||||
Index and frame creation also supports options like `timeQuantum` or `inverseEnabled`. When creating new index or new frame, add options by using the keys documented in [API reference](../api-reference).
|
||||
Frame creation also supports options like `timeQuantum` or `inverseEnabled`. When creating a new frame, add options by using the keys documented in [API reference](../api-reference).
|
||||
|
||||
- `:create index <indexname> timeQuantum=YM`
|
||||
- `:create frame <framename> inverseEnabled=true cacheSize=10000`
|
||||
|
|
|
|||
16
handler.go
16
handler.go
|
|
@ -126,14 +126,15 @@ func (h *Handler) SetRestricted() {
|
|||
func loadCommon(router *mux.Router, handler *Handler) {
|
||||
router.HandleFunc("/cluster/message", handler.handlePostClusterMessage).Methods("POST")
|
||||
router.HandleFunc("/cluster/resize/set-coordinator", handler.handlePostClusterResizeSetCoordinator).Methods("POST")
|
||||
router.HandleFunc("/schema", handler.handleGetSchema).Methods("GET")
|
||||
router.HandleFunc("/status", handler.handleGetStatus).Methods("GET")
|
||||
router.HandleFunc("/version", handler.handleGetVersion).Methods("GET")
|
||||
router.PathPrefix("/debug/pprof/").Handler(http.DefaultServeMux).Methods("GET")
|
||||
router.HandleFunc("/debug/vars", handler.handleExpvar).Methods("GET")
|
||||
router.HandleFunc("/slices/max", handler.handleGetSlicesMax).Methods("GET") // TODO: deprecate, but it's being used by the client (for backups)
|
||||
router.HandleFunc("/fragment/data", handler.handleGetFragmentData).Methods("GET")
|
||||
router.HandleFunc("/hosts", handler.handleGetHosts).Methods("GET")
|
||||
router.HandleFunc("/id", handler.handleGetID).Methods("GET")
|
||||
router.HandleFunc("/schema", handler.handleGetSchema).Methods("GET")
|
||||
router.HandleFunc("/slices/max", handler.handleGetSlicesMax).Methods("GET") // TODO: deprecate, but it's being used by the client (for backups)
|
||||
router.HandleFunc("/status", handler.handleGetStatus).Methods("GET")
|
||||
router.HandleFunc("/version", handler.handleGetVersion).Methods("GET")
|
||||
}
|
||||
|
||||
func loadRestricted(router *mux.Router, handler *Handler) {
|
||||
|
|
@ -2197,4 +2198,11 @@ func (h *Handler) handlePostClusterMessage(w http.ResponseWriter, r *http.Reques
|
|||
}
|
||||
}
|
||||
|
||||
func (h *Handler) handleGetID(w http.ResponseWriter, r *http.Request) {
|
||||
_, err := w.Write([]byte(h.Holder.NodeID))
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
type defaultClusterMessageResponse struct{}
|
||||
|
|
|
|||
27
holder.go
27
holder.go
|
|
@ -19,16 +19,20 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/pilosa/pilosa/internal"
|
||||
uuid "github.com/satori/go.uuid"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -65,6 +69,8 @@ type Holder struct {
|
|||
CacheFlushInterval time.Duration
|
||||
|
||||
LogOutput io.Writer
|
||||
|
||||
NodeID string
|
||||
}
|
||||
|
||||
// NewHolder returns a new instance of Holder.
|
||||
|
|
@ -523,6 +529,27 @@ func (h *Holder) setFileLimit() {
|
|||
|
||||
func (h *Holder) logger() *log.Logger { return log.New(h.LogOutput, "", log.LstdFlags) }
|
||||
|
||||
func (h *Holder) loadNodeID() error {
|
||||
idPath := path.Join(h.Path, "ID")
|
||||
nodeID := ""
|
||||
nodeIDBytes, err := ioutil.ReadFile(idPath)
|
||||
if err == nil {
|
||||
h.NodeID = strings.TrimSpace(string(nodeIDBytes))
|
||||
} else if os.IsNotExist(err) {
|
||||
u := uuid.NewV4()
|
||||
nodeID = u.String()
|
||||
err = ioutil.WriteFile(idPath, []byte(nodeID), 0600)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
h.NodeID = nodeID
|
||||
} else if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// HolderSyncer is an active anti-entropy tool that compares the local holder
|
||||
// with a remote holder based on block checksums and resolves differences.
|
||||
type HolderSyncer struct {
|
||||
|
|
|
|||
|
|
@ -728,8 +728,9 @@ func (m *NodeStatus) GetSchema() *Schema {
|
|||
}
|
||||
|
||||
type ClusterStatus struct {
|
||||
State string `protobuf:"bytes,1,opt,name=State,proto3" json:"State,omitempty"`
|
||||
NodeSet []*URI `protobuf:"bytes,2,rep,name=NodeSet" json:"NodeSet,omitempty"`
|
||||
State string `protobuf:"bytes,1,opt,name=State,proto3" json:"State,omitempty"`
|
||||
NodeSet []*URI `protobuf:"bytes,2,rep,name=NodeSet" json:"NodeSet,omitempty"`
|
||||
ClusterID string `protobuf:"bytes,3,opt,name=ClusterID,proto3" json:"ClusterID,omitempty"`
|
||||
}
|
||||
|
||||
func (m *ClusterStatus) Reset() { *m = ClusterStatus{} }
|
||||
|
|
@ -751,6 +752,13 @@ func (m *ClusterStatus) GetNodeSet() []*URI {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (m *ClusterStatus) GetClusterID() string {
|
||||
if m != nil {
|
||||
return m.ClusterID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type Field struct {
|
||||
Name string `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name,omitempty"`
|
||||
Type string `protobuf:"bytes,2,opt,name=Type,proto3" json:"Type,omitempty"`
|
||||
|
|
@ -986,7 +994,8 @@ func (m *SetCoordinatorMessage) GetNew() *URI {
|
|||
}
|
||||
|
||||
type Topology struct {
|
||||
NodeSet []*URI `protobuf:"bytes,1,rep,name=NodeSet" json:"NodeSet,omitempty"`
|
||||
NodeSet []*URI `protobuf:"bytes,1,rep,name=NodeSet" json:"NodeSet,omitempty"`
|
||||
ClusterID string `protobuf:"bytes,2,opt,name=ClusterID,proto3" json:"ClusterID,omitempty"`
|
||||
}
|
||||
|
||||
func (m *Topology) Reset() { *m = Topology{} }
|
||||
|
|
@ -1001,6 +1010,13 @@ func (m *Topology) GetNodeSet() []*URI {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (m *Topology) GetClusterID() string {
|
||||
if m != nil {
|
||||
return m.ClusterID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*IndexMeta)(nil), "internal.IndexMeta")
|
||||
proto.RegisterType((*FrameMeta)(nil), "internal.FrameMeta")
|
||||
|
|
@ -1997,6 +2013,12 @@ func (m *ClusterStatus) MarshalTo(dAtA []byte) (int, error) {
|
|||
i += n
|
||||
}
|
||||
}
|
||||
if len(m.ClusterID) > 0 {
|
||||
dAtA[i] = 0x1a
|
||||
i++
|
||||
i = encodeVarintPrivate(dAtA, i, uint64(len(m.ClusterID)))
|
||||
i += copy(dAtA[i:], m.ClusterID)
|
||||
}
|
||||
return i, nil
|
||||
}
|
||||
|
||||
|
|
@ -2306,6 +2328,12 @@ func (m *Topology) MarshalTo(dAtA []byte) (int, error) {
|
|||
i += n
|
||||
}
|
||||
}
|
||||
if len(m.ClusterID) > 0 {
|
||||
dAtA[i] = 0x12
|
||||
i++
|
||||
i = encodeVarintPrivate(dAtA, i, uint64(len(m.ClusterID)))
|
||||
i += copy(dAtA[i:], m.ClusterID)
|
||||
}
|
||||
return i, nil
|
||||
}
|
||||
|
||||
|
|
@ -2736,6 +2764,10 @@ func (m *ClusterStatus) Size() (n int) {
|
|||
n += 1 + l + sovPrivate(uint64(l))
|
||||
}
|
||||
}
|
||||
l = len(m.ClusterID)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovPrivate(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
|
|
@ -2873,6 +2905,10 @@ func (m *Topology) Size() (n int) {
|
|||
n += 1 + l + sovPrivate(uint64(l))
|
||||
}
|
||||
}
|
||||
l = len(m.ClusterID)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovPrivate(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
|
|
@ -6151,6 +6187,35 @@ func (m *ClusterStatus) Unmarshal(dAtA []byte) error {
|
|||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 3:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field ClusterID", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowPrivate
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= (uint64(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthPrivate
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.ClusterID = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipPrivate(dAtA[iNdEx:])
|
||||
|
|
@ -7183,6 +7248,35 @@ func (m *Topology) Unmarshal(dAtA []byte) error {
|
|||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field ClusterID", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowPrivate
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= (uint64(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthPrivate
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.ClusterID = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipPrivate(dAtA[iNdEx:])
|
||||
|
|
@ -7312,81 +7406,82 @@ var (
|
|||
func init() { proto.RegisterFile("private.proto", fileDescriptorPrivate) }
|
||||
|
||||
var fileDescriptorPrivate = []byte{
|
||||
// 1208 bytes of a gzipped FileDescriptorProto
|
||||
// 1222 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x57, 0xcf, 0x6f, 0x1b, 0xc5,
|
||||
0x17, 0xff, 0xae, 0xd7, 0x76, 0xec, 0xe7, 0xba, 0x75, 0xe7, 0xdb, 0x16, 0x27, 0x8a, 0x5c, 0x33,
|
||||
0x07, 0x12, 0x2a, 0x11, 0xc0, 0x91, 0x10, 0x04, 0x55, 0x82, 0xc6, 0xae, 0xba, 0x40, 0x92, 0x32,
|
||||
0x4e, 0x8b, 0xe0, 0x80, 0x34, 0xb1, 0x87, 0x64, 0x95, 0xf5, 0xae, 0xd9, 0x1d, 0x27, 0x71, 0x0f,
|
||||
0xdc, 0xe0, 0x00, 0x77, 0xc4, 0x9d, 0x7f, 0x86, 0x23, 0x7f, 0x02, 0x0a, 0x7f, 0x04, 0x12, 0x17,
|
||||
0xd0, 0xbc, 0x9d, 0xd9, 0x5d, 0xff, 0x0c, 0xc9, 0x6d, 0xdf, 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, 0x7a, 0xa6, 0x97, 0x29, 0x85, 0xdb, 0xce, 0x60,
|
||||
0x18, 0x84, 0x92, 0x89, 0x68, 0x18, 0xf8, 0x91, 0x20, 0x35, 0xb0, 0x3b, 0x61, 0xa8, 0xcf, 0xae,
|
||||
0x3e, 0xe9, 0x77, 0x50, 0x7b, 0xe2, 0x05, 0xbd, 0xd3, 0x36, 0x97, 0x9c, 0x89, 0x6f, 0x47, 0x22,
|
||||
0x92, 0xe4, 0x1e, 0x14, 0x30, 0x0b, 0x1a, 0x17, 0x0b, 0x4a, 0x8b, 0x91, 0xd4, 0x61, 0x8e, 0x05,
|
||||
0xa5, 0x45, 0x7b, 0x0c, 0x45, 0x9e, 0xc5, 0x82, 0xd2, 0x76, 0x3d, 0xb7, 0x17, 0x87, 0x20, 0xcf,
|
||||
0x62, 0x81, 0x10, 0xc8, 0xbf, 0x74, 0xc5, 0xb9, 0x3e, 0x37, 0x7e, 0x53, 0x07, 0xee, 0x66, 0xf6,
|
||||
0xd7, 0x34, 0x1f, 0x40, 0x91, 0x05, 0xe7, 0x4e, 0x3b, 0xaa, 0x5b, 0x4d, 0x7b, 0x33, 0xcf, 0xb4,
|
||||
0x84, 0xd1, 0xc5, 0xf4, 0xab, 0xa5, 0x1c, 0x2e, 0xa5, 0x0a, 0xba, 0x0a, 0x05, 0x0c, 0xb5, 0x3a,
|
||||
0x65, 0x6a, 0xab, 0x3e, 0xe9, 0x3f, 0x16, 0x94, 0xf7, 0xf8, 0x05, 0xd2, 0x88, 0xc8, 0x63, 0x28,
|
||||
0x75, 0x25, 0xf7, 0xfb, 0x3c, 0xec, 0x23, 0xa8, 0xd2, 0x7a, 0x3d, 0x0d, 0x61, 0x02, 0xdb, 0x32,
|
||||
0x98, 0x8e, 0x2f, 0xc3, 0x31, 0x4b, 0x4c, 0xc8, 0x0e, 0xac, 0xe8, 0x9a, 0x40, 0x0e, 0x95, 0x56,
|
||||
0x73, 0x9e, 0x75, 0x52, 0x36, 0xca, 0xd8,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a6, 0x5a, 0x00, 0xeb, 0x66, 0x92, 0x4c, 0x30, 0x59, 0xde, 0x93, 0x1f, 0x00,
|
||||
0xa4, 0x50, 0xdd, 0xee, 0x4b, 0xea, 0x33, 0x03, 0xa6, 0xcf, 0x60, 0xdd, 0x8c, 0xb9, 0x6b, 0x6c,
|
||||
0x68, 0xaa, 0x25, 0x97, 0x56, 0x0b, 0xed, 0x80, 0xfd, 0x82, 0x39, 0xea, 0xaa, 0xc3, 0x6e, 0x35,
|
||||
0x29, 0xd2, 0x92, 0x32, 0x79, 0x16, 0x44, 0xd2, 0x98, 0xa8, 0x6f, 0xa5, 0x7b, 0x1e, 0x84, 0x12,
|
||||
0x19, 0x57, 0x19, 0x7e, 0x53, 0x07, 0x6a, 0xfb, 0x41, 0x5f, 0x74, 0x25, 0x97, 0xc9, 0x24, 0x7a,
|
||||
0x88, 0xae, 0xd1, 0x61, 0xa5, 0x55, 0x4d, 0x0f, 0xf6, 0x82, 0x39, 0x0c, 0x37, 0x55, 0x03, 0x5e,
|
||||
0x19, 0x98, 0xa1, 0x84, 0x02, 0xfd, 0xd1, 0x02, 0x30, 0xbe, 0x46, 0xd1, 0xd5, 0x5e, 0xde, 0xcd,
|
||||
0xdc, 0xa9, 0xb3, 0xc3, 0x2a, 0x59, 0x62, 0x99, 0x9b, 0x77, 0xd3, 0xcc, 0x26, 0x1d, 0xf5, 0x5a,
|
||||
0x8a, 0x8f, 0xf5, 0xfa, 0xfc, 0x9c, 0xee, 0x43, 0x75, 0xd7, 0x1b, 0x45, 0x52, 0x84, 0x9a, 0x4e,
|
||||
0xc2, 0xd9, 0xca, 0x70, 0x26, 0x1b, 0xb0, 0x82, 0x94, 0x85, 0xd4, 0x23, 0x60, 0x8a, 0xa8, 0x59,
|
||||
0xa5, 0x5d, 0x28, 0x2c, 0xee, 0x5c, 0x02, 0x79, 0x7c, 0xce, 0xe9, 0x60, 0xe3, 0x4b, 0xae, 0x06,
|
||||
0xf6, 0x9e, 0x1b, 0x57, 0x87, 0xcd, 0xd4, 0x27, 0x6a, 0xf8, 0x05, 0x56, 0xaf, 0xd2, 0x70, 0x75,
|
||||
0x91, 0xdd, 0x8d, 0xab, 0x41, 0x4d, 0xde, 0x9b, 0x5c, 0x39, 0xe6, 0x45, 0x64, 0x67, 0x5e, 0x44,
|
||||
0x3f, 0xe7, 0xe0, 0x2e, 0x13, 0x91, 0xfb, 0x4a, 0x38, 0x7e, 0x24, 0xc3, 0x51, 0xd2, 0xc9, 0x9f,
|
||||
0x04, 0x47, 0x4e, 0x1b, 0xbd, 0xda, 0x2c, 0x16, 0x4c, 0x8e, 0x72, 0x0b, 0x73, 0xf4, 0xb6, 0x7a,
|
||||
0x43, 0x07, 0x61, 0x5f, 0xb5, 0x73, 0x10, 0xea, 0xa8, 0x4f, 0x01, 0xb3, 0x08, 0xf2, 0x0e, 0xac,
|
||||
0x74, 0x83, 0x51, 0xd8, 0x4b, 0x66, 0xfd, 0x83, 0x14, 0x1c, 0xb3, 0x8a, 0x97, 0x99, 0x81, 0x65,
|
||||
0x72, 0x5a, 0x58, 0x9e, 0x53, 0xf2, 0x78, 0x2a, 0xa7, 0xf8, 0xba, 0xad, 0xb4, 0x5e, 0x4b, 0x0d,
|
||||
0x26, 0x96, 0xd9, 0x24, 0x9a, 0x7e, 0x6f, 0xc1, 0xad, 0x2c, 0x85, 0xff, 0x54, 0xe7, 0x71, 0x2a,
|
||||
0x72, 0x73, 0x53, 0x61, 0xcf, 0x4b, 0x45, 0x3e, 0x4d, 0x45, 0xfa, 0x10, 0x2a, 0x64, 0x1e, 0x42,
|
||||
0xf4, 0x04, 0x56, 0x67, 0xf2, 0xb3, 0x1b, 0x0c, 0x86, 0xaa, 0x10, 0x6e, 0x9a, 0xa7, 0x7b, 0x50,
|
||||
0xe8, 0x84, 0xa1, 0xce, 0x50, 0x99, 0xc5, 0x02, 0xfd, 0x12, 0xee, 0x77, 0x85, 0xcc, 0xa4, 0x27,
|
||||
0xd3, 0xe1, 0x07, 0x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, 0x3b, 0x69, 0x73, 0xc9, 0x99, 0xf8, 0x6e, 0x24,
|
||||
0x22, 0x49, 0x96, 0xa1, 0x80, 0x59, 0xd0, 0xb8, 0x58, 0x50, 0x5a, 0x8c, 0xa4, 0x0e, 0x73, 0x2c,
|
||||
0x28, 0x2d, 0xda, 0x63, 0x28, 0xf2, 0x2c, 0x16, 0x94, 0xb6, 0xeb, 0xb9, 0xbd, 0x38, 0x04, 0x79,
|
||||
0x16, 0x0b, 0x84, 0x40, 0xfe, 0xa5, 0x2b, 0xce, 0xf4, 0xb9, 0xf1, 0x9b, 0x3a, 0x70, 0x37, 0xb3,
|
||||
0xbf, 0xa6, 0xb9, 0x02, 0x45, 0x16, 0x9c, 0x39, 0xed, 0xa8, 0x6e, 0x35, 0xed, 0xcd, 0x3c, 0xd3,
|
||||
0x12, 0x46, 0x17, 0xd3, 0xaf, 0x96, 0x72, 0xb8, 0x94, 0x2a, 0xe8, 0x2a, 0x14, 0x30, 0xd4, 0xea,
|
||||
0x94, 0xa9, 0xad, 0xfa, 0xa4, 0xff, 0x5a, 0x50, 0xde, 0xe5, 0xe7, 0x48, 0x23, 0x22, 0x8f, 0xa0,
|
||||
0xd4, 0x95, 0xdc, 0xef, 0xf3, 0xb0, 0x8f, 0xa0, 0x4a, 0xeb, 0xcd, 0x34, 0x84, 0x09, 0x6c, 0xcb,
|
||||
0x60, 0x3a, 0xbe, 0x0c, 0xc7, 0x2c, 0x31, 0x21, 0xdb, 0xb0, 0xa4, 0x6b, 0x02, 0x39, 0x54, 0x5a,
|
||||
0xcd, 0x79, 0xd6, 0x49, 0xd9, 0x28, 0x63, 0x63, 0xb0, 0xf6, 0x31, 0x54, 0x27, 0xdc, 0x2a, 0xae,
|
||||
0x27, 0x62, 0x6c, 0x32, 0x72, 0x22, 0xc6, 0x2a, 0x76, 0xa7, 0xdc, 0x1b, 0xc5, 0x71, 0xce, 0xb3,
|
||||
0x58, 0xd8, 0xce, 0x7d, 0x68, 0xad, 0x6d, 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 0x7c, 0xeb, 0xfa, 0xae, 0x74, 0x03, 0x3f, 0xaa, 0x17, 0xd1, 0x64,
|
||||
0x35, 0xbb, 0xf5, 0x04, 0x82, 0xcd, 0x98, 0xd0, 0x1f, 0x2d, 0xb8, 0x33, 0xa5, 0xbc, 0x82, 0x57,
|
||||
0xee, 0x72, 0x5e, 0x1f, 0x24, 0x23, 0xd3, 0x46, 0x60, 0x63, 0x21, 0x9b, 0xc9, 0x09, 0xfa, 0x9b,
|
||||
0x05, 0xcb, 0xf3, 0x00, 0x73, 0xd9, 0x34, 0x00, 0x9e, 0x85, 0xee, 0x80, 0x87, 0xe3, 0xcf, 0xc5,
|
||||
0x58, 0xdf, 0x1e, 0x19, 0x0d, 0xf9, 0x12, 0x56, 0xa6, 0x7c, 0x7d, 0xda, 0x8b, 0x43, 0x14, 0x93,
|
||||
0xba, 0xbf, 0x90, 0x54, 0x8c, 0x63, 0x0b, 0xcc, 0xe9, 0xdf, 0x16, 0xdc, 0x9b, 0xbb, 0x94, 0x56,
|
||||
0x9f, 0x95, 0x2d, 0xf4, 0x07, 0x50, 0x7b, 0xa9, 0x06, 0x43, 0x5b, 0x44, 0xd2, 0xf5, 0xb9, 0x42,
|
||||
0xea, 0xf2, 0x9c, 0xd1, 0x13, 0x07, 0x4a, 0xa8, 0xdb, 0xe5, 0x43, 0x4d, 0xf3, 0x9d, 0x2b, 0x68,
|
||||
0x6e, 0x19, 0xbc, 0x9e, 0x9b, 0x46, 0x54, 0x64, 0x70, 0x8e, 0x9b, 0x4b, 0x01, 0x05, 0x35, 0x11,
|
||||
0x27, 0x0c, 0xae, 0x35, 0xd5, 0x02, 0x58, 0x37, 0x93, 0x64, 0x82, 0xc9, 0xe5, 0x3d, 0xf9, 0x11,
|
||||
0x40, 0x0a, 0xd5, 0xed, 0x7e, 0x49, 0x7d, 0x66, 0xc0, 0xf4, 0x29, 0xac, 0x9b, 0x31, 0x77, 0x8d,
|
||||
0x0d, 0x4d, 0xb5, 0xe4, 0x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, 0x42, 0x32, 0xef, 0x25, 0x3b, 0xf3, 0x5e, 0xfa, 0x25, 0x07, 0x77, 0x99, 0x88,
|
||||
0xdc, 0x57, 0xc2, 0xf1, 0x23, 0x19, 0x8e, 0x92, 0x3e, 0xff, 0x2c, 0x38, 0x74, 0xda, 0xe8, 0xd5,
|
||||
0x66, 0xb1, 0x60, 0x32, 0x98, 0x5b, 0x98, 0xc1, 0x77, 0xd5, 0x0b, 0x3b, 0x08, 0xfb, 0xaa, 0xd9,
|
||||
0x83, 0x50, 0xe7, 0x64, 0x0a, 0x98, 0x45, 0x90, 0xf7, 0x60, 0xa9, 0x1b, 0x8c, 0xc2, 0x5e, 0x72,
|
||||
0x13, 0xac, 0xa4, 0xe0, 0x98, 0x55, 0xbc, 0xcc, 0x0c, 0x2c, 0x93, 0xf1, 0xc2, 0xe5, 0x19, 0x27,
|
||||
0x8f, 0xa6, 0x32, 0x8e, 0x6f, 0xdf, 0x4a, 0xeb, 0x8d, 0xd4, 0x60, 0x62, 0x99, 0x4d, 0xa2, 0xe9,
|
||||
0x0f, 0x16, 0xdc, 0xca, 0x52, 0x78, 0xad, 0x2e, 0x88, 0x53, 0x91, 0x9b, 0x9b, 0x0a, 0x7b, 0x5e,
|
||||
0x2a, 0xf2, 0x69, 0x2a, 0xd2, 0x67, 0x52, 0x21, 0xf3, 0x4c, 0xa2, 0xc7, 0xb0, 0x3a, 0x93, 0x9f,
|
||||
0x9d, 0x60, 0x30, 0x54, 0x85, 0x70, 0xd3, 0x3c, 0x2d, 0x43, 0xa1, 0x13, 0x86, 0x3a, 0x43, 0x65,
|
||||
0x16, 0x0b, 0xf4, 0x2b, 0xb8, 0xd7, 0x15, 0x32, 0x93, 0x9e, 0x4c, 0xff, 0xef, 0x7b, 0xfd, 0x05,
|
||||
0x27, 0xdf, 0xf7, 0xfa, 0x0a, 0xb0, 0x27, 0xce, 0x16, 0x6c, 0xb8, 0x27, 0xce, 0xe8, 0x73, 0x28,
|
||||
0x1d, 0x04, 0xc3, 0xc0, 0x0b, 0x8e, 0xc6, 0xd9, 0x16, 0xb3, 0x5e, 0xbf, 0xc5, 0x72, 0x53, 0x2d,
|
||||
0xf6, 0xb8, 0xf6, 0xfb, 0x45, 0xc3, 0xfa, 0xe3, 0xa2, 0x61, 0xfd, 0x79, 0xd1, 0xb0, 0x7e, 0xfd,
|
||||
0xab, 0xf1, 0xbf, 0xc3, 0x22, 0xfe, 0xfd, 0x3d, 0xfc, 0x2f, 0x00, 0x00, 0xff, 0xff, 0xb9, 0x4f,
|
||||
0x86, 0xdb, 0x0e, 0x0e, 0x00, 0x00,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -135,6 +135,7 @@ message NodeStatus {
|
|||
message ClusterStatus {
|
||||
string State = 1;
|
||||
repeated URI NodeSet = 2;
|
||||
string ClusterID = 3;
|
||||
}
|
||||
|
||||
message Field {
|
||||
|
|
@ -180,5 +181,6 @@ message SetCoordinatorMessage {
|
|||
|
||||
message Topology {
|
||||
repeated URI NodeSet = 1;
|
||||
string ClusterID = 2;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -665,13 +665,19 @@ func (b *Bitmap) UnmarshalBinary(data []byte) error {
|
|||
c := b.containers[i]
|
||||
switch c.container_type {
|
||||
case ContainerRun:
|
||||
c.array = nil
|
||||
c.bitmap = nil
|
||||
runCount := binary.LittleEndian.Uint16(data[offset : offset+runCountHeaderSize])
|
||||
c.runs = (*[0xFFFFFFF]interval16)(unsafe.Pointer(&data[offset+runCountHeaderSize]))[:runCount]
|
||||
opsOffset = int(offset) + runCountHeaderSize + len(c.runs)*interval16Size
|
||||
case ContainerArray:
|
||||
c.runs = nil
|
||||
c.bitmap = nil
|
||||
c.array = (*[0xFFFFFFF]uint16)(unsafe.Pointer(&data[offset]))[:c.n]
|
||||
opsOffset = int(offset) + len(c.array)*2 // sizeof(uint32)
|
||||
case ContainerBitmap:
|
||||
c.array = nil
|
||||
c.runs = nil
|
||||
c.bitmap = (*[0xFFFFFFF]uint64)(unsafe.Pointer(&data[offset]))[:bitmapN]
|
||||
opsOffset = int(offset) + len(c.bitmap)*8 // sizeof(uint64)
|
||||
}
|
||||
|
|
@ -1019,17 +1025,16 @@ func (c *container) unmap() {
|
|||
return
|
||||
}
|
||||
|
||||
if c.array != nil {
|
||||
switch c.container_type {
|
||||
case ContainerArray:
|
||||
tmp := make([]uint16, len(c.array))
|
||||
copy(tmp, c.array)
|
||||
c.array = tmp
|
||||
}
|
||||
if c.bitmap != nil {
|
||||
case ContainerBitmap:
|
||||
tmp := make([]uint64, len(c.bitmap))
|
||||
copy(tmp, c.bitmap)
|
||||
c.bitmap = tmp
|
||||
}
|
||||
if c.runs != nil {
|
||||
case ContainerRun:
|
||||
tmp := make([]interval16, len(c.runs))
|
||||
copy(tmp, c.runs)
|
||||
c.runs = tmp
|
||||
|
|
@ -1614,21 +1619,17 @@ func (c *container) runToArray() {
|
|||
func (c *container) clone() *container {
|
||||
other := &container{n: c.n, container_type: c.container_type}
|
||||
|
||||
if c.array != nil {
|
||||
switch c.container_type {
|
||||
case ContainerArray:
|
||||
other.array = make([]uint16, len(c.array))
|
||||
copy(other.array, c.array)
|
||||
}
|
||||
|
||||
if c.bitmap != nil {
|
||||
case ContainerBitmap:
|
||||
other.bitmap = make([]uint64, len(c.bitmap))
|
||||
copy(other.bitmap, c.bitmap)
|
||||
}
|
||||
|
||||
if c.runs != nil {
|
||||
case ContainerRun:
|
||||
other.runs = make([]interval16, len(c.runs))
|
||||
copy(other.runs, c.runs)
|
||||
}
|
||||
|
||||
return other
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -347,8 +347,8 @@ func TestRunMax(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestIntersectionCountArrayRun(t *testing.T) {
|
||||
a := &container{array: []uint16{1, 5, 10, 11, 12}}
|
||||
b := &container{runs: []interval16{{start: 2, last: 10}, {start: 12, last: 13}, {start: 15, last: 16}}}
|
||||
a := &container{container_type: ContainerArray, array: []uint16{1, 5, 10, 11, 12}}
|
||||
b := &container{container_type: ContainerRun, runs: []interval16{{start: 2, last: 10}, {start: 12, last: 13}, {start: 15, last: 16}}}
|
||||
|
||||
ret := intersectionCountArrayRun(a, b)
|
||||
if ret != 3 {
|
||||
|
|
@ -357,16 +357,16 @@ func TestIntersectionCountArrayRun(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestIntersectionCountBitmapRun(t *testing.T) {
|
||||
a := &container{bitmap: []uint64{0x8000000000000000}}
|
||||
b := &container{runs: []interval16{{start: 63, last: 64}}}
|
||||
a := &container{container_type: ContainerBitmap, bitmap: []uint64{0x8000000000000000}}
|
||||
b := &container{container_type: ContainerRun, runs: []interval16{{start: 63, last: 64}}}
|
||||
|
||||
ret := intersectionCountBitmapRun(a, b)
|
||||
if ret != 1 {
|
||||
t.Fatalf("count of %v with %v should be 1, but got %v", a.bitmap, b.runs, ret)
|
||||
}
|
||||
|
||||
a = &container{bitmap: []uint64{0xF0000001, 0xFF00000000000000, 0xFF000000000000F0, 0x0F0000}}
|
||||
b = &container{runs: []interval16{{start: 29, last: 31}, {start: 125, last: 134}, {start: 191, last: 197}, {start: 200, last: 300}}}
|
||||
a = &container{container_type: ContainerBitmap, bitmap: []uint64{0xF0000001, 0xFF00000000000000, 0xFF000000000000F0, 0x0F0000}}
|
||||
b = &container{container_type: ContainerRun, runs: []interval16{{start: 29, last: 31}, {start: 125, last: 134}, {start: 191, last: 197}, {start: 200, last: 300}}}
|
||||
|
||||
ret = intersectionCountBitmapRun(a, b)
|
||||
if ret != 14 {
|
||||
|
|
@ -414,6 +414,8 @@ func TestIntersectionCountRunRun(t *testing.T) {
|
|||
bruns: []interval16{{start: 9, last: 9}, {start: 11, last: 17}}, exp: 6},
|
||||
}
|
||||
for i, test := range tests {
|
||||
a.container_type = ContainerRun
|
||||
b.container_type = ContainerRun
|
||||
a.runs = test.aruns
|
||||
b.runs = test.bruns
|
||||
ret := intersectionCountRunRun(a, b)
|
||||
|
|
@ -454,6 +456,8 @@ func TestIntersectArrayRun(t *testing.T) {
|
|||
}
|
||||
|
||||
for i, test := range tests {
|
||||
a.container_type = ContainerArray
|
||||
b.container_type = ContainerRun
|
||||
a.array = test.array
|
||||
b.runs = test.runs
|
||||
ret := intersectArrayRun(a, b)
|
||||
|
|
@ -510,6 +514,8 @@ func TestIntersectRunRun(t *testing.T) {
|
|||
},
|
||||
}
|
||||
for i, test := range tests {
|
||||
a.container_type = ContainerRun
|
||||
b.container_type = ContainerRun
|
||||
a.runs = test.aruns
|
||||
b.runs = test.bruns
|
||||
ret := intersectRunRun(a, b)
|
||||
|
|
@ -573,6 +579,8 @@ func TestIntersectBitmapRunBitmap(t *testing.T) {
|
|||
for i, v := range test.exp {
|
||||
exp[i] = v
|
||||
}
|
||||
a.container_type = ContainerBitmap
|
||||
b.container_type = ContainerRun
|
||||
ret := intersectBitmapRun(a, b)
|
||||
if ret.isArray() {
|
||||
ret.arrayToBitmap()
|
||||
|
|
@ -632,6 +640,8 @@ func TestIntersectBitmapRunArray(t *testing.T) {
|
|||
a.bitmap[i] = v
|
||||
}
|
||||
b.runs = test.runs
|
||||
a.container_type = ContainerBitmap
|
||||
b.container_type = ContainerRun
|
||||
ret := intersectBitmapRun(a, b)
|
||||
if !reflect.DeepEqual(ret.array, test.exp) {
|
||||
t.Fatalf("test #%v expected %v, but got %v", i, test.exp, ret.array)
|
||||
|
|
@ -873,6 +883,8 @@ func TestUnionRunRun(t *testing.T) {
|
|||
for i, test := range tests {
|
||||
a.runs = test.aruns
|
||||
b.runs = test.bruns
|
||||
a.container_type = ContainerRun
|
||||
b.container_type = ContainerRun
|
||||
ret := unionRunRun(a, b)
|
||||
if !reflect.DeepEqual(ret.runs, test.exp) {
|
||||
t.Fatalf("test #%v expected %v, but got %v", i, test.exp, ret.runs)
|
||||
|
|
@ -913,6 +925,8 @@ func TestUnionArrayRun(t *testing.T) {
|
|||
for i, test := range tests {
|
||||
a.array = test.array
|
||||
b.runs = test.runs
|
||||
a.container_type = ContainerArray
|
||||
b.container_type = ContainerRun
|
||||
ret := unionArrayRun(a, b)
|
||||
if !reflect.DeepEqual(ret.array, test.exp) {
|
||||
t.Fatalf("test #%v expected %v, but got %v", i, test.exp, ret.array)
|
||||
|
|
@ -921,7 +935,7 @@ func TestUnionArrayRun(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestBitmapSetRange(t *testing.T) {
|
||||
c := &container{bitmap: make([]uint64, bitmapN)}
|
||||
c := &container{container_type: ContainerBitmap, bitmap: make([]uint64, bitmapN)}
|
||||
tests := []struct {
|
||||
bitmap []uint64
|
||||
start uint64
|
||||
|
|
@ -961,7 +975,7 @@ func TestBitmapSetRange(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestArrayToBitmap(t *testing.T) {
|
||||
a := &container{}
|
||||
a := &container{container_type: ContainerArray}
|
||||
tests := []struct {
|
||||
array []uint16
|
||||
exp []uint64
|
||||
|
|
@ -992,7 +1006,7 @@ func TestArrayToBitmap(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestBitmapToArray(t *testing.T) {
|
||||
a := &container{}
|
||||
a := &container{container_type: ContainerBitmap}
|
||||
tests := []struct {
|
||||
bitmap []uint64
|
||||
exp []uint16
|
||||
|
|
@ -1023,7 +1037,7 @@ func TestBitmapToArray(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRunToBitmap(t *testing.T) {
|
||||
a := &container{}
|
||||
a := &container{container_type: ContainerRun}
|
||||
tests := []struct {
|
||||
runs []interval16
|
||||
exp []uint64
|
||||
|
|
@ -1077,7 +1091,7 @@ func getFullBitmap() []uint64 {
|
|||
}
|
||||
|
||||
func TestBitmapToRun(t *testing.T) {
|
||||
a := &container{}
|
||||
a := &container{container_type: ContainerBitmap}
|
||||
tests := []struct {
|
||||
bitmap []uint64
|
||||
exp []interval16
|
||||
|
|
@ -1155,7 +1169,7 @@ func TestBitmapToRun(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestArrayToRun(t *testing.T) {
|
||||
a := &container{}
|
||||
a := &container{container_type: ContainerArray}
|
||||
tests := []struct {
|
||||
array []uint16
|
||||
exp []interval16
|
||||
|
|
@ -1189,7 +1203,7 @@ func TestArrayToRun(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRunToArray(t *testing.T) {
|
||||
a := &container{}
|
||||
a := &container{container_type: ContainerRun}
|
||||
tests := []struct {
|
||||
runs []interval16
|
||||
exp []uint16
|
||||
|
|
@ -1223,7 +1237,7 @@ func TestRunToArray(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestBitmapZeroRange(t *testing.T) {
|
||||
c := &container{bitmap: make([]uint64, bitmapN)}
|
||||
c := &container{container_type: ContainerBitmap, bitmap: make([]uint64, bitmapN)}
|
||||
tests := []struct {
|
||||
bitmap []uint64
|
||||
start uint64
|
||||
|
|
@ -1267,8 +1281,8 @@ func TestBitmapZeroRange(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUnionBitmapRun(t *testing.T) {
|
||||
a := &container{bitmap: make([]uint64, bitmapN)}
|
||||
b := &container{}
|
||||
a := &container{container_type: ContainerBitmap, bitmap: make([]uint64, bitmapN)}
|
||||
b := &container{container_type: ContainerRun}
|
||||
tests := []struct {
|
||||
bitmap []uint64
|
||||
runs []interval16
|
||||
|
|
@ -1288,6 +1302,7 @@ func TestUnionBitmapRun(t *testing.T) {
|
|||
}
|
||||
a.n = a.bitmapCountRange(0, 65535)
|
||||
b.runs = test.runs
|
||||
b.n = b.runCountRange(0, 65535)
|
||||
ret := unionBitmapRun(a, b)
|
||||
if ret.isArray() {
|
||||
ret.arrayToBitmap()
|
||||
|
|
@ -1305,7 +1320,7 @@ func TestUnionBitmapRun(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestBitmapCountRuns(t *testing.T) {
|
||||
c := &container{bitmap: make([]uint64, bitmapN)}
|
||||
c := &container{container_type: ContainerBitmap, bitmap: make([]uint64, bitmapN)}
|
||||
tests := []struct {
|
||||
bitmap []uint64
|
||||
exp int
|
||||
|
|
@ -1355,7 +1370,7 @@ func TestBitmapCountRuns(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestArrayCountRuns(t *testing.T) {
|
||||
c := &container{}
|
||||
c := &container{container_type: ContainerArray}
|
||||
tests := []struct {
|
||||
array []uint16
|
||||
exp int
|
||||
|
|
@ -1396,8 +1411,8 @@ func TestArrayCountRuns(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDifferenceArrayRun(t *testing.T) {
|
||||
a := &container{}
|
||||
b := &container{}
|
||||
a := &container{container_type: ContainerArray}
|
||||
b := &container{container_type: ContainerRun}
|
||||
tests := []struct {
|
||||
array []uint16
|
||||
runs []interval16
|
||||
|
|
@ -1422,8 +1437,8 @@ func TestDifferenceArrayRun(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDifferenceRunArray(t *testing.T) {
|
||||
a := &container{}
|
||||
b := &container{}
|
||||
a := &container{container_type: ContainerRun}
|
||||
b := &container{container_type: ContainerArray}
|
||||
tests := []struct {
|
||||
runs []interval16
|
||||
array []uint16
|
||||
|
|
@ -1493,8 +1508,8 @@ func MakeLastBitSet() []uint64 {
|
|||
}
|
||||
|
||||
func TestDifferenceRunBitmap(t *testing.T) {
|
||||
a := &container{}
|
||||
b := &container{bitmap: make([]uint64, bitmapN)}
|
||||
a := &container{container_type: ContainerRun}
|
||||
b := &container{container_type: ContainerBitmap, bitmap: make([]uint64, bitmapN)}
|
||||
tests := []struct {
|
||||
runs []interval16
|
||||
bitmap []uint64
|
||||
|
|
@ -1556,8 +1571,8 @@ func TestDifferenceRunBitmap(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDifferenceBitmapRun(t *testing.T) {
|
||||
a := &container{bitmap: make([]uint64, bitmapN)}
|
||||
b := &container{}
|
||||
a := &container{container_type: ContainerBitmap, bitmap: make([]uint64, bitmapN)}
|
||||
b := &container{container_type: ContainerRun}
|
||||
tests := []struct {
|
||||
bitmap []uint64
|
||||
runs []interval16
|
||||
|
|
@ -1584,7 +1599,7 @@ func TestDifferenceBitmapRun(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDifferenceBitmapArray(t *testing.T) {
|
||||
b := &container{bitmap: make([]uint64, bitmapN), container_type: ContainerBitmap}
|
||||
b := &container{container_type: ContainerBitmap, bitmap: make([]uint64, bitmapN)}
|
||||
a := &container{container_type: ContainerArray}
|
||||
tests := []struct {
|
||||
bitmap []uint64
|
||||
|
|
@ -2513,8 +2528,9 @@ func TestSearc64(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestIntersectArrayBitmap(t *testing.T) {
|
||||
a, b := &container{}, &container{
|
||||
bitmap: make([]uint64, bitmapN),
|
||||
a, b := &container{container_type: ContainerArray}, &container{
|
||||
container_type: ContainerBitmap,
|
||||
bitmap: make([]uint64, bitmapN),
|
||||
}
|
||||
tests := []struct {
|
||||
array []uint16
|
||||
|
|
|
|||
|
|
@ -211,6 +211,11 @@ func (s *Server) Open() error {
|
|||
// buffered channel.
|
||||
s.Cluster.ListenForJoins()
|
||||
|
||||
// Load local ID.
|
||||
if err := s.Holder.loadNodeID(); err != nil {
|
||||
s.Logger().Println(err)
|
||||
}
|
||||
|
||||
// Start background monitoring.
|
||||
s.wg.Add(3)
|
||||
go func() { defer s.wg.Done(); s.monitorAntiEntropy() }()
|
||||
|
|
@ -571,7 +576,8 @@ func (s *Server) monitorDiagnostics() {
|
|||
s.diagnostics.Set("Cluster", strings.Join(NodeSet(s.Cluster.NodeSet()).ToStrings(), ","))
|
||||
s.diagnostics.Set("NumNodes", len(s.Cluster.Nodes))
|
||||
s.diagnostics.Set("NumCPU", runtime.NumCPU())
|
||||
// TODO: unique cluster ID
|
||||
s.diagnostics.Set("NodeID", s.Holder.NodeID)
|
||||
s.diagnostics.Set("ClusterID", s.Cluster.ID)
|
||||
|
||||
// Flush the diagnostics metrics at startup, then on each tick interval
|
||||
flush := func() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue