accumulo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Billie Rinaldi <billie.rina...@gmail.com>
Subject Re: POM dependencies for an Accumulo Client
Date Wed, 29 May 2013 17:45:08 GMT
On Wed, May 29, 2013 at 10:29 AM, Aaron <aarongmldt@gmail.com> 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,
> config);
>
> writer.addMutation(mutation);
>
> writer.flush();
>
> writer.close();
>
>  // Now let's see if we can see it
>
> Scanner scan = this.testUserConn.createScanner(tableName, newAuthorizations(
> auths));
>
> Range range = new Range(rowId);
>
> scan.setRange(range);
>
> scan.fetchColumnFamily(colFam);
>
>  for(Entry<Key,Value> entry : scan)
>
> {
>
> log.info("key = " + entry.getKey().toString());
>
> log.info("value = " + entry.getValue().toString());
>
> Assert.assertTrue(strValue.equals(entry.getValue().toString()));
>
> }
>
>  scan.close();
>
> }
>
> catch (TableNotFoundException | MutationsRejectedException e)
>
> {
>
> e.printStackTrace();
>
> }
>
> }
>
>  @Test
>
> public void testSimpleUpdate()
>
> {
>
> Text rowID = new Text ("rowid_update");
>
> 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 origMutation= new Mutation(rowID);
>
> origMutation.put(colFam,  colQual,  vis, System.currentTimeMillis(),
> value);
>
>  BatchWriterConfig config = new BatchWriterConfig();
>
> try
>
> {
>
> BatchWriter writer = this.testUserConn.createBatchWriter(tableName,
> config);
>
>
>  // Add the entry to be modified
>
> writer.addMutation(origMutation);
>
> writer.flush();
>
>  // Now let's change the value/timestamp
>
> Mutation updateMutation= new Mutation(rowID);
>
> updateMutation.put(colFam, colQual, vis, System.currentTimeMillis(),
>
> new Value(UUID.randomUUID().toString().getBytes()));
>
> writer.addMutation(updateMutation);
>
> writer.flush();
>
> writer.close();
>
>  // Now let's see if we can see it
>
> Scanner scan = this.testUserConn.createScanner(tableName, newAuthorizations(
> auths));
>
> Range range = new Range(rowID);
>
> scan.setRange(range);
>
> scan.fetchColumnFamily(colFam);
>
>  for(Entry<Key,Value> entry : scan)
>
> {
>
> log.info("key = " + entry.getKey().toString());
>
> log.info("value = " + entry.getValue().toString());
>
> Assert.assertFalse(strValue.equals(entry.getValue().toString()));
>
> }
>
>  scan.close();
>
> }
>
> catch (TableNotFoundException | MutationsRejectedException e)
>
> {
>
> e.printStackTrace();
>
> }
>
> }
>
>  @Test
>
> public void testSimpleDelete()
>
> {
>
> Text rowID = new Text ("rowid_delete");
>
> Text colFam = new Text("myColFam");
>
> Text colQual = new Text("myColQual");
>
> ColumnVisibility vis = new ColumnVisibility("public");
>
>  String strValue = UUID.randomUUID().toString();
>
> log.info("strValue = " + strValue);
>
> Value value = new Value(strValue.getBytes());
>
>  BatchWriterConfig config = new BatchWriterConfig();
>
> try
>
> {
>
> BatchWriter writer = this.testUserConn.createBatchWriter(tableName,
> config);
>
>
>  // Add the entry to be modified
>
> Mutation origMutation= new Mutation(rowID);
>
> origMutation.put(colFam,  colQual,  vis, System.currentTimeMillis(),
> value);
>
> writer.addMutation(origMutation);
>
> writer.flush();
>
>  // Now let's see if we can see it
>
> Scanner scan = this.testUserConn.createScanner(tableName, newAuthorizations(
> auths));
>
> Range range = new Range(rowID);
>
> scan.setRange(range);
>
> scan.fetchColumnFamily(colFam);
>
> for(Entry<Key,Value> entry : scan)
>
> {
>
> log.info("key = " + entry.getKey().toString());
>
> log.info("value = " + entry.getValue().toString());
>
> Assert.assertTrue(strValue.equals(entry.getValue().toString()));
>
> }
>
>
>  // Delete it
>
> BatchDeleter deleter = this.testUserConn.createBatchDeleter(tableName, newAuthorizations(
> auths), 1, config);
>
> List<Range> ranges = Arrays.asList(new Range(rowID));
>
> deleter.setRanges(ranges);
>
> deleter.delete();
>
>
>  scan.fetchColumnFamily(colFam);
>
> for(Entry<Key,Value> entry : scan)
>
> {
>
> log.info("key = " + entry.getKey().toString());
>
> log.info("value = " + entry.getValue().toString());
>
> }
>
>  scan.close();
>
> }
>
> catch (TableNotFoundException | MutationsRejectedException e)
>
> {
>
> e.printStackTrace();
>
> }
>
> }
>
> }
>
>
>
> On Tue, May 28, 2013 at 9:38 PM, albertoaflores <aaflores@gmail.com>wrote:
>
>> Thanks Aaron, I'll give these a shot...
>>
>>
>>
>> --
>> View this message in context:
>> http://apache-accumulo.1065345.n5.nabble.com/POM-dependencies-for-an-Accumulo-Client-tp4182p4355.html
>> Sent from the Users mailing list archive at Nabble.com.
>>
>
>

Mime
View raw message