Some changes to allow the ability to subclass the stats class and

record more extensive, per-table stats.
This commit is contained in:
Andrzej Kapolka
2011-04-01 04:44:04 +00:00
parent e41e3c9961
commit 531b9a3234
6 changed files with 30 additions and 8 deletions
@@ -388,6 +388,10 @@ public abstract class DepotRepository
}
return mods;
}
@Override
public void updateStats (Stats stats) {
stats.noteModification(pClass);
}
});
}
@@ -639,6 +643,10 @@ public abstract class DepotRepository
created[0] = true;
return mods;
}
@Override
public void updateStats (Stats stats) {
stats.noteModification(pClass);
}
});
return created[0];
}
@@ -706,7 +714,7 @@ public abstract class DepotRepository
* @throws DatabaseException if any problem is encountered communicating with the database.
*/
public <T extends PersistentRecord> int deleteAll (
Class<T> type, final WhereClause where, CacheInvalidator invalidator)
final Class<T> type, final WhereClause where, CacheInvalidator invalidator)
throws DatabaseException
{
if (invalidator instanceof ValidatingCacheInvalidator) {
@@ -723,6 +731,10 @@ public abstract class DepotRepository
protected int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException {
return builder.prepare(conn).executeUpdate();
}
@Override
public void updateStats (Stats stats) {
stats.noteModification(type);
}
});
}
@@ -827,7 +839,7 @@ public abstract class DepotRepository
/**
* A helper method for the various partial update methods.
*/
protected int doUpdate (CacheInvalidator invalidator, UpdateClause update)
protected int doUpdate (CacheInvalidator invalidator, final UpdateClause update)
{
final SQLBuilder builder = _ctx.getSQLBuilder(DepotTypes.getDepotTypes(_ctx, update));
builder.newQuery(update);
@@ -836,6 +848,10 @@ public abstract class DepotRepository
protected int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException {
return builder.prepare(conn).executeUpdate();
}
@Override
public void updateStats (Stats stats) {
stats.noteModification(update.getPersistentClass());
}
});
}
@@ -120,8 +120,9 @@ public class Stats
}
}
public synchronized void noteQuery (int cachedQueries, int uncachedQueries, int explicitQueries,
int cachedRecords, int uncachedRecords)
public synchronized void noteQuery (
Class<? extends PersistentRecord> type, int cachedQueries, int uncachedQueries,
int explicitQueries, int cachedRecords, int uncachedRecords)
{
_cachedQueries += cachedQueries;
_uncachedQueries += uncachedQueries;
@@ -130,6 +131,11 @@ public class Stats
_uncachedRecords += uncachedRecords;
}
public synchronized void noteModification (Class<? extends PersistentRecord> type)
{
// nothing by default
}
protected int _totalOps;
protected long _connectionWaitTime;
@@ -88,7 +88,7 @@ public class FindAllKeysQuery<T extends PersistentRecord> extends Fetcher<List<K
// from Fetcher
public void updateStats (Stats stats)
{
stats.noteQuery(0, 1, 0, 0, 0); // one uncached query
stats.noteQuery(_marsh.getPersistentClass(), 0, 1, 0, 0, 0); // one uncached query
}
protected boolean _forUpdate;
@@ -348,7 +348,7 @@ public abstract class FindAllQuery<T extends PersistentRecord,R>
// from Fetcher
public void updateStats (Stats stats)
{
stats.noteQuery(_cachedQueries, _uncachedQueries, _explicitQueries,
stats.noteQuery(_type, _cachedQueries, _uncachedQueries, _explicitQueries,
_cachedRecords, _uncachedRecords);
}
@@ -112,7 +112,7 @@ public class FindOneQuery<T extends PersistentRecord> extends Fetcher<T>
// from Operation
public void updateStats (Stats stats)
{
stats.noteQuery(0, 0, 0, _cachedRecords, 1-_cachedRecords);
stats.noteQuery(_marsh.getPersistentClass(), 0, 0, 0, _cachedRecords, 1-_cachedRecords);
}
protected CacheKey getCacheKey ()
@@ -144,7 +144,7 @@ public abstract class Modifier
// from interface Operation
public void updateStats (Stats stats)
{
// nothing to update for modifiers
// nothing to update by default
}
/**