- switched logging ot application where possible

- implemented new _parent spec, including virtual nodes
- removed some rarely-used property settings for apps and db directory
This commit is contained in:
hns 2001-03-05 16:10:38 +00:00
parent 9e05814d90
commit 7904cf2bca
10 changed files with 114 additions and 134 deletions

View file

@ -25,8 +25,8 @@ public class DbMapping {
DbSource source; DbSource source;
String table; String table;
String[] parent; // list of properties to try for parent ParentInfo[] parent; // list of properties to try for parent
Boolean[] anonymous; // are parent relations anonymous or not?
DbMapping subnodes; DbMapping subnodes;
DbMapping properties; DbMapping properties;
private Relation subnodesRel; private Relation subnodesRel;
@ -110,6 +110,16 @@ public class DbMapping {
nameField = props.getProperty ("_name"); nameField = props.getProperty ("_name");
String parentMapping = props.getProperty ("_parent");
if (parentMapping != null) {
// comma-separated list of properties to be used as parent
StringTokenizer st = new StringTokenizer (parentMapping, ",;");
parent = new ParentInfo[st.countTokens()];
for (int i=0; i<parent.length; i++)
parent[i] = new ParentInfo (st.nextToken().trim());
} else
parent = null;
lastTypeChange = lastmod; lastTypeChange = lastmod;
// set the cached schema & keydef to null so it's rebuilt the next time around // set the cached schema & keydef to null so it's rebuilt the next time around
schema = null; schema = null;
@ -124,7 +134,7 @@ public class DbMapping {
public synchronized void rewire () { public synchronized void rewire () {
// if (table != null && source != null) { // if (table != null && source != null) {
// IServer.getLogger().log ("set data source for "+typename+" to "+source); // app.logEvent ("set data source for "+typename+" to "+source);
Hashtable p2d = new Hashtable (); Hashtable p2d = new Hashtable ();
Hashtable d2p = new Hashtable (); Hashtable d2p = new Hashtable ();
@ -138,36 +148,16 @@ public class DbMapping {
p2d.put (propName, rel); p2d.put (propName, rel);
if (rel.localField != null) if (rel.localField != null)
d2p.put (rel.localField, rel); d2p.put (rel.localField, rel);
// IServer.getLogger().log ("Mapping "+propName+" -> "+dbField); // app.logEvent ("Mapping "+propName+" -> "+dbField);
} }
} catch (Exception x) { } catch (Exception x) {
IServer.getLogger ().log ("Error in type.properties: "+x.getMessage ()); app.logEvent ("Error in type.properties: "+x.getMessage ());
} }
} }
prop2db = p2d; prop2db = p2d;
db2prop = d2p; db2prop = d2p;
String ano = props.getProperty ("_anonymous");
if (ano != null) {
// comma-separated list of true/false values
StringTokenizer st = new StringTokenizer (ano, ",; ");
anonymous = new Boolean[st.countTokens()];
for (int i=0; i<anonymous.length; i++)
anonymous[i] = "false".equalsIgnoreCase (st.nextToken().trim()) ? Boolean.FALSE : Boolean.TRUE;
} else
anonymous = null;
String parentMapping = props.getProperty ("_parent");
if (parentMapping != null) {
// comma-separated list of properties to be used as parent
StringTokenizer st = new StringTokenizer (parentMapping, ",; ");
parent = new String[st.countTokens()];
for (int i=0; i<parent.length; i++)
parent[i] = st.nextToken().trim();
} else
parent = null;
String subnodeMapping = props.getProperty ("_subnodes"); String subnodeMapping = props.getProperty ("_subnodes");
if (subnodeMapping != null) { if (subnodeMapping != null) {
try { try {
@ -177,7 +167,7 @@ public class DbMapping {
else else
subnodes = (DbMapping) app.getDbMapping (subnodeMapping); subnodes = (DbMapping) app.getDbMapping (subnodeMapping);
} catch (Exception x) { } catch (Exception x) {
IServer.getLogger ().log ("Error in type.properties: "+x.getMessage ()); app.logEvent ("Error in type.properties: "+x.getMessage ());
subnodesRel = null; subnodesRel = null;
} }
} else } else
@ -195,13 +185,13 @@ public class DbMapping {
if (propertiesRel.subnodesAreProperties && subnodesRel != null) if (propertiesRel.subnodesAreProperties && subnodesRel != null)
propertiesRel.groupby = subnodesRel.groupby; propertiesRel.groupby = subnodesRel.groupby;
} catch (Exception x) { } catch (Exception x) {
IServer.getLogger ().log ("Error in type.properties: "+x.getMessage ()); app.logEvent ("Error in type.properties: "+x.getMessage ());
propertiesRel = null; propertiesRel = null;
} }
} else } else
propertiesRel = null; propertiesRel = null;
IServer.getLogger().log ("rewiring: "+this); app.logEvent ("rewiring: "+this);
} }
@ -264,13 +254,13 @@ public class DbMapping {
return (Relation) prop2db.get (propName); return (Relation) prop2db.get (propName);
} }
public synchronized String[] getParentPropNames () { public synchronized ParentInfo[] getParentInfo () {
return parent; return parent;
} }
public synchronized Boolean[] getAnonymous () { /* public synchronized Boolean[] getAnonymous () {
return anonymous; return anonymous;
} }*/
public DbMapping getSubnodeMapping () { public DbMapping getSubnodeMapping () {
return subnodes; return subnodes;
@ -383,6 +373,7 @@ public class DbMapping {
return lastTypeChange; return lastTypeChange;
} }
} }

