mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Extracted constants from DatabaseComponent interface.
This commit is contained in:
@@ -30,16 +30,6 @@ import net.sf.briar.api.transport.ConnectionWindow;
|
||||
*/
|
||||
public interface DatabaseComponent {
|
||||
|
||||
static final int MEGABYTES = 1024 * 1024;
|
||||
|
||||
// FIXME: These should be configurable
|
||||
static final long MIN_FREE_SPACE = 300L * MEGABYTES;
|
||||
static final long CRITICAL_FREE_SPACE = 100L * MEGABYTES;
|
||||
static final int MAX_BYTES_BETWEEN_SPACE_CHECKS = 5 * MEGABYTES;
|
||||
static final long MAX_MS_BETWEEN_SPACE_CHECKS = 60L * 1000L; // 1 min
|
||||
static final int BYTES_PER_SWEEP = 5 * MEGABYTES;
|
||||
static final long EXPIRY_MODULUS = 60L * 60L * 1000L; // 1 hour
|
||||
|
||||
/**
|
||||
* Opens the database.
|
||||
* @param resume True to reopen an existing database or false to create a
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package net.sf.briar.db;
|
||||
|
||||
import static net.sf.briar.db.DatabaseConstants.BYTES_PER_SWEEP;
|
||||
import static net.sf.briar.db.DatabaseConstants.CRITICAL_FREE_SPACE;
|
||||
import static net.sf.briar.db.DatabaseConstants.MAX_BYTES_BETWEEN_SPACE_CHECKS;
|
||||
import static net.sf.briar.db.DatabaseConstants.MAX_MS_BETWEEN_SPACE_CHECKS;
|
||||
import static net.sf.briar.db.DatabaseConstants.MIN_FREE_SPACE;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.BitSet;
|
||||
|
||||
14
components/net/sf/briar/db/DatabaseConstants.java
Normal file
14
components/net/sf/briar/db/DatabaseConstants.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package net.sf.briar.db;
|
||||
|
||||
interface DatabaseConstants {
|
||||
|
||||
static final int MEGABYTE = 1024 * 1024;
|
||||
|
||||
// FIXME: These should be configurable
|
||||
static final long MIN_FREE_SPACE = 300L * MEGABYTE;
|
||||
static final long CRITICAL_FREE_SPACE = 100L * MEGABYTE;
|
||||
static final int MAX_BYTES_BETWEEN_SPACE_CHECKS = 5 * MEGABYTE;
|
||||
static final long MAX_MS_BETWEEN_SPACE_CHECKS = 60L * 1000L; // 1 min
|
||||
static final int BYTES_PER_SWEEP = 5 * MEGABYTE;
|
||||
static final long EXPIRY_MODULUS = 60L * 60L * 1000L; // 1 hour
|
||||
}
|
||||
@@ -21,7 +21,6 @@ import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
import net.sf.briar.api.Rating;
|
||||
import net.sf.briar.api.db.DatabaseComponent;
|
||||
import net.sf.briar.api.db.DbException;
|
||||
import net.sf.briar.api.db.Status;
|
||||
import net.sf.briar.api.protocol.AuthorId;
|
||||
@@ -1509,7 +1508,7 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
rs = ps.executeQuery();
|
||||
if(rs.next()) {
|
||||
timestamp = rs.getLong(1);
|
||||
timestamp -= timestamp % DatabaseComponent.EXPIRY_MODULUS;
|
||||
timestamp -= timestamp % DatabaseConstants.EXPIRY_MODULUS;
|
||||
}
|
||||
if(rs.next()) throw new DbStateException();
|
||||
rs.close();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.sf.briar.db;
|
||||
|
||||
import static net.sf.briar.api.db.DatabaseComponent.BYTES_PER_SWEEP;
|
||||
import static net.sf.briar.api.db.DatabaseComponent.MIN_FREE_SPACE;
|
||||
import static net.sf.briar.db.DatabaseConstants.BYTES_PER_SWEEP;
|
||||
import static net.sf.briar.db.DatabaseConstants.MIN_FREE_SPACE;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user