use of org.apache.hadoop.conf.Configuration in project camel by apache.
the class HdfsAppendTest method testAppend.
@Test
public void testAppend() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start1").to("hdfs2://localhost:9000/tmp/test/test-camel-simple-write-file1?append=true&fileSystemType=HDFS");
}
});
startCamelContext();
for (int i = 0; i < 10; ++i) {
template.sendBody("direct:start1", "PIPPQ");
}
Configuration conf = new Configuration();
Path file = new Path("hdfs://localhost:9000/tmp/test/test-camel-simple-write-file1");
FileSystem fs = FileSystem.get(file.toUri(), conf);
FSDataInputStream in = fs.open(file);
byte[] buffer = new byte[5];
int ret = 0;
for (int i = 0; i < 20; ++i) {
ret = in.read(buffer);
System.out.println("> " + new String(buffer));
}
ret = in.read(buffer);
assertEquals(-1, ret);
in.close();
}
use of org.apache.hadoop.conf.Configuration in project camel by apache.
the class HdfsAppendTest method testAppendWithDynamicFileName.
@Test
public void testAppendWithDynamicFileName() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start1").to("hdfs2://localhost:9000/tmp/test-dynamic/?append=true&fileSystemType=HDFS");
}
});
startCamelContext();
for (int i = 0; i < ITERATIONS; ++i) {
template.sendBodyAndHeader("direct:start1", "HELLO", Exchange.FILE_NAME, "camel-hdfs2.log");
}
Configuration conf = new Configuration();
Path file = new Path("hdfs://localhost:9000/tmp/test-dynamic/camel-hdfs2.log");
FileSystem fs = FileSystem.get(file.toUri(), conf);
FSDataInputStream in = fs.open(file);
byte[] buffer = new byte[5];
for (int i = 0; i < ITERATIONS; ++i) {
assertEquals(5, in.read(buffer));
System.out.println("> " + new String(buffer));
}
int ret = in.read(buffer);
assertEquals(-1, ret);
in.close();
}
use of org.apache.hadoop.conf.Configuration in project hadoop by apache.
the class DelegationTokenAuthenticationFilter method getProxyuserConfiguration.
/**
* Returns the proxyuser configuration. All returned properties must start
* with <code>proxyuser.</code>'
* <p/>
* Subclasses may override this method if the proxyuser configuration is
* read from other place than the filter init parameters.
*
* @param filterConfig filter configuration object
* @return the proxyuser configuration properties.
* @throws ServletException thrown if the configuration could not be created.
*/
protected Configuration getProxyuserConfiguration(FilterConfig filterConfig) throws ServletException {
// this filter class gets the configuration from the filter configs, we are
// creating an empty configuration and injecting the proxyuser settings in
// it. In the initialization of the filter, the returned configuration is
// passed to the ProxyUsers which only looks for 'proxyusers.' properties.
Configuration conf = new Configuration(false);
Enumeration<?> names = filterConfig.getInitParameterNames();
while (names.hasMoreElements()) {
String name = (String) names.nextElement();
if (name.startsWith(PROXYUSER_PREFIX + ".")) {
String value = filterConfig.getInitParameter(name);
conf.set(name, value);
}
}
return conf;
}
use of org.apache.hadoop.conf.Configuration in project hadoop by apache.
the class DelegationTokenAuthenticationFilter method init.
@Override
public void init(FilterConfig filterConfig) throws ServletException {
super.init(filterConfig);
AuthenticationHandler handler = getAuthenticationHandler();
AbstractDelegationTokenSecretManager dtSecretManager = (AbstractDelegationTokenSecretManager) filterConfig.getServletContext().getAttribute(DELEGATION_TOKEN_SECRET_MANAGER_ATTR);
if (dtSecretManager != null && handler instanceof DelegationTokenAuthenticationHandler) {
DelegationTokenAuthenticationHandler dtHandler = (DelegationTokenAuthenticationHandler) getAuthenticationHandler();
dtHandler.setExternalDelegationTokenSecretManager(dtSecretManager);
}
if (handler instanceof PseudoAuthenticationHandler || handler instanceof PseudoDelegationTokenAuthenticationHandler) {
setHandlerAuthMethod(SaslRpcServer.AuthMethod.SIMPLE);
}
if (handler instanceof KerberosAuthenticationHandler || handler instanceof KerberosDelegationTokenAuthenticationHandler) {
setHandlerAuthMethod(SaslRpcServer.AuthMethod.KERBEROS);
}
// proxyuser configuration
Configuration conf = getProxyuserConfiguration(filterConfig);
ProxyUsers.refreshSuperUserGroupsConfiguration(conf, PROXYUSER_PREFIX);
}
use of org.apache.hadoop.conf.Configuration in project hadoop by apache.
the class DelegationTokenAuthenticationHandler method initTokenManager.
@VisibleForTesting
@SuppressWarnings("unchecked")
public void initTokenManager(Properties config) {
Configuration conf = new Configuration(false);
for (Map.Entry entry : config.entrySet()) {
conf.set((String) entry.getKey(), (String) entry.getValue());
}
String tokenKind = conf.get(TOKEN_KIND);
if (tokenKind == null) {
throw new IllegalArgumentException("The configuration does not define the token kind");
}
tokenKind = tokenKind.trim();
tokenManager = new DelegationTokenManager(conf, new Text(tokenKind));
tokenManager.init();
}
Aggregations