2015-09-05 306 views
3

我想在本地运行风暴起动器项目。我下面的说明从 -执行风暴起动器时出错

https://github.com/apache/storm/tree/master/examples/storm-starter

但是当我尝试执行风暴jar命令,我得到

ERROR StatusLogger Invalid URL C:/Users/xyzabc/apache-storm-0.10.0-beta/log4j2/cluster.xml java.net.MalformedURLException: unknown protocol: c 

我认为这是与在定义下面的一段cluster.xml和worker.xml

<RollingFile name="METRICS" 
       fileName="${sys:storm.log.dir}/metrics.log" 
       filePattern="${sys:storm.log.dir}/metrics.log.%i"> 

所以显然文件名需要像

file:///C:/Users/xyzabc/apache-storm-0.10.0-beta/log4j2/cluster.xml 

但是当我尝试这样做,通过设置

<RollingFile name="METRICS" 
        fileName="file:///${sys:storm.log.dir}/metrics.log" 
        filePattern="file:///${sys:storm.log.dir}/metrics.log.%i"> 

我得到这个错误

ERROR Unable to create file file:///C:\Users\xyzabc\apache-storm-0.10.0-beta\logs/metrics.log java.io.IOException: The filename, directory name, or volume label syntax is incorrect 

,你可以看到,它完全莫名其妙地打乱了的文件路径。

有没有一种方法可以在xml属性中正确呈现“file:///”?

+0

您尝试运行风暴启动的哪种拓扑结构?你真的需要指定前缀'file://'(btw:它应该只有两个斜线,而不是三个)。此外,我想知道(但我不是窗口用户)为什么你使用斜杠而不是反斜杠? –

+0

我的解决方案对您有帮助吗? –

回答

1

根据Microsoft命名约定,您应该只使用backslashes on the path,但是您应该使用反斜杠和前斜杠。

file:///C:\Users\xyzabc\apache-storm-0.10.0-beta\logs/metrics.log 

还有更多:

Note File I/O functions in the Windows API convert "/" to "\" as part of converting the name to an NT-style name, except when using the "\?\" prefix as detailed in the following sections.

For file I/O, the "\?\" prefix to a path string tells the Windows APIs to disable all string parsing and to send the string that follows it straight to the file system. For example, if the file system supports large paths and file names, you can exceed the MAX_PATH limits that are otherwise enforced by the Windows APIs. For more information about the normal maximum path limitation, see the previous section Maximum Path Length Limitation.

+0

有关于此的任何更新?如果可能,请尝试指定需要执行的操作 – AbtPst

+1

@ user2334092将正斜线更改为反斜杠... $ {sys:storm.log.dir} /metrics.log to $ {sys:storm.log.dir} \ metrics.log –

+0

我还需要file:///的前缀吗? – AbtPst

0

同样的问题,兄弟
但是,这个错误后:

storm\bin>ERROR StatusLogger Invalid URL D:/stuff/storm/log4j2/cluster.xml java.net.MalformedURLException: unknown protocol: d 

如果您打开Java进程,你会看到,全部作品:
screenshot

0

我有同样的问题,我编辑的风暴config.cmd并补充协议的URL ENV瓦尔:

if not %STORM_LOGBACK_CONFIGURATION_DIR% == nil (
    set STORM_LOGBACK_CONFIGURATION_FILE=file://%STORM_LOGBACK_CONFIGURATION_DIR%\cluster.xml 
) 

if not defined STORM_LOGBACK_CONFIGURATION_FILE (
    set STORM_LOGBACK_CONFIGURATION_FILE=file://%STORM_HOME%\log4j2\cluster.xml 
) 

我相信你所得到的“无法创建文件”的问题,因为它期待一个路径,而不是一个URL。尝试恢复这些更改并查看它是否有效。

+0

这些行已经存在于storm-config.cmd中。他们需要在storm-config.cmd中通过添加“file://”前缀来修改,而不是在storm.cmd中。 – VladH

2

删除\ log4j2 \ worker.xml和\ log4j2 \ cluster.xml中的所有更改。

编辑\ bin \ storm-config.cmd并在指定条目下修改。

set STORM_LOGBACK_CONFIGURATION_FILE=%STORM_LOGBACK_CONFIGURATION_DIR%\cluster.xml

set STORM_LOGBACK_CONFIGURATION_FILE=file://%STORM_LOGBACK_CONFIGURATION_DIR%\cluster.xml

set STORM_LOGBACK_CONFIGURATION_FILE=%STORM_HOME%\log4j2\cluster.xml

set STORM_LOGBACK_CONFIGURATION_FILE=file://%STORM_HOME%\log4j2\cluster.xml

这则广告文件://关于logback配置条目storm-config.cmd有助于解决问题。