Skip to content

Commit

Permalink
merge new dht code
Browse files Browse the repository at this point in the history
  • Loading branch information
isdal committed Mar 11, 2012
1 parent 42cc4fc commit 961fd20
Show file tree
Hide file tree
Showing 77 changed files with 9,868 additions and 3,452 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -25,7 +25,7 @@ error.log
.gwt/

# Run output
plugins/
./plugins/
speed_check.log

# Eclipse
Expand Down
71 changes: 64 additions & 7 deletions az_src/src/com/aelitis/azureus/core/dht/DHT.java
Expand Up @@ -30,6 +30,7 @@
import com.aelitis.azureus.core.dht.router.DHTRouter;
import com.aelitis.azureus.core.dht.speed.DHTSpeedTester;
import com.aelitis.azureus.core.dht.transport.DHTTransport;
import com.aelitis.azureus.core.dht.transport.DHTTransportContact;
import com.aelitis.azureus.core.dht.transport.DHTTransportValue;

/**
Expand All @@ -51,14 +52,21 @@ public interface
public static final String PR_ORIGINAL_REPUBLISH_INTERVAL = "OriginalRepublishInterval";
public static final String PR_CACHE_REPUBLISH_INTERVAL = "CacheRepublishInterval";

public static final byte FLAG_SINGLE_VALUE = 0x00;
public static final byte FLAG_DOWNLOADING = 0x01;
public static final byte FLAG_SEEDING = 0x02;
public static final byte FLAG_MULTI_VALUE = 0x04;
public static final byte FLAG_STATS = 0x08;
public static final byte FLAG_SINGLE_VALUE = 0x00;
public static final byte FLAG_DOWNLOADING = 0x01;
public static final byte FLAG_SEEDING = 0x02;
public static final byte FLAG_MULTI_VALUE = 0x04;
public static final byte FLAG_STATS = 0x08;
public static final byte FLAG_ANON = 0x10;
public static final byte FLAG_PRECIOUS = 0x20;
public static final byte FLAG_PUT_AND_FORGET = 0x40; // local only
public static final byte FLAG_OBFUSCATE_LOOKUP = (byte)0x80; // local only

public static final int MAX_VALUE_SIZE = 256;
public static final int MAX_VALUE_SIZE = 512;

public static final byte REP_FACT_NONE = 0;
public static final byte REP_FACT_DEFAULT = (byte)0xff;

// diversification types, don't change as serialised!!!!

public static final byte DT_NONE = 1;
Expand All @@ -79,6 +87,47 @@ public interface
byte flags,
DHTOperationListener listener );

/**
* default is HIGH PRIORITY. if you change to low priority then do so consistently as
* operations can get out of order otherwise
* @param key
* @param description
* @param value
* @param flags
* @param high_priority
* @param listener
*/

public void
put(
byte[] key,
String description,
byte[] value,
byte flags,
boolean high_priority,
DHTOperationListener listener );

public void
put(
byte[] key,
String description,
byte[] value,
byte flags,
byte life_hours,
boolean high_priority,
DHTOperationListener listener );

public void
put(
byte[] key,
String description,
byte[] value,
byte flags,
byte life_hours,
byte replication_control, // 4 bits 1->14 republish hours; 0=vuze default | 4 bits 0->15 maintain replicas; [ff=no replication control-use default]
boolean high_priority,
DHTOperationListener listener );

