Last updated January 27, 2011 12:06, by Jørgen Austvik
Feedicon  

Resource Allocations

Resource allocations let you reserve some shared resource, so that different tests does not use the same resource and fail because of it.

General

The com.sun.jet.jag.client.ResourceAllocatorClient let you reserve a resource on a machine. It is a simple mechanism that lets you store values in a Map<String, Object> that lives in JAG.

If you use the ResourceAllocator, you should probably write a wrapper around it, like PortAllocator, to make it easy to use.

Port Numbers

The com.sun.jet.jag.client.PortAllocator client let you allocate port number for the given batch, rig or machine. Internally the PortAllocator uses the ResourceAllocator on the first client machine for all allocations, so it doesn't matter which JAG you start the port allocator agains.

Before the PortAllocator existed, JETPorts were used to reserve port numbers. The problem with JETPorts is that it can not work in a setting with more than one client (it stored its setting in map/hash in a single JVM), so JETPorts has been deprecated.

There are four methods that you should use, depending on which scope you want to reserve the port for :

 int getBatchPort(String process)
 int getRigPort(String process, String rigName) 
 int getMachinePort(String process, JAGInstance machine)
 void deallocatePort(int portNr)

PortAllocator checks that all allocations for a process are done on the same level. That is if you allocate process "foo" on a machine, and later try to allocate it for a batch, you will get an error.

If you getMachinePort("bar", ...) on two different machines, you might or might not get the same port number, but you are sure that the port number is not reserved on rig or batch level.

After you are finished using a port, you should deallocate it with deallocatePort().

  • Mysql
  • Glassfish
  • Jruby
  • Rails
  • Nblogo
Terms of Use; Privacy Policy;
© 2010, Oracle Corporation and/or its affiliates
(revision 20120518.3c65429)
 
 
Close
loading
Please Confirm
Close