Skip to content
Snippets Groups Projects
Commit f8386ffa authored by Gwenaelle ABEILLE's avatar Gwenaelle ABEILLE
Browse files

remove unused code

parent 15f30f3c
No related branches found
No related tags found
No related merge requests found
package HdbArchiver.Collector.Tools.commit;
import java.sql.Connection;
import fr.soleil.hdbtdbArchivingApi.ArchivingApi.DataBaseManager;
import fr.soleil.hdbtdbArchivingApi.ArchivingApi.DataBaseManagement.DbCommands.ConnectionCommands;
import fr.soleil.hdbtdbArchivingApi.ArchivingTools.Tools.ArchivingException;
public class CommitRunnable implements Runnable {
private long commitPeriod;
private DataBaseManager dbApi;
public CommitRunnable(long _commitPeriod, DataBaseManager _dbApi) {
this.commitPeriod = _commitPeriod * 1000 * 60;
this.dbApi = _dbApi;
}
public void run() {
while (true) {
long commitTime = this.commit();
long sleepDuration = Math.max(this.commitPeriod - commitTime, 0);
this.doSleep(sleepDuration);
}
}
private long commit() {
long before = System.currentTimeMillis();
Connection conn = null;
// System.out.println ( "CommitRunnable/commit/"+ new
// java.util.Date(before).toString());
try {
conn = this.dbApi.getDbConn().getConnection();
ConnectionCommands.commit(conn, this.dbApi.getDbUtil());
} catch (ArchivingException e) {
e.printStackTrace();
} finally {
if (conn != null)
try {
this.dbApi.getDbConn().closeConnection(conn);
} catch (ArchivingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
long after = System.currentTimeMillis();
return after - before;
}
private void doSleep(long sleepDuration) {
try {
Thread.sleep(sleepDuration);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
\ No newline at end of file
/* Synchrotron Soleil
*
* File : CommitThread.java
*
* Project : archiving
*
* Description :
*
* Author : CLAISSE
*
* Original : 23 nov. 06
*
* Revision: Author:
* Date: State:
*
* Log: CommitThread.java,v
*
*/
/*
* Created on 23 nov. 06
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package HdbArchiver.Collector.Tools.commit;
import fr.soleil.hdbtdbArchivingApi.ArchivingApi.DataBaseManager;
public class CommitThread extends Thread {
public CommitThread(long _commitPeriod, DataBaseManager dbApi) {
super(new CommitRunnable(_commitPeriod, dbApi));
super.setPriority(Thread.MIN_PRIORITY);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment