You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by sa...@apache.org on 2015/11/09 05:53:18 UTC

[1/2] incubator-trafodion git commit: [TRAFODION-1591] Script to find ports not-in-use

Repository: incubator-trafodion
Updated Branches:
  refs/heads/master 392b99b96 -> cce8b85c8


[TRAFODION-1591] Script to find ports not-in-use


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

Branch: refs/heads/master
Commit: f8b2ace37c0ea8ef14f46a4fe35da2f4dddac059
Parents: 514479f
Author: Dave Birdsall <db...@apache.org>
Authored: Thu Nov 5 21:13:07 2015 +0000
Committer: Dave Birdsall <db...@apache.org>
Committed: Thu Nov 5 21:13:07 2015 +0000

----------------------------------------------------------------------
 core/sqf/sql/scripts/findPort.py | 106 ++++++++++++++++++++++++++++++++++
 1 file changed, 106 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/f8b2ace3/core/sqf/sql/scripts/findPort.py
----------------------------------------------------------------------
diff --git a/core/sqf/sql/scripts/findPort.py b/core/sqf/sql/scripts/findPort.py
new file mode 100644
index 0000000..89ff510
--- /dev/null
+++ b/core/sqf/sql/scripts/findPort.py
@@ -0,0 +1,106 @@
+# @@@ START COPYRIGHT @@@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# @@@ END COPYRIGHT @@@
+#
+#  This script finds ranges of ports suitable for input
+#  to the Trafodion install_local_hadoop script.
+#
+import os
+import sys
+import subprocess 
+import re
+import sets
+import argparse  # requires Python 2.7
+
+
+
+
+# beginning of main
+
+# pseudocode
+#
+# do a "netstat | grep localhost" to obtain raw port-in-use info
+#
+# inUseRanges = empty set
+# for each line
+#    for each occurrance of the string "localhost:nnnnn"
+#       rangeInUse = integer(nnnnn/200) (assume a range of 200 ports is needed)
+#       add rangeInUse to inUseRanges
+#    end for
+# end for
+#
+# for each possible range starting from the smallest in rangeInUse and ending at 48800
+#     if it isn't in the inUseRanges set
+#         print it out as a possible port range to use
+#     end if
+# end for
+  
+
+
+# process command line arguments
+
+parser = argparse.ArgumentParser(
+    description='This script finds possible port ranges to use with install_local_hadoop.')
+
+args = parser.parse_args()  # exits and prints help if args are incorrect
+
+exitCode = 0
+
+# get the set of lines to process ( netstat | grep localhost )
+
+p1 = subprocess.Popen(["netstat"], stdout=subprocess.PIPE)
+p2 = subprocess.Popen(["grep","localhost"], stdin=p1.stdout, stdout=subprocess.PIPE, close_fds=True)
+
+# process the lines, looking for port numbers
+
+pattern = r'localhost:(?P<portNumber>[0-9]{5})'
+matcher = re.compile(pattern)
+
+inUseRanges = sets.Set()
+
+for line in p2.stdout: 
+    result = matcher.findall(line)
+    for occurrance in result:
+        rangeInUse = int(occurrance)/200
+        inUseRanges.add(rangeInUse)
+
+# avoid recommending low ranges; our lowest recommendation
+# will be the first unused range above the lowest in-use range
+
+# avoid ranges in the ephemeral port range 49191-65535 also
+
+print
+
+foundOne = False
+minInUse = min(inUseRanges)
+for r in range(min(inUseRanges)+1,48800/200):
+    if r not in inUseRanges:
+        if not foundOne:
+            print "Port ranges not in use:"
+        foundOne = True
+        print 200*r
+
+if not foundOne:
+    print "All port ranges from " + str(200*minInUse) + " through 48800 are in use."
+    exitCode = 1
+
+print
+
+exit(exitCode)


[2/2] incubator-trafodion git commit: Merge remote branch 'origin/pr/162/head' into merge_trafodion1591

Posted by sa...@apache.org.
Merge remote branch 'origin/pr/162/head' into merge_trafodion1591


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

Branch: refs/heads/master
Commit: cce8b85c88f758a757b5db76835d5495559a3758
Parents: 392b99b f8b2ace
Author: Sandhya Sundaresan <sa...@apache.org>
Authored: Mon Nov 9 04:52:09 2015 +0000
Committer: Sandhya Sundaresan <sa...@apache.org>
Committed: Mon Nov 9 04:52:09 2015 +0000

----------------------------------------------------------------------
 core/sqf/sql/scripts/findPort.py | 106 ++++++++++++++++++++++++++++++++++
 1 file changed, 106 insertions(+)
----------------------------------------------------------------------