Search in sources :

Example 6 with ClientConfiguration

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

the class ShellConfigTest method testZooKeeperHostFromOption.

@Test
public void testZooKeeperHostFromOption() throws Exception {
    ClientConfiguration clientConfig = ClientConfiguration.create();
    clientConfig.withZkHosts("cc_hostname");
    assertEquals("opt_hostname", Shell.getZooKeepers("opt_hostname", clientConfig));
}
Also used : ClientConfiguration(org.apache.accumulo.core.client.ClientConfiguration) Test(org.junit.Test)

Example 7 with ClientConfiguration

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

the class ShellConfigTest method testZooKeeperHostFromClientConfig.

@Test
public void testZooKeeperHostFromClientConfig() throws Exception {
    ClientConfiguration clientConfig = ClientConfiguration.create();
    clientConfig.withZkHosts("cc_hostname");
    assertEquals("cc_hostname", Shell.getZooKeepers(null, clientConfig));
}
Also used : ClientConfiguration(org.apache.accumulo.core.client.ClientConfiguration) Test(org.junit.Test)

Example 8 with ClientConfiguration

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

the class ShellConfigTest method testZooKeeperHostFallBackToSite.

/**
 * Tests getting the ZK hosts config value will fail on String parameter, client config and then fall back to Site configuration. SiteConfiguration will get
 * the accumulo-site.xml from the classpath in src/test/resources
 */
@Test
public void testZooKeeperHostFallBackToSite() throws Exception {
    ClientConfiguration clientConfig = ClientConfiguration.create();
    assertFalse("Client config contains zk hosts", clientConfig.containsKey(ClientConfiguration.ClientProperty.INSTANCE_ZK_HOST.getKey()));
    assertEquals("ShellConfigTestZKHostValue", Shell.getZooKeepers(null, clientConfig));
}
Also used : ClientConfiguration(org.apache.accumulo.core.client.ClientConfiguration) Test(org.junit.Test)

Example 9 with ClientConfiguration

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

the class ShellSetInstanceTest method testSetInstance_HdfsZooInstance.

private void testSetInstance_HdfsZooInstance(boolean explicitHdfs, boolean onlyInstance, boolean onlyHosts) throws Exception {
    ClientConfiguration clientConf = createMock(ClientConfiguration.class);
    ShellOptionsJC opts = createMock(ShellOptionsJC.class);
    expect(opts.isFake()).andReturn(false);
    expect(opts.getClientConfiguration()).andReturn(clientConf);
    expect(opts.isHdfsZooInstance()).andReturn(explicitHdfs);
    if (!explicitHdfs) {
        expect(opts.getZooKeeperInstance()).andReturn(Collections.emptyList());
        if (onlyInstance) {
            expect(opts.getZooKeeperInstanceName()).andReturn("instance");
            expect(clientConf.withInstance("instance")).andReturn(clientConf);
        } else {
            expect(opts.getZooKeeperInstanceName()).andReturn(null);
        }
        if (onlyHosts) {
            expect(opts.getZooKeeperHosts()).andReturn("host3,host4");
            expect(clientConf.withZkHosts("host3,host4")).andReturn(clientConf);
        } else {
            expect(opts.getZooKeeperHosts()).andReturn(null);
        }
    }
    replay(opts);
    if (!onlyInstance) {
        expect(clientConf.get(ClientProperty.INSTANCE_NAME)).andReturn(null);
    }
    mockStatic(ConfigSanityCheck.class);
    ConfigSanityCheck.validate(EasyMock.<AccumuloConfiguration>anyObject());
    expectLastCall().atLeastOnce();
    replay(ConfigSanityCheck.class);
    if (!onlyHosts) {
        expect(clientConf.containsKey(ClientProperty.INSTANCE_ZK_HOST.getKey())).andReturn(true).atLeastOnce();
        expect(clientConf.get(ClientProperty.INSTANCE_ZK_HOST)).andReturn("host1,host2").atLeastOnce();
        expect(clientConf.withZkHosts("host1,host2")).andReturn(clientConf);
    }
    if (!onlyInstance) {
        expect(clientConf.containsKey(Property.INSTANCE_VOLUMES.getKey())).andReturn(false).atLeastOnce();
        @SuppressWarnings("deprecation") String INSTANCE_DFS_DIR_KEY = Property.INSTANCE_DFS_DIR.getKey();
        @SuppressWarnings("deprecation") String INSTANCE_DFS_URI_KEY = Property.INSTANCE_DFS_URI.getKey();
        expect(clientConf.containsKey(INSTANCE_DFS_DIR_KEY)).andReturn(true).atLeastOnce();
        expect(clientConf.containsKey(INSTANCE_DFS_URI_KEY)).andReturn(true).atLeastOnce();
        expect(clientConf.getString(INSTANCE_DFS_URI_KEY)).andReturn("hdfs://nn1").atLeastOnce();
        expect(clientConf.getString(INSTANCE_DFS_DIR_KEY)).andReturn("/dfs").atLeastOnce();
    }
    UUID randomUUID = null;
    if (!onlyInstance) {
        mockStatic(ZooUtil.class);
        randomUUID = UUID.randomUUID();
        expect(ZooUtil.getInstanceIDFromHdfs(anyObject(Path.class), anyObject(AccumuloConfiguration.class))).andReturn(randomUUID.toString());
        replay(ZooUtil.class);
        expect(clientConf.withInstance(randomUUID)).andReturn(clientConf);
    }
    replay(clientConf);
    ZooKeeperInstance theInstance = createMock(ZooKeeperInstance.class);
    expectNew(ZooKeeperInstance.class, new Class<?>[] { ClientConfiguration.class }, clientConf).andReturn(theInstance);
    replay(theInstance, ZooKeeperInstance.class);
    shell.setInstance(opts);
    verify(theInstance, ZooKeeperInstance.class);
}
Also used : Path(org.apache.hadoop.fs.Path) BeforeClass(org.junit.BeforeClass) AfterClass(org.junit.AfterClass) UUID(java.util.UUID) ClientConfiguration(org.apache.accumulo.core.client.ClientConfiguration) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance)

