Skip to content
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 @@ -80,6 +80,10 @@ public static Set<TableId> tableIds() {
return ALL_IDS;
}

public static Set<String> tableNames() {
return ALL_NAMES;
}

public static boolean containsTableId(TableId tableId) {
return ALL_IDS.contains(tableId);
}
Expand Down

Large diffs are not rendered by default.

44 changes: 17 additions & 27 deletions test/src/main/java/org/apache/accumulo/test/ImportExportIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,7 @@ private void doExportImportThenScan(boolean fenced, AccumuloClient client, Strin
// Make a directory we can use to throw the export and import directories
// Must exist on the filesystem the cluster is running.
FileSystem fs = cluster.getFileSystem();
log.info("Using FileSystem: " + fs);
Path baseDir = new Path(cluster.getTemporaryPath(), getClass().getName());
fs.deleteOnExit(baseDir);
if (fs.exists(baseDir)) {
log.info("{} exists on filesystem, deleting", baseDir);
assertTrue(fs.delete(baseDir, true), "Failed to deleted " + baseDir);
}
log.info("Creating {}", baseDir);
assertTrue(fs.mkdirs(baseDir), "Failed to create " + baseDir);
Path baseDir = createBaseDir(cluster, getClass());
Path exportDir = new Path(baseDir, "export");
fs.deleteOnExit(exportDir);
Path importDirA = new Path(baseDir, "import-a");
Expand Down Expand Up @@ -287,15 +279,7 @@ public void testExportImportOffline(boolean fenced) throws Exception {

// Make export and import directories
FileSystem fs = cluster.getFileSystem();
log.info("Using FileSystem: " + fs);
Path baseDir = new Path(cluster.getTemporaryPath(), getClass().getName());
fs.deleteOnExit(baseDir);
if (fs.exists(baseDir)) {
log.info("{} exists on filesystem, deleting", baseDir);
assertTrue(fs.delete(baseDir, true), "Failed to deleted " + baseDir);
}
log.info("Creating {}", baseDir);
assertTrue(fs.mkdirs(baseDir), "Failed to create " + baseDir);
Path baseDir = createBaseDir(cluster, getClass());
Path exportDir = new Path(baseDir, "export");
fs.deleteOnExit(exportDir);
Path importDirA = new Path(baseDir, "import-a");
Expand Down Expand Up @@ -457,15 +441,7 @@ public void testImportedTableIsOnDemand() throws Exception {
// Make a directory we can use to throw the export and import directories
// Must exist on the filesystem the cluster is running.
FileSystem fs = cluster.getFileSystem();
log.info("Using FileSystem: " + fs);
Path baseDir = new Path(cluster.getTemporaryPath(), getClass().getName());
fs.deleteOnExit(baseDir);
if (fs.exists(baseDir)) {
log.info("{} exists on filesystem, deleting", baseDir);
assertTrue(fs.delete(baseDir, true), "Failed to deleted " + baseDir);
}
log.info("Creating {}", baseDir);
assertTrue(fs.mkdirs(baseDir), "Failed to create " + baseDir);
Path baseDir = createBaseDir(cluster, getClass());
Path exportDir = new Path(baseDir, "export");
fs.deleteOnExit(exportDir);
Path importDirA = new Path(baseDir, "import-a");
Expand Down Expand Up @@ -641,4 +617,18 @@ private Set<Range> createRanges() {
new Range("row_" + String.format("%010d", 699), false, "row_" + String.format("%010d", 749),
true));
}

public static Path createBaseDir(AccumuloCluster cluster, Class<?> clazz) throws IOException {
FileSystem fs = cluster.getFileSystem();
log.info("Using FileSystem: " + fs);
Path baseDir = new Path(cluster.getTemporaryPath(), clazz.getName());
fs.deleteOnExit(baseDir);
if (fs.exists(baseDir)) {
log.info("{} exists on filesystem, deleting", baseDir);
assertTrue(fs.delete(baseDir, true), "Failed to deleted " + baseDir);
}
log.info("Creating {}", baseDir);
assertTrue(fs.mkdirs(baseDir), "Failed to create " + baseDir);
return baseDir;
}
}
3 changes: 2 additions & 1 deletion test/src/main/java/org/apache/accumulo/test/MetaSplitIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,13 @@ public void restoreMetadataSplits() throws Exception {
}

@Test
public void testRootTableSplit() {
public void testRootTableSplit() throws Exception {
try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) {
SortedSet<Text> splits = new TreeSet<>();
splits.add(new Text("5"));
assertThrows(AccumuloException.class,
() -> client.tableOperations().addSplits(SystemTables.ROOT.tableName(), splits));
assertTrue(client.tableOperations().listSplits(SystemTables.ROOT.tableName()).isEmpty());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public static void teardown() {
private static final Map<String,String> OPTIONS_2 =
Map.of("hasher", "murmur3_32", "modulus", "997");

private static final SamplerConfiguration SC1 =
public static final SamplerConfiguration SC1 =
new SamplerConfiguration(RowSampler.class.getName()).setOptions(OPTIONS_1);
private static final SamplerConfiguration SC2 =
new SamplerConfiguration(RowSampler.class.getName()).setOptions(OPTIONS_2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.accumulo.test.functional;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand Down Expand Up @@ -358,18 +359,18 @@ public void testCloneWithSplits() throws Exception {
}

@Test
public void testCloneRootTable() {
public void testCloneSystemTables() {
try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) {
assertThrows(AccumuloException.class, () -> client.tableOperations()
.clone(SystemTables.ROOT.tableName(), "rc1", CloneConfiguration.empty()));
}
}

@Test
public void testCloneMetadataTable() {
try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) {
assertThrows(AccumuloException.class, () -> client.tableOperations()
.clone(SystemTables.METADATA.tableName(), "mc1", CloneConfiguration.empty()));
var sysTables = SystemTables.values();
var tableNames = getUniqueNames(sysTables.length);

for (int i = 0; i < sysTables.length; i++) {
var sysTable = sysTables[i];
var cloneTableName = tableNames[i];
assertThrows(Exception.class, () -> client.tableOperations().clone(sysTable.tableName(),
cloneTableName, CloneConfiguration.empty()));
assertFalse(client.tableOperations().exists(cloneTableName));
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import static org.apache.accumulo.test.functional.ReadWriteIT.m;
import static org.apache.accumulo.test.functional.ReadWriteIT.t;
import static org.apache.accumulo.test.functional.ReadWriteIT.verify;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.ByteArrayOutputStream;
Expand Down Expand Up @@ -101,13 +102,25 @@ public void sunnyLG() throws Exception {
try (AccumuloClient accumuloClient = Accumulo.newClient().from(getClientProps()).build()) {
final String tableName = getUniqueNames(1)[0];
accumuloClient.tableOperations().create(tableName);
Map<String,Set<Text>> groups = new TreeMap<>();
groups.put("g1", Collections.singleton(t("colf")));
accumuloClient.tableOperations().setLocalityGroups(tableName, groups);
createAndSetLocalityGroups(accumuloClient, tableName);
verifyLocalityGroupSet(accumuloClient, tableName);
verifyLocalityGroupsInRFile(accumuloClient, tableName);
}
}

public static void createAndSetLocalityGroups(AccumuloClient client, String tableName)
throws Exception {
Map<String,Set<Text>> groups = new TreeMap<>();
groups.put("g1", Collections.singleton(t("colf")));
client.tableOperations().setLocalityGroups(tableName, groups);
}

public static void verifyLocalityGroupSet(AccumuloClient client, String tableName)
throws Exception {
assertEquals(Collections.singleton(t("colf")),
client.tableOperations().getLocalityGroups(tableName).get("g1"));
}

/**
* Pretty much identical to sunnyLG, but verifies locality groups are created when configured in
* NewTableConfiguration prior to table creation.
Expand Down