net.tomp2p.rpc
Class StorageRPC

java.lang.Object
  extended by org.jboss.netty.channel.SimpleChannelHandler
      extended by net.tomp2p.rpc.ReplyHandler
          extended by 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 Class Summary
 
Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler
org.jboss.netty.channel.ChannelHandler.Sharable
 
Constructor Summary
StorageRPC(PeerBean peerBean, ConnectionBean connectionBean)
           
 
Method Summary
 FutureResponse add(PeerAddress remotePeer, Number160 locationKey, Number160 domainKey, Collection<Data> dataSet, boolean protectDomain, boolean signMessage, boolean list, ChannelCreator channelCreator, boolean forceUDP, SenderCacheStrategy senderCacheStrategy)
          Adds data on a remote peer.
 FutureResponse compareAndPut(PeerAddress remotePeer, Number160 locationKey, Number160 domainKey, Map<Number160,HashData> hashDataMap, FutureSuccessEvaluator futureSuccessEvaluator, boolean protectDomain, boolean protectEntry, boolean signMessage, boolean partialPut, ChannelCreator channelCreator, boolean forceUDP)
          Compares and puts data on a peer.
 FutureResponse get(PeerAddress remotePeer, Number160 locationKey, Number160 domainKey, Collection<Number160> contentKeys, SimpleBloomFilter<Number160> keyBloomFilter, SimpleBloomFilter<Number160> contentBloomFilter, boolean signMessage, boolean digest, boolean returnBloomFilter, boolean range, ChannelCreator channelCreator, boolean forceUDP)
          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, boolean forceUDP, SenderCacheStrategy senderCacheStrategy)
          Stores data on a remote peer.
 FutureResponse putIfAbsent(PeerAddress remotePeer, Number160 locationKey, Number160 domainKey, Map<Number160,Data> dataMap, boolean protectDomain, boolean protectEntry, boolean signMessage, ChannelCreator channelCreator, boolean forceUDP, SenderCacheStrategy senderCacheStrategy)
          Stores data on a remote peer.
 FutureResponse remove(PeerAddress remotePeer, Number160 locationKey, Number160 domainKey, Collection<Number160> contentKeys, boolean sendBackResults, boolean signMessage, ChannelCreator channelCreator, boolean forceUDP)
          Removes data from a peer.
 
Methods inherited from class net.tomp2p.rpc.ReplyHandler
createMessage, createResponseMessage, exceptionCaught, forwardMessage, getConnectionBean, getPeerBean, registerIoHandler, setSignReply
 
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
 

Constructor Detail

StorageRPC

public StorageRPC(PeerBean peerBean,
                  ConnectionBean connectionBean)
Method Detail

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,
                          boolean forceUDP,
                          SenderCacheStrategy senderCacheStrategy)
Stores data on a remote peer. Overwrites data if the data already exists. This is an RPC.

Parameters:
remotePeer - The remote peer to store the data
locationKey - The location of the data
domainKey - The domain of the data
dataMap - The map with the content key and data
protectDomain - Set to true if the domain should be set to protected. This means that this domain is flagged an a public key is stored for this entry. An update or removal can only be made with the matching private key.
protectEntry - Set to true if the entry should be set to protected. This means that this domain is flagged an a public key is stored for this entry. An update or removal can only be made with the matching private key.
signMessage - Set to true if the message should be signed. For protecting an entry, this needs to be set to true.
channelCreator - The channel creator
forceUDP - Set to true if the communication should be UDP, default is TCP
Returns:
FutureResponse that stores which content keys have been stored.

putIfAbsent

public FutureResponse putIfAbsent(PeerAddress remotePeer,
                                  Number160 locationKey,
                                  Number160 domainKey,
                                  Map<Number160,Data> dataMap,
                                  boolean protectDomain,
                                  boolean protectEntry,
                                  boolean signMessage,
                                  ChannelCreator channelCreator,
                                  boolean forceUDP,
                                  SenderCacheStrategy senderCacheStrategy)
Stores data on a remote peer. Only stores data if the data does not already exist. This is an RPC.

