Search in sources :

Example 61 with AccumuloConfiguration

use of org.apache.accumulo.core.conf.AccumuloConfiguration in project accumulo by apache.

the class ClientServiceHandler method checkTableClass.

@Override
public boolean checkTableClass(TInfo tinfo, TCredentials credentials, String tableName, String className, String interfaceMatch) throws TException, ThriftTableOperationException, ThriftSecurityException {
    security.authenticateUser(credentials, credentials);
    TableId tableId = checkTableId(context, tableName, null);
    ClassLoader loader = getClass().getClassLoader();
    Class<?> shouldMatch;
    try {
        shouldMatch = loader.loadClass(interfaceMatch);
        AccumuloConfiguration conf = context.getTableConfiguration(tableId);
        String context = ClassLoaderUtil.tableContext(conf);
        Class<?> test = ClassLoaderUtil.loadClass(context, className, shouldMatch);
        test.getDeclaredConstructor().newInstance();
        return true;
    } catch (Exception e) {
        log.warn("Error checking object types", e);
        return false;
    }
}
Also used : TableId(org.apache.accumulo.core.data.TableId) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) NamespaceNotFoundException(org.apache.accumulo.core.client.NamespaceNotFoundException) ThriftSecurityException(org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) TException(org.apache.thrift.TException) IOException(java.io.IOException) ThriftTableOperationException(org.apache.accumulo.core.clientImpl.thrift.ThriftTableOperationException) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration)

Example 62 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.ACCUMULO.id()) && isIteratorOrConstraint(key)) {
        // ignore iterators from parent if system namespace
        getParent = null;
    } else {
        getParent = parent;
    }
    return getPropCacheAccessor().get(property, getPath(), getParent);
}
Also used : AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration)

Example 63 with AccumuloConfiguration

use of org.apache.accumulo.core.conf.AccumuloConfiguration in project accumulo by apache.

the class ZooCachePropertyAccessorTest method testGetProperties.

@Test
public void testGetProperties() {
    Map<String, String> props = new java.util.HashMap<>();
    AccumuloConfiguration parent = createMock(AccumuloConfiguration.class);
    Predicate<String> filter = createMock(Predicate.class);
    parent.getProperties(props, filter);
    replay(parent);
    String child1 = "child1";
    String child2 = "child2";
    List<String> children = new java.util.ArrayList<>();
    children.add(child1);
    children.add(child2);
    expect(zc.getChildren(PATH)).andReturn(children);
    expect(zc.get(PATH + "/" + child1)).andReturn(VALUE_BYTES);
    expect(zc.get(PATH + "/" + child2)).andReturn(null);
    replay(zc);
    expect(filter.test(child1)).andReturn(true);
    expect(filter.test(child2)).andReturn(true);
    replay(filter);
    a.getProperties(props, PATH, filter, parent, null);
    assertEquals(1, props.size());
    assertEquals(VALUE, props.get(child1));
    verify(parent);
}
Also used : AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration) Test(org.junit.Test)

Example 64 with AccumuloConfiguration

use of org.apache.accumulo.core.conf.AccumuloConfiguration in project accumulo by apache.

the class ZooCachePropertyAccessorTest method testGet_Parent_Null.

@Test
public void testGet_Parent_Null() {
    AccumuloConfiguration parent = createMock(AccumuloConfiguration.class);
    expect(parent.get(PROP)).andReturn(null);
    replay(parent);
    expect(zc.get(FULL_PATH)).andReturn(null);
    replay(zc);
    assertNull(a.get(PROP, PATH, parent));
}
Also used : AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration) Test(org.junit.Test)

Example 65 with AccumuloConfiguration

use of org.apache.accumulo.core.conf.AccumuloConfiguration in project accumulo by apache.

the class ZooCachePropertyAccessorTest method testGetProperties_Filter.

@Test
public void testGetProperties_Filter() {
    Map<String, String> props = new java.util.HashMap<>();
    AccumuloConfiguration parent = createMock(AccumuloConfiguration.class);
    Predicate<String> filter = createMock(Predicate.class);
    parent.getProperties(props, filter);
    replay(parent);
    String child1 = "child1";
    List<String> children = new java.util.ArrayList<>();
    children.add(child1);
    expect(zc.getChildren(PATH)).andReturn(children);
    replay(zc);
    expect(filter.test(child1)).andReturn(false);
    replay(filter);
    a.getProperties(props, PATH, filter, parent, null);
    assertEquals(0, props.size());
}
Also used : AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration) Test(org.junit.Test)

Aggregations

AccumuloConfiguration (org.apache.accumulo.core.conf.AccumuloConfiguration)164 Test (org.junit.Test)51 Path (org.apache.hadoop.fs.Path)44 IOException (java.io.IOException)31 ConfigurationCopy (org.apache.accumulo.core.conf.ConfigurationCopy)31 Configuration (org.apache.hadoop.conf.Configuration)27 HashMap (java.util.HashMap)24 ArrayList (java.util.ArrayList)23 Key (org.apache.accumulo.core.data.Key)23 FileSystem (org.apache.hadoop.fs.FileSystem)22 Value (org.apache.accumulo.core.data.Value)21 ServerContext (org.apache.accumulo.server.ServerContext)18 Property (org.apache.accumulo.core.conf.Property)16 DefaultConfiguration (org.apache.accumulo.core.conf.DefaultConfiguration)15 HostAndPort (org.apache.accumulo.core.util.HostAndPort)15 Map (java.util.Map)12 ByteArrayOutputStream (java.io.ByteArrayOutputStream)11 DataInputStream (java.io.DataInputStream)11 SamplerConfiguration (org.apache.accumulo.core.client.sample.SamplerConfiguration)11 SamplerConfigurationImpl (org.apache.accumulo.core.sample.impl.SamplerConfigurationImpl)11