Hi, I have a java application (a genetic algorithm, to be precise) that periodically starts a native process (the fitness function), waits for it to complete and reads the file it outputs. However, the native process can only be run once, because it reads from a conf file and binds a few sockets. Is there a way to virtualize the native process so that I can run multiple copies simultaneously?
Can process be run simultaneously at all from command line?
If it binds to the same port all the time, then it does not look to me that it can.
Judging from your tags, i think you're asking if there's a java API for machine virtualisation. Sadly, there isn't.
Of course, you can use java (with such native glue code or scripts are as necessary) to drive anything the operating system can do, so you could use java to spawn VMs to run the fitness program. Might be rather painful, though.
Are the ports bound specified in the conf file? Could you use a procedure like:
- Grab a global lock
- Pick a random fistful of ports
- Edit the configuration file to use those ports
- Spawn the fitness program
- Release the lock
To have several running at once?
Even better, if you can tell the program where to look for its config file, you can do this without the lock:
- Copy the configuration file to a temporary location
- Pick a random fistful of ports
- Edit the copy of the configuration file to use those ports
- Spawn the fitness program using that copy of the configuration file
Any use?
Sounds like you need to modify the fitness process or coordinate with multiple physical/virtual machines to run a distributed app.
To go the distributed route, your main program needs to connect to a similar process on each of the other machines you want to use and coordinate when/what to run when it needs to do fitness calculations.
Why does your fitness test need to bind to ports?