01: /*
02: Copyright (C) 2004 David Bucciarelli (davibu@interfree.it)
03:
04: This program is free software; you can redistribute it and/or
05: modify it under the terms of the GNU General Public License
06: as published by the Free Software Foundation; either version 2
07: of the License, or (at your option) any later version.
08:
09: This program is distributed in the hope that it will be useful,
10: but WITHOUT ANY WARRANTY; without even the implied warranty of
11: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: GNU General Public License for more details.
13:
14: You should have received a copy of the GNU General Public License
15: along with this program; if not, write to the Free Software
16: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17: */
18:
19: package org.homedns.dade.jcgrid.client;
20:
21: import java.io.*;
22: import java.net.*;
23: import javax.net.ssl.*;
24:
25: import org.apache.log4j.*;
26:
27: import org.homedns.dade.jcgrid.*;
28: import org.homedns.dade.jcgrid.message.*;
29: import org.homedns.dade.jcgrid.server.*;
30: import org.homedns.dade.jcgrid.vfs.*;
31: import org.homedns.dade.jcgrid.util.*;
32:
33: public class GridClient extends GridNodeGeneric {
34: private final static String className = GridClient.class.getName();
35: private static Logger log = Logger.getLogger(className);
36: private static Logger logDetail = Logger.getLogger("DETAIL."
37: + className);
38:
39: private vfsSession session;
40:
41: public GridClient() {
42: super (new GridNodeClientConfig());
43:
44: if (log.isDebugEnabled())
45: log.debug("Start GridClient()");
46:
47: session = null;
48:
49: super .getNodeConfig().setWorkingDir(
50: System.getProperty("user.dir"));
51:
52: if (log.isDebugEnabled())
53: log.debug("End GridClient()");
54: }
55:
56: public void send(GridMessage msg) throws Exception {
57: if (log.isDebugEnabled())
58: log.debug("Start send(" + msg + ")");
59:
60: super .getGridMessageChannel().send(msg);
61:
62: if (log.isDebugEnabled())
63: log.debug("End send()");
64: }
65:
66: public GridMessage recv() throws Exception {
67: if (log.isDebugEnabled())
68: log.debug("Start recv()");
69:
70: GridMessage msg = super .getGridMessageChannel().recv();
71:
72: if (log.isDebugEnabled())
73: log.debug("End recv(" + msg + ")");
74:
75: return msg;
76: }
77:
78: //----------------------------- Start & Stop -------------------------------
79:
80: public void start() throws Exception {
81: if (log.isDebugEnabled())
82: logDetail.debug("Start start()");
83:
84: super .start();
85:
86: if (this .getNodeConfig().getGridConfig().getUseVFS()) {
87: session = new vfsSession(super .getNodeConfig()
88: .getWorkingDir());
89: session.start();
90: log.warn("VFS session size: " + session.getSize()
91: / (1024 * 1024) + "MB");
92:
93: session.syncVFSSession(super .getGridMessageChannel());
94: }
95:
96: if (log.isDebugEnabled())
97: log.debug("End start()");
98: }
99: }
|