需要通用/动态序列化/编组,类似于 Terracotta
问题:我使用的软件 Lift 有“用户会话”,可以在其中放置任何类型的对象,这些对象在用户请求之间保留(带有 GC 超时)。虽然它易于使用且功能强大,但它有一个主要缺点:对象不可序列化,因此您无法将它们分发到其他服务器实例以实现高可用性。
是否有一个 API/工具可以获取一个随机对象,通过反射分析它的结构,创建一个可以提取所有对象数据的编组器/反编组器,并以一种可用于将对象分发到的格式返回它其他 JVM。编组器/解组器本身应该是可序列化的。应该有一种方法来明确定义一些数据应该被忽略,例如使用瞬态,并且还应该能够认识到一些引用的对象实际上是必须以特殊方式处理的系统对象(单例)。理想情况下,它应该是一个迭代过程,因此您可以限制要编组的对象的“大小”。
这有点类似于 Terracotta 所做的,只不过我想实现自己的传输和后端,并且我不想使用他们的“增强器”,因为将类的包限制为修改,因此它必须在运行时修改我的所有类以防万一,这将非常昂贵。
编辑:严格来说,拥有自己的传输和后端并不是绝对必须的,但 Terracotta 的服务器是单点故障,我想要一个完全分布式的系统,我可以在其中强制进行最小复制级别,以及我可以将请求转发到拥有用户会话副本的服务器。
Problem: The Software I use, Lift, has "user sessions", where one can put any kind of objects, which are preserved between user requests (with a GC timeout). While it's easy to use and powerful, it has one major drawback: the objects aren't serializable, so you cannot distribute them to other server instances to achieve high availability.
Is there an API/tool out there that can take a random object, analyze it's structure through reflection, create a marshaller/unmarshaller that can extract all the object's data, and return it in a format that can then be used to distribute the object to other JVM. The marshaller/unmarshaller itself should be serializable. There should be a way to explicitly define that some data should be ignored, like using transient for example, and it should also be possible to recognize that some referenced objects are actually system objects (singletons) that have to be handled in a special way. Ideally, it should be an iterative process, so you can put a limit to how "big" the object to marshal can be.
This is somewhat similar to what Terracotta does, except that I want to implement my own transport and back-end, and I don't want to use their "enhancer", because it would be very difficult to limit the packages of the classes to modify, and so it would have to modify all my classes at run-time just in case, which would be very expensive.
Edit: Strictly speaking, having my own transport and back-end isn't an absolute must, but Terracotta's server is a Single-Point-Of-Failure, and I want a system that is thoroughly distributed, where I can force a minimum replication level, and where I can forward a request to a server owning a copy of the user session.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
虽然这不是我想要的,但我发现至少有一种 Terracotta 的替代品,称为 XSTM 它们似乎有相似的概念,同时更具“可扩展性”。
Although this isn't quite what I wanted, I found out that there is at least one alternative to Terracotta, which is called XSTM They seem to have a similar concept, while being more "extensible".