Skip to content
Permalink
Browse files
Fixes #5 Create tarball with scripts for running proxy (#9)
  • Loading branch information
mikewalch committed Nov 12, 2019
1 parent bb1e646 commit 7a74561253313562ad8fbe256d3588bbb456b010
Showing 8 changed files with 308 additions and 18 deletions.
@@ -24,6 +24,23 @@ an Apache [Thrift] service so that users can use their preferred programming
language to communicate with Accumulo (provided that language has a supported
Thrift language binding).

# Running the Accumulo proxy

1. Build the proxy tarball and install it.

```
cd /path/to/accumulo-proxy
mvn clean package -Ptarball
tar xzvf ./target/accumulo-proxy-2.0.0-SNAPSHOT-bin.tar.gz -C /path/to/install
```

2. Edit `proxy.properties` and `accumulo-client.properties` and run the proxy.

```
cd /path/to/install/accumulo-proxy-2.0.0-SNAPSHOT
./bin/accumulo-proxy -p conf/proxy.properties -c $ACCUMULO_HOME/conf/accumulo-client.properties
```

[accumulo]: https://accumulo.apache.org
[Thrift]: https://thrift.apache.org
[li]: https://img.shields.io/badge/license-ASL-blue.svg
25 pom.xml
@@ -662,6 +662,31 @@
</plugins>
</build>
<profiles>
<profile>
<id>tarball</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>binary-assembly</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
<configuration>
<descriptors>
<descriptor>src/main/assemble/binary-release.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>thrift</id>
<build>
@@ -1,3 +1,5 @@
#! /usr/bin/env bash

# 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.
@@ -13,10 +15,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Port to run proxy on
port=42424
# 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
maxFrameSize=16M
BIN_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

cd $BIN_DIR/..

. conf/proxy-env.sh

java org.apache.accumulo.proxy.Proxy "${@}"
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>bin</id>
<formats>
<format>tar.gz</format>
</formats>
<componentDescriptors>
<componentDescriptor>src/main/assemble/component.xml</componentDescriptor>
</componentDescriptors>
</assembly>
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<component xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/component/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/component/1.1.2 http://maven.apache.org/xsd/component-1.1.2.xsd">
<dependencySets>
<dependencySet>
<outputDirectory>lib</outputDirectory>
<directoryMode>0755</directoryMode>
<fileMode>0644</fileMode>
<useProjectArtifact>true</useProjectArtifact>
<useTransitiveDependencies>false</useTransitiveDependencies>
<includes>
<!-- if you update this list, you should also update the assembly
pom.xml section which executes the maven-dependency-plugin to generate a
version listing for packaged artifacts -->
<include>${groupId}:${artifactId}</include>
<include>com.google.guava:guava</include>
<include>commons-lang:commons-lang</include>
<include>org.apache.thrift:libthrift</include>
<include>org.slf4j:slf4j-api</include>
<include>org.slf4j:slf4j-log4j12</include>
</includes>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<outputDirectory>bin</outputDirectory>
<directory>src/main/assemble/bin</directory>
<directoryMode>0755</directoryMode>
<fileMode>0755</fileMode>
</fileSet>
<fileSet>
<outputDirectory>conf</outputDirectory>
<directory>src/main/assemble/conf</directory>
<directoryMode>0755</directoryMode>
<fileMode>0644</fileMode>
</fileSet>
<fileSet>
<directory>./</directory>
<fileMode>0644</fileMode>
<includes>
<include>README.md</include>
<include>LICENSE</include>
<include>NOTICE</include>
</includes>
</fileSet>
<fileSet>
<outputDirectory>thrift</outputDirectory>
<directory>src/main/thrift</directory>
<directoryMode>0755</directoryMode>
<fileMode>0755</fileMode>
</fileSet>
</fileSets>
</component>
@@ -0,0 +1,22 @@
#! /usr/bin/env bash

# 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.

CONF_DIR=$(readlink -f ./conf)
LIB_DIR=./lib

CLASSPATH="$CONF_DIR:$LIB_DIR/*:$(accumulo classpath)"
export CLASSPATH
@@ -0,0 +1,137 @@
# 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.

###############################
## Accumulo Proxy configuration
###############################

# Port to run proxy on
port=42424
# 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
maxFrameSize=16M

########################################################################

################################
## Accumulo client configuration
################################

## NOTE - All properties that have a default are set with it. Properties that
## are uncommented must be set by the user.

## Instance properties
## --------------
## Name of Accumulo instance to connect to
instance.name=myinstance

## Zookeeper connection information for Accumulo instance
instance.zookeepers=localhost:2181

## Zookeeper session timeout
#instance.zookeepers.timeout=30s


