accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mwa...@apache.org
Subject accumulo git commit: ACCUMULO-4673 Review proxy docs & example code
Date Wed, 05 Jul 2017 18:50:44 GMT
Repository: accumulo
Updated Branches:
  refs/heads/master 5abce363a -> 2a92a1d40


ACCUMULO-4673 Review proxy docs & example code

* Deleted proxy docs & example code as they were moved
  to documentation in accumulo-website repo
* proxy.thrift now lives in lib/proxy/thrift of release tarball
* generated lang bindings now go to lib/proxy/
* proxy.properties file is in conf/templates now
* the proxy can now be run using accumulo-service


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/2a92a1d4
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/2a92a1d4
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/2a92a1d4

Branch: refs/heads/master
Commit: 2a92a1d4056404fa475cac002de3ecd461aabc84
Parents: 5abce36
Author: Mike Walch <mwalch@apache.org>
Authored: Mon Jul 3 11:05:48 2017 -0400
Committer: Mike Walch <mwalch@apache.org>
Committed: Wed Jul 5 14:41:58 2017 -0400

----------------------------------------------------------------------
 assemble/bin/accumulo-service                   |   3 +-
 assemble/conf/accumulo-env.sh                   |   2 +-
 assemble/src/main/assemblies/component.xml      |  27 +--
 proxy/README                                    |  62 -------
 proxy/examples/python/README                    |  24 ---
 proxy/examples/python/TestClient.py             |  47 -----
 proxy/examples/python/TestNamespace.py          | 172 -------------------
 proxy/examples/ruby/README                      |  26 ---
 proxy/examples/ruby/test_client.rb              |  48 ------
 proxy/proxy.properties                          |  12 +-
 .../java/org/apache/accumulo/proxy/Proxy.java   |  39 +++--
 11 files changed, 41 insertions(+), 421 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/2a92a1d4/assemble/bin/accumulo-service
----------------------------------------------------------------------
diff --git a/assemble/bin/accumulo-service b/assemble/bin/accumulo-service
index d44ab37..54161af 100755
--- a/assemble/bin/accumulo-service
+++ b/assemble/bin/accumulo-service
@@ -23,6 +23,7 @@ Services:
   gc          Accumulo garbage collector
   monitor     Accumulo monitor
   master      Accumulo master
+  proxy       Accumulo proxy
   tserver     Accumulo tserver
   tracer      Accumulo tracter
 
@@ -135,7 +136,7 @@ function main() {
   service="$1"
   pid_file="${basedir}/run/accumulo-${service}.pid"
   case "$service" in
-    gc|master|monitor|tserver|tracer)
+    gc|master|monitor|proxy|tserver|tracer)
       if [[ -z $2 ]]; then
         invalid_args "<command> cannot be empty"
       fi

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2a92a1d4/assemble/conf/accumulo-env.sh
----------------------------------------------------------------------
diff --git a/assemble/conf/accumulo-env.sh b/assemble/conf/accumulo-env.sh
index c1362c0..58173d5 100644
--- a/assemble/conf/accumulo-env.sh
+++ b/assemble/conf/accumulo-env.sh
@@ -96,7 +96,7 @@ case "$cmd" in
   monitor)
     JAVA_OPTS=("${JAVA_OPTS[@]}" "-Dlog4j.configuration=log4j-monitor.properties")
     ;;
-  gc|master|tserver|tracer)
+  gc|master|proxy|tserver|tracer)
     JAVA_OPTS=("${JAVA_OPTS[@]}" "-Dlog4j.configuration=log4j-service.properties")
     ;;
   *)

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2a92a1d4/assemble/src/main/assemblies/component.xml
----------------------------------------------------------------------
diff --git a/assemble/src/main/assemblies/component.xml b/assemble/src/main/assemblies/component.xml
index f28b2c6..8b39ccf 100644
--- a/assemble/src/main/assemblies/component.xml
+++ b/assemble/src/main/assemblies/component.xml
@@ -81,7 +81,7 @@
     <!-- Lift generated thrift proxy code into its own directory -->
     <fileSet>
       <directory>../proxy/target</directory>
