本文整理汇总了Java中net.tomp2p.peers.PeerAddress.getPeerId方法的典型用法代码示例。如果您正苦于以下问题:Java PeerAddress.getPeerId方法的具体用法?Java PeerAddress.getPeerId怎么用?Java PeerAddress.getPeerId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.tomp2p.peers.PeerAddress
的用法示例。
在下文中一共展示了PeerAddress.getPeerId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: submit
import net.tomp2p.peers.PeerAddress; //导入方法依赖的package包/类
public FutureAsyncTask submit(final PeerAddress remotePeer, ChannelCreator channelCreator, final Number160 taskId,
Map<Number160, Data> dataMap, Worker mapper, boolean forceUDP, boolean sign) {
final Number320 taskKey = new Number320(taskId, remotePeer.getPeerId());
final FutureAsyncTask futureAsyncTask = new FutureAsyncTask(remotePeer);
futureAsyncTask.addCancellation(new Cancel() {
@Override
public void cancel() {
taskFailed(taskKey);
}
});
tasks.put(taskKey, futureAsyncTask);
FutureResponse futureResponse = taskRPC.sendTask(remotePeer, channelCreator, taskId, dataMap, mapper,
peerBean.getKeyPair(), forceUDP, sign);
futureResponse.addListener(new BaseFutureAdapter<FutureResponse>() {
@Override
public void operationComplete(FutureResponse future) throws Exception {
if (future.isSuccess()) {
// keep track of it and poll to see if its still alive
scheduler.keepTrack(remotePeer, taskId, (TaskResultListener) AsyncTask.this);
} else {
futureAsyncTask.setFailed(future);
}
}
});
return futureAsyncTask;
}
示例2: putReferred
import net.tomp2p.peers.PeerAddress; //导入方法依赖的package包/类
public boolean putReferred(Number160 locationKey, Number160 domainKey, PeerAddress peerAddress,
PeerAddress referrer, Data attachement, ReferrerType type) {
Number160 peerId = peerAddress.getPeerId();
// we cannot do public key check, because these data is referenced from
// other peers and we don't know about the timeouts as well
// store the data
if (canStoreSecondary(locationKey, domainKey)) {
// maybe we have space in our secondary tracker, store them there!
Number320 key = new Number320(locationKey, domainKey);
if (storeData(peerAddress, attachement, peerId, key, trackerDataSecondary,
reverseTrackerDataSecondary, getSecondaryFactor())) {
if (ReferrerType.MESH == type) {
if (!isSecondaryTracker(locationKey, domainKey)) {
maintenance
.addTrackerMaintenance(peerAddress, referrer, locationKey, domainKey, this);
}
}
return true;
}
}
return false;
}
示例3: routing
import net.tomp2p.peers.PeerAddress; //导入方法依赖的package包/类
public static void routing(Number160 key, Peer[] peers, int start) {
System.out.println("routing: searching for key " + key);
NavigableSet<PeerAddress> pa1 = new TreeSet<PeerAddress>(PeerMap.createComparator(key));
NavigableSet<PeerAddress> queried = new TreeSet<PeerAddress>(PeerMap.createComparator(key));
Number160 result = Number160.ZERO;
Number160 resultPeer = new Number160("0xd75d1a3d57841fbc9e2a3d175d6a35dc2e15b9f");
int round = 0;
while (!resultPeer.equals(result)) {
System.out.println("round " + round);
round++;
pa1.addAll(peers[start].getPeerBean().peerMap().getAll());
queried.add(peers[start].getPeerAddress());
System.out.println("closest so far: " + queried.first());
PeerAddress next = pa1.pollFirst();
while (queried.contains(next)) {
next = pa1.pollFirst();
}
result = next.getPeerId();
start = findNr(next.getPeerId().toString(), peers);
}
}
示例4: put
import net.tomp2p.peers.PeerAddress; //导入方法依赖的package包/类
public boolean put(Number160 locationKey, Number160 domainKey, PeerAddress peerAddress,
PublicKey publicKey, Data attachement) {
if (logger.isDebugEnabled()) {
logger.debug("try to store on tracker " + locationKey);
}
Number160 peerId = peerAddress.getPeerId();
// check if this guy is offline
if (isOffline(peerAddress)) {
return false;
}
// check identity
if (!identityManagement.checkIdentity(peerId, publicKey)) {
return false;
}
// store the data
if (canStorePrimary(locationKey, domainKey, false)) {
// we have space in our primary tracker, store them there!
Number320 key = new Number320(locationKey, domainKey);
if (storeData(peerAddress, attachement, peerId, key, trackerDataMesh, reverseTrackerDataMesh,
getPrimanyFactor())) {
if (replication != null) {
replication.updateAndNotifyResponsibilities(locationKey);
}
return true;
}
}
// do not store in the secondary map, since this is used for PEX, for
// unknown peers.
return false;
}