voldemort.client.protocol.admin
Class SocketResourceFactory

java.lang.Object
  extended by voldemort.client.protocol.admin.SocketResourceFactory
All Implemented Interfaces:
ResourceFactory<SocketDestination,SocketAndStreams>

public class SocketResourceFactory
extends java.lang.Object
implements ResourceFactory<SocketDestination,SocketAndStreams>

A Factory for creating sockets


Field Summary
static org.apache.log4j.Logger logger
           
 
Constructor Summary
SocketResourceFactory(int soTimeoutMs, int socketBufferSize)
           
SocketResourceFactory(int soTimeoutMs, int socketBufferSize, boolean socketKeepAlive)
           
 
Method Summary
 void close()
           
 SocketAndStreams create(SocketDestination dest)
          Create a socket for the given host/port
 void destroy(SocketDestination dest, SocketAndStreams sands)
          Close the socket
 int getNumberCreated()
           
 int getNumberDestroyed()
           
 int getTimeout()
           
 void setLastClosedTimestamp(SocketDestination socketDestination)
          Assigns the last closed timestamp based on the current time in nanoseconds.
 boolean validate(SocketDestination dest, SocketAndStreams sands)
          Check that the given resource is valid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

public static final org.apache.log4j.Logger logger
Constructor Detail

SocketResourceFactory

public SocketResourceFactory(int soTimeoutMs,
                             int socketBufferSize)

SocketResourceFactory

public SocketResourceFactory(int soTimeoutMs,
                             int socketBufferSize,
                             boolean socketKeepAlive)
Method Detail

destroy

public void destroy(SocketDestination dest,
                    SocketAndStreams sands)
             throws java.lang.Exception
Close the socket

Specified by:
destroy in interface ResourceFactory<SocketDestination,SocketAndStreams>
Parameters:
dest - The key of the resource
sands - The resource
Throws:
java.lang.Exception

create

public SocketAndStreams create(SocketDestination dest)
                        throws java.lang.Exception
Create a socket for the given host/port

Specified by:
create in interface ResourceFactory<SocketDestination,SocketAndStreams>
Parameters:
dest - The key
Returns:
The created resource
Throws:
java.lang.Exception

validate

public boolean validate(SocketDestination dest,
                        SocketAndStreams sands)
Description copied from interface: ResourceFactory
Check that the given resource is valid. This is called once on every checkout, so that the checked out resource is guaranteed to be valid (though it could immediately become invalid).

Specified by:
validate in interface ResourceFactory<SocketDestination,SocketAndStreams>
Parameters:
dest - The key of the resource
sands - The resource
Returns:
True iff the resource is valid

getTimeout

public int getTimeout()

getNumberCreated

public int getNumberCreated()

getNumberDestroyed

public int getNumberDestroyed()

close

public void close()
Specified by:
close in interface ResourceFactory<SocketDestination,SocketAndStreams>

setLastClosedTimestamp

public void setLastClosedTimestamp(SocketDestination socketDestination)
Assigns the last closed timestamp based on the current time in nanoseconds.

This value starts off as 0 and is updated via this method each time the node is marked as unavailable.



Jay Kreps, Roshan Sumbaly, Alex Feinberg, Bhupesh Bansal, Lei Gao, Chinmay Soman, Vinoth Chandar, Zhongjie Wu