net.tomp2p.p2p
Class Peer

java.lang.Object
  extended by net.tomp2p.p2p.Peer

public class Peer
extends Object

TomP2P implements besides the following distributed hash table (DHT) operations:

also the following operations: The advantage of TomP2P is that multiple values can be stored in one location. Furthermore, TomP2P also provides to store keys in different domains to avoid key collisions.

Author:
Thomas Bocek

Field Summary
static int BLOOMFILTER_SIZE
           
 
Constructor Summary
Peer(int p2pID, KeyPair keyPair)
           
Peer(int p2pID, Number160 nodeId)
           
Peer(int p2pID, Number160 nodeId, ConnectionConfiguration connectionConfiguration)
           
Peer(int p2pID, Number160 nodeId, KeyPair keyPair)
           
Peer(int p2pID, Number160 nodeId, P2PConfiguration peerConfiguration, ConnectionConfiguration connectionConfiguration, KeyPair keyPair)
           
Peer(KeyPair keyPair)
           
Peer(Number160 nodeId)
           
Peer(Number160 nodeId, KeyPair keyPair)
           
 
Method Summary
 FutureDHT add(Number160 locationKey, Collection<Data> dataCollection, ConfigurationStore config)
           
 FutureDHT add(Number160 locationKey, Data data)
           
 FutureDHT add(Number160 locationKey, Data data, ConfigurationStore config)
           
 ScheduledFuture<?> addIndirectReplicaiton(Runnable runnable)
           
 ScheduledFuture<?> addMaintainance(Runnable runnable)
           
 void addPeerListener(PeerListener listener)
           
 FutureTracker addToTracker(Number160 locationKey, ConfigurationTrackerStore config)
           
 FutureBootstrap bootstrap(InetSocketAddress address)
           
 FutureBootstrap bootstrap(PeerAddress peerAddress)
           
 FutureBootstrap bootstrap(PeerAddress peerAddress, Collection<PeerAddress> bootstrapTo, ConfigurationStore config)
           
 FutureBootstrap bootstrapBroadcast()
           
 FutureBootstrap bootstrapBroadcast(int port)
           
 PeerConnection createPeerConnection(PeerAddress destination, int idleTCPMillis)
          Opens a TCP connection and keeps it open.
 void customLoggerMessage(String customMessage)
           
 FutureDiscover discover(PeerAddress peerAddress)
          Discover attempts to find the external IP address of this peer.
 FutureDHT get(Number160 locationKey)
           
 FutureDHT get(Number160 locationKey, ConfigurationGet config)
           
 FutureDHT get(Number160 locationKey, Set<Number160> keyCollection, ConfigurationGet config)
           
 FutureDHT getAll(Number160 locationKey)
           
 FutureDHT getAll(Number160 locationKey, ConfigurationGet config)
           
 ConnectionBean getConnectionBean()
           
 ConnectionConfiguration getConnectionConfiguration()
           
 ConnectionHandler getConnectionHandler()
           
 DistributedHashHashMap getDHT()
           
 DirectDataRPC getDirectDataRPC()
           
 FutureTracker getFromTracker(Number160 locationKey, ConfigurationTrackerGet config)
           
 FutureTracker getFromTracker(Number160 locationKey, ConfigurationTrackerGet config, Set<Number160> knownPeers)
           
 FutureTracker getFromTrackerCreateBloomfilter1(Number160 locationKey, ConfigurationTrackerGet config, Collection<PeerAddress> knownPeers)
           
 FutureTracker getFromTrackerCreateBloomfilter2(Number160 locationKey, ConfigurationTrackerGet config, Collection<Number160> knownPeers)
           
 HandshakeRPC getHandshakeRPC()
           
 P2PConfiguration getP2PConfiguration()
           
 int getP2PID()
           
 PeerAddress getPeerAddress()
           
 PeerBean getPeerBean()
           
 PeerExchangeRPC getPeerExchangeRPC()
           
 Number160 getPeerID()
           
 Map<BaseFuture,Long> getPendingFutures()
           
 QuitRPC getQuitRPC()
           
 DistributedRouting getRouting()
           
 StorageRPC getStoreRPC()
           
 DistributedTracker getTracker()
           
 TrackerRPC getTrackerRPC()
           
