|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.bigdata.service.ResourceService
public abstract class ResourceService
A service which permits resources (managed files or buffers) identified by a
UUID to be read by a remote service. This class runs one thread to
accept connections and thread pool to send data.
ResourceService in the HA
branch. The NIO pieces of this class should be based on the work in the
HA branch on the write replication pipeline. The main structure of this
class is based on the ResourceService since it allows
concurrent connections, which the write pipeline does not support
(because it is designed specifically for a node to node streaming
replication protocol), however the class as originally implemented does
not allow us to keep connections open., Nodes should hold open connections for buffer transfers to avoid
overhead with establishing those connections and problems with
immediate reconnect under heavy load., Should have start() method to defer initialization of thread pools and
the ServerSocket until outside of the constructor. Either
handle visibility appropriately for those fields or move them and the
shutdown protocol into an inner class which is only initialized when
the service is running., Verify that multiple transfers may proceed in parallel to the from the
same source to the same receiver. This is important in order for low
latency queries to remain lively when we are moving a shard from one
node to another. This also suggests that we may want to have different
pools for servicing buffer requests for low latency queries versus
requests for high latency queries and shards., If we had an Adler32 native implementation then we could
checksum the nio ByteBuffers without copying the data into the
Java heap. The Adler32 implementation is based on zlib, which
is an acceptable license. So we might create a JNI component for that.
Also, there may be direct JNI calls available into the underlying zlib
library from Java.
This could be created in a fairly straightforward manner by bundling
zlib, bundling a Make file for our JNI components, and using
GetDirectByteBufferAddress to access the data on the C
heap. See JNI Spec, JNI FAQ,
and ZLib project., The change log for this class is as follows:
- hold open connections in order to avoid problems with socket reconnects;
- exchange buffers using NIO transfers rather than sending files using standard file IO and streams.
- done. make the counter updates thread safe using CATs.
- added generics to the base class used to fetch files or buffers.
- added a ResourceService.ResourceTypeEnum byte in the request protocol (breaks
compatibility for earlier versions of this service).
| Nested Class Summary | |
|---|---|
static class |
ResourceService.Counters
Performance counters for the ResourceService. |
static class |
ResourceService.FetchResourceTask<S,T>
Client for a BufferService reads a single resource from the
specified service, writing it into the local file system. |
static class |
ResourceService.ReadBufferTask
Class sends a request for a remote ByteBuffer and then receives
the data into a local ByteBuffer. |
static class |
ResourceService.ReadResourceTask
Task sends a request for a file's data and then receives the data onto a local file. |
static class |
ResourceService.ResourceTypeEnum
Type safe enumeration of the kinds of resources which can be served. |
static class |
ResourceService.StatusEnum
Known status codes. |
| Field Summary | |
|---|---|
ResourceService.Counters |
counters
Performance counters for this service. |
protected static org.apache.log4j.Logger |
log
|
| Constructor Summary | |
|---|---|
ResourceService(InetSocketAddress addr,
int requestServicePoolSize)
Create and start the service. |
|
| Method Summary | |
|---|---|
void |
awaitRunning(long timeout,
TimeUnit unit)
Wait until the service is running. |
protected void |
finalize()
Overridden to ensure that the service is always shutdown. |
InetSocketAddress |
getAddr()
Return the address at which this service is accepting connections. |
protected abstract ByteBuffer |
getBuffer(UUID uuid)
Return ByteBuffer identified by the UUID. |
protected abstract File |
getResource(UUID uuid)
Return file identified by the UUID. |
boolean |
isOpen()
|
void |
shutdown()
|
void |
shutdownNow()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final org.apache.log4j.Logger log
public final ResourceService.Counters counters
| Constructor Detail |
|---|
public ResourceService(InetSocketAddress addr,
int requestServicePoolSize)
throws IOException
addr - The IP address and port at which the service will accept
connections. The port MAY be zero to use an ephemeral port.requestServicePoolSize - The size of the thread pool that will handle requests. When
ZERO (0) a cached thread pool will be used with no specific
size limit.
IOException| Method Detail |
|---|
public InetSocketAddress getAddr()
protected void finalize()
throws Throwable
finalize in class ObjectThrowable
public void awaitRunning(long timeout,
TimeUnit unit)
throws InterruptedException,
TimeoutException
timeout - The timeout.unit - The unit for the timeout.
InterruptedException - if interrupted while waiting.
TimeoutException - if the timeout expired before the service was running.public boolean isOpen()
public void shutdown()
shutdown() and shutdownNow() methods and the
internal lock?public void shutdownNow()
protected abstract File getResource(UUID uuid)
throws Exception
UUID.
uuid -
null if there is no file associated
with that UUID.
Exception - if the resource may not be served.
protected abstract ByteBuffer getBuffer(UUID uuid)
throws Exception
ByteBuffer identified by the UUID.
uuid -
ByteBuffer -or- null if there is no
buffer associated with that UUID.
Exception - if the resource may not be served.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||