use of org.apache.hadoop.io.Text in project camel by apache.
the class HdfsProducerTest method testWriteTextWithKey.
@Test
public void testWriteTextWithKey() throws Exception {
if (!canTest()) {
return;
}
String txtKey = "THEKEY";
String txtValue = "CIAO MONDO !";
template.sendBodyAndHeader("direct:write_text2", txtValue, "KEY", txtKey);
Configuration conf = new Configuration();
Path file1 = new Path("file:///" + TEMP_DIR.toUri() + "/test-camel-text2");
FileSystem fs1 = FileSystem.get(file1.toUri(), conf);
SequenceFile.Reader reader = new SequenceFile.Reader(fs1, file1, conf);
Text key = (Text) ReflectionUtils.newInstance(reader.getKeyClass(), conf);
Text value = (Text) ReflectionUtils.newInstance(reader.getValueClass(), conf);
reader.next(key, value);
assertEquals(key.toString(), txtKey);
assertEquals(value.toString(), txtValue);
IOHelper.close(reader);
}
use of org.apache.hadoop.io.Text in project camel by apache.
the class HdfsProducerTest method testArrayWriteText.
@Test
public void testArrayWriteText() throws Exception {
if (!canTest()) {
return;
}
String txtValue = "CIAO MONDO !";
template.sendBody("direct:write_text4", txtValue);
Configuration conf = new Configuration();
Path file1 = new Path("file:///" + TEMP_DIR.toUri() + "/test-camel-text4");
FileSystem fs1 = FileSystem.get(file1.toUri(), conf);
ArrayFile.Reader reader = new ArrayFile.Reader(fs1, "file:///" + TEMP_DIR.toUri() + "/test-camel-text4", conf);
Text value = (Text) ReflectionUtils.newInstance(reader.getValueClass(), conf);
reader.next(value);
assertEquals(value.toString(), txtValue);
IOHelper.close(reader);
}
use of org.apache.hadoop.io.Text in project camel by apache.
the class HdfsProducerTest method testProducerClose.
@Test
public void testProducerClose() throws Exception {
if (!canTest()) {
return;
}
for (int i = 0; i < 10; ++i) {
// send 10 messages, and mark to close in last message
template.sendBodyAndHeader("direct:start1", "PAPPO" + i, HdfsConstants.HDFS_CLOSE, i == 9 ? true : false);
}
Configuration conf = new Configuration();
Path file1 = new Path("file:///" + TEMP_DIR.toUri() + "/test-camel1");
SequenceFile.Reader reader = new SequenceFile.Reader(conf, SequenceFile.Reader.file(file1));
Writable key = (Writable) ReflectionUtils.newInstance(reader.getKeyClass(), conf);
Writable value = (Writable) ReflectionUtils.newInstance(reader.getValueClass(), conf);
int i = 0;
while (reader.next(key, value)) {
Text txt = (Text) value;
assertEquals("PAPPO" + i, txt.toString());
++i;
}
IOHelper.close(reader);
}
use of org.apache.hadoop.io.Text in project camel by apache.
the class HdfsProducerTest method testMapWriteTextWithKey.
@Test
public void testMapWriteTextWithKey() throws Exception {
if (!canTest()) {
return;
}
String txtKey = "THEKEY";
String txtValue = "CIAO MONDO !";
template.sendBodyAndHeader("direct:write_text3", txtValue, "KEY", txtKey);
Configuration conf = new Configuration();
MapFile.Reader reader = new MapFile.Reader(new Path("file:///" + TEMP_DIR.toUri() + "/test-camel-text3"), conf);
Text key = (Text) ReflectionUtils.newInstance(reader.getKeyClass(), conf);
Text value = (Text) ReflectionUtils.newInstance(reader.getValueClass(), conf);
reader.next(key, value);
assertEquals(key.toString(), txtKey);
assertEquals(value.toString(), txtValue);
IOHelper.close(reader);
}
use of org.apache.hadoop.io.Text 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