Calculate the timestamp outside the subscription/transport update

writer - this will allow it to be saved so new connections can work
out whether they should send updates.
This commit is contained in:
akwizgran
2011-08-14 13:36:21 +02:00
parent 4497774311
commit 2c13e35dc4
9 changed files with 31 additions and 27 deletions

View File

@@ -445,7 +445,7 @@ class ReadWriteLockDatabaseComponent<Txn> extends DatabaseComponentImpl<Txn> {
Txn txn = db.startTransaction();
try {
Map<Group, Long> subs = db.getVisibleSubscriptions(txn, c);
s.writeSubscriptions(subs);
s.writeSubscriptionUpdate(subs, System.currentTimeMillis());
if(LOG.isLoggable(Level.FINE))
LOG.fine("Added " + subs.size() + " subscriptions");
db.commitTransaction(txn);
@@ -475,7 +475,8 @@ class ReadWriteLockDatabaseComponent<Txn> extends DatabaseComponentImpl<Txn> {
try {
Map<String, Map<String, String>> transports =
db.getTransports(txn);
t.writeTransports(transports);
long timestamp = System.currentTimeMillis();
t.writeTransportUpdate(transports, timestamp);
if(LOG.isLoggable(Level.FINE))
LOG.fine("Added " + transports.size() + " transports");
db.commitTransaction(txn);

View File

@@ -339,7 +339,7 @@ class SynchronizedDatabaseComponent<Txn> extends DatabaseComponentImpl<Txn> {
Txn txn = db.startTransaction();
try {
Map<Group, Long> subs = db.getVisibleSubscriptions(txn, c);
s.writeSubscriptions(subs);
s.writeSubscriptionUpdate(subs, System.currentTimeMillis());
if(LOG.isLoggable(Level.FINE))
LOG.fine("Added " + subs.size() + " subscriptions");
db.commitTransaction(txn);
@@ -363,7 +363,8 @@ class SynchronizedDatabaseComponent<Txn> extends DatabaseComponentImpl<Txn> {
try {
Map<String, Map<String, String>> transports =
db.getTransports(txn);
t.writeTransports(transports);
long timestamp = System.currentTimeMillis();
t.writeTransportUpdate(transports, timestamp);
if(LOG.isLoggable(Level.FINE))
LOG.fine("Added " + transports.size() + " transports");
db.commitTransaction(txn);

View File

@@ -20,10 +20,11 @@ class SubscriptionWriterImpl implements SubscriptionWriter {
w = writerFactory.createWriter(out);
}
public void writeSubscriptions(Map<Group, Long> subs) throws IOException {
public void writeSubscriptionUpdate(Map<Group, Long> subs, long timestamp)
throws IOException {
w.writeUserDefinedTag(Tags.SUBSCRIPTION_UPDATE);
w.writeMap(subs);
w.writeInt64(System.currentTimeMillis());
w.writeInt64(timestamp);
out.flush();
}
}

View File

@@ -20,7 +20,8 @@ class TransportWriterImpl implements TransportWriter {
w = writerFactory.createWriter(out);
}
public void writeTransports(Map<String, Map<String, String>> transports)
public void writeTransportUpdate(
Map<String, Map<String, String>> transports, long timestamp)
throws IOException {
w.writeUserDefinedTag(Tags.TRANSPORT_UPDATE);
w.writeListStart();
@@ -30,7 +31,7 @@ class TransportWriterImpl implements TransportWriter {
w.writeMap(e.getValue());
}
w.writeListEnd();
w.writeInt64(System.currentTimeMillis());
w.writeInt64(timestamp);
out.flush();
}
}