Commit af56e478 authored by Andre Freyssinet's avatar Andre Freyssinet

JORAM-331: Implements getCommitCount in order to detect transaction freeze.

parent aca94550
/*
* Copyright (C) 2001 - 2012 ScalAgent Distributed Technologies
* Copyright (C) 2001 - 2019 ScalAgent Distributed Technologies
* Copyright (C) 1996 - 2000 BULL
* Copyright (C) 1996 - 2000 INRIA
*
......@@ -43,10 +43,23 @@ public final class ATransaction extends AbstractTransaction implements ATransact
final static int CLEANUP_THRESHOLD_OPERATION = 36000;
final static int CLEANUP_THRESHOLD_SIZE = 8 * Mb;
private int commitCount = 0; // Number of commited transaction in clog.
private int operationCount = 0; // Number of operations reported to clog.
private int cumulativeSize = 0; // Byte amount in clog.
/**
* Number of commit operation since starting up.
*/
private int commitCount = 0;
/**
* Returns the number of commit operation since starting up.
*
* @return The number of commit operation.
*/
public final int getCommitCount() {
return commitCount;
}
/**
* Log of all operations already commited but not reported on disk
* by the "garbage" Thread. On event (at least previous log plog must
......@@ -437,6 +450,7 @@ public final class ATransaction extends AbstractTransaction implements ATransact
}
op.free();
}
commitCount += 1;
// Be careful, do not clear log before all modifications are reported
// to disk, in order to avoid load errors.
log.clear();
......
......@@ -125,6 +125,20 @@ public abstract class DBTransaction extends AbstractTransaction implements DBTra
phase = newPhase;
}
/**
* Number of commit operation since starting up.
*/
private int commitCount = 0;
/**
* Returns the number of commit operation since starting up.
*
* @return The number of commit operation.
*/
public final int getCommitCount() {
return commitCount;
}
/**
* Returns an array of strings naming the persistent objects denoted by
* a name that satisfy the specified prefix. Each string is an object name.
......@@ -300,6 +314,7 @@ public abstract class DBTransaction extends AbstractTransaction implements DBTra
try {
conn.commit();
commitCount += 1;
} catch (SQLException sqle) {
throw new IOException(sqle.getMessage());
}
......
/*
* Copyright (C) 2001 - 2011 ScalAgent Distributed Technologies
* Copyright (C) 2001 - 2019 ScalAgent Distributed Technologies
* Copyright (C) 1996 - 2000 BULL
* Copyright (C) 1996 - 2000 INRIA
*
......@@ -57,6 +57,20 @@ public final class JTransaction extends BaseTransaction implements JTransactionM
return startTime;
}
/**
* Number of commit operation since starting up.
*/
private int commitCount = 0;
/**
* Returns the number of commit operation since starting up.
*
* @return The number of commit operation.
*/
public final int getCommitCount() {
return commitCount;
}
public static final String EMPTY_STRING = new String();
/**
......@@ -389,6 +403,7 @@ public final class JTransaction extends BaseTransaction implements JTransactionM
logFile.writeUTF("");
setPhase(COMMIT);
_commit();
commitCount += 1;
log.clear();
if (release) {
......
/*
* Copyright (C) 2001 - 2009 ScalAgent Distributed Technologies
* Copyright (C) 2001 - 2019 ScalAgent Distributed Technologies
* Copyright (C) 1996 - 2000 BULL
* Copyright (C) 1996 - 2000 INRIA
*
......@@ -54,6 +54,20 @@ public final class NullTransaction extends BaseTransaction implements NullTransa
phase = newPhase;
}
/**
* Number of commit operation since starting up.
*/
private int commitCount = 0;
/**
* Returns the number of commit operation since starting up.
*
* @return The number of commit operation.
*/
public final int getCommitCount() {
return commitCount;
}
public NullTransaction() {}
/**
......@@ -156,6 +170,7 @@ public final class NullTransaction extends BaseTransaction implements NullTransa
throw new IllegalStateException("Can not commit.");
setPhase(COMMIT);
commitCount += 1;
if (release) {
// Change the transaction state.
setPhase(FREE);
......
/*
* Copyright (C) 2001 - 2011 ScalAgent Distributed Technologies
* Copyright (C) 2001 - 2019 ScalAgent Distributed Technologies
* Copyright (C) 1996 - 2000 BULL
* Copyright (C) 1996 - 2000 INRIA
*
......@@ -116,6 +116,13 @@ public interface Transaction {
* @return the string representation of the transaction state.
*/
String getPhaseInfo();
/**
* Returns the number of commit operation since startup.
*
* @return The number of commit operation.
*/
public int getCommitCount();
/**
* Start a transaction validation, the validation phase needs 3 phases: begin, commit
......
/*
* Copyright (C) 2005 - 2006 ScalAgent Distributed Technologies
* Copyright (C) 2005 - 2019 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -30,11 +30,23 @@ public interface TransactionMBean {
boolean isPersistent();
/**
*
* Returns the transaction state.
* @return the transaction state.
*/
public int getPhase();
/**
* Returns a string representation of the transaction state.
* @return the string representation of the transaction state.
*/
public String getPhaseInfo();
/**
* Returns the number of commit operation since startup.
*
* @return The number of commit operation.
*/
public int getCommitCount();
/**
* Returns the starting time.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment