当前位置: 首页>>代码示例>>Java>>正文


Java PeerAddress.equals方法代码示例

本文整理汇总了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);
}
 
开发者ID:Hive2Hive,项目名称:Hive2Hive,代码行数:29,代码来源:ContactOtherClientsStepTest.java

示例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);
}
 
开发者ID:Hive2Hive,项目名称:Hive2Hive,代码行数:29,代码来源:ContactOtherClientsStepTest.java

示例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);
}
 
开发者ID:Hive2Hive,项目名称:Hive2Hive,代码行数:25,代码来源:ContactOtherClientsStepTest.java

示例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;
}
 
开发者ID:Hive2Hive,项目名称:Hive2Hive,代码行数:38,代码来源:ContactOtherClientsStep.java

示例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));
}
 
开发者ID:Hive2Hive,项目名称:Hive2Hive,代码行数:7,代码来源:ContactOtherClientsStepTest.java


注:本文中的net.tomp2p.peers.PeerAddress.equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。