集群环境下后台作业的输出
我正在用Java编写简单的web应用程序(仅用于教育目的),它允许管理员手动执行一些后台维护作业(例如通过Runtime.exec在系统上执行一些进程 - 它实际上不相关)。后台作业 ofc 在其自己的线程中运行并输出一些信息。我想知道,通过网络界面将该输出传递给用户的正确方法是什么?例如,管理员在几分钟后返回,并想要查看他运行的作业的输出。更重要的是,如何在集群环境中解决这个问题,其中作业在单个实例上运行,但输出查看发生在另一个实例上?是否有任何已知的良好实践?
我想,在非集群环境中,内存中的输出缓冲区就足够了。但在集群环境中,我只能想到该输出的数据库/文件存储,但这很麻烦(临时资源必须稍后删除等)。
提前致谢。
I am writing simple webapp in Java (for educational purpuses only) which allows admin to manually execute some background maintenance jobs (e.g. execute some process on system via Runtime.exec - its actually irrelevant). Background job ofc runs in its own thread and outputs some info. I am wondering, whats the correct way to pass that output to user via web interface? For example, admin returns after few minutes, and wants to look at output of job he ran. More importantly, how to solve this in a clustered environment, where job runs on single instance, but output viewing happens on another? Is there any known well practices?
I guess, in non-clustered env output buffer in memory would be enough. But in clustered env i can only think of db/file store for that output, but thats cumbersome (temporary resources must be removed later etc).
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议使用数据库(尽管我同意你的观点,它只是一个临时资源)。
无论您使用什么存储介质,都需要在应用程序服务器集群之间共享,因此需要在某个时候进行整理。与其他任何东西相比,数据库执行内务管理并不困难。
此外,这些“临时”资源随着时间的推移会变得永久,因为后台过程的结果变得更加重要(在审计员等看来),尽管这在您的情况下不太可能
I suggest a database ( although I take your point about it being only a temporary resource ).
Whatever storage medium you use, it'll need to be shared across your application server cluster, and will therefore need to be tidied at some point. A database is no more difficult to perform housekeeping on that anything else.
Also, these "temporary" resources have a habit of becoming permanent over time as the results of the back ground process take on greater significance ( in the eyes of auditors etc ), although that's not likely in your case