-      <outputDirectory>proxy/thrift</outputDirectory>
+      <outputDirectory>lib/proxy</outputDirectory>
       <directoryMode>0755</directoryMode>
       <fileMode>0644</fileMode>
       <includes>
@@ -92,39 +92,18 @@
     </fileSet>
     <fileSet>
       <directory>../proxy</directory>
-      <outputDirectory>proxy</outputDirectory>
+      <outputDirectory>conf/templates</outputDirectory>
       <directoryMode>0755</directoryMode>
       <fileMode>0644</fileMode>
       <includes>
-        <include>README</include>
         <include>proxy.properties</include>
       </includes>
     </fileSet>
     <fileSet>
-      <directory>../proxy/examples</directory>
-      <outputDirectory>proxy/examples</outputDirectory>
-      <directoryMode>0755</directoryMode>
-      <fileMode>0755</fileMode>
-      <includes>
-        <include>**/*.py</include>
-        <include>**/*.rb</include>
-      </includes>
-    </fileSet>
-    <fileSet>
-      <directory>../proxy/examples</directory>
-      <outputDirectory>proxy/examples</outputDirectory>
-      <directoryMode>0755</directoryMode>
-      <fileMode>0644</fileMode>
-      <excludes>
-        <exclude>**/*.py</exclude>
-        <exclude>**/*.rb</exclude>
-      </excludes>
-    </fileSet>
-    <fileSet>
       <directory>../proxy/src/main/thrift</directory>
       <directoryMode>0755</directoryMode>
       <fileMode>0644</fileMode>
