Module org.refcodes.p2p
Package org.refcodes.p2p
Interface Peer<LOCATOR,HEADER extends P2PHeader<LOCATOR>,TAIL extends P2PTail<LOCATOR>,MSG extends P2PMessage<LOCATOR,HEADER,?,TAIL>,ROUTER extends PeerRouter<LOCATOR,HEADER,TAIL,MSG>>
-
- Type Parameters:
ROUTER
- ThePeerRouter
type to use when routingP2PMessage
instances.LOCATOR
- Defines the type of the locators identifying a peer.HEADER
- TheP2PHeader
defines the static attributes addressed for the target of theP2PMessage
(a header might be signed as it is not modified during dispatch).TAIL
- TheP2PTail
describes the dynamic attributes required during dispatch of aP2PMessage
(a tail is modified during dispatch by having the visited hops appended).MSG
- The (sub-)type of theP2PMessage
being processed by the accordingPeer
(sub-)type.
- All Superinterfaces:
org.refcodes.mixin.LocatorAccessor<LOCATOR>
,PeerRouter<LOCATOR,HEADER,TAIL,MSG>
,Terminal<LOCATOR>
- All Known Implementing Classes:
AbstractPeer
public interface Peer<LOCATOR,HEADER extends P2PHeader<LOCATOR>,TAIL extends P2PTail<LOCATOR>,MSG extends P2PMessage<LOCATOR,HEADER,?,TAIL>,ROUTER extends PeerRouter<LOCATOR,HEADER,TAIL,MSG>> extends PeerRouter<LOCATOR,HEADER,TAIL,MSG>, Terminal<LOCATOR>
APeer
represents a physical peer usingPeerRouter
instances to communicate with its direct neighbours. You can think of aPeer
being the skeleton and aPeerRouter
being the stub (as of RPC) of a peer.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.refcodes.mixin.LocatorAccessor
org.refcodes.mixin.LocatorAccessor.LocatorBuilder<T extends Object,B extends org.refcodes.mixin.LocatorAccessor.LocatorBuilder<T,B>>, org.refcodes.mixin.LocatorAccessor.LocatorMutator<T extends Object>, org.refcodes.mixin.LocatorAccessor.LocatorProperty<T extends Object>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
addPeerRouter(ROUTER aPeerRouter)
Adds aPeerRouter
to the list of the knownPeerRouter
instances.Set<ROUTER>
peerRouters()
Retrieves all known (attached)PeerRouter
instances.boolean
removePeerRouter(ROUTER aPeerRouter)
Removes aPeerRouter
from the list of the knownPeerRouter
instances.<P> void
sendMessage(LOCATOR aDestination, P aPayload)
Convenience method forPeerRouter.sendMessage(P2PMessage)
.-
Methods inherited from interface org.refcodes.p2p.PeerRouter
getHopCount, getHopCount, sendMessage
-
-
-
-
Method Detail
-
peerRouters
Set<ROUTER> peerRouters()
Retrieves all known (attached)PeerRouter
instances.- Returns:
- The known (attached)
PeerRouter
instances.
-
addPeerRouter
boolean addPeerRouter(ROUTER aPeerRouter)
Adds aPeerRouter
to the list of the knownPeerRouter
instances.- Parameters:
aPeerRouter
- ThePeerRouter
being added.- Returns:
- False in case this
PeerRouter
has already been added.
-
removePeerRouter
boolean removePeerRouter(ROUTER aPeerRouter)
Removes aPeerRouter
from the list of the knownPeerRouter
instances.- Parameters:
aPeerRouter
- ThePeerRouter
to be removed.- Returns:
- False in case this
PeerRouter
has not been added (or already been removed).
-
sendMessage
<P> void sendMessage(LOCATOR aDestination, P aPayload) throws NoSuchDestinationException, IOException
Convenience method forPeerRouter.sendMessage(P2PMessage)
.- Type Parameters:
P
- The type of the payload in question.- Parameters:
aDestination
- The destination of the message.aPayload
- The payload to be sent.- Throws:
NoSuchDestinationException
- thrown in case there is none such destination peer.IOException
- thrown in case I/O problems occurred while accessing the mesh.
-
-