Search in sources :

Example 26 with AccumuloConfiguration

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

Example 27 with AccumuloConfiguration

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);
}
Also used : IOException(java.io.IOException) LoggingRunnable(org.apache.accumulo.fate.util.LoggingRunnable) Daemon(org.apache.accumulo.core.util.Daemon) ContextManager(org.apache.accumulo.start.classloader.vfs.ContextManager) LoggingRunnable(org.apache.accumulo.fate.util.LoggingRunnable) Tablet(org.apache.accumulo.tserver.tablet.Tablet) Map(java.util.Map) TreeMap(java.util.TreeMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) LRUMap(org.apache.commons.collections.map.LRUMap) SortedMap(java.util.SortedMap) HashMap(java.util.HashMap) HashSet(java.util.HashSet) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration)

Example 28 with AccumuloConfiguration

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);
    }
}
Also used : Status(org.apache.accumulo.server.replication.proto.Replication.Status) Instance(org.apache.accumulo.core.client.Instance) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance) HdfsZooInstance(org.apache.accumulo.server.client.HdfsZooInstance) KerberosToken(org.apache.accumulo.core.client.security.tokens.KerberosToken) ClientContext(org.apache.accumulo.core.client.impl.ClientContext) ServerConfigurationFactory(org.apache.accumulo.server.conf.ServerConfigurationFactory) IOException(java.io.IOException) PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) File(java.io.File) RFile(org.apache.accumulo.core.file.rfile.RFile) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation)

Example 29 with AccumuloConfiguration

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;
}
Also used : AccumuloException(org.apache.accumulo.core.client.AccumuloException) Table(org.apache.accumulo.core.client.impl.Table) RemoteReplicationException(org.apache.accumulo.core.replication.thrift.RemoteReplicationException) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) AccumuloReplicationReplayer(org.apache.accumulo.core.replication.AccumuloReplicationReplayer) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration)

Example 30 with AccumuloConfiguration

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

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