/**
* Returns value if originated from here for key
* @param key
Expand Down Expand Up @@ -115,6 +164,13 @@ public interface
String description,
DHTOperationListener listener );

public byte[]
remove(
DHTTransportContact[] contacts,
byte[] key,
String description,
DHTOperationListener listener );

public boolean
isDiversified(
byte[] key );
Expand Down Expand Up @@ -191,5 +247,6 @@ public interface
getLogger();

public void
print();
print(
boolean full );
}
Expand Up @@ -43,13 +43,15 @@ public class
}

public void
diversified()
diversified(
String desc )
{
}

public void
found(
DHTTransportContact contact )
DHTTransportContact contact,
boolean is_closest )
{
}

Expand Down
Expand Up @@ -40,11 +40,13 @@ public interface
int active_searches );

public void
diversified();
diversified(
String desc );

public void
found(
DHTTransportContact contact );
DHTTransportContact contact,
boolean is_closest );

public void
read(
Expand Down
19 changes: 17 additions & 2 deletions az_src/src/com/aelitis/azureus/core/dht/DHTStorageAdapter.java
Expand Up @@ -38,6 +38,9 @@
public interface
DHTStorageAdapter
{
public int
getNetwork();

// local value operations

/**
Expand Down Expand Up @@ -91,15 +94,18 @@ public interface
getExistingDiversification(
byte[] key,
boolean put_operation,
boolean exhaustive_get );
boolean exhaustive_get,
int max_depth );

public byte[][]
createNewDiversification(
String description,
DHTTransportContact cause,
byte[] key,
boolean put_operation,
byte diversification_type,
boolean exhaustive_get );
boolean exhaustive_get,
int max_depth );

public int
getNextValueVersions(
Expand Down Expand Up @@ -130,4 +136,13 @@ public interface
public byte[]
getStorageForKey(
String key );

public int
getRemoteFreqDivCount();

public int
getRemoteSizeDivCount();

public int
getKeyCount();
}
Expand Up @@ -36,4 +36,7 @@ public interface

public byte
getDiversification();

public String
getString();
}
76 changes: 62 additions & 14 deletions az_src/src/com/aelitis/azureus/core/dht/control/DHTControl.java
Expand Up @@ -53,12 +53,18 @@ public interface
seed(
boolean full_wait );

public boolean
isSeeded();

public void
put(
byte[] key,
String description,
byte[] value,
byte flags,
byte life_hours,
byte replication_control,
boolean high_priority,
DHTOperationListener listener );

public boolean
Expand Down Expand Up @@ -86,6 +92,13 @@ public interface
String description,
DHTOperationListener listener );

public byte[]
remove(
DHTTransportContact[] contacts,
byte[] key,
String description,
DHTOperationListener listener );

public DHTControlStats
getStats();

Expand Down Expand Up @@ -116,14 +129,16 @@ public interface

// support methods for DB

public List
public List<DHTTransportContact>
getClosestKContactsList(
byte[] id,
boolean live_only );

public List
sortContactsByDistance(
List contacts );
public List<DHTTransportContact>
getClosestContactsList(
byte[] id,
int num_to_return,
boolean live_only );

public void
putEncodedKey(
Expand All @@ -135,17 +150,35 @@ public interface

public void
putDirectEncodedKeys(
byte[][] keys,
String description,
DHTTransportValue[][] value_sets,
List contacts );
byte[][] keys,
String description,
DHTTransportValue[][] value_sets,
List<DHTTransportContact> contacts );

public void
putDirectEncodedKeys(
byte[][] keys,
String description,
DHTTransportValue[][] value_sets,
DHTTransportContact contact,
DHTOperationListener listener );

public int
computeAndCompareDistances(
byte[] n1,
byte[] n2,
byte[] pivot );

public byte[]
computeDistance(
byte[] n1,
byte[] n2 );

public int
compareDistances(
byte[] n1,
byte[] n2 );

public boolean
verifyContact(
DHTTransportContact c,
Expand All @@ -154,17 +187,31 @@ public interface
public boolean
lookup(
byte[] id,
String description,
long timeout,
DHTOperationListener listener );

/**
* Returns a list of DHTContact objects
* @return
*/
public boolean
lookupEncoded(
byte[] id,
String description,
long timeout,
boolean high_priority,
DHTOperationListener listener );

public byte[]
getObfuscatedKey(
byte[] plain_key );

public List

public List<DHTControlContact>
getContacts();

// debug method only

public void
pingAll();

public void
addListener(
DHTControlListener l );
Expand All @@ -174,5 +221,6 @@ public interface
DHTControlListener l );

public void
print();
print(
boolean full );
}
Expand Up @@ -38,12 +38,14 @@ public interface

public byte[][]
diversify(
String description,
DHTTransportContact cause,
boolean put_operation,
boolean existing,
byte[] key,
byte type,
boolean exhaustive );
boolean exhaustive,
int max_depth );

public boolean
isDiversified(
Expand Down

0 comments on commit 961fd20

Please sign in to comment.