Assuring that the generated random number is positive
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/vre-management/smart-executor-client@112002 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
4bda8dc2d7
commit
2eeb9419c8
|
@ -79,10 +79,18 @@ public class SmartExecutorPluginQuery implements Query<EndpointReference> {
|
|||
throw new DiscoveryException("No running SmartExecutor wich match the requested conditions");
|
||||
}
|
||||
|
||||
/* Getting randomly one the host */
|
||||
/*
|
||||
* Generating a random number, assuring that is positive and
|
||||
* and limiting from 0 to the number of discovered ServiceEndpoints
|
||||
* Please note that there is only one ServiceEndpoints for each running
|
||||
* ghn
|
||||
*/
|
||||
Random random = new Random();
|
||||
int i = random.nextInt() % serviceEndpoints.size();
|
||||
int number = random.nextInt();
|
||||
number = (number < 0) ? -number : number;
|
||||
int i = number % serviceEndpoints.size();
|
||||
|
||||
/* Getting random hosts using the generated random number*/
|
||||
String hostedOn = serviceEndpoints.get(i).profile().runtime().hostedOn();
|
||||
gCoreEndpointDiscoveryQuery.addCondition(format(containsFormat, hostedOn));
|
||||
|
||||
|
|
Loading…
Reference in New Issue