Search in sources :

Example 66 with AccumuloClient

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));
    }
}
Also used : AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) Text(org.apache.hadoop.io.Text) Test(org.junit.Test)

Example 67 with AccumuloClient

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));
    }
}
Also used : AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) Text(org.apache.hadoop.io.Text) Test(org.junit.Test)

Example 68 with AccumuloClient

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));
    }
}
Also used : AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) Text(org.apache.hadoop.io.Text) Test(org.junit.Test)

Example 69 with AccumuloClient

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);
    }
}
Also used : AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) ArrayList(java.util.ArrayList) Text(org.apache.hadoop.io.Text) Test(org.junit.Test)

Example 70 with AccumuloClient

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));
    }
}
Also used : AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) Text(org.apache.hadoop.io.Text) Test(org.junit.Test)

Aggregations

AccumuloClient (org.apache.accumulo.core.client.AccumuloClient)500 Test (org.junit.Test)411 BatchWriter (org.apache.accumulo.core.client.BatchWriter)149 Text (org.apache.hadoop.io.Text)143 Mutation (org.apache.accumulo.core.data.Mutation)138 Scanner (org.apache.accumulo.core.client.Scanner)122 Value (org.apache.accumulo.core.data.Value)118 Key (org.apache.accumulo.core.data.Key)108 NewTableConfiguration (org.apache.accumulo.core.client.admin.NewTableConfiguration)91 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)64 HashMap (java.util.HashMap)61 Range (org.apache.accumulo.core.data.Range)51 TreeSet (java.util.TreeSet)50 ArrayList (java.util.ArrayList)47 Entry (java.util.Map.Entry)41 Path (org.apache.hadoop.fs.Path)39 CompactionConfig (org.apache.accumulo.core.client.admin.CompactionConfig)34 Authorizations (org.apache.accumulo.core.security.Authorizations)34 BatchScanner (org.apache.accumulo.core.client.BatchScanner)32 HashSet (java.util.HashSet)31