使用 Yarn 的注册表错误:服务注册表操作处于错误状态:初始化



我正在尝试编写一个Yarn应用程序主机,它将自己提交到Yarn的注册表(Hadoop2.6)中

从本质上讲,这就是应用程序主程序试图做的事情:

ApplicationId id = ...
String path = ...
YarnConfiguration conf = new YarnConfiguration();    
RegistryOperations registryOperations = RegistryOperationsFactory.createInstance(conf);
ServiceRecord record = new ServiceRecord();
record.set(YarnRegistryAttributes.YARN_ID, applicationId);
record.set(YarnRegistryAttributes.YARN_PERSISTENCE,PersistencePolicies.APPLICATION_ATTEMPT);
registryOperations.bind(path, record, BindFlags.CREATE | BindFlags.OVERWRITE);

当将此代码提交给hadoop2.6时,我得到以下异常:

org.apache.hadoop.service.ServiceStateException: Service RegistryOperations is in wrong state: INITED
at org.apache.hadoop.registry.client.impl.zk.CuratorService.checkServiceLive(CuratorService.java:184)
at org.apache.hadoop.registry.client.impl.zk.CuratorService.zkSet(CuratorService.java:633)
at org.apache.hadoop.registry.client.impl.zk.RegistryOperationsService.bind(RegistryOperationsService.java:114)
...

在谷歌上搜索这个问题没有得到可用的结果,所以我尝试检查相关的Yarn的源代码——目前没有成功

还有人有这个问题吗?你知道是什么原因导致的,或者如何解决吗?

在读取RegistryOperationsFactory javadoc时,它说调用任何create*函数都将初始化生成的RegistryOperations实例。我不知道的是,当RegistryOperationsFactory初始化它时,它仍然需要启动。。所以这个代码有效:

ApplicationId id = ...
String path = ...
YarnConfiguration conf = new YarnConfiguration();    
RegistryOperations registryOperations = RegistryOperationsFactory.createInstance(conf);
registryOperations.start();
ServiceRecord record = new ServiceRecord();
record.set(YarnRegistryAttributes.YARN_ID, applicationId);
record.set(YarnRegistryAttributes.YARN_PERSISTENCE,PersistencePolicies.APPLICATION_ATTEMPT);
registryOperations.bind(path, record, BindFlags.CREATE | BindFlags.OVERWRITE);

相关内容

  • 没有找到相关文章

最新更新