2
// The nordugrid-arc-java package is required. To compile and run this example:
4
// export CLASSPATH=/usr/lib64/java/arc.jar:.
5
// export LD_LIBRARY_PATH=/usr/lib64/java
6
// javac ResourceDiscovery.java
7
// java ResourceDiscovery ldap://index1.nordugrid.org/Mds-vo-name=NorduGrid,o=grid
9
// The PATHs above may vary depending on ARC install location and system
12
import nordugrid.arc.*; // For the sake of brevity in this example import everything from arc
14
public class ResourceDiscovery implements ComputingServiceTypeConsumer
18
public ResourceDiscovery() {
22
public static void main(String[] args)
24
// Set up logging to stderr with level VERBOSE (a lot of output will be shown)
25
LogStream_ostream logstdout = new LogStream_ostream(nordugrid.arc.arc.getStdout());
26
logstdout.setFormat(nordugrid.arc.LogFormat.ShortFormat);
27
Logger.getRootLogger().addDestination(logstdout);
28
Logger.getRootLogger().setThreshold(nordugrid.arc.LogLevel.VERBOSE);
29
Logger logger = new Logger(Logger.getRootLogger(), "resourcediscovery");
31
// Create Endpoint object from the passed argument (registry or index service)
32
Endpoint e = new Endpoint(args[0], Endpoint.CapabilityEnum.REGISTRY);
34
// This object holds various attributes, including proxy location and selected services.
35
UserConfig uc = new UserConfig("");
37
// Example Java consumer
38
ResourceDiscovery rd = new ResourceDiscovery();
40
// Create a instance for discovering computing services at the registry service.
41
ComputingServiceRetriever csr = new ComputingServiceRetriever(uc);
43
csr.addEndpoint(e); // Add endpoint ... which initiates discovery.
44
csr._wait(); // Wait for results to be retrieved.
46
for (ComputingServiceType cst : csr) {
47
System.out.println(cst);
50
System.out.println(rd.i + " services found.");
53
public void addEntity(ComputingServiceType cst) {