01: /*
02: * This file or a portion of this file is licensed under the terms of
03: * the Globus Toolkit Public License, found in file GTPL, or at
04: * http://www.globus.org/toolkit/download/license.html. This notice must
05: * appear in redistributions of this file, with or without modification.
06: *
07: * Redistributions of this Software, with or without modification, must
08: * reproduce the GTPL in: (1) the Software, or (2) the Documentation or
09: * some other similar material which is provided with the Software (if
10: * any).
11: *
12: * Copyright 1999-2004 University of Chicago and The University of
13: * Southern California. All rights reserved.
14: */
15:
16: package org.griphyn.vdl.router;
17:
18: import org.griphyn.vdl.classes.*;
19: import org.griphyn.vdl.router.*;
20: import org.griphyn.vdl.dbschema.*;
21: import org.griphyn.vdl.dax.*;
22: import org.griphyn.vdl.util.Logging;
23: import java.io.*;
24: import java.sql.SQLException;
25: import java.lang.reflect.*;
26:
27: public class DiamondTest {
28: public static void main(String[] args)
29: throws IllegalArgumentException, IOException,
30: ClassNotFoundException, NoSuchMethodException,
31: InstantiationException, SQLException,
32: IllegalAccessException, InvocationTargetException {
33: // create debug output
34: Logging.instance().register("dag", System.err);
35: Logging.instance().register("state", System.err);
36: Logging.instance().register("route", System.err);
37:
38: // create new route object, in memory classes
39: Definitions original = org.griphyn.vdl.router.CreateDiamond
40: .create();
41:
42: // serialize onto disk
43: Logging.instance().log("default", 0, "serializing to disk");
44: ObjectOutputStream oos = new ObjectOutputStream(
45: new FileOutputStream("data.out"));
46: oos.writeObject(original);
47: oos.flush();
48: oos.close();
49: Logging.instance().log("default", 0, "serializing done");
50:
51: // de-serialize from file
52: Logging.instance().log("default", 0, "de-serialize from disk");
53: ObjectInputStream ois = new ObjectInputStream(
54: new FileInputStream("data.out"));
55: Definitions diamond = (Definitions) ois.readObject();
56: ois.close();
57: Logging.instance().log("default", 0, "de-serializing done");
58:
59: // create a router
60: Route r = new Route(new InMemorySchema(diamond));
61:
62: // request known production
63: BookKeeper bk = r.requestLfn("f.d");
64:
65: // show us the result
66: System.out.println(bk.toString());
67:
68: // show the DAX
69: System.out.println("----------");
70: System.out.println(bk.getDAX("testing").toXML("", null));
71: System.exit(0);
72: }
73: }
|