apache - 向 Oozie 工作流通知添加授权

标签 apache hadoop oozie oozie-coordinator

Apache Oozie 具有 oozie.wf.workflow.notification.url 属性来通知自定义端点有关作业状态更新。

<property>
    <name>oozie.wf.workflow.notification.url</name>
    <value>http://SERVER:8080/endpoint/oozieUpdate?jobId=$jobId%26status=$status</value>
</property>

我有一个用例,其中端点必须对传入请求进行身份验证,但我找不到允许我配置 Oozie 以便它将身份验证 header 发送到此通知 URL(例如基本身份验证)的解决方案。有办法吗?

最佳答案

我怀疑您能否在 oozie 的当前状态下使用 oozie.wf.workflow.notification.url 来做到这一点。我检查了 oozie source code并发现了这个:

org.apache.oozie.client.OozieClient (属性读入常量):

public static final String WORKFLOW_NOTIFICATION_URL = "oozie.wf.workflow.notification.url";

org.apache.oozie.command.wf.WorkflowNotificationXCommand (常量用于组成proxyConf变量):

public WorkflowNotificationXCommand(WorkflowJobBean workflow) {
    super("job.notification", "job.notification", 0);
    ParamChecker.notNull(workflow, "workflow");
    jobId = workflow.getId();
    url = workflow.getWorkflowInstance().getConf().get(OozieClient.WORKFLOW_NOTIFICATION_URL);
    if (url != null) {
        url = url.replaceAll(JOB_ID_PATTERN, workflow.getId());
        url = url.replaceAll(STATUS_PATTERN, workflow.getStatus().toString());
        proxyConf = workflow.getWorkflowInstance().getConf()
                .get(OozieClient.WORKFLOW_NOTIFICATION_PROXY, ConfigurationService.get(NOTIFICATION_PROXY_KEY));
        LOG.debug("Proxy :" + proxyConf);
    }
}

org.apache.oozie.command.NotificationXCommand (http 使用 proxyConf 变量在 WorkflowNotificationXCommand 的父类(super class)中调用自身):

protected void sendNotification() {
    if (url != null) {
        Proxy proxy = getProxy(proxyConf);
        try {
            URL url = new URL(this.url);
            HttpURLConnection urlConn = (HttpURLConnection) url.openConnection(proxy);
            urlConn.setConnectTimeout(getTimeOut());
            urlConn.setReadTimeout(getTimeOut());
            if (urlConn.getResponseCode() != HttpURLConnection.HTTP_OK) {
                handleRetry();
            }
        }
        catch (IOException ex) {
            handleRetry();
        }
    }
    else {
        LOG.info("No Notification URL is defined. Therefore nothing to notify for job " + jobId);

    }

}

如您所见,此处未使用 httpURLConnection.setRequestProperty(,) 设置 header 。

不过,您可以使用自定义 java 操作来解决问题,您可以使用您喜欢的任何 header 从它进行 http 调用。

关于apache - 向 Oozie 工作流通知添加授权,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38567688/

相关文章:

apache - Tomcat Assets 无法通过 Apache 反向代理加载

hadoop - 如何为Hadoop MapReduce2 History Server启用GC日志记录,同时防止日志文件覆盖和限制磁盘空间使用

hadoop - 具有多个文件的WholeFileInputFormat输入

oozie - oozie 4.2.0 版本中的重试最大值

hadoop - 有没有办法在删除文件时将 skipTrash 选项插入 oozie fs (HDFS) 操作?

php - PHP 中的子域漂亮 URL

php - 将html解析为php,htaccess提示下载

linux - svn : an existing connection was forcibly closed by the remote host

sql - PIG - 如何按具有多个条目的字段分组

hadoop - Hadoop Oozie shell 操作中的 kerberos 票证和委托(delegate) token 使用