use of org.apache.accumulo.core.conf.AccumuloConfiguration in project accumulo by apache.
the class HdfsZooInstance method _getInstanceID.
private static synchronized void _getInstanceID() {
if (instanceId == null) {
AccumuloConfiguration acuConf = SiteConfiguration.getInstance();
// InstanceID should be the same across all volumes, so just choose one
VolumeManager fs;
try {
fs = VolumeManagerImpl.get();
} catch (IOException e) {
throw new RuntimeException(e);
}
Path instanceIdPath = Accumulo.getAccumuloInstanceIdPath(fs);
log.trace("Looking for instanceId from {}", instanceIdPath);
String instanceIdFromFile = ZooUtil.getInstanceIDFromHdfs(instanceIdPath, acuConf);
instanceId = instanceIdFromFile;
}
}
use of org.apache.accumulo.core.conf.AccumuloConfiguration in project accumulo by apache.
the class NamespaceConfiguration method get.
@Override
public String get(Property property) {
String key = property.getKey();
AccumuloConfiguration getParent;
if (!(namespaceId.equals(Namespace.ID.ACCUMULO) && isIteratorOrConstraint(key))) {
getParent = parent;
} else {
// ignore iterators from parent if system namespace
getParent = null;
}
return getPropCacheAccessor().get(property, getPath(), getParent);
}
use of org.apache.accumulo.core.conf.AccumuloConfiguration in project accumulo by apache.
the class Shell method getZooInstance.
/*
* Takes instanceName and keepers as separate arguments, rather than just packaged into the clientConfig, so that we can fail over to accumulo-site.xml or
* HDFS config if they're unspecified.
*/
private static Instance getZooInstance(String instanceName, String keepersOption, ClientConfiguration clientConfig) {
UUID instanceId = null;
if (instanceName == null) {
instanceName = clientConfig.get(ClientProperty.INSTANCE_NAME);
}
String keepers = getZooKeepers(keepersOption, clientConfig);
if (instanceName == null) {
AccumuloConfiguration conf = SiteConfiguration.getInstance();
Path instanceDir = new Path(VolumeConfiguration.getVolumeUris(conf)[0], "instance_id");
instanceId = UUID.fromString(ZooUtil.getInstanceIDFromHdfs(instanceDir, conf));
}
if (instanceId != null) {
return new ZooKeeperInstance(clientConfig.withInstance(instanceId).withZkHosts(keepers));
} else {
return new ZooKeeperInstance(clientConfig.withInstance(instanceName).withZkHosts(keepers));
}
}
use of org.apache.accumulo.core.conf.AccumuloConfiguration in project accumulo by apache.
the class ShellOptionsJC method getClientConfiguration.
public ClientConfiguration getClientConfiguration() throws ConfigurationException, FileNotFoundException {
ClientConfiguration clientConfig = clientConfigFile == null ? ClientConfiguration.loadDefault() : ClientConfiguration.fromFile(new File(getClientConfigFile()));
if (useSsl()) {
clientConfig.setProperty(ClientProperty.INSTANCE_RPC_SSL_ENABLED, "true");
}
if (useSasl()) {
clientConfig.setProperty(ClientProperty.INSTANCE_RPC_SASL_ENABLED, "true");
}
if (!getZooKeeperInstance().isEmpty()) {
List<String> zkOpts = getZooKeeperInstance();
String instanceName = zkOpts.get(0);
String hosts = zkOpts.get(1);
clientConfig.setProperty(ClientProperty.INSTANCE_ZK_HOST, hosts);
clientConfig.setProperty(ClientProperty.INSTANCE_NAME, instanceName);
}
// If the user provided the hosts, set the ZK for tracing too
if (null != zooKeeperHosts && !zooKeeperHosts.isEmpty()) {
clientConfig.setProperty(ClientProperty.INSTANCE_ZK_HOST, zooKeeperHosts);
}
if (null != zooKeeperInstanceName && !zooKeeperInstanceName.isEmpty()) {
clientConfig.setProperty(ClientProperty.INSTANCE_NAME, zooKeeperInstanceName);
}
// Automatically try to add in the proper ZK from accumulo-site for backwards compat.
if (!clientConfig.containsKey(ClientProperty.INSTANCE_ZK_HOST.getKey())) {
AccumuloConfiguration siteConf = SiteConfiguration.getInstance();
clientConfig.withZkHosts(siteConf.get(Property.INSTANCE_ZK_HOST));
}
return clientConfig;
}
use of org.apache.accumulo.core.conf.AccumuloConfiguration in project accumulo by apache.
the class AccumuloReplicaSystemTest method mutationsNotReReplicatedToPeers.
@Test
public void mutationsNotReReplicatedToPeers() throws Exception {
AccumuloReplicaSystem ars = new AccumuloReplicaSystem();
Map<String, String> confMap = new HashMap<>();
confMap.put(Property.REPLICATION_NAME.getKey(), "source");
AccumuloConfiguration conf = new ConfigurationCopy(confMap);
ars.setConf(conf);
LogFileValue value = new LogFileValue();
value.mutations = new ArrayList<>();
Mutation m = new Mutation("row");
m.put("", "", new Value(new byte[0]));
value.mutations.add(m);
m = new Mutation("row2");
m.put("", "", new Value(new byte[0]));
m.addReplicationSource("peer");
value.mutations.add(m);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(baos);
// Replicate our 2 mutations to "peer", from tableid 1 to tableid 1
ars.writeValueAvoidingReplicationCycles(out, value, new ReplicationTarget("peer", "1", Table.ID.of("1")));
out.close();
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
DataInputStream in = new DataInputStream(bais);
int numMutations = in.readInt();
Assert.assertEquals(1, numMutations);
m = new Mutation();
m.readFields(in);
Assert.assertEquals("row", new String(m.getRow()));
Assert.assertEquals(1, m.getReplicationSources().size());
Assert.assertTrue("Expected source cluster to be listed in mutation replication source", m.getReplicationSources().contains("source"));
}
Aggregations