Search in sources :

Example 31 with Connector

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

the class DynamicThreadPoolsIT method updateMajcDelay.

@Before
public void updateMajcDelay() throws Exception {
    Connector c = getConnector();
    majcDelay = c.instanceOperations().getSystemConfiguration().get(Property.TSERV_MAJC_DELAY.getKey());
    c.instanceOperations().setProperty(Property.TSERV_MAJC_DELAY.getKey(), "100ms");
    if (getClusterType() == ClusterType.STANDALONE) {
        Thread.sleep(ConfigurationTypeHelper.getTimeInMillis(majcDelay));
    }
}
Also used : Connector(org.apache.accumulo.core.client.Connector) Before(org.junit.Before)

Example 32 with Connector

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

the class FateStarvationIT method run.

@Test
public void run() throws Exception {
    String tableName = getUniqueNames(1)[0];
    Connector c = getConnector();
    c.tableOperations().create(tableName);
    c.tableOperations().addSplits(tableName, TestIngest.getSplitPoints(0, 100000, 50));
    TestIngest.Opts opts = new TestIngest.Opts();
    opts.random = 89;
    opts.timestamp = 7;
    opts.dataSize = 50;
    opts.rows = 100000;
    opts.cols = 1;
    opts.setTableName(tableName);
    ClientConfiguration clientConf = cluster.getClientConfig();
    if (clientConf.hasSasl()) {
        opts.updateKerberosCredentials(clientConf);
    } else {
        opts.setPrincipal(getAdminPrincipal());
    }
    TestIngest.ingest(c, opts, new BatchWriterOpts());
    c.tableOperations().flush(tableName, null, null, true);
    List<Text> splits = new ArrayList<>(TestIngest.getSplitPoints(0, 100000, 67));
    Random rand = new Random();
    for (int i = 0; i < 100; i++) {
        int idx1 = rand.nextInt(splits.size() - 1);
        int idx2 = rand.nextInt(splits.size() - (idx1 + 1)) + idx1 + 1;
        c.tableOperations().compact(tableName, splits.get(idx1), splits.get(idx2), false, false);
    }
    c.tableOperations().offline(tableName);
    FunctionalTestUtils.assertNoDanglingFateLocks(getConnector().getInstance(), getCluster());
}
Also used : Connector(org.apache.accumulo.core.client.Connector) Random(java.util.Random) TestIngest(org.apache.accumulo.test.TestIngest) BatchWriterOpts(org.apache.accumulo.core.cli.BatchWriterOpts) ArrayList(java.util.ArrayList) BatchWriterOpts(org.apache.accumulo.core.cli.BatchWriterOpts) Text(org.apache.hadoop.io.Text) ClientConfiguration(org.apache.accumulo.core.client.ClientConfiguration) Test(org.junit.Test)

Example 33 with Connector

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

the class HalfDeadTServerIT method test.

public String test(int seconds, boolean expectTserverDied) throws Exception {
    if (!makeDiskFailureLibrary())
        return null;
    Connector c = getConnector();
    assertEquals(1, c.instanceOperations().getTabletServers().size());
    // create our own tablet server with the special test library
    String javaHome = System.getProperty("java.home");
    String javaBin = javaHome + File.separator + "bin" + File.separator + "java";
    String classpath = System.getProperty("java.class.path");
    classpath = new File(cluster.getConfig().getDir(), "conf") + File.pathSeparator + classpath;
    String className = TabletServer.class.getName();
    ArrayList<String> argList = new ArrayList<>();
    argList.addAll(Arrays.asList(javaBin, "-cp", classpath));
    argList.addAll(Arrays.asList(Main.class.getName(), className));
    ProcessBuilder builder = new ProcessBuilder(argList);
    Map<String, String> env = builder.environment();
    env.put("ACCUMULO_HOME", cluster.getConfig().getDir().getAbsolutePath());
    env.put("ACCUMULO_LOG_DIR", cluster.getConfig().getLogDir().getAbsolutePath());
    String trickFilename = cluster.getConfig().getLogDir().getAbsolutePath() + "/TRICK_FILE";
    env.put("TRICK_FILE", trickFilename);
    String libPath = System.getProperty("user.dir") + "/target/fake_disk_failure.so";
    env.put("LD_PRELOAD", libPath);
    env.put("DYLD_INSERT_LIBRARIES", libPath);
    env.put("DYLD_FORCE_FLAT_NAMESPACE", "true");
    Process ingest = null;
    Process tserver = builder.start();
    DumpOutput t = new DumpOutput(tserver.getInputStream());
    try {
        t.start();
        sleepUninterruptibly(1, TimeUnit.SECONDS);
        // don't need the regular tablet server
        cluster.killProcess(ServerType.TABLET_SERVER, cluster.getProcesses().get(ServerType.TABLET_SERVER).iterator().next());
        sleepUninterruptibly(1, TimeUnit.SECONDS);
        c.tableOperations().create("test_ingest");
        assertEquals(1, c.instanceOperations().getTabletServers().size());
        int rows = 100 * 1000;
        ingest = cluster.exec(TestIngest.class, "-u", "root", "-i", cluster.getInstanceName(), "-z", cluster.getZooKeepers(), "-p", ROOT_PASSWORD, "--rows", rows + "");
        sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
        // block I/O with some side-channel trickiness
        File trickFile = new File(trickFilename);
        try {
            assertTrue(trickFile.createNewFile());
            sleepUninterruptibly(seconds, TimeUnit.SECONDS);
        } finally {
            if (!trickFile.delete()) {
                log.error("Couldn't delete {}", trickFile);
            }
        }
        if (seconds <= 10) {
            assertEquals(0, ingest.waitFor());
            VerifyIngest.Opts vopts = new VerifyIngest.Opts();
            vopts.rows = rows;
            vopts.setPrincipal("root");
            VerifyIngest.verifyIngest(c, vopts, new ScannerOpts());
        } else {
            sleepUninterruptibly(5, TimeUnit.SECONDS);
            tserver.waitFor();
            t.join();
            tserver = null;
        }
        // verify the process was blocked
        String results = t.toString();
        assertTrue(results.contains("sleeping\nsleeping\nsleeping\n"));
        return results;
    } finally {
        if (ingest != null) {
            ingest.destroy();
            ingest.waitFor();
        }
        if (tserver != null) {
            try {
                if (expectTserverDied) {
                    try {
                        tserver.exitValue();
                    } catch (IllegalThreadStateException e) {
                        fail("Expected TServer to kill itself, but it is still running");
                    }
                }
            } finally {
                tserver.destroy();
                tserver.waitFor();
                t.join();
            }
        }
    }
}
Also used : Connector(org.apache.accumulo.core.client.Connector) ScannerOpts(org.apache.accumulo.core.cli.ScannerOpts) ArrayList(java.util.ArrayList) ScannerOpts(org.apache.accumulo.core.cli.ScannerOpts) TestIngest(org.apache.accumulo.test.TestIngest) VerifyIngest(org.apache.accumulo.test.VerifyIngest) File(java.io.File)

