gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 15:11:14 25 4
gpt4 key购买 nike

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com