-      <outputDirectory>proxy/thrift</outputDirectory>
+      <outputDirectory>lib/proxy/thrift</outputDirectory>
       <includes>
         <include>*.thrift</include>
       </includes>

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2a92a1d4/proxy/README
----------------------------------------------------------------------
diff --git a/proxy/README b/proxy/README
deleted file mode 100644
index 7880de7..0000000
--- a/proxy/README
+++ /dev/null
@@ -1,62 +0,0 @@
-Title: Apache Accumulo Proxy
-Notice:    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.
-
-This module provides proxy server for Apache Accumulo. It enables using languages 
-other than Java to interact with the database.
-
-1. Building
-
-The proxy server is built by the Accumulo build process. Read ../README
-for more information.
-
-2. Installation
-
-The proxy server is installed during the Accumulo installation process. Read ../README
-for more information.
-
-3. Configuration
-
-Please note the proxy server only functions correctly when connected to an 
-Accumulo 1.5 instance, or when run standalone in the Mock configuration.
-
- - Edit the proxy.properties file.
-    - Change the useMockInstance value to 'true' if you wish to use an in-memory Mock instance.
-    - Change the useMiniAccumulo value to 'true' if you wish to use a Mini Accumulo Cluster.
-    - When using a "real" Accumulo instance:
-        - Ensure useMockInstance and useMiniAccumulo are both set to 'false'
-        - Set the instance name
-        - Set the list of ZooKeepers
-
-4. Execution
-
-Run the following command.
-
- ./bin/accumulo proxy -p ./proxy/proxy.properties
-
-5. Clients
-
-You need the language-specific library for Thrift installed to be able to use said Thrift
client 
-code in that language. In other words, you need to install the Python Thrift library to use
the Python 
-example. Typically, your operating system's package manager will be able to automatically
install
-these for you in an expected location such as /usr/lib/python/site-packages/thrift.
-
-An example Java client is incuded with this distribution in the class TestProxyClient. Also
the 
-unit tests included show how to use the proxy. Normal Accumulo APIs are emulated wherever
possible.
-
-Additional client examples can be found in the examples directory. These clients are tested
and 
-functional; however, the setup for each language is beyond the scope of this document currently.

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2a92a1d4/proxy/examples/python/README
----------------------------------------------------------------------
diff --git a/proxy/examples/python/README b/proxy/examples/python/README
deleted file mode 100644
index 093f3cf..0000000
--- a/proxy/examples/python/README
+++ /dev/null
@@ -1,24 +0,0 @@
-Title: Apache Accumulo Python Example
-Notice:    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.
-
-This is an example python client for the accumulo proxy. After launching the proxy server,
You should be able to run it by typing:
-
-
-PYTHONPATH=path/to/generated/api:path/to/thrift/libs python TestClient.py
-
-As a warning, this script will create a table in your accumulo instance and add a few cells
to it.

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2a92a1d4/proxy/examples/python/TestClient.py
----------------------------------------------------------------------
diff --git a/proxy/examples/python/TestClient.py b/proxy/examples/python/TestClient.py
deleted file mode 100644
index f104387..0000000
--- a/proxy/examples/python/TestClient.py
+++ /dev/null
@@ -1,47 +0,0 @@
-#! /usr/bin/env python
-
-# 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.
-
-import sys
-
-from thrift import Thrift
-from thrift.transport import TSocket
-from thrift.transport import TTransport
-from thrift.protocol import TCompactProtocol
-
-from accumulo import AccumuloProxy
-from accumulo.ttypes import *
-
-transport = TSocket.TSocket('localhost', 42424)
-transport = TTransport.TFramedTransport(transport)
-protocol = TCompactProtocol.TCompactProtocol(transport)
-client = AccumuloProxy.Client(protocol)
-transport.open()
-
-login = client.login('root', {'password':'secret'})
-
-print client.listTables(login)
-
-testtable = "pythontest"
-if not client.tableExists(login, testtable):
-    client.createTable(login, testtable, True, TimeType.MILLIS)
-
-row1 = {'a':[ColumnUpdate('a','a',value='value1'), ColumnUpdate('b','b',value='value2')]}
-client.updateAndFlush(login, testtable, row1)
-
-cookie = client.createScanner(login, testtable, None)
-for entry in client.nextK(cookie, 10).results:
-   print entry

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2a92a1d4/proxy/examples/python/TestNamespace.py
----------------------------------------------------------------------
diff --git a/proxy/examples/python/TestNamespace.py b/proxy/examples/python/TestNamespace.py
deleted file mode 100644
index 1e3db5e..0000000
--- a/proxy/examples/python/TestNamespace.py
+++ /dev/null
@@ -1,172 +0,0 @@
-#! /usr/bin/env python
-
-# 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.
-
-from thrift.protocol import TCompactProtocol
-from thrift.transport import TSocket, TTransport
-
-from proxy import AccumuloProxy
-from proxy.ttypes import NamespacePermission, IteratorSetting, IteratorScope, AccumuloException
-
-
-def main():
-    transport = TSocket.TSocket('localhost', 42424)
-    transport = TTransport.TFramedTransport(transport)
-    protocol = TCompactProtocol.TCompactProtocol(transport)
-    client = AccumuloProxy.Client(protocol)
-    transport.open()
-    login = client.login('root', {'password': 'password'})
-
-    client.createLocalUser(login, 'user1', 'password1')
-
-    print client.listNamespaces(login)
-
-    # create a namespace and give the user1 all permissions
-    print 'creating namespace testing'
-    client.createNamespace(login, 'testing')
-    assert client.namespaceExists(login, 'testing')
-    print client.listNamespaces(login)
-
-    print 'testing namespace renaming'
-    client.renameNamespace(login, 'testing', 'testing2')
-    assert not client.namespaceExists(login, 'testing')
-    assert client.namespaceExists(login, 'testing2')
-    client.renameNamespace(login, 'testing2', 'testing')
-    assert not client.namespaceExists(login, 'testing2')
-    assert client.namespaceExists(login, 'testing')
-
-    print 'granting all namespace permissions to user1'
-    for k, v in NamespacePermission._VALUES_TO_NAMES.iteritems():
-        client.grantNamespacePermission(login, 'user1', 'testing', k)
-
-    # make sure the last operation worked
-    for k, v in NamespacePermission._VALUES_TO_NAMES.iteritems():
-        assert client.hasNamespacePermission(login, 'user1', 'testing', k), \
-            'user1 does\'nt have namespace permission %s' % v
-
-    print 'default namespace: ' + client.defaultNamespace()
-    print 'system namespace: ' + client.systemNamespace()
-
-    # grab the namespace properties
-    print 'retrieving namespace properties'
-    props = client.getNamespaceProperties(login, 'testing')
-    assert props and props['table.compaction.major.ratio'] == '3'
-
-    # update a property and verify it is good
-    print 'setting namespace property table.compaction.major.ratio = 4'
-    client.setNamespaceProperty(login, 'testing', 'table.compaction.major.ratio', '4')
-    props = client.getNamespaceProperties(login, 'testing')
-    assert props and props['table.compaction.major.ratio'] == '4'
-
-    print 'retrieving namespace ID map'
-    nsids = client.namespaceIdMap(login)
-    assert nsids and 'accumulo' in nsids
-
-    print 'attaching debug iterator to namespace testing'
-    setting = IteratorSetting(priority=40, name='DebugTheThings',
-                              iteratorClass='org.apache.accumulo.core.iterators.DebugIterator',
properties={})
-    client.attachNamespaceIterator(login, 'testing', setting, [IteratorScope.SCAN])
-    setting = client.getNamespaceIteratorSetting(login, 'testing', 'DebugTheThings', IteratorScope.SCAN)
-    assert setting and setting.name == 'DebugTheThings'
-
-    # make sure the iterator is in the list
-    iters = client.listNamespaceIterators(login, 'testing')
-    found = False
-    for name, scopes in iters.iteritems():
-        if name == 'DebugTheThings':
-            found = True
-            break
-    assert found
-
-    print 'checking for iterator conflicts'
-
-    # this next statment should be fine since we are on a different scope
-    client.checkNamespaceIteratorConflicts(login, 'testing', setting, [IteratorScope.MINC])
-
-    # this time it should throw an exception since we have already added the iterator with
this scope
-    try:
-        client.checkNamespaceIteratorConflicts(login, 'testing', setting, [IteratorScope.SCAN,
IteratorScope.MINC])
-    except AccumuloException:
-        pass
-    else:
-        assert False, 'There should have been a namespace iterator conflict!'
-
-    print 'removing debug iterator from namespace testing'
-    client.removeNamespaceIterator(login, 'testing', 'DebugTheThings', [IteratorScope.SCAN])
-
-    # make sure the iterator is NOT in the list anymore
-    iters = client.listNamespaceIterators(login, 'testing')
-    found = False
-    for name, scopes in iters.iteritems():
-        if name == 'DebugTheThings':
-            found = True
-            break
-    assert not found
-
-    print 'adding max mutation size namespace constraint'
-    constraintid = client.addNamespaceConstraint(login, 'testing',
-                                                 'org.apache.accumulo.test.constraints.MaxMutationSize')
-
-    print 'make sure constraint was added'
-    constraints = client.listNamespaceConstraints(login, 'testing')
-    found = False
-    for name, cid in constraints.iteritems():
-        if cid == constraintid and name == 'org.apache.accumulo.test.constraints.MaxMutationSize':
-            found = True
-            break
-    assert found
-
-    print 'remove max mutation size namespace constraint'
-    client.removeNamespaceConstraint(login, 'testing', constraintid)
-
-    print 'make sure constraint was removed'
-    constraints = client.listNamespaceConstraints(login, 'testing')
-    found = False
-    for name, cid in constraints.iteritems():
-        if cid == constraintid and name == 'org.apache.accumulo.test.constraints.MaxMutationSize':
-            found = True
-            break
-    assert not found
-
-    print 'test a namespace class load of the VersioningIterator'
-    res = client.testNamespaceClassLoad(login, 'testing', 'org.apache.accumulo.core.iterators.user.VersioningIterator',
-                                        'org.apache.accumulo.core.iterators.SortedKeyValueIterator')
-    assert res
-
-    print 'test a bad namespace class load of the VersioningIterator'
-    res = client.testNamespaceClassLoad(login, 'testing', 'org.apache.accumulo.core.iterators.user.VersioningIterator',
-                                        'dummy')
-    assert not res
-
-    # revoke the permissions
-    print 'revoking namespace permissions for user1'
-    for k, v in NamespacePermission._VALUES_TO_NAMES.iteritems():
-        client.revokeNamespacePermission(login, 'user1', 'testing', k)
-
-    # make sure the last operation worked
-    for k, v in NamespacePermission._VALUES_TO_NAMES.iteritems():
-        assert not client.hasNamespacePermission(login, 'user1', 'testing', k), \
-            'user1 does\'nt have namespace permission %s' % v
-
-    print 'deleting namespace testing'
-    client.deleteNamespace(login, 'testing')
-    assert not client.namespaceExists(login, 'testing')
-
-    print 'deleting user1'
-    client.dropLocalUser(login, 'user1')
-
-if __name__ == "__main__":
-    main()

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2a92a1d4/proxy/examples/ruby/README
----------------------------------------------------------------------
diff --git a/proxy/examples/ruby/README b/proxy/examples/ruby/README
deleted file mode 100644
index 1b616b0..0000000
--- a/proxy/examples/ruby/README
+++ /dev/null
@@ -1,26 +0,0 @@
-Title: Apache Accumulo Ruby Example
-Notice:    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.
-
-This directory contains the compiled thrift Accumulo proxy API and an example client for
ruby.
-
-To run this script, type the following:
-ruby -I . test_client.rb <host of server>
-
-(the -I option is needed for ruby 1.9.x)
-
-Warning: the script as it is will attempt to connect to your accumulo instance, create a
table, and add some rows to it.

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2a92a1d4/proxy/examples/ruby/test_client.rb
----------------------------------------------------------------------
diff --git a/proxy/examples/ruby/test_client.rb b/proxy/examples/ruby/test_client.rb
deleted file mode 100644
index 6310a2f..0000000
--- a/proxy/examples/ruby/test_client.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-
-# 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.
-
-require 'rubygems'
-require 'thrift'
-require 'accumulo_proxy'
-
-server = ARGV[0] || 'localhost'
-
-socket = Thrift::Socket.new(server, 42424, 9001)
-transport = Thrift::FramedTransport.new(socket)
-proto = Thrift::CompactProtocol.new(transport)
-proxy = Accumulo::AccumuloProxy::Client.new(proto)
-
-# open up the connect
-transport.open()
-
-# Test if the server is up
-login = proxy.login('root', {'password' => 'secret'})
-
-# print out a table list
-puts "List of tables: #{proxy.listTables(login).inspect}"
-
-testtable = "rubytest"
-proxy.createTable(login, testtable, true, Accumulo::TimeType::MILLIS) unless proxy.tableExists(login,testtable)

