net.tomp2p.rpc
Class StorageRPC
java.lang.Object
org.jboss.netty.channel.SimpleChannelHandler
net.tomp2p.rpc.ReplyHandler
net.tomp2p.rpc.StorageRPC
- All Implemented Interfaces:
- org.jboss.netty.channel.ChannelDownstreamHandler, org.jboss.netty.channel.ChannelHandler, org.jboss.netty.channel.ChannelUpstreamHandler
public class StorageRPC
- extends ReplyHandler
| Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler |
org.jboss.netty.channel.ChannelHandler.Sharable |
|
Method Summary |
FutureResponse |
add(PeerAddress remotePeer,
Number160 locationKey,
Number160 domainKey,
Collection<Data> dataSet,
boolean protectDomain,
boolean signMessage,
ChannelCreator channelCreator)
|
boolean |
checkMessage(Message message)
Before a reply can be done, the message needs to be checked. |
FutureResponse |
compareAndPut(PeerAddress remotePeer,
Number160 locationKey,
Number160 domainKey,
Map<Number160,HashData> hashDataMap,
boolean protectDomain,
boolean protectEntry,
boolean signMessage,
boolean partialPut,
ChannelCreator channelCreator)
Compares and puts data on a peer. |
FutureResponse |
get(PeerAddress remotePeer,
Number160 locationKey,
Number160 domainKey,
Collection<Number160> contentKeys,
PublicKey protectedDomains,
boolean signMessage,
boolean digest,
ChannelCreator channelCreator)
Starts an RPC to get the data from a remote peer. |
PeerAddress |
getPeerAddress()
|
Message |
handleResponse(Message message,
boolean sign)
If the message is OK, that has been previously checked by the user using
checkMessage, a reply to the message is generated here. |
FutureResponse |
put(PeerAddress remotePeer,
Number160 locationKey,
Number160 domainKey,
Map<Number160,Data> dataMap,
boolean protectDomain,
boolean protectEntry,
boolean signMessage,
ChannelCreator channelCreator)
|
FutureResponse |
putIfAbsent(PeerAddress remotePeer,
Number160 locationKey,
Number160 domainKey,
Map<Number160,Data> dataMap,
boolean protectDomain,
boolean protectEntry,
boolean signMessage,
ChannelCreator channelCreator)
|
FutureResponse |
remove(PeerAddress remotePeer,
Number160 locationKey,
Number160 domainKey,
Collection<Number160> contentKeys,
boolean sendBackResults,
boolean signMessage,
ChannelCreator channelCreator)
|
| Methods inherited from class org.jboss.netty.channel.SimpleChannelHandler |
bindRequested, channelBound, channelClosed, channelConnected, channelDisconnected, channelInterestChanged, channelOpen, channelUnbound, childChannelClosed, childChannelOpen, closeRequested, connectRequested, disconnectRequested, handleDownstream, handleUpstream, messageReceived, setInterestOpsRequested, unbindRequested, writeComplete, writeRequested |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
StorageRPC
public StorageRPC(PeerBean peerBean,
ConnectionBean connectionBean)
getPeerAddress
public PeerAddress getPeerAddress()
put
public FutureResponse put(PeerAddress remotePeer,
Number160 locationKey,
Number160 domainKey,
Map<Number160,Data> dataMap,
boolean protectDomain,
boolean protectEntry,
boolean signMessage,
ChannelCreator channelCreator)
putIfAbsent
public FutureResponse putIfAbsent(PeerAddress remotePeer,
Number160 locationKey,
Number160 domainKey,
Map<Number160,Data> dataMap,
boolean protectDomain,
boolean protectEntry,
boolean signMessage,
ChannelCreator channelCreator)
compareAndPut
public FutureResponse compareAndPut(PeerAddress remotePeer,
Number160 locationKey,
Number160 domainKey,
Map<Number160,HashData> hashDataMap,
boolean protectDomain,
boolean protectEntry,
boolean signMessage,
boolean partialPut,
ChannelCreator channelCreator)
- Compares and puts data on a peer. It first compares the hashes that the
user provided on the remote peer, and if the hashes match, the data is
stored. If the flag partial put has been set, then it will store those
data where the hashes match and ignore the others.
- Parameters:
remotePeer - The remote peer to store the datalocationKey - The location keydomainKey - The domain keyhashDataMap - The map with the data and the hashes to compare toprotectDomain - Protect the domainprotectEntry - Protect the entrysignMessage - Sing messagepartialPut - Set to true if partial puts should be allowed. If set
to false, then the complete map must match the hash, otherwise it
wont be stored.channelCreator - The channel creator
- Returns:
- FutureResponse that stores which content keys have been stored.
add
public FutureResponse add(PeerAddress remotePeer,
Number160 locationKey,
Number160 domainKey,
Collection<Data> dataSet,
boolean protectDomain,
boolean signMessage,
ChannelCreator channelCreator)
get
public FutureResponse get(PeerAddress remotePeer,
Number160 locationKey,
Number160 domainKey,
Collection<Number160> contentKeys,
PublicKey protectedDomains,
boolean signMessage,
boolean digest,
ChannelCreator channelCreator)
- Starts an RPC to get the data from a remote peer.
- Parameters:
remotePeer - The remote peer to send this requestlocationKey - The location keydomainKey - The domain keycontentKeys - The content keys or null if requested allprotectedDomains - Add the public key to protect the domain. In order to make this work, the message needs to be signedsignMessage - Adds a public key and signs the messagedigest - Returns a list of hashes of the data stored on this peerchannelCreator - The channel creator that creates connections. Typically we need one connection here.
- Returns:
- The future response to keep track of future events
remove
public FutureResponse remove(PeerAddress remotePeer,
Number160 locationKey,
Number160 domainKey,
Collection<Number160> contentKeys,
boolean sendBackResults,
boolean signMessage,
ChannelCreator channelCreator)
checkMessage
public boolean checkMessage(Message message)
- Description copied from class:
ReplyHandler
- Before a reply can be done, the message needs to be checked. If you
return false, then the peer is removed from the map and the channel is
closed.
- Specified by:
checkMessage in class ReplyHandler
- Parameters:
message - Request message
- Returns:
- True if a request should be generated, false if channel should be
closed and nothing should be replied
handleResponse
public Message handleResponse(Message message,
boolean sign)
throws IOException
- Description copied from class:
ReplyHandler
- If the message is OK, that has been previously checked by the user using
checkMessage, a reply to the message is generated here.
- Specified by:
handleResponse in class ReplyHandler
- Parameters:
message - Request message
- Throws:
IOException
Copyright © 2012. All Rights Reserved.