use of org.apache.accumulo.core.client.AccumuloClient in project accumulo by apache.
the class ShellCreateTableIT method testCreateTableWithSplitsFile4.
/**
* Use shell to create a table with a supplied file containing splits.
*
* The splits will be contained in a file, sorted and un-encoded with a blank line and no repeats.
*/
@Test
public void testCreateTableWithSplitsFile4() throws IOException, AccumuloSecurityException, TableNotFoundException, AccumuloException {
String splitsFile = System.getProperty("user.dir") + "/target/splitFile";
try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) {
generateSplitsFile(splitsFile, 100, 31, false, false, true, true, false);
SortedSet<Text> expectedSplits = readSplitsFromFile(splitsFile);
final String tableName = getUniqueNames(1)[0];
ts.exec("createtable " + tableName + " -sf " + splitsFile, true);
Collection<Text> createdSplits = client.tableOperations().listSplits(tableName);
assertEquals(expectedSplits, new TreeSet<>(createdSplits));
} finally {
Files.delete(Paths.get(splitsFile));
}
}
use of org.apache.accumulo.core.client.AccumuloClient in project accumulo by apache.
the class ShellCreateTableIT method testCreateTableWithBinarySplitsFile4.
/**
* Use shell to create a table with a supplied file containing splits.
*
* The splits will be contained in a file, sorted and encoded with a blank line and no repeats.
*/
@Test
public void testCreateTableWithBinarySplitsFile4() throws IOException, AccumuloSecurityException, TableNotFoundException, AccumuloException {
String splitsFile = System.getProperty("user.dir") + "/target/splitFile";
try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) {
generateSplitsFile(splitsFile, 100, 31, true, true, true, true, false);
SortedSet<Text> expectedSplits = readSplitsFromFile(splitsFile);
final String tableName = getUniqueNames(1)[0];
ts.exec("createtable " + tableName + " -sf " + splitsFile, true);
Collection<Text> createdSplits = client.tableOperations().listSplits(tableName);
assertEquals(expectedSplits, new TreeSet<>(createdSplits));
} finally {
Files.delete(Paths.get(splitsFile));
}
}
use of org.apache.accumulo.core.client.AccumuloClient in project accumulo by apache.
the class ShellCreateTableIT method testCreateTableWithSplitsFile7.
/**
* Use shell to create a table with a supplied file containing splits.
*
* The splits will be contained in a file, sorted and encoded with a blank line and repeats.
*/
@Test
public void testCreateTableWithSplitsFile7() throws IOException, AccumuloSecurityException, TableNotFoundException, AccumuloException {
String splitsFile = System.getProperty("user.dir") + "/target/splitFile";
try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) {
generateSplitsFile(splitsFile, 100, 12, false, false, true, true, true);
SortedSet<Text> expectedSplits = readSplitsFromFile(splitsFile);
final String tableName = getUniqueNames(1)[0];
ts.exec("createtable " + tableName + " -sf " + splitsFile, true);
Collection<Text> createdSplits = client.tableOperations().listSplits(tableName);
assertEquals(expectedSplits, new TreeSet<>(createdSplits));
} finally {
Files.delete(Paths.get(splitsFile));
}
}
use of org.apache.accumulo.core.client.AccumuloClient in project accumulo by apache.
the class ShellCreateTableIT method testCreateTableWithCopySplitsFromOtherTable.
/**
* Use shell to create a table that used splits from another table.
*/
@Test
public void testCreateTableWithCopySplitsFromOtherTable() throws IOException, AccumuloSecurityException, TableNotFoundException, AccumuloException {
// create a table and add some splits
try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) {
final String[] tableNames = getUniqueNames(2);
final String tableName0 = tableNames[0];
final String tableName2 = tableNames[1];
ts.exec("createtable " + tableName0, true);
String output = ts.exec("tables", true);
assertTrue(output.contains(tableName0));
ts.exec("table " + tableName0, true);
// add splits to this table using the addsplits command.
List<Text> splits = new ArrayList<>();
splits.add(new Text("ccccc"));
splits.add(new Text("fffff"));
splits.add(new Text("mmmmm"));
splits.add(new Text("sssss"));
ts.exec("addsplits " + splits.get(0) + " " + splits.get(1) + " " + splits.get(2) + " " + splits.get(3), true);
// Now create a table that will used the previous tables splits and create them at table
// creation
ts.exec("createtable " + tableName2 + " --copy-splits " + tableName0, true);
ts.exec("table " + tableName0, true);
String tablesOutput = ts.exec("tables", true);
assertTrue(tablesOutput.contains(tableName2));
Collection<Text> createdSplits = client.tableOperations().listSplits(tableName2);
assertEquals(new TreeSet<>(splits), new TreeSet<>(createdSplits));
ts.exec("deletetable -f " + tableName0, true);
ts.exec("deletetable -f " + tableName2, true);
}
}
use of org.apache.accumulo.core.client.AccumuloClient in project accumulo by apache.
the class ShellCreateTableIT method testCreateTableWithSplitsFile5.
/**
* Use shell to create a table with a supplied file containing splits.
*
* The splits will be contained in a file, sorted and un-encoded with a blank line and no repeats.
*/
@Test
public void testCreateTableWithSplitsFile5() throws IOException, AccumuloSecurityException, TableNotFoundException, AccumuloException {
String splitsFile = System.getProperty("user.dir") + "/target/splitFile";
try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) {
generateSplitsFile(splitsFile, 100, 32, false, false, true, false, true);
SortedSet<Text> expectedSplits = readSplitsFromFile(splitsFile);
final String tableName = getUniqueNames(1)[0];
ts.exec("createtable " + tableName + " -sf " + splitsFile, true);
Collection<Text> createdSplits = client.tableOperations().listSplits(tableName);
assertEquals(expectedSplits, new TreeSet<>(createdSplits));
} finally {
Files.delete(Paths.get(splitsFile));
}
}
Aggregations