本文整理汇总了Java中net.tomp2p.peers.PeerAddress.equals方法的典型用法代码示例。如果您正苦于以下问题:Java PeerAddress.equals方法的具体用法?Java PeerAddress.equals怎么用?Java PeerAddress.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.tomp2p.peers.PeerAddress
的用法示例。
在下文中一共展示了PeerAddress.equals方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: allClientsAreAlive
import net.tomp2p.peers.PeerAddress; //导入方法依赖的package包/类
/**
* All client nodes are alive.
*
* @throws NoSessionException
* @throws NoPeerConnectionException
*/
@Test
public void allClientsAreAlive() throws NoSessionException, NoPeerConnectionException {
Locations fakedLocations = new Locations(userId);
fakedLocations.addPeerAddress(network.get(0).getConnection().getPeer().peerAddress());
// responding nodes
fakedLocations.addPeerAddress(network.get(1).getConnection().getPeer().peerAddress());
fakedLocations.addPeerAddress(network.get(2).getConnection().getPeer().peerAddress());
fakedLocations.addPeerAddress(network.get(3).getConnection().getPeer().peerAddress());
Locations result = runProcessStep(fakedLocations,
isInitialClient(fakedLocations, network.get(0).getConnection().getPeer().peerAddress()));
assertEquals(4, result.getPeerAddresses().size());
PeerAddress newClientsEntry = null;
for (PeerAddress address : result.getPeerAddresses()) {
if (address.equals(network.get(0).getConnection().getPeer().peerAddress())) {
newClientsEntry = address;
break;
}
}
assertNotNull(newClientsEntry);
}
示例2: notAllClientsAreAlive
import net.tomp2p.peers.PeerAddress; //导入方法依赖的package包/类
/**
* Some client nodes are offline.
*
* @throws NoSessionException
* @throws NoPeerConnectionException
*/
@Test
public void notAllClientsAreAlive() throws NoSessionException, NoPeerConnectionException {
Locations fakedLocations = new Locations(userId);
fakedLocations.addPeerAddress(network.get(0).getConnection().getPeer().peerAddress());
fakedLocations.addPeerAddress(network.get(1).getConnection().getPeer().peerAddress());
// not responding nodes
fakedLocations.addPeerAddress(network.get(4).getConnection().getPeer().peerAddress());
fakedLocations.addPeerAddress(network.get(5).getConnection().getPeer().peerAddress());
Locations result = runProcessStep(fakedLocations,
isInitialClient(fakedLocations, network.get(0).getConnection().getPeer().peerAddress()));
assertEquals(2, result.getPeerAddresses().size());
PeerAddress newClientsEntry = null;
for (PeerAddress address : result.getPeerAddresses()) {
if (address.equals(network.get(0).getConnection().getPeer().peerAddress())) {
newClientsEntry = address;
break;
}
}
assertNotNull(newClientsEntry);
}
示例3: notCompleteLocations
import net.tomp2p.peers.PeerAddress; //导入方法依赖的package包/类
/**
* Received a location map without own location entry.
*
* @throws NoSessionException
* @throws NoPeerConnectionException
*/
@Test
public void notCompleteLocations() throws NoSessionException, NoPeerConnectionException {
Locations fakedLocations = new Locations(userId);
fakedLocations.addPeerAddress(network.get(1).getConnection().getPeer().peerAddress());
Locations result = runProcessStep(fakedLocations,
isInitialClient(fakedLocations, network.get(0).getConnection().getPeer().peerAddress()));
assertEquals(2, result.getPeerAddresses().size());
PeerAddress newClientsEntry = null;
for (PeerAddress address : result.getPeerAddresses()) {
if (address.equals(network.get(0).getConnection().getPeer().peerAddress())) {
newClientsEntry = address;
break;
}
}
assertNotNull(newClientsEntry);
}
示例4: sendBlocking
import net.tomp2p.peers.PeerAddress; //导入方法依赖的package包/类
private void sendBlocking(Set<PeerAddress> peerAddresses, final PublicKey ownPublicKey) {
waitForResponses = new CountDownLatch(peerAddresses.size());
boolean hasSlowPeers = false;
for (final PeerAddress address : peerAddresses) {
// contact all other clients (exclude self)
if (!address.equals(networkManager.getConnection().getPeer().peerAddress())) {
logger.debug("Sending contact message to check for aliveness to {}", address);
String evidence = UUID.randomUUID().toString();
evidences.put(address, evidence);
hasSlowPeers = hasSlowPeers || address.isSlow();
final ContactPeerMessage message = new ContactPeerMessage(address, evidence);
message.setCallBackHandler(this);
// asynchronously send all messages (parallel)
new Thread(new Runnable() {
@Override
public void run() {
if (!messageManager.sendDirect(message, ownPublicKey)) {
responses.put(address, false);
}
}
}).start();
}
}
// wait (blocking) until all responses are here or the time's up
int waitTime = hasSlowPeers ? H2HConstants.CONTACT_SLOW_PEERS_AWAIT_MS : H2HConstants.CONTACT_PEERS_AWAIT_MS;
try {
logger.debug("Waiting for at most {}ms for the response of other clients", waitTime);
waitForResponses.await(waitTime, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
logger.error("Could not wait the given time for the clients to respond.", e);
}
isUpdated = true;
}
示例5: isInitialClient
import net.tomp2p.peers.PeerAddress; //导入方法依赖的package包/类
private boolean isInitialClient(Locations locations, PeerAddress client) {
ArrayList<PeerAddress> list = new ArrayList<PeerAddress>();
list.addAll(locations.getPeerAddresses());
PeerAddress initial = NetworkUtils.choseFirstPeerAddress(list);
return (initial.equals(client));
}