public class ServiceDispatcher extends StoppableThread
| Modifier and Type | Class and Description |
|---|---|
static class |
ServiceDispatcher.ExecutingRunnable |
static class |
ServiceDispatcher.ExecutingService
A service that is run immediately in a thread allocated to it.
|
class |
ServiceDispatcher.LazyQueuingService
A queuing service that starts the thread that services the requests
lazily, upon first request and terminates the thread when the service is
unregistered.
|
class |
ServiceDispatcher.QueuingService
A service where requests are simply added to the supplied queue.
|
static class |
ServiceDispatcher.Response
The response to a service request.
|
static class |
ServiceDispatcher.ServiceConnectFailedException |
Thread.State, Thread.UncaughtExceptionHandlerenvImplMAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY| Constructor and Description |
|---|
ServiceDispatcher(InetSocketAddress socketAddress,
DataChannelFactory channelFactory)
Convenience overloading for when the dispatcher is created without a
replicated environment, e.g.
|
ServiceDispatcher(InetSocketAddress socketAddress,
RepImpl repImpl,
DataChannelFactory channelFactory)
Create a ServiceDispatcher listening on a specific socket for service
requests.
|
| Modifier and Type | Method and Description |
|---|---|
void |
cancel(String serviceName)
Cancels the registration of a service.
|
static void |
doServiceHandshake(DataChannel channel,
String serviceName)
Used by the client to set up a channel for the service.
|
static void |
doServiceHandshake(DataChannel channel,
String serviceName,
ServiceHandshake.AuthenticationMethod[] authInfo)
A variation on the method above.
|
DataChannelFactory |
getChannelFactory() |
protected Logger |
getLogger() |
InetSocketAddress |
getSocketAddress()
Returns the specific socket address associated with the dispatcher.
|
InetAddress |
getSocketBoundAddress()
For testing only.
|
protected int |
initiateSoftShutdown()
Threads that use shutdownThread() must define this method.
|
boolean |
isRegistered(String serviceName) |
void |
preShutdown()
Stop accepting new connections, while the individual services quiesce
and shut themselves down.
|
void |
register(com.sleepycat.je.rep.utilint.ServiceDispatcher.Service service) |
void |
register(String serviceName,
BlockingQueue<DataChannel> serviceQueue)
Registers a service queue with the ServiceDispatcher.
|
void |
run()
The central run method.
|
void |
setSimulateIOException(String serviceName,
boolean simulateException) |
void |
shutdown()
Shuts down the dispatcher, so that it's no longer listening for service
requests.
|
DataChannel |
takeChannel(String serviceName,
int soTimeout)
Returns the next socketChannel created in response to a request for the
service.
|
cleanup, getSavedShutdownException, getTotalCpuTime, getTotalUserTime, handleUncaughtException, isShutdown, saveShutdownException, shutdownDone, shutdownThreadactiveCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yieldpublic ServiceDispatcher(InetSocketAddress socketAddress, RepImpl repImpl, DataChannelFactory channelFactory) throws IOException
socketAddress - the socket on which it listens for service
requests. This address may be extended to cover all local addresses, if
RepParams.BIND_INADDR_ANY has been set to true.IOException - if the socket could not be bound.public ServiceDispatcher(InetSocketAddress socketAddress, DataChannelFactory channelFactory) throws IOException
IOExceptionServiceDispatcher(InetSocketAddress, RepImpl, DataChannelFactory)public void preShutdown()
public void shutdown()
protected int initiateSoftShutdown()
StoppableThreadinitiateSoftShutdown in class StoppableThreadprotected Logger getLogger()
getLogger in class StoppableThreadStoppableThread.getLogger()public static void doServiceHandshake(DataChannel channel, String serviceName) throws IOException, ServiceDispatcher.ServiceConnectFailedException
channel - the channel that is the basis for the serviceserviceName - the service running on the channelIOException - if the output stream could not be establishedServiceDispatcher.ServiceConnectFailedException - if the connection could not be
made.public static void doServiceHandshake(DataChannel channel, String serviceName, ServiceHandshake.AuthenticationMethod[] authInfo) throws IOException, ServiceDispatcher.ServiceConnectFailedException
channel - the channel that is the basis for the serviceserviceName - the service running on the channelauthInfo - a list of authentication methods supported by the
caller.ServiceDispatcher.ServiceConnectFailedException - if the connection could not be
made.IOExceptionpublic DataChannel takeChannel(String serviceName, int soTimeout) throws InterruptedException
serviceName - the service for which the channel must be created.soTimeout - the timeout for the underlying socketInterruptedExceptionpublic InetSocketAddress getSocketAddress()
RepParams.BIND_INADDR_ANY has been set to true, this is one
of the addresses that the socket is associated with.getSocketBoundAddress()public InetAddress getSocketBoundAddress()
RepParams.BIND_INADDR_ANY has been set to true.public void register(String serviceName, BlockingQueue<DataChannel> serviceQueue)
serviceName - the name of the service being requestedserviceQueue - the queue that will be used to hold channels
established for the service.public void register(com.sleepycat.je.rep.utilint.ServiceDispatcher.Service service)
public boolean isRegistered(String serviceName)
public void setSimulateIOException(String serviceName, boolean simulateException)
public void cancel(String serviceName)
serviceName - the name of the service being cancelledpublic DataChannelFactory getChannelFactory()
public void run()
Copyright © 2024. All rights reserved.