Example 34 with Connector

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

the class ConstraintIT method run.

@Test
public void run() throws Exception {
    String[] tableNames = getUniqueNames(3);
    Connector c = getConnector();
    for (String table : tableNames) {
        c.tableOperations().create(table);
        c.tableOperations().addConstraint(table, NumericValueConstraint.class.getName());
        c.tableOperations().addConstraint(table, AlphaNumKeyConstraint.class.getName());
    }
    // A static sleep to just let ZK do its thing
    Thread.sleep(10 * 1000);
    // Then check that the client has at least gotten the updates
    for (String table : tableNames) {
        log.debug("Checking constraints on {}", table);
        Map<String, Integer> constraints = c.tableOperations().listConstraints(table);
        while (!constraints.containsKey(NumericValueConstraint.class.getName()) || !constraints.containsKey(AlphaNumKeyConstraint.class.getName())) {
            log.debug("Failed to verify constraints. Sleeping and retrying");
            Thread.sleep(2000);
            constraints = c.tableOperations().listConstraints(table);
        }
        log.debug("Verified all constraints on {}", table);
    }
    log.debug("Verified constraints on all tables. Running tests");
    test1(tableNames[0]);
    test2(tableNames[1], false);
    test2(tableNames[2], true);
}
Also used : Connector(org.apache.accumulo.core.client.Connector) NumericValueConstraint(org.apache.accumulo.test.constraints.NumericValueConstraint) AlphaNumKeyConstraint(org.apache.accumulo.test.constraints.AlphaNumKeyConstraint) Test(org.junit.Test)

Example 35 with Connector

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

the class CreateManyScannersIT method run.

@Test
public void run() throws Exception {
    Connector c = getConnector();
    String tableName = getUniqueNames(1)[0];
    c.tableOperations().create(tableName);
    for (int i = 0; i < 100000; i++) {
        c.createScanner(tableName, Authorizations.EMPTY);
    }
}
Also used : Connector(org.apache.accumulo.core.client.Connector) Test(org.junit.Test)

Aggregations

Connector (org.apache.accumulo.core.client.Connector)622 Test (org.junit.Test)415 BatchWriter (org.apache.accumulo.core.client.BatchWriter)171 Value (org.apache.accumulo.core.data.Value)162 Text (org.apache.hadoop.io.Text)160 Scanner (org.apache.accumulo.core.client.Scanner)158 Mutation (org.apache.accumulo.core.data.Mutation)152 BatchWriterConfig (org.apache.accumulo.core.client.BatchWriterConfig)143 Key (org.apache.accumulo.core.data.Key)139 PasswordToken (org.apache.accumulo.core.client.security.tokens.PasswordToken)101 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)87 AccumuloException (org.apache.accumulo.core.client.AccumuloException)83 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)75 Range (org.apache.accumulo.core.data.Range)74 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)65 Authorizations (org.apache.accumulo.core.security.Authorizations)60 HashSet (java.util.HashSet)57 Instance (org.apache.accumulo.core.client.Instance)55 ArrayList (java.util.ArrayList)53 Entry (java.util.Map.Entry)53