Add transports to DB during startup. #269

This commit is contained in:
akwizgran
2016-03-28 13:47:23 +01:00
parent 0417639410
commit 9714713d73
40 changed files with 276 additions and 402 deletions

View File

@@ -235,12 +235,6 @@ public interface DatabaseComponent {
Map<ContactId, TransportKeys> getTransportKeys(Transaction txn,
TransportId t) throws DbException;
/**
* Returns the maximum latencies in milliseconds of all transports.
*/
Map<TransportId, Integer> getTransportLatencies(Transaction txn)
throws DbException;
/**
* Increments the outgoing stream counter for the given contact and
* transport in the given rotation period .

View File

@@ -1,23 +0,0 @@
package org.briarproject.api.event;
import org.briarproject.api.TransportId;
/** An event that is broadcast when a transport is added. */
public class TransportAddedEvent extends Event {
private final TransportId transportId;
private final int maxLatency;
public TransportAddedEvent(TransportId transportId, int maxLatency) {
this.transportId = transportId;
this.maxLatency = maxLatency;
}
public TransportId getTransportId() {
return transportId;
}
public int getMaxLatency() {
return maxLatency;
}
}

View File

@@ -1,17 +0,0 @@
package org.briarproject.api.event;
import org.briarproject.api.TransportId;
/** An event that is broadcast when a transport is removed. */
public class TransportRemovedEvent extends Event {
private final TransportId transportId;
public TransportRemovedEvent(TransportId transportId) {
this.transportId = transportId;
}
public TransportId getTransportId() {
return transportId;
}
}

View File

@@ -9,10 +9,9 @@ import java.io.InputStream;
*/
public interface TransportConnectionReader {
/** Returns the maximum latency of the transport in milliseconds. */
long getMaxLatency();
/** Returns an input stream for reading from the transport connection. */
/**
* Returns an input stream for reading from the transport connection.
*/
InputStream getInputStream() throws IOException;
/**
@@ -20,10 +19,13 @@ public interface TransportConnectionReader {
* simplex, the connection is closed. If the transport is duplex, the
* connection is closed if <tt>exception</tt> is true or the other side of
* the connection has been marked as closed.
* @param exception true if the connection is being closed because of an
* exception. This may affect how resources are disposed of.
*
* @param exception true if the connection is being closed because of an
* exception. This may affect how resources are disposed
* of.
* @param recognised true if the connection is definitely a Briar transport
* connection. This may affect how resources are disposed of.
* connection. This may affect how resources are disposed
* of.
*/
void dispose(boolean exception, boolean recognised) throws IOException;
}

View File

@@ -2,12 +2,23 @@ package org.briarproject.api.plugins.duplex;
import org.briarproject.api.TransportId;
/** Factory for creating a plugin for a duplex transport. */
/**
* Factory for creating a plugin for a duplex transport.
*/
public interface DuplexPluginFactory {
/** Returns the plugin's transport identifier. */
/**
* Returns the plugin's transport identifier.
*/
TransportId getId();
/** Creates and returns a plugin, or null if no plugin can be created. */
/**
* Returns the maximum latency of the transport in milliseconds.
*/
int getMaxLatency();
/**
* Creates and returns a plugin, or null if no plugin can be created.
*/
DuplexPlugin createPlugin(DuplexPluginCallback callback);
}

View File

@@ -2,12 +2,23 @@ package org.briarproject.api.plugins.simplex;
import org.briarproject.api.TransportId;
/** Factory for creating a plugin for a simplex transport. */
/**
* Factory for creating a plugin for a simplex transport.
*/
public interface SimplexPluginFactory {
/** Returns the plugin's transport identifier. */
/**
* Returns the plugin's transport identifier.
*/
TransportId getId();
/** Creates and returns a plugin, or null if no plugin can be created. */
/**
* Returns the maximum latency of the transport in milliseconds.
*/
int getMaxLatency();
/**
* Creates and returns a plugin, or null if no plugin can be created.
*/
SimplexPlugin createPlugin(SimplexPluginCallback callback);
}

View File

@@ -1,6 +1,5 @@
package org.briarproject.api.sync;
import org.briarproject.api.TransportId;
import org.briarproject.api.contact.ContactId;
import java.io.InputStream;
@@ -8,12 +7,11 @@ import java.io.OutputStream;
public interface SyncSessionFactory {
SyncSession createIncomingSession(ContactId c, TransportId t,
InputStream in);
SyncSession createIncomingSession(ContactId c, InputStream in);
SyncSession createSimplexOutgoingSession(ContactId c, TransportId t,
int maxLatency, OutputStream out);
SyncSession createSimplexOutgoingSession(ContactId c, int maxLatency,
OutputStream out);
SyncSession createDuplexOutgoingSession(ContactId c, TransportId t,
int maxLatency, int maxIdleTime, OutputStream out);
SyncSession createDuplexOutgoingSession(ContactId c, int maxLatency,
int maxIdleTime, OutputStream out);
}