Parameters:
remotePeer - The remote peer to store the data
locationKey - The location of the data
domainKey - The domain of the data
dataMap - The map with the content key and data
protectDomain - Set to true if the domain should be set to protected. This means that this domain is flagged an a public key is stored for this entry. An update or removal can only be made with the matching private key.
protectEntry - Set to true if the entry should be set to protected. This means that this domain is flagged an a public key is stored for this entry. An update or removal can only be made with the matching private key.
signMessage - Set to true if the message should be signed. For protecting an entry, this needs to be set to true.
channelCreator - The channel creator
forceUDP - Set to true if the communication should be UDP, default is TCP
Returns:
FutureResponse that stores which content keys have been stored.

compareAndPut

public FutureResponse compareAndPut(PeerAddress remotePeer,
                                    Number160 locationKey,
                                    Number160 domainKey,
                                    Map<Number160,HashData> hashDataMap,
                                    FutureSuccessEvaluator futureSuccessEvaluator,
                                    boolean protectDomain,
                                    boolean protectEntry,
                                    boolean signMessage,
                                    boolean partialPut,
                                    ChannelCreator channelCreator,
                                    boolean forceUDP)
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. This is an RPC.

Parameters:
remotePeer - The remote peer to store the data
locationKey - The location key
domainKey - The domain key
hashDataMap - The map with the data and the hashes to compare to
futureSuccessEvaluator - The evaluator that determines if a future was a success.
protectDomain - Protect the domain
protectEntry - Protect the entry
signMessage - Set to true if the message should be signed. For protecting an entry, this needs to be set to true.
partialPut - 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
forceUDP - Set to true if the communication should be UDP, default is TCP
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,
                          boolean list,
                          ChannelCreator channelCreator,
                          boolean forceUDP,
                          SenderCacheStrategy senderCacheStrategy)
Adds data on a remote peer. The main difference to #put(PeerAddress, Number160, Number160, Map, Type, boolean, ChannelCreator, boolean) and #putIfAbsent(PeerAddress, Number160, Number160, Map, boolean, boolean, boolean, ChannelCreator, boolean) is that it will convert the data collection to map. The key for the map will be the SHA-1 hash of the data. This is an RPC.

Parameters:
remotePeer - The remote peer to store the data
locationKey - The location key
domainKey - The domain key
dataSet - The set with data. This will be converted to a map. The key for the map is the SHA-1 of the data.
protectDomain - Set to true if the domain should be set to protected. This means that this domain is flagged an a public key is stored for this entry. An update or removal can only be made with the matching private key.
signMessage - Set to true if the message should be signed. For protecting an entry, this needs to be set to true.
channelCreator - The channel creator
forceUDP - Set to true if the communication should be UDP, default is TCP
Returns:
FutureResponse that stores which content keys have been stored.

get

public FutureResponse get(PeerAddress remotePeer,
                          Number160 locationKey,
                          Number160 domainKey,
                          Collection<Number160> contentKeys,
                          SimpleBloomFilter<Number160> keyBloomFilter,
                          SimpleBloomFilter<Number160> contentBloomFilter,
                          boolean signMessage,
                          boolean digest,
                          boolean returnBloomFilter,
                          boolean range,
                          ChannelCreator channelCreator,
                          boolean forceUDP)
Get the data from a remote peer. This is an RPC.

Parameters:
remotePeer - The remote peer to send this request
locationKey - The location key
domainKey - The domain key
contentKeys - The content keys or null if requested all
signMessage - Adds a public key and signs the message
digest - Returns a list of hashes of the data stored on this peer
channelCreator - The channel creator that creates connections. Typically we need one connection here.
forceUDP - Set to true if the communication should be UDP, default is TCP
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,
                             boolean forceUDP)
Removes data from a peer. This is an RPC.

Parameters:
remotePeer - The remote peer to send this request
locationKey - The location key
domainKey - The domain key
contentKeys - The content keys or null if requested all
sendBackResults - Set to true if the removed data should be sent back
signMessage - Adds a public key and signs the message. For protected entry and domains, this needs to be provided.
channelCreator - The channel creator that creates connections
forceUDP - Set to true if the communication should be UDP, default is TCP
Returns:
The future response to keep track of future events

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 © 2013. All Rights Reserved.