Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use AccumuloClient instead of deprecated Connector #2502

Merged
merged 3 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private void setupMockAccumuloUser(ConnectionPoolProperties conf, AccumuloClient
PasswordToken password = new PasswordToken(new byte[0]);
if (pair != null && user.equals(pair.getFirst()))
password = pair.getSecond();
SecurityOperations security = cache.getInstance().getConnector(user, password).securityOperations();
SecurityOperations security = new InMemoryAccumuloClient(user, cache.getInstance()).securityOperations();
Set<String> users = security.listLocalUsers();
if (!users.contains(conf.getUsername())) {
security.createLocalUser(conf.getUsername(), new PasswordToken(conf.getPassword()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.junit.Before;
import org.junit.Test;

import datawave.accumulo.inmemory.InMemoryAccumuloClient;
import datawave.accumulo.inmemory.InMemoryInstance;

public class MetricsTableConfigHelperTest {
Expand All @@ -31,7 +32,7 @@ public class MetricsTableConfigHelperTest {

@Before
public void setUp() throws Exception {
tops = new InMemoryInstance().getConnector("user", new PasswordToken("pass")).tableOperations();
tops = new InMemoryAccumuloClient("root", new InMemoryInstance()).tableOperations();

String tableName = MetricsConfiguration.getTable(conf);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
import java.util.TreeSet;
import java.util.concurrent.TimeUnit;

import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.BatchWriter;
import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.IteratorSetting;
import org.apache.accumulo.core.client.MutationsRejectedException;
import org.apache.accumulo.core.client.Scanner;
Expand All @@ -27,6 +27,7 @@
import org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator;
import org.apache.accumulo.core.security.Authorizations;
import org.apache.accumulo.core.security.ColumnVisibility;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.ArrayWritable;
import org.apache.hadoop.io.DataInputBuffer;
import org.apache.hadoop.io.Writable;
Expand All @@ -36,7 +37,9 @@
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;

import datawave.accumulo.inmemory.InMemoryAccumuloClient;
import datawave.accumulo.inmemory.InMemoryInstance;
import datawave.ingest.data.config.ingest.AccumuloHelper;
import datawave.ingest.protobuf.Uid;
import datawave.query.iterator.SourceManagerTest;

Expand All @@ -45,10 +48,12 @@ public class DiscoveryIteratorTest {

@Test
public void testHappyPath() throws Throwable {
Connector con = new InMemoryInstance("DiscoveryIteratorTest").getConnector("root", new PasswordToken(""));
con.tableOperations().create("index");
writeSample(con.createBatchWriter("index", new BatchWriterConfig().setMaxLatency(0, TimeUnit.SECONDS).setMaxMemory(0).setMaxWriteThreads(1)));
Scanner s = con.createScanner("index", new Authorizations("FOO"));
InMemoryInstance instance = new InMemoryInstance("DiscoveryIteratorTest");
AccumuloClient client = new InMemoryAccumuloClient("root", instance);

client.tableOperations().create("index");
writeSample(client.createBatchWriter("index", new BatchWriterConfig().setMaxLatency(0, TimeUnit.SECONDS).setMaxMemory(0).setMaxWriteThreads(1)));
Scanner s = client.createScanner("index", new Authorizations("FOO"));
s.addScanIterator(new IteratorSetting(50, DiscoveryIterator.class));
s.setRange(new Range());

Expand Down Expand Up @@ -203,11 +208,13 @@ public void testZeroAndNegative() throws Throwable {

@Test
public void testReverseIndex() throws Throwable {
Connector con = new InMemoryInstance("DiscoveryIteratorTest").getConnector("root", new PasswordToken(""));
con.tableOperations().create("reverseIndex");
writeSample(con.createBatchWriter("reverseIndex", new BatchWriterConfig().setMaxLatency(0, TimeUnit.SECONDS).setMaxMemory(0).setMaxWriteThreads(1)),
InMemoryInstance instance = new InMemoryInstance("DiscoveryIteratorTest");
AccumuloClient client = new InMemoryAccumuloClient("root", instance);

client.tableOperations().create("reverseIndex");
writeSample(client.createBatchWriter("reverseIndex", new BatchWriterConfig().setMaxLatency(0, TimeUnit.SECONDS).setMaxMemory(0).setMaxWriteThreads(1)),
true);
Scanner s = con.createScanner("reverseIndex", new Authorizations("FOO"));
Scanner s = client.createScanner("reverseIndex", new Authorizations("FOO"));
IteratorSetting setting = new IteratorSetting(50, DiscoveryIterator.class);
setting.addOption(DiscoveryLogic.REVERSE_INDEX, "true");
s.addScanIterator(setting);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import java.util.Set;

import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Value;
import org.apache.log4j.Logger;
Expand Down
Loading