views:

28

answers:

4

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?

+1  A: 

Fork it or use Threads?

Stefan
+1  A: 

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.

Alexander Pogrebnyak
+1  A: 

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:

  1. Grab a global lock
  2. Pick a random fistful of ports
  3. Edit the configuration file to use those ports
  4. Spawn the fitness program
  5. 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:

  1. Copy the configuration file to a temporary location
  2. Pick a random fistful of ports
  3. Edit the copy of the configuration file to use those ports
  4. Spawn the fitness program using that copy of the configuration file

Any use?

Tom Anderson
Yes, you can specify which ports are to be used in the conf file. Althoud I can't tell the program which conf file to use, I can start the proggram, overwrite the conf file, start a second instance that binds other ports.
reseter
A: 

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?

Jonathan
The fitness application uses a client/server architecture and the two parts communicate over a UDP connection.
reseter