本文整理汇总了Java中lbms.plugins.mldht.kad.DHT.DHTtype.IPV4_DHT属性的典型用法代码示例。如果您正苦于以下问题:Java DHTtype.IPV4_DHT属性的具体用法?Java DHTtype.IPV4_DHT怎么用?Java DHTtype.IPV4_DHT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类lbms.plugins.mldht.kad.DHT.DHTtype
的用法示例。
在下文中一共展示了DHTtype.IPV4_DHT属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: asNodeList
public NodeList asNodeList() {
return new NodeList() {
@Override
public int packedSize() {
return entries.size() * owner.getType().NODES_ENTRY_LENGTH;
}
@Override
public Stream<KBucketEntry> entries() {
return entries.stream();
}
@Override
public AddressType type() {
return owner.getType() == DHTtype.IPV4_DHT ? AddressType.V4 : AddressType.V6;
}
};
}
示例2: roundTripPut
StorageItem roundTripPut(StorageItem in) throws IOException, MessageException {
// create message from item
PutRequest req = new PutRequest();
req.populateFromStorage(in);
req.setID(Key.createRandomKey());
req.setMTID(new byte[4]);
req.setToken(new byte[4]);
// encode
ByteBuffer encoded = ByteBuffer.allocate(1500);
req.encode(encoded);
// decode
Map<String, Object> decoded = new BDecoder().decode(encoded.duplicate());
MessageDecoder decoder = new MessageDecoder(null, DHTtype.IPV4_DHT);
decoder.toDecode(encoded, decoded);
PutRequest roundTripped = (PutRequest) decoder.parseMessage();
// re-create item from round-tripped message
return new StorageItem(roundTripped);
}
示例3: MldhtService
@Inject
public MldhtService(IRuntimeLifecycleBinder lifecycleBinder, Config config, DHTConfig dhtConfig) {
this.dht = new DHT(dhtConfig.shouldUseIPv6()? DHTtype.IPV6_DHT : DHTtype.IPV4_DHT);
this.config = toMldhtConfig(dhtConfig);
this.localAddress = config.getAcceptorAddress();
this.useRouterBootstrap = dhtConfig.shouldUseRouterBootstrap();
this.publicBootstrapNodes = dhtConfig.getPublicBootstrapNodes();
this.bootstrapNodes = dhtConfig.getBootstrapNodes();
lifecycleBinder.onStartup(LifecycleBinding.bind(this::start).description("Initialize DHT facilities").async().build());
lifecycleBinder.onShutdown("Shutdown DHT facilities", this::shutdown);
}
示例4: getNodes
public NodeList getNodes(DHTtype type)
{
if(type == DHTtype.IPV4_DHT)
return nodes;
if(type == DHTtype.IPV6_DHT)
return nodes6;
return null;
}