peerinfobundle.java
来自「Java P2P技术内幕:《Java P2P技术内幕》源码」· Java 代码 · 共 80 行
JAVA
80 行
package primecruncher;import net.jxta.protocol.ModuleSpecAdvertisement;import net.jxta.protocol.PeerAdvertisement;import net.jxta.protocol.PipeAdvertisement;import net.jxta.peer.PeerID;import net.jxta.pipe.PipeID;import net.jxta.id.ID;/** * Hold information about a discovered peer. Information includes: * peer's advertisment * peer's ModuleSpecAdvertisement * Performance Metics for the peer * * TODO: Implement persistence mechanism */class PeerInfoBundle { //private PeerAdvertisement peerAdvertisement = null; private ModuleSpecAdvertisement moduleSpecAdvertisement = null; private PeerMetrics peerMetrics = null; PeerInfoBundle(ModuleSpecAdvertisement mAdv) { //this.peerAdvertisement = adv; this.moduleSpecAdvertisement = mAdv; peerMetrics = new PeerMetrics(); } /* protected PeerAdvertisement getPeerAdvertisement() { return peerAdvertisement; } */ protected ModuleSpecAdvertisement getModuleSpecAdvertisement() { return moduleSpecAdvertisement; } protected PeerMetrics getPeerMetrics() { return peerMetrics; } /** * Two peer info bundles are equal if, and only if, they contain the same * pipe advertisement inside the module spec advertisement. */ public boolean equals(Object o) { if (o instanceof PeerInfoBundle) { PeerInfoBundle b = (PeerInfoBundle)o; ID bPipd = b.moduleSpecAdvertisement.getPipeAdvertisement().getPipeID(); ID ourID = moduleSpecAdvertisement.getPipeAdvertisement().getPipeID(); return ourID.getUniqueValue().equals(bPipd.getUniqueValue()); } return false; } /** * Return the hashCode() semantics for the pipe ID embedded in the module spec * advertisement. */ public int hashCode() { return moduleSpecAdvertisement.getPipeAdvertisement().getPipeID().getUniqueValue().hashCode(); } class PeerMetrics { }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?