Moved the subscription and transport timestamps out of the contacts

table so it's not necessary to hold a write lock on the (heavily used)
contacts table to update them.
This commit is contained in:
akwizgran
2011-08-14 14:46:12 +02:00
parent 2c13e35dc4
commit 5e0aadd373
12 changed files with 122 additions and 63 deletions
@@ -779,7 +779,7 @@ public abstract class DatabaseComponentTest extends TestCase {
oneOf(database).getVisibleSubscriptions(txn, contactId);
will(returnValue(Collections.singletonMap(group, 0L)));
// Add the subscriptions to the writer
oneOf(subscriptionWriter).writeSubscriptionUpdate(
oneOf(subscriptionWriter).writeSubscriptions(
with(Collections.singletonMap(group, 0L)),
with(any(long.class)));
}});
@@ -812,7 +812,7 @@ public abstract class DatabaseComponentTest extends TestCase {
oneOf(database).getTransports(txn);
will(returnValue(transports));
// Add the properties to the writer
oneOf(transportWriter).writeTransportUpdate(with(transports),
oneOf(transportWriter).writeTransports(with(transports),
with(any(long.class)));
}});
DatabaseComponent db = createDatabaseComponent(database, cleaner);
-9
View File
@@ -1200,15 +1200,12 @@ public class H2DatabaseTest extends TestCase {
// Add a contact and subscribe to a group
assertEquals(contactId, db.addContact(txn, transports, secret));
db.addSubscription(txn, group);
// The group should not be visible to the contact
assertEquals(Collections.emptyList(), db.getVisibility(txn, groupId));
// Make the group visible to the contact
db.setVisibility(txn, groupId, Collections.singleton(contactId));
assertEquals(Collections.singletonList(contactId),
db.getVisibility(txn, groupId));
// Make the group invisible again
db.setVisibility(txn, groupId, Collections.<ContactId>emptySet());
assertEquals(Collections.emptyList(), db.getVisibility(txn, groupId));
@@ -1225,10 +1222,8 @@ public class H2DatabaseTest extends TestCase {
// Add a contact
assertEquals(contactId, db.addContact(txn, transports, secret));
// Get the connection window for a new transport
ConnectionWindow w = db.getConnectionWindow(txn, contactId, 123);
// The connection window should exist and be in the initial state
assertNotNull(w);
assertEquals(0L, w.getCentre());
@@ -1245,19 +1240,15 @@ public class H2DatabaseTest extends TestCase {
// Add a contact
assertEquals(contactId, db.addContact(txn, transports, secret));
// Get the connection window for a new transport
ConnectionWindow w = db.getConnectionWindow(txn, contactId, 123);
// The connection window should exist and be in the initial state
assertNotNull(w);
assertEquals(0L, w.getCentre());
assertEquals(0, w.getBitmap());
// Update the connection window and store it
w.setSeen(5L);
db.setConnectionWindow(txn, contactId, 123, w);
// Check that the connection window was stored
w = db.getConnectionWindow(txn, contactId, 123);
assertNotNull(w);