Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/benbjohnson/etcd into ben…
Browse files Browse the repository at this point in the history
…bjohnson-master

Conflicts:
	README.md
  • Loading branch information
benbjohnson committed Nov 14, 2013
2 parents b988f5b + aa047b1 commit f499100
Show file tree
Hide file tree
Showing 294 changed files with 17,741 additions and 33,481 deletions.
6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
src/
pkg/
/etcd
/server/release_version.go
/go-bindata
release_version.go
/machine*
.vagrant/
conf
info
log
33 changes: 33 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
v0.2
* Support directory creation and removal.
* Add Compare-and-Swap (CAS) support.
* Support recursive GETs.
* Support fully consistent GETs.
* Allow clients to watch specific paths.
* Allow clients to watch for key expiration.
* Unique key generation.
* Support hidden paths.
* Refactor low-level data store.
* Modularize store, server and API code.
* Integrate Gorilla Web Toolkit.
* Add tiered configuration (command line args, env variables, config file).
* Add peer protocol versioning.
* Add rolling upgrade support for future versions.
* Sync key expiration across cluster.
* Significantly improve test coverage.
* Improve migration testing.
* Configurable snapshot count.
* Reduce TCP connection count.
* Fix TCP connection leak.
* Bug Fixes: https://github.com/coreos/etcd/issues?milestone=1&state=closed

Contributors:
* Xiang Li (@xiangli-cmu)
* Ben Johnson (@benbjohnson)
* Brandon Philips (@philips)
* Yifan (@yifan-gu)
* Rob Szumski
* Hongchao Deng (@fengjingchao)
* Kelsey Hightower (@kelseyhightower)
* Adrián (@adrianlzt)
* Antonio Terreno (@aterreno)
58 changes: 58 additions & 0 deletions Documentation/errorcode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
Error Code
======

This document describes the error code in **Etcd** project.

It's categorized into four groups:

- Command Related Error
- Post Form Related Error
- Raft Related Error
- Etcd Related Error

Error code corresponding strerror
------

const (
EcodeKeyNotFound = 100
EcodeTestFailed = 101
EcodeNotFile = 102
EcodeNoMoreMachine = 103
EcodeNotDir = 104
EcodeNodeExist = 105
EcodeKeyIsPreserved = 106

EcodeValueRequired = 200
EcodePrevValueRequired = 201
EcodeTTLNaN = 202
EcodeIndexNaN = 203

EcodeRaftInternal = 300
EcodeLeaderElect = 301

EcodeWatcherCleared = 400
EcodeEventIndexCleared = 401
)

// command related errors
errors[100] = "Key Not Found"
errors[101] = "Test Failed" //test and set
errors[102] = "Not A File"
errors[103] = "Reached the max number of machines in the cluster"
errors[104] = "Not A Directory"
errors[105] = "Already exists" // create
errors[106] = "The prefix of given key is a keyword in etcd"

// Post form related errors
errors[200] = "Value is Required in POST form"
errors[201] = "PrevValue is Required in POST form"
errors[202] = "The given TTL in POST form is not a number"
errors[203] = "The given index in POST form is not a number"

// raft related errors
errors[300] = "Raft Internal Error"
errors[301] = "During Leader Election"

// etcd related errors
errors[400] = "watcher is cleared due to etcd recovery"
errors[401] = "The event in requested index is outdated and cleared"
101 changes: 101 additions & 0 deletions Documentation/etcd-file-system.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#Etcd File System

## Structure
[TODO]
![alt text](./img/etcd_fs_structure.jpg "etcd file system structure")

## Node
In **Etcd**, the **Node** is the rudimentary element constructing the whole.
Currently **Etcd** file system is comprised in a Unix-like way of files and directories, and they are two kinds of nodes different in:

- **File Node** has data associated with it.
- **Directory Node** has children nodes associated with it.

Besides the file and directory difference, all nodes have common attributes and operations as follows:

### Attributes:
- **Expiration Time** [optional]

The node will be deleted when it expires.

- **ACL**

The path of access control list of the node.

### Operation:
- **Get** (path, recursive, sorted)

Get the content of the node
- If the node is a file, the data of the file will be returned.
- If the node is a directory, the child nodes of the directory will be returned.
- If recursive is true, it will recursively get the nodes of the directory.
- If sorted is true, the result will be sorted based on the path.

- **Create** (path, value[optional], ttl [optional])

Create a file. Create operation will help to create intermediate directories with no expiration time.
- If the file already exists, create will fail.
- If the value is given, set will create a file.
- If the value is not given, set will crate a directory.
- If ttl is given, the node will be deleted when it expires.

- **Update** (path, value[optional], ttl [optional])

Update the content of the node.
- If the value is given, the value of the key will be updated.
- If ttl is given, the expiration time of the node will be updated.

- **Delete** (path, recursive)

Delete the node of given path.
- If the node is a directory:
- If recursive is true, the operation will delete all nodes under the directory.
- If recursive is false, error will be returned.

- **TestAndSet** (path, prevValue [prevIndex], value, ttl)

Atomic *test and set* value to a file. If test succeeds, this operation will change the previous value of the file to the given value.
- If the prevValue is given, it will test against previous value of
the node.
- If the prevValue is empty, it will test if the node is not existing.
- If the prevValue is not empty, it will test if the prevValue is equal to the current value of the file.
- If the prevIndex is given, it will test if the create/last modified index of the node is equal to prevIndex.

