Search in sources :

Example 36 with AccumuloConfiguration

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;
    }
}
Also used : Path(org.apache.hadoop.fs.Path) VolumeManager(org.apache.accumulo.server.fs.VolumeManager) IOException(java.io.IOException) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration)

Example 37 with AccumuloConfiguration

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);
}
Also used : AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration)

Example 38 with AccumuloConfiguration

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));
    }
}
Also used : Path(org.apache.hadoop.fs.Path) UUID(java.util.UUID) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance)

Example 39 with AccumuloConfiguration

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;
}
Also used : File(java.io.File) ClientConfiguration(org.apache.accumulo.core.client.ClientConfiguration) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration)

Example 40 with AccumuloConfiguration

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"));
}
Also used : ConfigurationCopy(org.apache.accumulo.core.conf.ConfigurationCopy) HashMap(java.util.HashMap) DataOutputStream(java.io.DataOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) DataInputStream(java.io.DataInputStream) ReplicationTarget(org.apache.accumulo.core.replication.ReplicationTarget) ByteArrayInputStream(java.io.ByteArrayInputStream) LogFileValue(org.apache.accumulo.tserver.logger.LogFileValue) Value(org.apache.accumulo.core.data.Value) LogFileValue(org.apache.accumulo.tserver.logger.LogFileValue) Mutation(org.apache.accumulo.core.data.Mutation) ServerMutation(org.apache.accumulo.server.data.ServerMutation) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration) Test(org.junit.Test)

Aggregations

AccumuloConfiguration (org.apache.accumulo.core.conf.AccumuloConfiguration)117 Test (org.junit.Test)44 Path (org.apache.hadoop.fs.Path)26 ConfigurationCopy (org.apache.accumulo.core.conf.ConfigurationCopy)25 IOException (java.io.IOException)23 Configuration (org.apache.hadoop.conf.Configuration)19 HashMap (java.util.HashMap)17 ClientConfiguration (org.apache.accumulo.core.client.ClientConfiguration)13 Key (org.apache.accumulo.core.data.Key)13 DefaultConfiguration (org.apache.accumulo.core.conf.DefaultConfiguration)12 Property (org.apache.accumulo.core.conf.Property)12 Value (org.apache.accumulo.core.data.Value)12 ByteArrayInputStream (java.io.ByteArrayInputStream)11 DataInputStream (java.io.DataInputStream)11 FileSystem (org.apache.hadoop.fs.FileSystem)11 ArrayList (java.util.ArrayList)10 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)9 Text (org.apache.hadoop.io.Text)9 ByteArrayOutputStream (java.io.ByteArrayOutputStream)8 AccumuloException (org.apache.accumulo.core.client.AccumuloException)8