-
-update1 = Accumulo::ColumnUpdate.new({'colFamily' => "cf1", 'colQualifier' => "cq1",
'value'=> "a"})
-update2 = Accumulo::ColumnUpdate.new({'colFamily' => "cf2", 'colQualifier' => "cq2",
'value'=> "b"})
-proxy.updateAndFlush(login,testtable,{'row1' => [update1,update2]})
-
-cookie = proxy.createScanner(login,testtable,nil)
-result = proxy.nextK(cookie,10)
-result.results.each{ |keyvalue| puts "Key: #{keyvalue.key.inspect} Value: #{keyvalue.value}"
}
-
-transport.close()

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2a92a1d4/proxy/proxy.properties
----------------------------------------------------------------------
diff --git a/proxy/proxy.properties b/proxy/proxy.properties
index 6a38c43..e6f3d2d 100644
--- a/proxy/proxy.properties
+++ b/proxy/proxy.properties
@@ -13,12 +13,16 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+# Accumulo instance name
+instance=test
+# List of Zookeepers
+zookeepers=localhost:2181
+# Port to run proxy on
+port=42424
+# Set to true if you wish to an in-memory Mock instance
 useMockInstance=false
+# Set to true if you wish to use an Mini Accumulo Cluster
 useMiniAccumulo=false
 protocolFactory=org.apache.thrift.protocol.TCompactProtocol$Factory
 tokenClass=org.apache.accumulo.core.client.security.tokens.PasswordToken