- **Renew** (path, ttl)

Set the node's expiration time to (current time + ttl)

## ACL

### Theory
Etcd exports a Unix-like file system interface consisting of files and directories, collectively called nodes.
Each node has various meta-data, including three names of access control lists used to control reading, writing and changing (change ACL names for the node).

We are storing the ACL names for nodes under a special *ACL* directory.
Each node has ACL name corresponding to one file within *ACL* dir.
Unless overridden, a node naturally inherits the ACL names of its parent directory on creation.

For each ACL name, it has three children: *R (Reading)*, *W (Writing)*, *C (Changing)*

Each permission is also a node. Under the node it contains the users who have this permission for the file refering to this ACL name.

### Example
[TODO]
### Diagram
[TODO]

### Interface

Testing permissions:

- (node *Node) get_perm()
- (node *Node) has_perm(perm string, user string)

Setting/Changing permissions:

- (node *Node) set_perm(perm string)
- (node *Node) change_ACLname(aclname string)


## User Group
[TODO]
104 changes: 104 additions & 0 deletions Documentation/external-documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Etcd Configuration

Configuration options can be set in three places:

1. Command line flags
2. Environment variables
3. Configuration file

Options set on the command line take precedence over all other sources.
Options set in environment variables take precedence over options set in
configuration files.

## Command Line Flags

### Required

* `-n` - The node name. Defaults to `default-name`.

### Optional

* `-c` - The advertised public hostname:port for client communication. Defaults to `127.0.0.1:4001`.
* `-cl` - The listening hostname for client communication. Defaults to advertised ip.
* `-C` - A comma separated list of machines in the cluster (i.e `"203.0.113.101:7001,203.0.113.102:7001"`).
* `-CF` - The file path containing a comma separated list of machines in the cluster.
* `-clientCAFile` - The path of the client CAFile. Enables client cert authentication when present.
* `-clientCert` - The cert file of the client.
* `-clientKey` - The key file of the client.
* `-configfile` - The path of the etcd config file. Defaults to `/etc/etcd/etcd.conf`.
* `-cors` - A comma separated white list of origins for cross-origin resource sharing.
* `-cpuprofile` - The path to a file to output cpu profile data. Enables cpu profiling when present.
* `-d` - The directory to store log and snapshot. Defaults to the current working directory.
* `-m` - The max size of result buffer. Defaults to `1024`.
* `-maxsize` - The max size of the cluster. Defaults to `9`.
* `-r` - The max retry attempts when trying to join a cluster. Defaults to `3`.
* `-s` - The advertised public hostname:port for server communication. Defaults to `127.0.0.1:7001`.
* `-sl` - The listening hostname for server communication. Defaults to advertised ip.
* `-serverCAFile` - The path of the CAFile. Enables client/peer cert authentication when present.
* `-serverCert` - The cert file of the server.
* `-serverKey` - The key file of the server.
* `-snapshot` - Open or close snapshot. Defaults to `false`.
* `-v` - Enable verbose logging. Defaults to `false`.
* `-vv` - Enable very verbose logging. Defaults to `false`.
* `-version` - Print the version and exit.
* `-w` - The hostname:port of web interface.

## Configuration File

The etcd configuration file is written in [TOML](https://github.com/mojombo/toml)
and read from `/etc/etcd/etcd.conf` by default.

```TOML
advertised_url = "127.0.0.1:4001"
ca_file = ""
cert_file = ""
cors = []
cpu_profile_file = ""
datadir = "."
key_file = ""
listen_host = "127.0.0.1:4001"
machines = []
machines_file = ""
max_cluster_size = 9
max_result_buffer = 1024
max_retry_attempts = 3
name = "default-name"
snapshot = false
verbose = false
very_verbose = false
web_url = ""

[peer]
advertised_url = "127.0.0.1:7001"
ca_file = ""
cert_file = ""
key_file = ""
listen_host = "127.0.0.1:7001"
```

## Environment Variables

* `ETCD_ADVERTISED_URL`
* `ETCD_CA_FILE`
* `ETCD_CERT_FILE`
* `ETCD_CORS`
* `ETCD_CONFIG_FILE`
* `ETCD_CPU_PROFILE_FILE`
* `ETCD_DATADIR`
* `ETCD_KEY_FILE`
* `ETCD_LISTEN_HOST`
* `ETCD_MACHINES`
* `ETCD_MACHINES_FILE`
* `ETCD_MAX_RETRY_ATTEMPTS`
* `ETCD_MAX_CLUSTER_SIZE`
* `ETCD_MAX_RESULT_BUFFER`
* `ETCD_NAME`
* `ETCD_SNAPSHOT`
* `ETCD_VERBOSE`
* `ETCD_VERY_VERBOSE`
* `ETCD_WEB_URL`
* `ETCD_PEER_ADVERTISED_URL`
* `ETCD_PEER_CA_FILE`
* `ETCD_PEER_CERT_FILE`
* `ETCD_PEER_KEY_FILE`
* `ETCD_PEER_LISTEN_HOST`
Binary file added Documentation/img/etcd_fs_structure.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f499100

Please sign in to comment.