servicename被忽略

kokeuurv  于 2021-06-02  发布在  Hadoop
关注(0)|答案(0)|浏览(229)

这是我的构建配置方法

private Configuration buildConfiguration() {
        Configuration conf = new Configuration();

        if (connectivityDetail.isSecureMode()) {
            conf.set("hadoop.security.authentication", "kerberos");
            conf.set("hadoop.http.authentication.type", "kerberos");
            conf.set("dfs.namenode.kerberos.principal", connectivityDetail.getHdfsServicePrincipal());
        }

        if (isHAEnabled()) {
            String hdfsServiceName = connectivityDetail.getHdfsServiceName();

            conf.set("fs.defaultFS", "hdfs://" + hdfsServiceName);
            conf.set("dfs.ha.namenodes." + hdfsServiceName, "nn0,nn1");
            conf.set("dfs.nameservices", hdfsServiceName);
            conf.set("dfs.client.failover.proxy.provider." + hdfsServiceName,
                    "org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider");
            conf.set("dfs.namenode.rpc-address." + hdfsServiceName + ".nn1",
                    connectivityDetail.getNameNodeUris().get(0));
            conf.set("dfs.namenode.rpc-address." + hdfsServiceName + ".nn0",
                    connectivityDetail.getNameNodeUris().get(1));
        }
        return conf;

    }

hdfsservice名称被错误地设置到配置对象中,但是我能够获得文件系统,并且一切都正常工作。我不知道为什么它不使用服务名称?
这就是我创建路径的方式

public static Path getHdfsResourceLocation(String resourceLocation) throws Exception {
         String[] hdfsURIs = OrchestrationConfigUtil.getHdfsUri();
         Path hdfsResourceLoc = null;
         if (isHAEnabled()) {
             hdfsResourceLoc = new Path(resourceLocation);
         } else {
             hdfsResourceLoc = FileContext.getFileContext(new URI(hdfsURIs[0])).makeQualified(new Path(resourceLocation));
         }
         return hdfsResourceLoc;
     }

一切正常工作与错误的服务名称,我不知道为什么?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题