Example 10 with ClientConfiguration

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

the class MasterFailoverIT method test.

@Test
public void test() throws Exception {
    Connector c = getConnector();
    String[] names = getUniqueNames(2);
    c.tableOperations().create(names[0]);
    TestIngest.Opts opts = new TestIngest.Opts();
    opts.setTableName(names[0]);
    ClientConfiguration clientConf = cluster.getClientConfig();
    if (clientConf.hasSasl()) {
        opts.updateKerberosCredentials(clientConf);
    } else {
        opts.setPrincipal(getAdminPrincipal());
    }
    TestIngest.ingest(c, opts, new BatchWriterOpts());
    ClusterControl control = cluster.getClusterControl();
    control.stopAllServers(ServerType.MASTER);
    // start up a new one
    control.startAllServers(ServerType.MASTER);
    // talk to it
    c.tableOperations().rename(names[0], names[1]);
    VerifyIngest.Opts vopts = new VerifyIngest.Opts();
    vopts.setTableName(names[1]);
    if (clientConf.hasSasl()) {
        vopts.updateKerberosCredentials(clientConf);
    } else {
        vopts.setPrincipal(getAdminPrincipal());
    }
    VerifyIngest.verifyIngest(c, vopts, new ScannerOpts());
}
Also used : Connector(org.apache.accumulo.core.client.Connector) ScannerOpts(org.apache.accumulo.core.cli.ScannerOpts) TestIngest(org.apache.accumulo.test.TestIngest) BatchWriterOpts(org.apache.accumulo.core.cli.BatchWriterOpts) ScannerOpts(org.apache.accumulo.core.cli.ScannerOpts) VerifyIngest(org.apache.accumulo.test.VerifyIngest) BatchWriterOpts(org.apache.accumulo.core.cli.BatchWriterOpts) ClientConfiguration(org.apache.accumulo.core.client.ClientConfiguration) ClusterControl(org.apache.accumulo.cluster.ClusterControl) Test(org.junit.Test)

Aggregations

ClientConfiguration (org.apache.accumulo.core.client.ClientConfiguration)78 Test (org.junit.Test)40 Connector (org.apache.accumulo.core.client.Connector)28 PasswordToken (org.apache.accumulo.core.client.security.tokens.PasswordToken)27 IOException (java.io.IOException)16 TestIngest (org.apache.accumulo.test.TestIngest)15 BatchWriterOpts (org.apache.accumulo.core.cli.BatchWriterOpts)13 ScannerOpts (org.apache.accumulo.core.cli.ScannerOpts)12 KerberosToken (org.apache.accumulo.core.client.security.tokens.KerberosToken)12 AccumuloConfiguration (org.apache.accumulo.core.conf.AccumuloConfiguration)11 VerifyIngest (org.apache.accumulo.test.VerifyIngest)11 ClusterUser (org.apache.accumulo.cluster.ClusterUser)9 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)9 ZooKeeperInstance (org.apache.accumulo.core.client.ZooKeeperInstance)8 Map (java.util.Map)7 AccumuloException (org.apache.accumulo.core.client.AccumuloException)6 Instance (org.apache.accumulo.core.client.Instance)6 AuthenticationToken (org.apache.accumulo.core.client.security.tokens.AuthenticationToken)6 Authorizations (org.apache.accumulo.core.security.Authorizations)6 Path (org.apache.hadoop.fs.Path)6