voldemort.utils.pool
Interface ResourceFactory<K,V>

All Known Implementing Classes:
ClientRequestExecutorFactory, SocketResourceFactory

public interface ResourceFactory<K,V>

Basic interface for poolable Object Factory


Method Summary
 void close()
           
 V create(K key)
          Create the given resource for the key.
 void destroy(K key, V obj)
          Destroy the given resource.
 boolean validate(K key, V value)
          Check that the given resource is valid.
 

Method Detail

create

V create(K key)
         throws java.lang.Exception
Create the given resource for the key. This is called once for each resource to create it.

Parameters:
key - The key
Returns:
The created resource
Throws:
java.lang.Exception

destroy

void destroy(K key,
             V obj)
             throws java.lang.Exception
Destroy the given resource. This is called only when validate() returns false for the resource or the pool is closed.

Parameters:
key - The key of the resource
obj - The resource
Throws:
java.lang.Exception

validate

boolean validate(K key,
                 V value)
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).

Parameters:
key - The key of the resource
value - The resource
Returns:
True iff the resource is valid

close

void close()


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