protected  void init(ConnectionHandler connectionHandler, Statistics statistics)
           
 boolean isListening()
           
 boolean isRunning()
           
 void listen()
           
 void listen(File messageLogger)
           
 void listen(int udpPort, int tcpPort)
           
 void listen(int udpPort, int tcpPort, Bindings bindings)
           
 void listen(int udpPort, int tcpPort, Bindings bindings, File messageLogger)
          Lets this node listen on a port
 void listen(int udpPort, int tcpPort, File messageLogger)
           
 void listen(int udpPort, int tcpPort, InetAddress bind)
           
 void listen(Peer master)
           
 FutureResponse ping(InetSocketAddress address)
           
 FutureDHT put(Number160 locationKey, Data data)
           
 FutureDHT put(Number160 locationKey, Data data, ConfigurationStore config)
           
 FutureDHT put(Number160 locationKey, Map<Number160,Data> dataMap, ConfigurationStore config)
           
 FutureDHT remove(Number160 locationKey)
           
 FutureDHT remove(Number160 locationKey, ConfigurationRemove config)
           
 FutureDHT remove(Number160 locationKey, Number160 contentKey)
           
 FutureDHT remove(Number160 locationKey, Set<Number160> keyCollection, ConfigurationRemove config)
           
 FutureDHT removeAll(Number160 locationKey)
           
 FutureDHT removeAll(Number160 locationKey, ConfigurationRemove config)
           
 void removePeerListener()
           
 FutureDHT send(Number160 locationKey, org.jboss.netty.buffer.ChannelBuffer buffer)
           
 FutureDHT send(Number160 locationKey, org.jboss.netty.buffer.ChannelBuffer buffer, ConfigurationDirect config)
           
 FutureDHT send(Number160 locationKey, Object object)
           
 FutureDHT send(Number160 locationKey, Object object, ConfigurationDirect config)
           
 FutureData send(PeerAddress remotePeer, org.jboss.netty.buffer.ChannelBuffer requestBuffer)
           
 FutureData send(PeerAddress remotePeer, Object object)
           
 FutureData send(PeerConnection connection, org.jboss.netty.buffer.ChannelBuffer requestBuffer)
           
 FutureData send(PeerConnection connection, Object object)
           
 void setDefaultStorageReplication()
           
 void setObjectDataReply(ObjectDataReply objectDataReply)
           
 void setPeerMap(PeerMap peerMap)
           
 void setRawDataReply(RawDataReply rawDataReply)
           
 void setupPortForwandingUPNP(String internalHost)
          The Dynamic and/or Private Ports are those from 49152 through 65535 (http://www.iana.org/assignments/port-numbers)
 void shutdown()
          Closes all connections of this node
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BLOOMFILTER_SIZE

public static final int BLOOMFILTER_SIZE
See Also:
Constant Field Values
Constructor Detail

Peer

public Peer(KeyPair keyPair)

Peer

public Peer(Number160 nodeId)

Peer

public Peer(Number160 nodeId,
            KeyPair keyPair)

Peer

public Peer(int p2pID,
            KeyPair keyPair)

Peer

public Peer(int p2pID,
            Number160 nodeId)

Peer

public Peer(int p2pID,
            Number160 nodeId,
            KeyPair keyPair)

Peer

public Peer(int p2pID,
            Number160 nodeId,
            ConnectionConfiguration connectionConfiguration)

Peer

public Peer(int p2pID,
            Number160 nodeId,
            P2PConfiguration peerConfiguration,
            ConnectionConfiguration connectionConfiguration,
            KeyPair keyPair)
Method Detail

addPeerListener

public void addPeerListener(PeerListener listener)

removePeerListener

public void removePeerListener()

shutdown

public void shutdown()
Closes all connections of this node

Throws:
InterruptedException

listen

public void listen()
            throws Exception
Throws:
Exception

listen

public void listen(File messageLogger)
            throws Exception
Throws:
Exception

listen

public void listen(int udpPort,
                   int tcpPort)
            throws Exception
Throws:
Exception

listen

public void listen(int udpPort,
                   int tcpPort,
                   File messageLogger)
            throws Exception
Throws:
Exception

listen

public void listen(int udpPort,
                   int tcpPort,
                   InetAddress bind)
            throws Exception
Throws:
Exception

listen

public void listen(int udpPort,
                   int tcpPort,
                   Bindings bindings)
            throws Exception
Throws:
Exception

listen

public void listen(int udpPort,
                   int tcpPort,
                   Bindings bindings,
                   File messageLogger)
            throws Exception
Lets this node listen on a port

Parameters:
udpPort - the UDP port to listen on
tcpPort - the TCP port to listen on
bindInformation - contains IP addresses to listen on
replication -
statServer -
Throws:
Exception

listen

public void listen(Peer master)
            throws Exception
Throws:
Exception

init

protected void init(ConnectionHandler connectionHandler,
                    Statistics statistics)

setDefaultStorageReplication

public void setDefaultStorageReplication()

getPendingFutures

public Map<BaseFuture,Long> getPendingFutures()

isRunning

public boolean isRunning()

isListening

public boolean isListening()

customLoggerMessage

public void customLoggerMessage(String customMessage)

getHandshakeRPC

public HandshakeRPC getHandshakeRPC()

getStoreRPC

public StorageRPC getStoreRPC()

getQuitRPC

public QuitRPC getQuitRPC()

getPeerExchangeRPC

public PeerExchangeRPC getPeerExchangeRPC()

getDirectDataRPC

public DirectDataRPC getDirectDataRPC()

getTrackerRPC

public TrackerRPC getTrackerRPC()

getRouting

public DistributedRouting getRouting()

addIndirectReplicaiton

public ScheduledFuture<?> addIndirectReplicaiton(Runnable runnable)

addMaintainance

public ScheduledFuture<?> addMaintainance(Runnable runnable)

getConnectionHandler

public ConnectionHandler getConnectionHandler()

getDHT

public DistributedHashHashMap getDHT()

getTracker

public DistributedTracker getTracker()

getPeerBean

public PeerBean getPeerBean()

getConnectionBean

public ConnectionBean getConnectionBean()

getPeerID

public Number160 getPeerID()

getPeerAddress

public PeerAddress getPeerAddress()

setPeerMap

public void setPeerMap(PeerMap peerMap)

getP2PID

public int getP2PID()

setRawDataReply

public void setRawDataReply(RawDataReply rawDataReply)

setObjectDataReply

public void setObjectDataReply(ObjectDataReply objectDataReply)

createPeerConnection

public PeerConnection createPeerConnection(PeerAddress destination,
                                           int idleTCPMillis)
Opens a TCP connection and keeps it open. The user can provide the idle timeout, which means that the connection gets closed after that time of inacitivty. If the other peer goes offline or closes the connection (due to inactivity), further requests with this connections reopens the connection.

Parameters:
destination - The end-point to connect to
idleSeconds - time in seconds after a connection gets closed if idle, -1 if it should remain always open until the user closes the connection manually.
Returns:
A class that needs to be passed to those methods that should use the already open connection.

send

public FutureData send(PeerAddress remotePeer,
                       org.jboss.netty.buffer.ChannelBuffer requestBuffer)

send

public FutureData send(PeerConnection connection,
                       org.jboss.netty.buffer.ChannelBuffer requestBuffer)

send

public FutureData send(PeerAddress remotePeer,
                       Object object)
                throws IOException
Throws:
IOException

send

public FutureData send(PeerConnection connection,
                       Object object)
                throws IOException
Throws:
IOException

bootstrapBroadcast

public FutureBootstrap bootstrapBroadcast()

bootstrapBroadcast

public FutureBootstrap bootstrapBroadcast(int port)

ping

public FutureResponse ping(InetSocketAddress address)

bootstrap

public FutureBootstrap bootstrap(InetSocketAddress address)

bootstrap

public FutureBootstrap bootstrap(PeerAddress peerAddress)

bootstrap

public FutureBootstrap bootstrap(PeerAddress peerAddress,
                                 Collection<PeerAddress> bootstrapTo,
                                 ConfigurationStore config)

setupPortForwandingUPNP

public void setupPortForwandingUPNP(String internalHost)
The Dynamic and/or Private Ports are those from 49152 through 65535 (http://www.iana.org/assignments/port-numbers)

Parameters:
internalHost -
port -

discover

public FutureDiscover discover(PeerAddress peerAddress)
Discover attempts to find the external IP address of this peer. This is done by first trying to set UPNP with port forwarding (gives us the external address), query UPNP for the external address, and pinging a well known peer.

Parameters:
peerAddress -
Returns:

put

public FutureDHT put(Number160 locationKey,
                     Data data)

put

public FutureDHT put(Number160 locationKey,
                     Data data,
                     ConfigurationStore config)

put

public FutureDHT put(Number160 locationKey,
                     Map<Number160,Data> dataMap,
                     ConfigurationStore config)

add

public FutureDHT add(Number160 locationKey,
                     Data data)

add

public FutureDHT add(Number160 locationKey,
                     Data data,
                     ConfigurationStore config)

add

public FutureDHT add(Number160 locationKey,
                     Collection<Data> dataCollection,
                     ConfigurationStore config)

getAll

public FutureDHT getAll(Number160 locationKey)

getAll

public FutureDHT getAll(Number160 locationKey,
                        ConfigurationGet config)

get

public FutureDHT get(Number160 locationKey)

get

public FutureDHT get(Number160 locationKey,
                     ConfigurationGet config)

get

public FutureDHT get(Number160 locationKey,
                     Set<Number160> keyCollection,
                     ConfigurationGet config)

removeAll

public FutureDHT removeAll(Number160 locationKey)

removeAll

public FutureDHT removeAll(Number160 locationKey,
                           ConfigurationRemove config)

remove

public FutureDHT remove(Number160 locationKey)

remove

public FutureDHT remove(Number160 locationKey,
                        ConfigurationRemove config)

remove

public FutureDHT remove(Number160 locationKey,
                        Number160 contentKey)

remove

public FutureDHT remove(Number160 locationKey,
                        Set<Number160> keyCollection,
                        ConfigurationRemove config)

send

public FutureDHT send(Number160 locationKey,
                      org.jboss.netty.buffer.ChannelBuffer buffer)

send

public FutureDHT send(Number160 locationKey,
                      org.jboss.netty.buffer.ChannelBuffer buffer,
                      ConfigurationDirect config)

send

public FutureDHT send(Number160 locationKey,
                      Object object)
               throws IOException
Throws:
IOException

send

public FutureDHT send(Number160 locationKey,
                      Object object,
                      ConfigurationDirect config)
               throws IOException
Throws:
IOException

getFromTracker

public FutureTracker getFromTracker(Number160 locationKey,
                                    ConfigurationTrackerGet config)

getFromTrackerCreateBloomfilter1

public FutureTracker getFromTrackerCreateBloomfilter1(Number160 locationKey,
                                                      ConfigurationTrackerGet config,
                                                      Collection<PeerAddress> knownPeers)

getFromTrackerCreateBloomfilter2

public FutureTracker getFromTrackerCreateBloomfilter2(Number160 locationKey,
                                                      ConfigurationTrackerGet config,
                                                      Collection<Number160> knownPeers)

getFromTracker

public FutureTracker getFromTracker(Number160 locationKey,
                                    ConfigurationTrackerGet config,
                                    Set<Number160> knownPeers)

addToTracker

public FutureTracker addToTracker(Number160 locationKey,
                                  ConfigurationTrackerStore config)

getConnectionConfiguration

public ConnectionConfiguration getConnectionConfiguration()

getP2PConfiguration

public P2PConfiguration getP2PConfiguration()


Copyright © 2011. All Rights Reserved.