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