ponymail-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From johndam...@apache.org
Subject [1/3] incubator-ponymail git commit: Prompt for shards and replicas. This closes #313.
Date Sat, 07 Jan 2017 23:10:13 GMT
Repository: incubator-ponymail
Updated Branches:
  refs/heads/master d8839084f -> e153c4abc


Prompt for shards and replicas.  This closes #313.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/8531faab
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/8531faab
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/8531faab

Branch: refs/heads/master
Commit: 8531faab4d1d89a12b223eec702b133f2afb7d90
Parents: d883908
Author: John D. Ament <johndament@apache.org>
Authored: Sat Jan 7 18:06:36 2017 -0500
Committer: John D. Ament <johndament@apache.org>
Committed: Sat Jan 7 18:06:36 2017 -0500

----------------------------------------------------------------------
 tools/setup.py | 32 ++++++++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/8531faab/tools/setup.py
----------------------------------------------------------------------
diff --git a/tools/setup.py b/tools/setup.py
index a478458..c02116a 100755
--- a/tools/setup.py
+++ b/tools/setup.py
@@ -63,6 +63,10 @@ parser.add_argument('--dbport', dest='dbport', type=str, nargs=1,
                    help='DB port')
 parser.add_argument('--dbname', dest='dbname', type=str, nargs=1,
                    help='ES DB name')
+parser.add_argument('--dbshards', dest='dbshards', type=int, nargs=1,
+                   help='DB Shard Count')
+parser.add_argument('--dbreplicas', dest='dbreplicas', type=int, nargs=1,
+                  help='DB Replica Count')
 parser.add_argument('--mailserver', dest='mailserver', type=str, nargs=1,
                    help='Host name of outgoing mail server')
 parser.add_argument('--mldom', dest='mldom', type=str, nargs=1,
@@ -89,7 +93,8 @@ mlserver = ""
 mldom = ""
 wc = ""
 wce = False
-
+shards = 0
+replicas = -1
 
 
 # If called with --defaults (like from Docker), use default values
@@ -101,6 +106,8 @@ if args.defaults:
     mldom = "example.org"
     wc = "Y"
     wce = True
+    shards = 1
+    replicas = 0
 
 # Accept CLI args, copy them
 if args.dbhost:
@@ -117,6 +124,10 @@ if args.wc:
     wc = args.wc
 if args.nwc:
     wc = False
+if args.dbshards:
+    shards = args.dbshards[0]
+if args.dbreplicas:
+    replicas = args.dbreplicas[0]
     
 while hostname == "":
     hostname = input("What is the hostname of the ElasticSearch server? (e.g. localhost):
")
@@ -141,6 +152,17 @@ while wc == "":
     if wc.lower() == "y":
         wce = True
 
+while shards < 1:
+    try:
+        shards = int(input("How many shards for the ElasticSearch index? "))
+    except ValueError:
+        pass
+
+while replicas < 0:
+    try:
+        replicas = int(input("How many replicas for each shard? "))
+    except ValueError:
+        pass
 
 print("Okay, I got all I need, setting up Pony Mail...")
 
@@ -167,6 +189,11 @@ def createIndex():
 
     print("Creating index " + dbname)
 
+    settings = {
+        "number_of_shards" :   shards,
+        "number_of_replicas" : replicas
+    }
+
     mappings = {
         "mbox" : {
           "properties" : {
@@ -400,7 +427,8 @@ def createIndex():
     }
  
     res = es.indices.create(index = dbname, body = {
-                "mappings" : mappings
+                "mappings" : mappings,
+                "settings": settings
             }
         )
     


Mime
View raw message