📄 peerinfobundle.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -