使用的 oozie 版本为 5.1
oozie 自定义 service步骤
- 实现
org.apache.oozie.service.Service
接口 - 修改 oozie 服务的配置文件
- 放置 jar 包
- 重启 oozie 服务
实现接口
实现 org.apache.oozie.service.Service
接口,使用 init
方法来初始化资源,使用 destory
方法来释放资源
新建一个 Maven
项目,引入 oozie
依赖,版本需要和 oozie 服务版本对应
<dependency>
<groupId>org.apache.oozie</groupId>
<artifactId>oozie-core</artifactId>
<version>5.1.0</version>
<scope>provided</scope>
</dependency>
自定义类实现 org.apache.oozie.service.Service
接口
package net.zhboom.service
import org.apache.oozie.service.Service;
import org.apache.oozie.service.ServiceException;
import org.apache.oozie.service.Services;
import org.apache.oozie.util.XLog;
/**
* @author zhboom
* @date 2023/5/19
*/
public class CustomOozieService implements Service {
private static XLog LOG = XLog.getLog(CustomOozieService.class);
@Override
public void init(Services services) throws ServiceException {
LOG.info("custom oozie service init");
}
@Override
public void destroy() {
LOG.info("custom oozie service destory");
}
@Override
public Class<? extends Service> getInterface() {
return CustomOozieService.class;
}
}
修改配置
修改 oozie-site.xml
文件,修改配置 oozie.services.ext
,多个自定义服务之间用英文逗号隔开
<property>
<name>oozie.services.ext</name>
<value>net.zhboom.service.CustomOozieService</value>
</property>
如果使用了 CM 管理,则只需在配置搜索 oozie.services.ext
并添加值即可
放置 jar 包
将自定义服务类打成 jar 包
并放置到 oozie server 所在的 libext/
文件夹下(注意配置权限)
重启服务
最后再重启 oozie 服务,自定义 oozie service 就完成了