Order sendable messages by timestamp. Also fixed some comments.

This commit is contained in:
akwizgran
2011-09-07 15:55:03 +01:00
parent bbf957cc94
commit 39be97a4d6
5 changed files with 10 additions and 12 deletions

View File

@@ -4,7 +4,7 @@ import java.io.IOException;
import net.sf.briar.api.protocol.BatchId; import net.sf.briar.api.protocol.BatchId;
/** An interface for creating an ack. */ /** An interface for creating an ack packet. */
public interface AckWriter { public interface AckWriter {
/** /**

View File

@@ -4,7 +4,7 @@ import java.io.IOException;
import net.sf.briar.api.protocol.BatchId; import net.sf.briar.api.protocol.BatchId;
/** An interface for creating a batch of messages. */ /** An interface for creating a batch packet. */
public interface BatchWriter { public interface BatchWriter {
/** Returns the capacity of the batch in bytes. */ /** Returns the capacity of the batch in bytes. */

View File

@@ -5,7 +5,7 @@ import java.io.IOException;
import net.sf.briar.api.protocol.MessageId; import net.sf.briar.api.protocol.MessageId;
import net.sf.briar.api.protocol.OfferId; import net.sf.briar.api.protocol.OfferId;
/** An interface for creating a have notification. */ /** An interface for creating an offer packet. */
public interface OfferWriter { public interface OfferWriter {
/** /**

View File

@@ -1144,8 +1144,8 @@ abstract class JdbcDatabase implements Database<Connection> {
+ " AND visibilities.contactId = ?" + " AND visibilities.contactId = ?"
+ " AND statuses.contactId = ?" + " AND statuses.contactId = ?"
+ " AND timestamp >= start" + " AND timestamp >= start"
+ " AND status = ? AND sendability > ZERO()"; + " AND status = ? AND sendability > ZERO()"
// FIXME: Investigate the performance impact of "ORDER BY timestamp" + " ORDER BY timestamp";
ps = txn.prepareStatement(sql); ps = txn.prepareStatement(sql);
ps.setInt(1, c.getInt()); ps.setInt(1, c.getInt());
ps.setInt(2, c.getInt()); ps.setInt(2, c.getInt());
@@ -1162,11 +1162,9 @@ abstract class JdbcDatabase implements Database<Connection> {
} }
rs.close(); rs.close();
ps.close(); ps.close();
if(!ids.isEmpty()) { if(LOG.isLoggable(Level.FINE))
if(LOG.isLoggable(Level.FINE)) LOG.fine(ids.size() + " sendable messages, " + total + "/" +
LOG.fine(ids.size() + " sendable messages, " + total capacity + " bytes");
+ " bytes");
}
return ids; return ids;
} catch(SQLException e) { } catch(SQLException e) {
tryToClose(rs); tryToClose(rs);

View File

@@ -68,7 +68,7 @@ public class ConstantsTest extends TestCase {
// Check that no more batch IDs can be written // Check that no more batch IDs can be written
assertFalse(a.writeBatchId(new BatchId(TestUtils.getRandomId()))); assertFalse(a.writeBatchId(new BatchId(TestUtils.getRandomId())));
a.finish(); a.finish();
// Check the size of the ack // Check the size of the serialised ack
assertTrue(out.size() > UniqueId.LENGTH * Ack.MAX_IDS_PER_ACK); assertTrue(out.size() > UniqueId.LENGTH * Ack.MAX_IDS_PER_ACK);
assertTrue(out.size() <= ProtocolConstants.MAX_PACKET_LENGTH); assertTrue(out.size() <= ProtocolConstants.MAX_PACKET_LENGTH);
} }
@@ -117,7 +117,7 @@ public class ConstantsTest extends TestCase {
// Check that no more message IDs can be written // Check that no more message IDs can be written
assertFalse(o.writeMessageId(new MessageId(TestUtils.getRandomId()))); assertFalse(o.writeMessageId(new MessageId(TestUtils.getRandomId())));
o.finish(); o.finish();
// Check the size of the offer // Check the size of the serialised offer
assertTrue(out.size() > UniqueId.LENGTH * Offer.MAX_IDS_PER_OFFER); assertTrue(out.size() > UniqueId.LENGTH * Offer.MAX_IDS_PER_OFFER);
assertTrue(out.size() <= ProtocolConstants.MAX_PACKET_LENGTH); assertTrue(out.size() <= ProtocolConstants.MAX_PACKET_LENGTH);
} }