JVM Clustering

I have a situation where I need to induce asynchronous behavior in a synchronous application.

To develop, there is a monolithic C ++ application that synchronously prises complex derivative products. This C ++ application comes with a java shell used by my application to interact with it.

Current design

My APP <------> Java Wrapper <---> C++ application 

Since calls from the java shell in C ++ are synchronous, I want to create asynchronous behavior by having a cluster of these java wrappers.

I would have a “Master wrapper” that would decide (either in a circular manner, or based on some real-time information from the cluster) that a separate wrapper receives.

Future design

  <---> Java Wrapper <---> C++ application My APP <------> Java Master Wrapper <---> Java Wrapper <---> C++ application <---> Java Wrapper <---> C++ application 

Do any of you have experience creating something like this? Any tips, links to tutorials, bits of code, etc. Would be most helpful.

Greetings

FYI, I looked briefly at the terracotta, and it seems to me that I need, but this is not an option (not an approved product from my company).

+4
source share
3 answers

If the “Java Master Wrapper” and “My App” are in the same JVM, you can force the Java Master Wrapper to add price results to the overall data structure consumed by My APP streams. If My APPs are different processes / JVMs, you can use JMS to distribute the results. ActiveMQ is one of the JMS providers.

+1
source

Is a C ++ application called as a set of JNI library functions or is it a process? You can simply consider the C ++ spawning subprocesses (give it main() ) and use its output in multiple threads in the same JVM. The C ++ program probably has a much better ability in the individual processes and coordinates several JVMs.

+1
source

It seems that you are not looking for a cluster, but a pool.

If the shell is executable within the same JVM with the main thread, the task is to reuse any of the available thread / worker pools. You can even decompile the shell to find out which classes its main () method uses and try to reproduce it in your application. This is for the CORBA application, it worked fine.

If each wrapper should be in different JVMs, the easiest way would be to allocate a thread pool (again), where each thread would look through its own instance of the Process object, writing requests to stdin, reading responses from stdout.

Of course, the thread for joining is not the most efficient design, so when you earned it, you can go to the model when a small pool of threads (or even one thread) watches a large pool of wrappers Process instances using the selector.

0
source

Source: https://habr.com/ru/post/1314563/


All Articles