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));
}
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));
}
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));
}
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);
}
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());
}
Aggregations