-port=42424
 maxFrameSize=16M
-
-instance=test
-zookeepers=localhost:2181

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2a92a1d4/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java
----------------------------------------------------------------------
diff --git a/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java b/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java
index 438e0d3..a9919a7 100644
--- a/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java
+++ b/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java
@@ -103,7 +103,7 @@ public class Proxy implements KeywordExecutable {
   }
 
   public static class Opts extends Help {
-    @Parameter(names = "-p", required = true, description = "properties file name", converter
= PropertiesConverter.class)
+    @Parameter(names = "-p", description = "properties file name", converter = PropertiesConverter.class)
     Properties prop;
   }
 
@@ -127,10 +127,25 @@ public class Proxy implements KeywordExecutable {
     Opts opts = new Opts();
     opts.parseArgs(Proxy.class.getName(), args);
 
-    boolean useMini = Boolean.parseBoolean(opts.prop.getProperty(USE_MINI_ACCUMULO_KEY, USE_MINI_ACCUMULO_DEFAULT));
-    boolean useMock = Boolean.parseBoolean(opts.prop.getProperty(USE_MOCK_INSTANCE_KEY, USE_MOCK_INSTANCE_DEFAULT));
-    String instance = opts.prop.getProperty(ACCUMULO_INSTANCE_NAME_KEY);
-    String zookeepers = opts.prop.getProperty(ZOOKEEPERS_KEY);
+    Properties props = new Properties();
+    if (opts.prop != null) {
+      props = opts.prop;
+    } else {
+      try (InputStream is = this.getClass().getClassLoader().getResourceAsStream("proxy.properties"))
{
+        if (is != null) {
+          props.load(is);
+        } else {
+          System.err.println("proxy.properties needs to be specified as argument (using -p)
or on "
+                             + "the classpath (by putting the file in conf/)");
+          System.exit(-1);
+        }
+      }
+    }
+
+    boolean useMini = Boolean.parseBoolean(props.getProperty(USE_MINI_ACCUMULO_KEY, USE_MINI_ACCUMULO_DEFAULT));
+    boolean useMock = Boolean.parseBoolean(props.getProperty(USE_MOCK_INSTANCE_KEY, USE_MOCK_INSTANCE_DEFAULT));
+    String instance = props.getProperty(ACCUMULO_INSTANCE_NAME_KEY);
+    String zookeepers = props.getProperty(ZOOKEEPERS_KEY);
 
     if (!useMini && !useMock && instance == null) {
       System.err.println("Properties file must contain one of : useMiniAccumulo=true, useMockInstance=true,
or instance=<instance name>");
@@ -142,7 +157,7 @@ public class Proxy implements KeywordExecutable {
       System.exit(1);
     }
 
-    if (!opts.prop.containsKey("port")) {
+    if (!props.containsKey("port")) {
       System.err.println("No port property");
       System.exit(1);
     }
@@ -152,8 +167,8 @@ public class Proxy implements KeywordExecutable {
       final File folder = Files.createTempDir();
       final MiniAccumuloCluster accumulo = new MiniAccumuloCluster(folder, "secret");
       accumulo.start();
-      opts.prop.setProperty("instance", accumulo.getConfig().getInstanceName());
-      opts.prop.setProperty("zookeepers", accumulo.getZooKeepers());
+      props.setProperty("instance", accumulo.getConfig().getInstanceName());
+      props.setProperty("zookeepers", accumulo.getZooKeepers());
       Runtime.getRuntime().addShutdownHook(new Thread() {
         @Override
         public void start() {
@@ -169,13 +184,13 @@ public class Proxy implements KeywordExecutable {
       });
     }
 
-    Class<? extends TProtocolFactory> protoFactoryClass = Class.forName(opts.prop.getProperty("protocolFactory",
TCompactProtocol.Factory.class.getName()))
+    Class<? extends TProtocolFactory> protoFactoryClass = Class.forName(props.getProperty("protocolFactory",
TCompactProtocol.Factory.class.getName()))
         .asSubclass(TProtocolFactory.class);
     TProtocolFactory protoFactory = protoFactoryClass.newInstance();
-    int port = Integer.parseInt(opts.prop.getProperty("port"));
-    String hostname = opts.prop.getProperty(THRIFT_SERVER_HOSTNAME, THRIFT_SERVER_HOSTNAME_DEFAULT);
+    int port = Integer.parseInt(props.getProperty("port"));
+    String hostname = props.getProperty(THRIFT_SERVER_HOSTNAME, THRIFT_SERVER_HOSTNAME_DEFAULT);
     HostAndPort address = HostAndPort.fromParts(hostname, port);
-    ServerAddress server = createProxyServer(address, protoFactory, opts.prop);
+    ServerAddress server = createProxyServer(address, protoFactory, props);
     // Wait for the server to come up
     while (!server.server.isServing()) {
       Thread.sleep(100);


Mime
View raw message