Search in sources :

Example 61 with AccumuloClient

use of org.apache.accumulo.core.client.AccumuloClient in project accumulo by apache.

the class ShellCreateTableIT method testCreateTableWithSplitsFile3.

/**
 * Use shell to create a table with a supplied file containing splits.
 *
 * The splits will be contained in a file, sorted and encoded with no repeats or blank lines.
 */
@Test
public void testCreateTableWithSplitsFile3() throws IOException, AccumuloSecurityException, TableNotFoundException, AccumuloException {
    String splitsFile = System.getProperty("user.dir") + "/target/splitFile";
    try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) {
        generateSplitsFile(splitsFile, 100, 23, false, true, true, false, 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 62 with AccumuloClient

use of org.apache.accumulo.core.client.AccumuloClient in project accumulo by apache.

the class ShellCreateTableIT method testCreateTableWithBinarySplitsFile3.

/**
 * Use shell to create a table with a supplied file containing splits.
 *
 * The splits will be contained in a file, sorted and encoded with no repeats or blank lines.
 */
@Test
public void testCreateTableWithBinarySplitsFile3() throws IOException, AccumuloSecurityException, TableNotFoundException, AccumuloException {
    String splitsFile = System.getProperty("user.dir") + "/target/splitFile";
    try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) {
        generateSplitsFile(splitsFile, 100, 23, true, true, true, false, 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 63 with AccumuloClient

use of org.apache.accumulo.core.client.AccumuloClient in project accumulo by apache.

the class ShellCreateTableIT method testCreateTableWithBinarySplitsFile2.

/**
 * Use shell to create a table with a supplied file containing splits.
 *
 * The splits will be contained in a file, unsorted and encoded with no repeats or blank lines.
 */
@Test
public void testCreateTableWithBinarySplitsFile2() throws IOException, AccumuloSecurityException, TableNotFoundException, AccumuloException {
    String splitsFile = System.getProperty("user.dir") + "/target/splitFile";
    try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) {
        generateSplitsFile(splitsFile, 300, 12, true, true, false, false, 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 64 with AccumuloClient

use of org.apache.accumulo.core.client.AccumuloClient in project accumulo by apache.

the class ShellCreateTableIT method testCreateTableWithBinarySplitsFile5.

/**
 * 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 testCreateTableWithBinarySplitsFile5() 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, true, true, 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)

Example 65 with AccumuloClient

use of org.apache.accumulo.core.client.AccumuloClient in project accumulo by apache.

the class ShellCreateTableIT method testCreateTableWithBinarySplitsFile6.

/**
 * Use shell to create a table with a supplied file containing splits.
 *
 * The splits will be contained in a file, unsorted and encoded with a blank line and repeats.
 */
@Test
public void testCreateTableWithBinarySplitsFile6() 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, true, true, false, 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)

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