use of org.apache.accumulo.core.conf.Property in project accumulo by apache.
the class TableConfigurationTest method testGet_InParent.
@Test
public void testGet_InParent() {
Property p = Property.INSTANCE_SECRET;
expect(zc.get(ZooUtil.getRoot(iid) + Constants.ZTABLES + "/" + TID + Constants.ZTABLE_CONF + "/" + p.getKey())).andReturn(null);
replay(zc);
expect(parent.get(p)).andReturn("sekrit");
replay(parent);
assertEquals("sekrit", c.get(Property.INSTANCE_SECRET));
}
use of org.apache.accumulo.core.conf.Property in project accumulo by apache.
the class ZooCachePropertyAccessorTest method testGet_InvalidFormat.
@Test
public void testGet_InvalidFormat() {
Property badProp = Property.MASTER_CLIENTPORT;
expect(zc.get(PATH + "/" + badProp.getKey())).andReturn(VALUE_BYTES);
replay(zc);
AccumuloConfiguration parent = createMock(AccumuloConfiguration.class);
expect(parent.get(badProp)).andReturn("12345");
replay(parent);
assertEquals("12345", a.get(badProp, PATH, parent));
}
use of org.apache.accumulo.core.conf.Property in project accumulo by apache.
the class TabletServer method startServer.
private HostAndPort startServer(AccumuloConfiguration conf, String address, Property portHint, TProcessor processor, String threadName) throws UnknownHostException {
Property maxMessageSizeProperty = (conf.get(Property.TSERV_MAX_MESSAGE_SIZE) != null ? Property.TSERV_MAX_MESSAGE_SIZE : Property.GENERAL_MAX_MESSAGE_SIZE);
ServerAddress sp = TServerUtils.startServer(this, address, portHint, processor, this.getClass().getSimpleName(), threadName, Property.TSERV_PORTSEARCH, Property.TSERV_MINTHREADS, Property.TSERV_THREADCHECK, maxMessageSizeProperty);
this.server = sp.server;
return sp.address;
}
use of org.apache.accumulo.core.conf.Property in project accumulo by apache.
the class TabletServer method startReplicationService.
private HostAndPort startReplicationService() throws UnknownHostException {
final ReplicationServicerHandler handler = new ReplicationServicerHandler(this);
ReplicationServicer.Iface rpcProxy = RpcWrapper.service(handler);
ReplicationServicer.Iface repl = TCredentialsUpdatingWrapper.service(rpcProxy, handler.getClass(), getConfiguration());
ReplicationServicer.Processor<ReplicationServicer.Iface> processor = new ReplicationServicer.Processor<>(repl);
AccumuloConfiguration conf = getServerConfigurationFactory().getSystemConfiguration();
Property maxMessageSizeProperty = (conf.get(Property.TSERV_MAX_MESSAGE_SIZE) != null ? Property.TSERV_MAX_MESSAGE_SIZE : Property.GENERAL_MAX_MESSAGE_SIZE);
ServerAddress sp = TServerUtils.startServer(this, clientAddress.getHost(), Property.REPLICATION_RECEIPT_SERVICE_PORT, processor, "ReplicationServicerHandler", "Replication Servicer", Property.TSERV_PORTSEARCH, Property.REPLICATION_MIN_THREADS, Property.REPLICATION_THREADCHECK, maxMessageSizeProperty);
this.replServer = sp.server;
log.info("Started replication service on {}", sp.address);
try {
// The replication service is unique to the thrift service for a tserver, not just a host.
// Advertise the host and port for replication service given the host and port for the tserver.
ZooReaderWriter.getInstance().putPersistentData(ZooUtil.getRoot(getInstance()) + ReplicationConstants.ZOO_TSERVERS + "/" + clientAddress.toString(), sp.address.toString().getBytes(UTF_8), NodeExistsPolicy.OVERWRITE);
} catch (Exception e) {
log.error("Could not advertise replication service port", e);
throw new RuntimeException(e);
}
return sp.address;
}
use of org.apache.accumulo.core.conf.Property in project accumulo by apache.
the class TracesResource method getScanner.
protected Pair<Scanner, UserGroupInformation> getScanner() throws AccumuloException, AccumuloSecurityException {
AccumuloConfiguration conf = Monitor.getContext().getConfiguration();
final boolean saslEnabled = conf.getBoolean(Property.INSTANCE_RPC_SASL_ENABLED);
UserGroupInformation traceUgi = null;
final String principal;
final AuthenticationToken at;
Map<String, String> loginMap = conf.getAllPropertiesWithPrefix(Property.TRACE_TOKEN_PROPERTY_PREFIX);
// May be null
String keytab = loginMap.get(Property.TRACE_TOKEN_PROPERTY_PREFIX.getKey() + "keytab");
if (keytab == null || keytab.length() == 0) {
keytab = conf.getPath(Property.GENERAL_KERBEROS_KEYTAB);
}
if (saslEnabled && null != keytab) {
principal = SecurityUtil.getServerPrincipal(conf.get(Property.TRACE_USER));
try {
traceUgi = UserGroupInformation.loginUserFromKeytabAndReturnUGI(principal, keytab);
} catch (IOException e) {
throw new RuntimeException("Failed to login as trace user", e);
}
} else {
principal = conf.get(Property.TRACE_USER);
}
if (!saslEnabled) {
if (loginMap.isEmpty()) {
Property p = Property.TRACE_PASSWORD;
at = new PasswordToken(conf.get(p).getBytes(UTF_8));
} else {
Properties props = new Properties();
int prefixLength = Property.TRACE_TOKEN_PROPERTY_PREFIX.getKey().length();
for (Entry<String, String> entry : loginMap.entrySet()) {
props.put(entry.getKey().substring(prefixLength), entry.getValue());
}
AuthenticationToken token = Property.createInstanceFromPropertyName(conf, Property.TRACE_TOKEN_TYPE, AuthenticationToken.class, new PasswordToken());
token.init(props);
at = token;
}
} else {
at = null;
}
final String table = conf.get(Property.TRACE_TABLE);
Scanner scanner;
if (null != traceUgi) {
try {
scanner = traceUgi.doAs(new PrivilegedExceptionAction<Scanner>() {
@Override
public Scanner run() throws Exception {
// Make the KerberosToken inside the doAs
AuthenticationToken token = at;
if (null == token) {
token = new KerberosToken();
}
return getScanner(table, principal, token);
}
});
} catch (IOException | InterruptedException e) {
throw new RuntimeException("Failed to obtain scanner", e);
}
} else {
if (null == at) {
throw new AssertionError("AuthenticationToken should not be null");
}
scanner = getScanner(table, principal, at);
}
return new Pair<>(scanner, traceUgi);
}
Aggregations