View file

@ -18,7 +18,7 @@ public abstract class IServer {
public static SystemProperties sysProps, dbProps; public static SystemProperties sysProps, dbProps;
public static Hashtable dbSources; public static Hashtable dbSources;
protected static String hopHome = null; protected static File hopHome = null;
private static Logger logger; private static Logger logger;
@ -65,7 +65,7 @@ public abstract class IServer {
return logger; return logger;
} }
public static String getHopHome () { public static File getHopHome () {
return hopHome; return hopHome;
} }

View file

@ -24,15 +24,14 @@ public class ApplicationManager {
private Hashtable applications; private Hashtable applications;
private int port; private int port;
private File appHome, dbHome; private File hopHome;
private SystemProperties props; private SystemProperties props;
private Server server; private Server server;
private long lastModified; private long lastModified;
public ApplicationManager (int port, File appHome, File dbHome, SystemProperties props, Server server) { public ApplicationManager (int port, File hopHome, SystemProperties props, Server server) {
this.port = port; this.port = port;
this.appHome = appHome; this.hopHome = hopHome;
this.dbHome = dbHome;
this.props = props; this.props = props;
this.server = server; this.server = server;
applications = new Hashtable (); applications = new Hashtable ();
@ -70,7 +69,7 @@ public class ApplicationManager {
private void start (String appName) { private void start (String appName) {
IServer.getLogger().log ("Building application "+appName); IServer.getLogger().log ("Building application "+appName);
try { try {
Application app = new Application (appName, dbHome, appHome); Application app = new Application (appName, Server.sysProps, hopHome);
applications.put (appName, app); applications.put (appName, app);
// if we're running with the embedded web server, set app base uri to /appname // if we're running with the embedded web server, set app base uri to /appname
if (server.websrv != null) if (server.websrv != null)

View file

@ -24,13 +24,15 @@ public class DbWrapper {
volatile long txncount=0; volatile long txncount=0;
private File dbBaseDir; private File dbBaseDir;
private NodeManager nmgr;
private String dbHome; private String dbHome;
public DbWrapper (String dbHome, String dbFilename, boolean useTx) throws DbException { public DbWrapper (String dbHome, String dbFilename, NodeManager nmgr, boolean useTx) throws DbException {
try {
this.dbHome = dbHome; this.dbHome = dbHome;
this.nmgr = nmgr;
try {
dbBaseDir = new File (dbHome); dbBaseDir = new File (dbHome);
if (!dbBaseDir.exists()) if (!dbBaseDir.exists())
dbBaseDir.mkdirs(); dbBaseDir.mkdirs();
@ -71,12 +73,12 @@ public class DbWrapper {
loaded = true; loaded = true;
} catch (NoClassDefFoundError noclass) { } catch (NoClassDefFoundError noclass) {
Server.getLogger().log ("Warning: Using internal file based db as fallback."); nmgr.app.logEvent ("Warning: Using internal file based db as fallback.");
Server.getLogger().log ("Reason: "+noclass); nmgr.app.logEvent ("Reason: "+noclass);
loaded = false; loaded = false;
} catch (UnsatisfiedLinkError nolib) { } catch (UnsatisfiedLinkError nolib) {
Server.getLogger().log ("Warning: Using internal file based db as fallback."); nmgr.app.logEvent ("Warning: Using internal file based db as fallback.");
Server.getLogger().log ("Reason: "+nolib); nmgr.app.logEvent ("Reason: "+nolib);
loaded = false; loaded = false;
} }
@ -89,7 +91,7 @@ public class DbWrapper {
// closing the dbenv leads to segfault when app is restarted // closing the dbenv leads to segfault when app is restarted
// dbenv.close (0); // dbenv.close (0);
// dbenv.remove (dbHome, Db.DB_FORCE); // dbenv.remove (dbHome, Db.DB_FORCE);
Server.getLogger ().log ("Closed Berkeley DB"); nmgr.app.logEvent ("Closed Berkeley DB");
} }
} }
@ -126,7 +128,7 @@ public class DbWrapper {
dbenv.txn_checkpoint (0, 0, 0); // for berkeley 3.0, remove third 0 parameter dbenv.txn_checkpoint (0, 0, 0); // for berkeley 3.0, remove third 0 parameter
txncount = 0; txncount = 0;
lastCheckpoint = now; lastCheckpoint = now;
Server.getLogger().log ("Spent "+(System.currentTimeMillis()-now)+" in checkpoint"); nmgr.app.logEvent ("Spent "+(System.currentTimeMillis()-now)+" in checkpoint");
} }
public IDGenerator getIDGenerator (DbTxn txn, String kstr) throws Exception { public IDGenerator getIDGenerator (DbTxn txn, String kstr) throws Exception {
@ -220,7 +222,7 @@ public class DbWrapper {
value.set_size (vbuf.length); value.set_size (vbuf.length);
db.put (txn, key, value, 0); db.put (txn, key, value, 0);
// IServer.getLogger().log ("saved "+obj+", size = "+vbuf.length); // nmgr.app.logEvent ("saved "+obj+", size = "+vbuf.length);
} }
private void deleteFromDB (DbTxn txn, String kstr) throws Exception { private void deleteFromDB (DbTxn txn, String kstr) throws Exception {

View file

@ -325,12 +325,12 @@ public class Node implements INode, Serializable {
if (!current.isActive ()) if (!current.isActive ())
throw new helma.framework.TimeoutException (); throw new helma.framework.TimeoutException ();
if (state == INVALID) { if (state == INVALID) {
IServer.getLogger().log ("Got Invalid Node: "+this); nmgr.logEvent ("Got Invalid Node: "+this);
Thread.dumpStack (); Thread.dumpStack ();
throw new ConcurrencyException ("Node "+this+" was invalidated by another thread."); throw new ConcurrencyException ("Node "+this+" was invalidated by another thread.");
} }
if (lock != null && lock != current && lock.isAlive () && lock.isActive ()) { if (lock != null && lock != current && lock.isAlive () && lock.isActive ()) {
IServer.getLogger().log ("Concurrency conflict for "+this+", lock held by "+lock); nmgr.logEvent ("Concurrency conflict for "+this+", lock held by "+lock);
throw new ConcurrencyException ("Tried to modify "+this+" from two threads at the same time."); throw new ConcurrencyException ("Tried to modify "+this+" from two threads at the same time.");
} }
current.visitNode (this); current.visitNode (this);
@ -593,19 +593,23 @@ public class Node implements INode, Serializable {
public INode getParent () { public INode getParent () {
// check what's specified in the type.properties for this node. // check what's specified in the type.properties for this node.
String[] parentProps = null; ParentInfo[] parentInfo = null;
if (dbmap != null && dbmap.isRelational ()) if (dbmap != null && dbmap.isRelational ())
parentProps = dbmap.getParentPropNames (); parentInfo = dbmap.getParentInfo ();
// check if current parent candidate matches presciption, if not, try to get it // check if current parent candidate matches presciption, if not, try to get it
if (parentProps != null) { if (parentInfo != null) {
for (int i=0; i<parentProps.length; i++) { for (int i=0; i<parentInfo.length; i++) {
INode pn = getNode (parentProps[i], false); ParentInfo pinfo = parentInfo[i];
INode pn = getNode (pinfo.propname, false);
if (pinfo.isroot && pn == null)
pn = nmgr.getNode ("0", nmgr.getDbMapping ("root"));
if (pn != null) { if (pn != null) {
// see if dbmapping specifies anonymity for this node // see if dbmapping specifies anonymity for this node
Boolean[] ano = dbmap.getAnonymous (); anonymous = !pinfo.named;
if (ano != null && ano.length > i) if (pinfo.virtualname != null)
anonymous = ano[i].booleanValue(); pn = pn.getNode (pinfo.virtualname, false);
if (pn != null)
return pn; return pn;
} }
} }
@ -895,7 +899,7 @@ public class Node implements INode, Serializable {
return node; return node;
} }
} catch (Exception noluck) { } catch (Exception noluck) {
IServer.getLogger ().log ("Error creating group-by node for "+sid+": "+noluck); nmgr.logEvent ("Error creating group-by node for "+sid+": "+noluck);
} }
return null; return null;
} }
@ -911,7 +915,7 @@ public class Node implements INode, Serializable {
public void removeNode (INode node) { public void removeNode (INode node) {
IServer.getLogger().log ("removing: "+ node); nmgr.logEvent ("removing: "+ node);
Node n = (Node) node; Node n = (Node) node;
checkWriteLock (); checkWriteLock ();
n.checkWriteLock (); n.checkWriteLock ();
@ -969,7 +973,7 @@ public class Node implements INode, Serializable {
// Server.throwNodeEvent (new NodeEvent (node, NodeEvent.NODE_REMOVED)); // Server.throwNodeEvent (new NodeEvent (node, NodeEvent.NODE_REMOVED));
// Server.throwNodeEvent (new NodeEvent (this, NodeEvent.SUBNODE_REMOVED, node)); // Server.throwNodeEvent (new NodeEvent (this, NodeEvent.SUBNODE_REMOVED, node));
lastmodified = System.currentTimeMillis (); lastmodified = System.currentTimeMillis ();
// IServer.getLogger().log ("released node "+node +" from "+this+" oldobj = "+what); // nmgr.logEvent ("released node "+node +" from "+this+" oldobj = "+what);
if (state == CLEAN) markAs (MODIFIED); if (state == CLEAN) markAs (MODIFIED);
} }
@ -994,7 +998,7 @@ public class Node implements INode, Serializable {
String pid = (String) e1.nextElement (); String pid = (String) e1.nextElement ();
Node pnode = nmgr.getNode (pid, null); Node pnode = nmgr.getNode (pid, null);
if (pnode != null) { if (pnode != null) {
IServer.getLogger().log("Warning: Can't unset node property of "+pnode.getFullName ()); nmgr.logEvent("Warning: Can't unset node property of "+pnode.getFullName ());
} }
} catch (Exception ignore) {} } catch (Exception ignore) {}
} }
@ -1163,7 +1167,7 @@ public class Node implements INode, Serializable {
} }
protected Property getProperty (String propname, boolean inherit) { protected Property getProperty (String propname, boolean inherit) {
// IServer.getLogger().log ("GETTING PROPERTY: "+propname); // nmgr.logEvent ("GETTING PROPERTY: "+propname);
if (propname == null) if (propname == null)
return null; return null;
Property prop = propMap == null ? null : (Property) propMap.get (propname.toLowerCase ()); Property prop = propMap == null ? null : (Property) propMap.get (propname.toLowerCase ());
@ -1275,7 +1279,7 @@ public class Node implements INode, Serializable {
} }
public void setString (String propname, String value) { public void setString (String propname, String value) {
// IServer.getLogger().log ("setting String prop"); // nmgr.logEvent ("setting String prop");
checkWriteLock (); checkWriteLock ();
if (propMap == null) if (propMap == null)
@ -1337,7 +1341,7 @@ public class Node implements INode, Serializable {
} }
public void setInteger (String propname, long value) { public void setInteger (String propname, long value) {
// IServer.getLogger().log ("setting bool prop"); // nmgr.logEvent ("setting bool prop");
checkWriteLock (); checkWriteLock ();
if (propMap == null) if (propMap == null)
@ -1360,7 +1364,7 @@ public class Node implements INode, Serializable {
} }
public void setFloat (String propname, double value) { public void setFloat (String propname, double value) {
// IServer.getLogger().log ("setting bool prop"); // nmgr.logEvent ("setting bool prop");
checkWriteLock (); checkWriteLock ();
if (propMap == null) if (propMap == null)
@ -1383,7 +1387,7 @@ public class Node implements INode, Serializable {
} }
public void setBoolean (String propname, boolean value) { public void setBoolean (String propname, boolean value) {
// IServer.getLogger().log ("setting bool prop"); // nmgr.logEvent ("setting bool prop");
checkWriteLock (); checkWriteLock ();
if (propMap == null) if (propMap == null)
@ -1407,7 +1411,7 @@ public class Node implements INode, Serializable {
public void setDate (String propname, Date value) { public void setDate (String propname, Date value) {
// IServer.getLogger().log ("setting date prop"); // nmgr.logEvent ("setting date prop");
checkWriteLock (); checkWriteLock ();
if (propMap == null) if (propMap == null)
@ -1430,7 +1434,7 @@ public class Node implements INode, Serializable {
} }
public void setJavaObject (String propname, Object value) { public void setJavaObject (String propname, Object value) {
// IServer.getLogger().log ("setting jobject prop"); // nmgr.logEvent ("setting jobject prop");
checkWriteLock (); checkWriteLock ();
if (propMap == null) if (propMap == null)
@ -1453,7 +1457,7 @@ public class Node implements INode, Serializable {
} }
public void setNode (String propname, INode value) { public void setNode (String propname, INode value) {
// IServer.getLogger().log ("setting node prop"); // nmgr.logEvent ("setting node prop");
checkWriteLock (); checkWriteLock ();
Node n = null; Node n = null;
@ -1473,8 +1477,8 @@ public class Node implements INode, Serializable {
n.setParent (this); n.setParent (this);
n.name = propname; n.name = propname;
n.anonymous = false; n.anonymous = false;
// IServer.getLogger().log ("adopted named node: "+n.getFullName ()); // nmgr.logEvent ("adopted named node: "+n.getFullName ());
} // else IServer.getLogger().log ("not adopted: "+n.getFullName ()); } // else nmgr.logEvent ("not adopted: "+n.getFullName ());
if (propMap == null) if (propMap == null)
propMap = new Hashtable (); propMap = new Hashtable ();
@ -1689,7 +1693,7 @@ public class Node implements INode, Serializable {
byte retval[] = new byte[content.length]; byte retval[] = new byte[content.length];
System.arraycopy (content, 0, retval, 0, content.length); System.arraycopy (content, 0, retval, 0, content.length);
// IServer.getLogger().log ("copied "+retval.length+ " bytes"); // nmgr.logEvent ("copied "+retval.length+ " bytes");
return retval; return retval;
} }

View file

@ -44,7 +44,7 @@ public final class NodeManager {
// Make actual cache size bigger, since we use it only up to the threshold // Make actual cache size bigger, since we use it only up to the threshold
// cache = new CacheMap ((int) Math.ceil (cacheSize/0.75f), 0.75f); // cache = new CacheMap ((int) Math.ceil (cacheSize/0.75f), 0.75f);
cache = new CacheMap (cacheSize, 0.75f); cache = new CacheMap (cacheSize, 0.75f);
IServer.getLogger().log ("set up node cache ("+cacheSize+")"); app.logEvent ("set up node cache ("+cacheSize+")");
safe = new WrappedNodeManager (this); safe = new WrappedNodeManager (this);
@ -55,7 +55,7 @@ public final class NodeManager {
idBaseValue = Math.max (1l, idBaseValue); // 0 and 1 are reserved for root nodes idBaseValue = Math.max (1l, idBaseValue); // 0 and 1 are reserved for root nodes
} catch (NumberFormatException ignore) {} } catch (NumberFormatException ignore) {}
db = new DbWrapper (dbHome, Server.dbFilename, Server.useTransactions); db = new DbWrapper (dbHome, Server.dbFilename, this, Server.useTransactions);
initDb (); initDb ();
logSql = "true".equalsIgnoreCase(props.getProperty ("logsql")); logSql = "true".equalsIgnoreCase(props.getProperty ("logsql"));
@ -287,7 +287,7 @@ public final class NodeManager {
if (dbm == null || !dbm.isRelational ()) { if (dbm == null || !dbm.isRelational ()) {
db.save (txn, node.getID (), node); db.save (txn, node.getID (), node);
} else { } else {
IServer.getLogger().log ("inserting relational node: "+node.getID ()); app.logEvent ("inserting relational node: "+node.getID ());
TableDataSet tds = null; TableDataSet tds = null;
try { try {
tds = new TableDataSet (dbm.getConnection (), dbm.getSchema (), dbm.getKeyDef ()); tds = new TableDataSet (dbm.getConnection (), dbm.getSchema (), dbm.getKeyDef ());
@ -553,7 +553,7 @@ public final class NodeManager {
} }
if (logSql) if (logSql)
IServer.getLogger().log ("### getNodeIDs: "+qds.getSelectString()); app.logEvent ("### getNodeIDs: "+qds.getSelectString());
qds.fetchRecords (); qds.fetchRecords ();
for (int i=0; i<qds.size (); i++) { for (int i=0; i<qds.size (); i++) {
@ -610,7 +610,7 @@ public final class NodeManager {
} }
if (logSql) if (logSql)
IServer.getLogger().log ("### getNodes: "+tds.getSelectString()); app.logEvent ("### getNodes: "+tds.getSelectString());
tds.fetchRecords (); tds.fetchRecords ();
for (int i=0; i<tds.size (); i++) { for (int i=0; i<tds.size (); i++) {
@ -668,7 +668,7 @@ public final class NodeManager {
} }
if (logSql) if (logSql)
IServer.getLogger().log ("### countNodes: "+qds.getSelectString()); app.logEvent ("### countNodes: "+qds.getSelectString());
qds.fetchRecords (); qds.fetchRecords ();
if (qds.size () == 0) if (qds.size () == 0)
@ -712,7 +712,7 @@ public final class NodeManager {
qds = new QueryDataSet (con, q); qds = new QueryDataSet (con, q);
if (logSql) if (logSql)
IServer.getLogger().log ("### getPropertyNames: "+qds.getSelectString()); app.logEvent ("### getPropertyNames: "+qds.getSelectString());
qds.fetchRecords (); qds.fetchRecords ();
for (int i=0; i<qds.size (); i++) { for (int i=0; i<qds.size (); i++) {
@ -751,7 +751,7 @@ public final class NodeManager {
tds.where (dbm.getIDField ()+" = '"+kstr+"'"); tds.where (dbm.getIDField ()+" = '"+kstr+"'");
if (logSql) if (logSql)
IServer.getLogger().log ("### getNodeByKey: "+tds.getSelectString()); app.logEvent ("### getNodeByKey: "+tds.getSelectString());
tds.fetchRecords (); tds.fetchRecords ();
@ -858,7 +858,7 @@ public final class NodeManager {
tds.where (where.toString ()); tds.where (where.toString ());
if (logSql) if (logSql)
IServer.getLogger().log ("### getNodeByRelation: "+tds.getSelectString()); app.logEvent ("### getNodeByRelation: "+tds.getSelectString());
tds.fetchRecords (); tds.fetchRecords ();

View file

@ -152,7 +152,7 @@ public final class Property implements IProperty, Serializable, Cloneable {
this.lvalue = date.getTime (); this.lvalue = date.getTime ();
return; return;
} catch (ParseException nodate) { } catch (ParseException nodate) {
IServer.getLogger().log ("Couldn't parse date: was expecting something like "+dateformat.format (new Date())); node.nmgr.logEvent ("Couldn't parse date: was expecting something like "+dateformat.format (new Date()));
// store as plain string // store as plain string
} }
} }

View file

@ -35,7 +35,6 @@ import com.sleepycat.db.*;
static String dbPropfile = "db.properties"; static String dbPropfile = "db.properties";
static String appsPropfile = "apps.properties"; static String appsPropfile = "apps.properties";
static SystemProperties appsProps; static SystemProperties appsProps;
static String dbDir = null;
static int port = 5055; static int port = 5055;
static int webport = 0; static int webport = 0;
@ -47,9 +46,11 @@ import com.sleepycat.db.*;
useTransactions = true; useTransactions = true;
String homeDir = null;
for (int i=0; i<args.length; i++) { for (int i=0; i<args.length; i++) {
if (args[i].equals ("-h") && i+1<args.length) if (args[i].equals ("-h") && i+1<args.length)
hopHome = args[++i]; homeDir = args[++i];
else if (args[i].equals ("-f") && i+1<args.length) else if (args[i].equals ("-f") && i+1<args.length)
propfile = args[++i]; propfile = args[++i];
else if (args[i].equals ("-t")) else if (args[i].equals ("-t"))
@ -73,17 +74,21 @@ import com.sleepycat.db.*;
// get main property file from home dir or vice versa, depending on what we have. // get main property file from home dir or vice versa, depending on what we have.
// get property file from hopHome // get property file from hopHome
if (propfile == null) { if (propfile == null) {
if (hopHome != null) if (homeDir != null)
propfile = new File (hopHome, "server.properties").getAbsolutePath (); propfile = new File (homeDir, "server.properties").getAbsolutePath ();
else else
propfile = new File ("server.properties").getAbsolutePath (); propfile = new File ("server.properties").getAbsolutePath ();
} }
sysProps = new SystemProperties (propfile); sysProps = new SystemProperties (propfile);
// get hopHome from property file // get hopHome from property file
if (hopHome == null) if (homeDir == null)
hopHome = sysProps.getProperty ("hophome"); homeDir = sysProps.getProperty ("hophome");
if (hopHome == null) if (homeDir == null)
hopHome = new File (propfile).getParent (); homeDir = new File (propfile).getParent ();
// create hopHome File object
hopHome = new File (homeDir);
getLogger().log ("propfile = "+propfile); getLogger().log ("propfile = "+propfile);
getLogger().log ("hopHome = "+hopHome); getLogger().log ("hopHome = "+hopHome);
@ -99,35 +104,14 @@ import com.sleepycat.db.*;
System.exit (0); System.exit (0);
} }
dbDir = sysProps.getProperty ("dbhome", "db"); File helper = new File (hopHome, "db.properties");
File helper = new File (dbDir);
if (hopHome != null && !helper.isAbsolute ())
helper = new File (hopHome, dbDir);
dbDir = helper.getAbsolutePath ();
getLogger().log ("dbHome = "+dbDir);
dbPropfile = sysProps.getProperty ("dbpropfile", "db.properties");
helper = new File (dbPropfile);
if (hopHome != null && !helper.isAbsolute ())
helper = new File (hopHome, dbPropfile);
dbPropfile = helper.getAbsolutePath (); dbPropfile = helper.getAbsolutePath ();
getLogger().log ("dbPropfile = "+dbPropfile); getLogger().log ("dbPropfile = "+dbPropfile);
appsPropfile = sysProps.getProperty ("appspropfile", "apps.properties"); helper = new File (hopHome, "apps.properties");
helper = new File (appsPropfile);
if (hopHome != null && !helper.isAbsolute ())
helper = new File (hopHome, appsPropfile);
appsPropfile = helper.getAbsolutePath (); appsPropfile = helper.getAbsolutePath ();
getLogger().log ("appsPropfile = "+appsPropfile); getLogger().log ("appsPropfile = "+appsPropfile);
File libdir = new File (hopHome, "lib");
Properties p = System.getProperties ();
String libpath = p.getProperty ("java.library.path");
if (libpath != null && libpath.length () > 0)
p.put ("java.library.path", libpath+System.getProperty("path.separator")+libdir.getCanonicalPath());
else
p.put ("java.library.path", libdir.getCanonicalPath());
paranoid = "true".equalsIgnoreCase (sysProps.getProperty ("paranoid")); paranoid = "true".equalsIgnoreCase (sysProps.getProperty ("paranoid"));
String language = sysProps.getProperty ("language"); String language = sysProps.getProperty ("language");
@ -225,21 +209,13 @@ import com.sleepycat.db.*;
// start application framework // start application framework
String appDir = sysProps.getProperty ("apphome", "apps");
File appHome = new File (appDir);
if (hopHome != null && !appHome.isAbsolute())
appHome = new File (hopHome, appDir);
appsProps = new SystemProperties (appsPropfile); appsProps = new SystemProperties (appsPropfile);
File dbHome = new File (dbDir); appManager = new ApplicationManager (port, hopHome, appsProps, this);
appManager = new ApplicationManager (port, appHome, dbHome, appsProps, this);
} catch (Exception gx) { } catch (Exception gx) {
getLogger().log ("Error initializing embedded database: "+gx); getLogger().log ("Error initializing embedded database: "+gx);
gx.printStackTrace (); gx.printStackTrace ();
/* try {
transactor.abort ();
} catch (Exception ignore) {} */
return; return;
} }

View file

@ -137,19 +137,19 @@ public class Transactor extends Thread {
nmgr.insertNode (nmgr.db, txn, node); nmgr.insertNode (nmgr.db, txn, node);
node.setState (Node.CLEAN); node.setState (Node.CLEAN);
ins++; ins++;
IServer.getLogger().log ("inserted: Node "+node.getName ()+"/"+node.getID ()); nmgr.app.logEvent ("inserted: Node "+node.getName ()+"/"+node.getID ());
} else if (nstate == Node.MODIFIED) { } else if (nstate == Node.MODIFIED) {
nmgr.updateNode (nmgr.db, txn, node); nmgr.updateNode (nmgr.db, txn, node);
node.setState (Node.CLEAN); node.setState (Node.CLEAN);
upd++; upd++;
IServer.getLogger().log ("updated: Node "+node.getName ()+"/"+node.getID ()); nmgr.app.logEvent ("updated: Node "+node.getName ()+"/"+node.getID ());
} else if (nstate == Node.DELETED) { } else if (nstate == Node.DELETED) {
// IServer.getLogger().log ("deleted: "+node.getFullName ()+" ("+node.getName ()+")"); // nmgr.app.logEvent ("deleted: "+node.getFullName ()+" ("+node.getName ()+")");
nmgr.deleteNode (nmgr.db, txn, node); nmgr.deleteNode (nmgr.db, txn, node);
nmgr.evictNode (node); nmgr.evictNode (node);
dlt++; dlt++;
} else { } else {
// IServer.getLogger().log ("noop: "+node.getFullName ()); // nmgr.app.logEvent ("noop: "+node.getFullName ());
} }
node.clearWriteLock (); node.clearWriteLock ();
} }
@ -168,7 +168,7 @@ public class Transactor extends Thread {
txn = null; txn = null;
} }
IServer.getLogger().log (tname+" "+l+" marked, "+ins+" inserted, "+upd+" updated, "+dlt+" deleted in "+(System.currentTimeMillis()-tstart)+" millis"); nmgr.app.logAccess (tname+" "+l+" marked, "+ins+" inserted, "+upd+" updated, "+dlt+" deleted in "+(System.currentTimeMillis()-tstart)+" millis");
} }
public synchronized void abort () throws Exception { public synchronized void abort () throws Exception {
@ -191,7 +191,7 @@ public class Transactor extends Thread {
nmgr.db.abortTransaction (txn); nmgr.db.abortTransaction (txn);
txn = null; txn = null;
} }
IServer.getLogger().log (tname+" aborted after "+(System.currentTimeMillis()-tstart)+" millis"); nmgr.app.logEvent (tname+" aborted after "+(System.currentTimeMillis()-tstart)+" millis");
} }
} }
@ -214,13 +214,13 @@ public class Transactor extends Thread {
} }
public void closeConnections () { public void closeConnections () {
// IServer.getLogger().log("Cleaning up Transactor thread"); // nmgr.app.logEvent("Cleaning up Transactor thread");
if (sqlCon != null) { if (sqlCon != null) {
for (Iterator i=sqlCon.values().iterator(); i.hasNext(); ) { for (Iterator i=sqlCon.values().iterator(); i.hasNext(); ) {
try { try {
Connection con = (Connection) i.next(); Connection con = (Connection) i.next();
con.close (); con.close ();
IServer.getLogger ().log ("Closing DB connection: "+con); nmgr.app.logEvent ("Closing DB connection: "+con);
} catch (Exception ignore) {} } catch (Exception ignore) {}
} }
sqlCon.clear (); sqlCon.clear ();

View file

@ -27,7 +27,7 @@ import java.util.Vector;
} catch (ObjectNotFoundException x) { } catch (ObjectNotFoundException x) {
return null; return null;
} catch (Exception x) { } catch (Exception x) {
Server.getLogger().log ("Error retrieving Node via DbMapping: "+x.getMessage ()); nmgr.app.logEvent ("Error retrieving Node via DbMapping: "+x.getMessage ());
if ("true".equalsIgnoreCase (Server.sysProps.getProperty("debug"))) if ("true".equalsIgnoreCase (Server.sysProps.getProperty("debug")))
x.printStackTrace(); x.printStackTrace();
throw new RuntimeException ("Error retrieving Node: "+x.getMessage ()); throw new RuntimeException ("Error retrieving Node: "+x.getMessage ());
@ -40,7 +40,7 @@ import java.util.Vector;
} catch (ObjectNotFoundException x) { } catch (ObjectNotFoundException x) {
return null; return null;
} catch (Exception x) { } catch (Exception x) {
Server.getLogger().log ("Error retrieving Node \""+id+"\" from "+home+": "+x.getMessage ()); nmgr.app.logEvent ("Error retrieving Node \""+id+"\" from "+home+": "+x.getMessage ());
if ("true".equalsIgnoreCase (Server.sysProps.getProperty("debug"))) if ("true".equalsIgnoreCase (Server.sysProps.getProperty("debug")))
x.printStackTrace(); x.printStackTrace();
throw new RuntimeException ("Error retrieving Node: "+x.getMessage ()); throw new RuntimeException ("Error retrieving Node: "+x.getMessage ());
@ -134,6 +134,14 @@ import java.util.Vector;
return nmgr.getCacheEntries (); return nmgr.getCacheEntries ();
} }
public void logEvent (String msg) {
nmgr.app.logEvent (msg);
}
public DbMapping getDbMapping (String name) {
return nmgr.app.getDbMapping (name);
}
} }