use of org.apache.accumulo.core.conf.AccumuloConfiguration in project accumulo by apache.
the class CryptoTest method testCryptoModuleParamsParsing.
@Test
public void testCryptoModuleParamsParsing() {
AccumuloConfiguration conf = setAndGetAccumuloConfig(CRYPTO_ON_CONF);
CryptoModuleParameters params = CryptoModuleFactory.createParamsObjectFromAccumuloConfiguration(conf);
assertNotNull(params);
assertEquals("AES/GCM/NoPadding", params.getCipherSuite());
assertEquals("AES/CBC/NoPadding", params.getAllOptions().get(Property.CRYPTO_WAL_CIPHER_SUITE.getKey()));
assertEquals("GCM", params.getCipherSuiteEncryptionMode());
assertEquals("AES", params.getKeyAlgorithmName());
assertEquals(128, params.getKeyLength());
assertEquals("SHA1PRNG", params.getRandomNumberGenerator());
assertEquals("SUN", params.getRandomNumberGeneratorProvider());
assertEquals("SunJCE", params.getSecurityProvider());
assertEquals("org.apache.accumulo.core.security.crypto.CachingHDFSSecretKeyEncryptionStrategy", params.getKeyEncryptionStrategyClass());
}
use of org.apache.accumulo.core.conf.AccumuloConfiguration in project accumulo by apache.
the class TabletServer method config.
public void config(String hostname) {
log.info("Tablet server starting on {}", hostname);
majorCompactorThread = new Daemon(new LoggingRunnable(log, new MajorCompactor(getConfiguration())));
majorCompactorThread.setName("Split/MajC initiator");
majorCompactorThread.start();
clientAddress = HostAndPort.fromParts(hostname, 0);
try {
AccumuloVFSClassLoader.getContextManager().setContextConfig(new ContextManager.DefaultContextsConfig() {
@Override
public Map<String, String> getVfsContextClasspathProperties() {
return getConfiguration().getAllPropertiesWithPrefix(Property.VFS_CONTEXT_CLASSPATH_PROPERTY);
}
});
} catch (IOException e) {
throw new RuntimeException(e);
}
// A task that cleans up unused classloader contexts
Runnable contextCleaner = new Runnable() {
@Override
public void run() {
Set<String> contextProperties = getServerConfigurationFactory().getSystemConfiguration().getAllPropertiesWithPrefix(Property.VFS_CONTEXT_CLASSPATH_PROPERTY).keySet();
Set<String> configuredContexts = new HashSet<>();
for (String prop : contextProperties) {
configuredContexts.add(prop.substring(Property.VFS_CONTEXT_CLASSPATH_PROPERTY.name().length()));
}
try {
AccumuloVFSClassLoader.getContextManager().removeUnusedContexts(configuredContexts);
} catch (IOException e) {
log.warn("{}", e.getMessage(), e);
}
}
};
AccumuloConfiguration aconf = getConfiguration();
SimpleTimer.getInstance(aconf).schedule(contextCleaner, 60000, 60000);
FileSystemMonitor.start(aconf, Property.TSERV_MONITOR_FS);
Runnable gcDebugTask = new Runnable() {
@Override
public void run() {
gcLogger.logGCInfo(getConfiguration());
}
};
SimpleTimer.getInstance(aconf).schedule(gcDebugTask, 0, TIME_BETWEEN_GC_CHECKS);
Runnable constraintTask = new Runnable() {
@Override
public void run() {
ArrayList<Tablet> tablets;
synchronized (onlineTablets) {
tablets = new ArrayList<>(onlineTablets.values());
}
for (Tablet tablet : tablets) {
tablet.checkConstraints();
}
}
};
SimpleTimer.getInstance(aconf).schedule(constraintTask, 0, 1000);
}
use of org.apache.accumulo.core.conf.AccumuloConfiguration in project accumulo by apache.
the class AccumuloReplicaSystem method replicate.
@Override
public Status replicate(final Path p, final Status status, final ReplicationTarget target, final ReplicaSystemHelper helper) {
final Instance localInstance = HdfsZooInstance.getInstance();
final AccumuloConfiguration localConf = new ServerConfigurationFactory(localInstance).getSystemConfiguration();
log.debug("Replication RPC timeout is {}", localConf.get(Property.REPLICATION_RPC_TIMEOUT.getKey()));
final String principal = getPrincipal(localConf, target);
final File keytab;
final String password;
if (localConf.getBoolean(Property.INSTANCE_RPC_SASL_ENABLED)) {
String keytabPath = getKeytab(localConf, target);
keytab = new File(keytabPath);
if (!keytab.exists() || !keytab.isFile()) {
log.error("{} is not a regular file. Cannot login to replicate", keytabPath);
return status;
}
password = null;
} else {
keytab = null;
password = getPassword(localConf, target);
}
if (null != keytab) {
try {
final UserGroupInformation accumuloUgi = UserGroupInformation.getCurrentUser();
// Get a UGI with the principal + keytab
UserGroupInformation ugi = UserGroupInformation.loginUserFromKeytabAndReturnUGI(principal, keytab.getAbsolutePath());
// Run inside a doAs to avoid nuking the Tserver's user
return ugi.doAs(new PrivilegedAction<Status>() {
@Override
public Status run() {
KerberosToken token;
try {
// Do *not* replace the current user
token = new KerberosToken(principal, keytab);
} catch (IOException e) {
log.error("Failed to create KerberosToken", e);
return status;
}
ClientContext peerContext = getContextForPeer(localConf, target, principal, token);
return _replicate(p, status, target, helper, localConf, peerContext, accumuloUgi);
}
});
} catch (IOException e) {
// Can't log in, can't replicate
log.error("Failed to perform local login", e);
return status;
}
} else {
// Simple case: make a password token, context and then replicate
PasswordToken token = new PasswordToken(password);
ClientContext peerContext = getContextForPeer(localConf, target, principal, token);
return _replicate(p, status, target, helper, localConf, peerContext, null);
}
}
use of org.apache.accumulo.core.conf.AccumuloConfiguration in project accumulo by apache.
the class ReplicationServicerHandler method replicateLog.
@Override
public long replicateLog(String tableIdStr, WalEdits data, TCredentials tcreds) throws RemoteReplicationException, TException {
Table.ID tableId = Table.ID.of(tableIdStr);
log.debug("Got replication request to tableID {} with {} edits", tableId, data.getEditsSize());
tabletServer.getSecurityOperation().authenticateUser(tabletServer.rpcCreds(), tcreds);
String tableName;
try {
tableName = Tables.getTableName(tabletServer.getInstance(), tableId);
} catch (TableNotFoundException e) {
log.error("Could not find table with id {}", tableId);
throw new RemoteReplicationException(RemoteReplicationErrorCode.TABLE_DOES_NOT_EXIST, "Table with id " + tableId + " does not exist");
}
AccumuloConfiguration conf = tabletServer.getConfiguration();
Map<String, String> replicationHandlers = conf.getAllPropertiesWithPrefix(Property.TSERV_REPLICATION_REPLAYERS);
String propertyForHandlerTable = Property.TSERV_REPLICATION_REPLAYERS.getKey() + tableId;
String handlerClassForTable = replicationHandlers.get(propertyForHandlerTable);
if (null == handlerClassForTable) {
if (!replicationHandlers.isEmpty()) {
log.debug("Could not find replication replayer for {}", tableId);
}
handlerClassForTable = conf.get(Property.TSERV_REPLICATION_DEFAULT_HANDLER);
}
log.debug("Using {} replication replayer for table {}", handlerClassForTable, tableId);
// Get class for replayer
Class<? extends AccumuloReplicationReplayer> clz;
try {
Class<?> untypedClz = Class.forName(handlerClassForTable);
clz = untypedClz.asSubclass(AccumuloReplicationReplayer.class);
} catch (ClassNotFoundException e) {
log.error("Could not instantiate replayer class {}", handlerClassForTable, e);
throw new RemoteReplicationException(RemoteReplicationErrorCode.CANNOT_INSTANTIATE_REPLAYER, "Could not instantiate replayer class " + handlerClassForTable);
}
// Create an instance
AccumuloReplicationReplayer replayer;
try {
replayer = clz.newInstance();
} catch (InstantiationException | IllegalAccessException e1) {
log.error("Could not instantiate replayer class {}", clz.getName());
throw new RemoteReplicationException(RemoteReplicationErrorCode.CANNOT_INSTANTIATE_REPLAYER, "Could not instantiate replayer class" + clz.getName());
}
long entriesReplicated;
try {
entriesReplicated = replayer.replicateLog(tabletServer, tableName, data);
} catch (AccumuloException | AccumuloSecurityException e) {
log.error("Could not get connection", e);
throw new RemoteReplicationException(RemoteReplicationErrorCode.CANNOT_AUTHENTICATE, "Cannot get connector as " + tabletServer.getCredentials().getPrincipal());
}
log.debug("Replicated {} mutations to {}", entriesReplicated, tableName);
return entriesReplicated;
}
use of org.apache.accumulo.core.conf.AccumuloConfiguration in project accumulo by apache.
the class VolumeManagerImpl method getLocal.
public static org.apache.accumulo.server.fs.VolumeManager getLocal(String localBasePath) throws IOException {
AccumuloConfiguration accConf = DefaultConfiguration.getInstance();
Volume defaultLocalVolume = VolumeConfiguration.create(FileSystem.getLocal(CachedConfiguration.getInstance()), localBasePath);
// The default volume gets placed in the map, but local filesystem is only used for testing purposes
return new VolumeManagerImpl(Collections.singletonMap(DEFAULT, defaultLocalVolume), defaultLocalVolume, accConf);
}
Aggregations