禁用服务器的不必要的concurrent manager

本文指导如何在Oracle E-Business Suite实例中,通过调整环境变量和使用Oracle Applications Manager (OAM) Context Editor,禁用不必要的服务器上的concurrentmanager,以实现更高效的批量处理服务。
禁用某服务器的不必要的concurrent manager,参考:
2.2 Enabling Concurrent Processing (Batch) Service on Application Tier Node(s)
In a multi-node Oracle E-Business Suite instance, you can have more than one application node where the Concurrent Processing (Batch) service is enabled. All the application node(s) where the Concurrent Processing (Batch) service is enabled should have the $APPLCSF and $FNDREVIVERPID environment variables set to the same value. A shared file system should be allocated for the concurrent manager logs and reviver pids. Verify and update the context file using the Oracle Applications Manager (OAM) Context Editor for all the Application Node(s):
Variable Name Variable Value
s_applcsf Same on all nodes
s_fndreviverpiddir Same on all nodes
s_isAdConc YES
s_isAdConcDev YES
s_batch_status enabled


也就是在不必要的服务器上把此参数改为disable,做autoconfig,以后就可以直接用adstrtal.sh 启动(不启动concurrent manager)

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/35489/viewspace-718830/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/35489/viewspace-718830/

package com.hn.nxaq.utils; import org.jodconverter.core.DocumentConverter; import org.jodconverter.core.document.DefaultDocumentFormatRegistry; import org.jodconverter.core.document.DocumentFormat; import org.jodconverter.core.office.OfficeException; import org.jodconverter.core.office.OfficeManager; import org.jodconverter.local.LocalConverter; import org.jodconverter.local.office.LocalOfficeManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; import java.util.concurrent.TimeoutException; /** * PPTX转PDF工具类,使用LibreOffice进行文档转换 */ public class Pdfutis { private static final Logger logger = LoggerFactory.getLogger(Pdfutis.class); private static final String LIBRE_OFFICE_HOME = "D:\\LibreOffice"; // LibreOffice安装路径 private static final long CONNECTION_TIMEOUT = 30000; // 连接超时时间(毫秒),减少到30秒 private static final long TASK_TIMEOUT = 120000; // 转换任务超时时间(毫秒),减少到2分钟 private static final long PROCESS_RETRY_INTERVAL = 500; // 进程检查重试间隔(毫秒) private OfficeManager officeManager; private DocumentConverter converter; private boolean initialized = false; /** * 初始化LibreOffice服务 */ public synchronized void init() { if (initialized && officeManager != null && officeManager.isRunning()) { logger.info("LibreOffice服务已在运行,无需重新初始化"); return; } try { // 仅在Windows系统终止残留进程,其他系统可能不需要 if (System.getProperty("os.name").toLowerCase().contains("win")) { killExistingProcesses(); } // 优化服务配置 officeManager = LocalOfficeManager.builder() .officeHome(new File(LIBRE_OFFICE_HOME)) .portNumbers(8100) .taskExecutionTimeout(TASK_TIMEOUT) .taskQueueTimeout(CONNECTION_TIMEOUT) .processTimeout(60000l) // 减少进程超时时间 .processRetryInterval(PROCESS_RETRY_INTERVAL) .disableOpengl(true) // 禁用OpenGL加速,可能提高稳定性 //.templateProfileDir(null) // 不使用模板配置文件 .build(); converter = LocalConverter.builder() .officeManager(officeManager) .build(); officeManager.start(); initialized = true; logger.info("LibreOffice服务启动成功"); } catch (OfficeException e) { logger.error("启动LibreOffice服务失败", e); initialized = false; throw new RuntimeException("初始化文档转换服务失败", e); } } /** * 终止所有残留的LibreOffice进程 */ private void killExistingProcesses() { try { // 使用WMIC命令查找所有LibreOffice进程 Process process = Runtime.getRuntime().exec("wmic process where \"name like 'soffice%'\" get processid"); BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); String line; while ((line = reader.readLine()) != null) { line = line.trim(); if (line.matches("\\d+")) { int pid = Integer.parseInt(line); // 终止进程 Runtime.getRuntime().exec("taskkill /F /PID " + pid); logger.info("已终止残留的LibreOffice进程: {}", pid); } } reader.close(); process.waitFor(); } catch (Exception e) { logger.error("检查/终止残留进程时出错", e); } } /** * 将PPTX文件转换为PDF * @param sourceFile PPTX源文件 * @param targetFile PDF目标文件 * @return 转换成功返回true,失败返回false */ public boolean convertPPTXToPDF(File sourceFile, File targetFile) { if (!initialized || officeManager == null || !officeManager.isRunning()) { logger.info("LibreOffice服务未启动,正在初始化..."); init(); } if (!sourceFile.exists() || !sourceFile.isFile()) { logger.error("源文件不存在: {}", sourceFile.getAbsolutePath()); return false; } // 检查临时目录 if (!checkTempDirectory()) { return false; } try { // 检查文件格式 DocumentFormat sourceFormat = DefaultDocumentFormatRegistry.getFormatByExtension("pptx"); DocumentFormat targetFormat = DefaultDocumentFormatRegistry.getFormatByExtension("pdf"); if (sourceFormat == null || targetFormat == null) { logger.error("不支持的文件格式"); return false; } logger.info("开始转换PPTX到PDF: {}", sourceFile.getName()); long startTime = System.currentTimeMillis(); // 执行转换 converter.convert(sourceFile) .as(sourceFormat) .to(targetFile) .as(targetFormat) .execute(); long endTime = System.currentTimeMillis(); logger.info("转换完成,耗时: {}ms,目标文件: {}", (endTime - startTime), targetFile.getAbsolutePath()); // 验证输出文件 if (targetFile.exists() && targetFile.length() > 0) { logger.info("目标文件验证成功: {} ({} bytes)", targetFile.getName(), targetFile.length()); return true; } else { logger.error("目标文件生成失败或为空: {}", targetFile.getAbsolutePath()); return false; } } catch (OfficeException e) { logger.error("转换过程中发生错误: {}", e.getMessage(), e); handleConversionError(e); return false; } catch (Exception e) { logger.error("未知错误", e); return false; } } /** * 检查临时目录状态 */ private boolean checkTempDirectory() { File tempDir = new File(System.getProperty("java.io.tmpdir")); if (!tempDir.exists() || !tempDir.isDirectory()) { logger.error("临时目录不存在: {}", tempDir.getAbsolutePath()); return false; } if (!tempDir.canWrite()) { logger.error("临时目录不可写: {}", tempDir.getAbsolutePath()); return false; } // 检查可用空间(至少500MB) long freeSpace = tempDir.getFreeSpace(); if (freeSpace < 536870912L) { // 500MB logger.error("临时目录可用空间严重不足: {}GB,转换可能失败", freeSpace / 1073741824L); return false; } else if (freeSpace < 1073741824L) { // 1GB logger.warn("临时目录可用空间不足: {}GB", freeSpace / 1073741824L); } return true; } /** * 处理转换错误并尝试恢复 */ private void handleConversionError(OfficeException e) { // 检查错误类型 if (e.getCause() instanceof TimeoutException) { logger.error("超时错误: 转换任务执行时间过长,当前超时设置为 {}ms", TASK_TIMEOUT); } // 尝试获取更多诊断信息 if (officeManager instanceof LocalOfficeManager) { LocalOfficeManager localManager = (LocalOfficeManager) officeManager; try { logger.info("LibreOffice服务状态: {}", localManager.isRunning() ? "运行中" : "已停止"); } catch (Exception ex) { logger.error("获取服务状态失败", ex); } } // 仅在服务未运行时重启 if (officeManager != null && !officeManager.isRunning()) { restartOfficeManager(); } } /** * 重启LibreOffice服务 */ private synchronized void restartOfficeManager() { if (officeManager == null) { logger.info("服务未初始化,跳过重启"); return; } try { logger.info("准备重启LibreOffice服务..."); // 终止残留进程 if (System.getProperty("os.name").toLowerCase().contains("win")) { killExistingProcesses(); } if (officeManager.isRunning()) { officeManager.stop(); logger.info("已停止当前LibreOffice服务"); } // 重新启动 officeManager.start(); initialized = true; logger.info("LibreOffice服务已重启"); } catch (OfficeException e) { logger.error("重启服务失败", e); initialized = false; } } /** * 关闭LibreOffice服务 */ public void shutdown() { try { if (officeManager != null && officeManager.isRunning()) { officeManager.stop(); logger.info("LibreOffice服务已关闭"); } initialized = false; } catch (OfficeException e) { logger.error("关闭服务失败", e); } } /** * 主方法示例 */ public static void main(String[] args) { Pdfutis converter = new Pdfutis(); converter.init(); try { File source = new File("D:\\project\\7.早调会发言材料 第二十二周.pptx"); File target = new File("D:\\project\\pdf\\test.pdf"); boolean result = converter.convertPPTXToPDF(source, target); if (result) { System.out.println("转换成功"); } else { System.out.println("转换失败"); } } finally { converter.shutdown(); // 确保资源释放 } } } 转换速度比较慢
07-17
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值