Storm:如何使用HA HDFS在HdfsBolt()中定义HDFS URI

时间:2016-04-14 12:05:48

标签: hdfs apache-storm

我尝试使用HdfsBolt将Storm拓扑的输出写入启用HA的HDFS。拓扑定义如下:

// Use pipe as record boundary
RecordFormat format = new DelimitedRecordFormat().withFieldDelimiter("|");
//Synchronize data buffer with the filesystem every 1000 tuples
SyncPolicy syncPolicy = new CountSyncPolicy(1000);
// Rotate data files when they reach five MB
FileRotationPolicy rotationPolicy = new FileSizeRotationPolicy(5.0f, FileSizeRotationPolicy.Units.MB);
// Use default, Storm-generated file names
FileNameFormat fileNameFormat = new DefaultFileNameFormat().withPath("/foo");

HdfsBolt hdfsBolt = new HdfsBolt()
      .withFsUrl("hdfs://devhdfs")
      .withFileNameFormat(fileNameFormat)
      .withRecordFormat(format)
      .withRotationPolicy(rotationPolicy)
      .withSyncPolicy(syncPolicy);

问题在于HdfsBolt不知道hdfs://devhdfs的价值,并触发了java.net.UnknownHostException

Caused by: java.lang.IllegalArgumentException: java.net.UnknownHostException: prehdfs

我有原始 core-site.xml ,其中包含该定义,但我不知道如何将其传递给HdfsBolt。任何提示?

2 个答案:

答案 0 :(得分:0)

Storm无法找到主持人" devhdfs"在网络中。通过ping检查主机是否可用,并检查hdfsurl是否有端口" hdfs:// devhdfs:port"并传递相同并尝试

答案 1 :(得分:0)

似乎将core-site.xmlhdfs-site.xml放入src/main/resources是可行的方法:)

我现在遇到其他一些问题,但它们似乎与HA有关,而与风暴无关。