Java Reference
In-Depth Information
} else {
boolean result;
if (values[i].hasNext())
result # true ;
else {
result # false ;
values[i] #
spec.attribute(names[i]).getValues().iterator();
}
value # (Value)values[i].next();
p.add(names[i],value,spec.attribute(names[i]).
getValues());
return result;
}
}
}
20.5.4
Test
The test driver is similar to the previous driver. There are two main
differences:
The preferences of the service provider are generated by the Resource
Allocator .
The driver is responsible for booking the resource upon successful
negotiation and for recomputing the provider's preferences.
import Negotiation.*;
import booking.*;
import java.util.*;
public class TestLocal {
public static void main(String[] args){
Specification spec # createSpec();
System.out.println(spec.toString());
ResourceAllocation resources # resources(spec);
// define the preference map of the server
PreferenceMap providerPref # resources.preference();
// creates the server negotiator
Negotiator provider # new BasicNegotiator(providerPref);
// define the preference map of the client
PreferenceMap clientPref # createClientPref(spec);
for ( int i # 0; i<300; !! i){
// creates the client negotiator
Negotiator client # new BasicNegotiator(clientPref);
// carry out the negotiation
Mediator mediator # new Mediator(10);
try {
 
Search WWH ::




Custom Search