Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Accumulo, mail # user - POM dependencies for an Accumulo Client


Copy link to this message
-
Re: POM dependencies for an Accumulo Client
Billie Rinaldi 2013-05-29, 17:45
On Wed, May 29, 2013 at 10:29 AM, Aaron <[EMAIL PROTECTED]> wrote:

> Wow..so, I made you copy a bunch of unnecessary things.  I wrote a bunch
> of simple unit tests, and came up with a minimal set of dependancies:
>
>  <dependencies>
>
> <dependency>
>
> <groupId>log4j</groupId>
>
> <artifactId>log4j</artifactId>
>
> <version>1.2.17</version>
>
> </dependency>
>
> <dependency>
>
> <groupId>org.apache.accumulo</groupId>
>
> <artifactId>accumulo-core</artifactId>
>
> <version>${accumulo.version}</version>
>
> </dependency>
>
> <dependency>
>
> <groupId>org.apache.hadoop</groupId>
>
> <artifactId>hadoop-common</artifactId>
>
> <version>${hadoop.version}</version>
>
> </dependency>
>

hadoop-common doesn't exist for hadoop 1.  hadoop-client exists for hadoop
1 and 2.  You may need additional dependencies if you use it instead (such
as commons-httpclient).

Billie
>  <dependency>
>
> <groupId>junit</groupId>
>
> <artifactId>junit</artifactId>
>
> <version>4.11</version>
>
> <scope>test</scope>
>
> </dependency>
>
> The accumulo-core & hadoop-common pull is all the necessary extras like
> zookeeper, and the other accumulo artifacts. Below is my simple Unit tests.
>
> public class CRUDTest
>
> {
>
> private static final Logger log = Logger.getLogger(CRUDTest.class);
>
>  private static final String zookeeperHost = "172.100.100.101";
>
> private static final String instanceName = "testinstance";
>
> private static final String root = "root";
>
> private static final String pass = "accumulopass";
>
>
>  private static final String tableName = "testtable";
>
> private static final String testuser = "testuser";
>
> private static final String testpass = "testpass";
>
> private static final String auths = "testauth";
>
>  private Instance instance;
>
> private Connector testUserConn;
>
>  @Before
>
> public void setup()
>
> {
>
> this.instance = new ZooKeeperInstance(instanceName, zookeeperHost, 20000);
>
> try
>
> {
>
> Connector rootConn = instance.getConnector(root, new PasswordToken(pass));
>
> log.info("Have the connector");
>
>  TableOperations tableOps = rootConn.tableOperations();
>
> if (!tableOps.exists(tableName))
>
> tableOps.create(tableName);
>
>  // Make sure our user has the proper permissions/auths
>
> SecurityOperations securOps = rootConn.securityOperations();
>
> securOps.createLocalUser(testuser, new PasswordToken(testpass));
>
> securOps.changeUserAuthorizations(testuser, new Authorizations(auths));
>
> securOps.grantTablePermission(testuser, tableName, TablePermission.WRITE);
>
> securOps.grantTablePermission(testuser, tableName, TablePermission.READ);
>
>
>  this.testUserConn = instance.getConnector(testuser, new PasswordToken(
> testpass));
>
> }
>
> catch (AccumuloException | AccumuloSecurityException |
> TableExistsException e)
>
> {
>
> e.printStackTrace();
>
> }
>
> }
>
>  @After
>
> public void teardown()
>
> {
>
> try
>
> {
>
> Connector rootConn = this.instance.getConnector(root, new PasswordToken(
> pass));
>
> TableOperations tableOps = rootConn.tableOperations();
>
> SecurityOperations securOps =rootConn.securityOperations();
>
>
>  tableOps.delete(tableName);
>
> securOps.dropLocalUser(testuser);
>
> }
>
> catch (AccumuloException | AccumuloSecurityException |
> TableNotFoundException e)
>
> {
>
> e.printStackTrace();
>
> }
>
> }
>
>
>  @Test
>
> public void testSimpleCreate()
>
> {
>
> String rowId = UUID.randomUUID().toString();
>
> Text rowID = new Text (rowId);
>
> Text colFam = new Text("myColFam");
>
> Text colQual = new Text("myColQual");
>
> ColumnVisibility vis = new ColumnVisibility(auths);
>
>  String strValue = UUID.randomUUID().toString();
>
> log.info("strValue = " + strValue);
>
> Value value = new Value(strValue.getBytes());
>
>  Mutation mutation= new Mutation(rowID);
>
> mutation.put(colFam,  colQual,  vis, System.currentTimeMillis(), value);
>
>  BatchWriterConfig config = new BatchWriterConfig();
>
> try
>
> {
>
> BatchWriter writer = this.testUserConn.createBatchWriter(tableName,