## Authentication properties
## --------------
## Authentication method (i.e password, kerberos, PasswordToken, KerberosToken, etc)
auth.type=password

## Accumulo principal/username for chosen authentication method
auth.principal=root

## Authentication token (ex. mypassword, /path/to/keytab)
auth.token=secret


## Batch Writer properties
## --------------
## The durability used to write to the write-ahead log. Legal values are: none, which skips the write-ahead log; log, which sends the data to the write-ahead log, but does nothing to make it durable; flush, which pushes data to the file system; and sync, which ensures the data is written to disk. Setting this property will change the durability for the BatchWriter session. A value of "default" will use the table's durability setting.
#batch.writer.durability=default

## Max amount of time (in seconds) to hold data in memory before flushing it
#batch.writer.latency.max=120s

## Max memory (in bytes) to batch before writing
#batch.writer.memory.max=50M

## Maximum number of threads to use for writing data to tablet servers.
#batch.writer.threads.max=3

## Max amount of time (in seconds) an unresponsive server will be re-tried. An exception is thrown when this timeout is exceeded. Set to zero for no timeout.
#batch.writer.timeout.max=0


## Batch Scanner properties
## --------------
## Number of concurrent query threads to spawn for querying
#batch.scanner.num.query.threads=3


## Scanner properties
## --------------
## Number of key/value pairs that will be fetched at time from tablet server
#scanner.batch.size=1000


## SSL properties
## --------------
## Enable SSL for client RPC
#ssl.enabled=false

## Password used to encrypt keystore
#ssl.keystore.password=

## Path to SSL keystore file
#ssl.keystore.path=

## Type of SSL keystore
#ssl.keystore.type=jks

## Password used to encrypt truststore
#ssl.truststore.password=

## Path to SSL truststore file
#ssl.truststore.path=

## Type of SSL truststore
#ssl.truststore.type=jks

## Use JSSE system properties to configure SSL
#ssl.use.jsse=false


## SASL properties
## --------------
## Enable SASL for client RPC
#sasl.enabled=false

## Kerberos principal/primary that Accumulo servers use to login
#sasl.kerberos.server.primary=accumulo

## SASL quality of protection. Valid values are 'auth', 'auth-int', and 'auth-conf'
#sasl.qop=auth


## Tracing properties
## --------------
## A list of span receiver classes to send trace spans
#trace.span.receivers=org.apache.accumulo.tracer.ZooTraceClient

## The zookeeper node where tracers are registered
#trace.zookeeper.path=/tracers

@@ -101,12 +101,9 @@ public Properties convert(String fileName) {
}

public static class Opts extends Help {
@Parameter(names = "-p", description = "proxy.properties path",
@Parameter(names = "-p", description = "proxy.properties path", required = true,
converter = PropertiesConverter.class)
Properties proxyProps;
@Parameter(names = "-c", description = "accumulo-client.properties path",
converter = PropertiesConverter.class)
Properties clientProps;
}

@Override
@@ -131,7 +128,6 @@ public void execute(final String[] args) throws Exception {
opts.parseArgs(Proxy.class.getName(), args);

Properties proxyProps = opts.proxyProps;
Properties clientProps = opts.clientProps;

boolean useMini = Boolean
.parseBoolean(proxyProps.getProperty(USE_MINI_ACCUMULO_KEY, USE_MINI_ACCUMULO_DEFAULT));
@@ -146,7 +142,7 @@ public void execute(final String[] args) throws Exception {
final File folder = Files.createTempDirectory(System.currentTimeMillis() + "").toFile();
final MiniAccumuloCluster accumulo = new MiniAccumuloCluster(folder, "secret");
accumulo.start();
clientProps = accumulo.getClientProperties();
proxyProps.putAll(accumulo.getClientProperties());
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
try {
accumulo.stop();
@@ -158,10 +154,6 @@ public void execute(final String[] args) throws Exception {
}
}
}));
} else if (clientProps == null) {
System.err.println("The '-c' option must be set with an accumulo-client.properties file or"
+ " proxy.properties must contain either useMiniAccumulo=true");
System.exit(1);
}

Class<? extends TProtocolFactory> protoFactoryClass = Class
@@ -173,7 +165,6 @@ public void execute(final String[] args) throws Exception {
String hostname = proxyProps.getProperty(THRIFT_SERVER_HOSTNAME,
THRIFT_SERVER_HOSTNAME_DEFAULT);
HostAndPort address = HostAndPort.fromParts(hostname, port);
proxyProps.putAll(clientProps);
ServerAddress server = createProxyServer(address, protoFactory, proxyProps);
// Wait for the server to come up
while (!server.server.isServing()) {

0 comments on commit 7a74561

Please sign in to comment.