You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2012/10/24 11:39:02 UTC
[2/2] git commit: Give each couchdb server a unique identifier
Give each couchdb server a unique identifier
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/da7636f7
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/da7636f7
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/da7636f7
Branch: refs/heads/1259-stable_replication_ids
Commit: da7636f7ca9606e2bcca2c8a8e82b626dacf3c8b
Parents: 6652937
Author: Robert Newson <rn...@apache.org>
Authored: Tue Oct 23 21:28:56 2012 +0100
Committer: Robert Newson <rn...@apache.org>
Committed: Tue Oct 23 21:28:56 2012 +0100
----------------------------------------------------------------------
src/couchdb/couch_httpd_misc_handlers.erl | 1 +
src/couchdb/couch_server.erl | 11 ++++++++++-
2 files changed, 11 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/da7636f7/src/couchdb/couch_httpd_misc_handlers.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_httpd_misc_handlers.erl b/src/couchdb/couch_httpd_misc_handlers.erl
index f7a4d75..2150bea 100644
--- a/src/couchdb/couch_httpd_misc_handlers.erl
+++ b/src/couchdb/couch_httpd_misc_handlers.erl
@@ -32,6 +32,7 @@
handle_welcome_req(#httpd{method='GET'}=Req, WelcomeMessage) ->
send_json(Req, {[
{couchdb, WelcomeMessage},
+ {uuid, couch_server:get_uuid()},
{version, list_to_binary(couch_server:get_version())}
] ++ case couch_config:get("vendor") of
[] ->
http://git-wip-us.apache.org/repos/asf/couchdb/blob/da7636f7/src/couchdb/couch_server.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_server.erl b/src/couchdb/couch_server.erl
index 0f40c51..5d3b8d1 100644
--- a/src/couchdb/couch_server.erl
+++ b/src/couchdb/couch_server.erl
@@ -13,7 +13,7 @@
-module(couch_server).
-behaviour(gen_server).
--export([open/2,create/2,delete/2,get_version/0]).
+-export([open/2,create/2,delete/2,get_version/0,get_uuid/0]).
-export([all_databases/0, all_databases/2]).
-export([init/1, handle_call/3,sup_start_link/0]).
-export([handle_cast/2,code_change/3,handle_info/2,terminate/2]).
@@ -43,6 +43,15 @@ get_version() ->
"0.0.0"
end.
+get_uuid() ->
+ case couch_config:get("couchdb", "uuid", nil) of
+ nil ->
+ UUID = couch_uuids:random(),
+ couch_config:set("couchdb", "uuid", ?b2l(UUID)),
+ UUID;
+ UUID -> ?l2b(UUID)
+ end.
+
get_stats() ->
{ok, #server{start_time=Time,dbs_open=Open}} =
gen_server:call(couch_server, get_server),