Class GrizzlyService
- java.lang.Object
-
- com.sun.enterprise.v3.services.impl.GrizzlyService
-
- All Implemented Interfaces:
fish.payara.monitoring.collect.MonitoringDataSource
,RequestDispatcher
,EventListener
,FutureProvider<Result<Thread>>
,org.glassfish.hk2.api.PostConstruct
,org.glassfish.hk2.api.PreDestroy
@Service @RunLevel(10) @Rank(50) public class GrizzlyService extends Object implements RequestDispatcher, org.glassfish.hk2.api.PostConstruct, org.glassfish.hk2.api.PreDestroy, EventListener, FutureProvider<Result<Thread>>, fish.payara.monitoring.collect.MonitoringDataSource
The Network Service is responsible for starting grizzly and register the top level proxy. It is also providing a runtime service where other services (like admin for instance) can register endpoints proxy to particular context root.- Author:
- Jerome Dochez
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GrizzlyService.NoopInvocationHandler
Probe provider that implements each probe provider method as a no-op.-
Nested classes/interfaces inherited from interface org.glassfish.api.event.EventListener
EventListener.Event<T>
-
-
Constructor Summary
Constructors Constructor Description GrizzlyService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addMapperUpdateListener(MapperUpdateListener listener)
AddsMapperUpdateListener
to listeners queue.void
addNetworkProxy(NetworkProxy proxy)
Add the new proxy to our list of proxies.boolean
closeNetworkProxy(NetworkProxy proxy)
void
collect(fish.payara.monitoring.collect.MonitoringDataCollector collector)
Future<Result<Thread>>
createNetworkProxy(NetworkListener listener)
void
event(EventListener.Event event)
Method is invoked each time Glassfish state changes.List<Future<Result<Thread>>>
getFutures()
org.glassfish.hk2.api.ServiceLocator
getHabitat()
Gets the habitat.Logger
getLogger()
Gets the logger.GrizzlyMonitoring
getMonitoring()
int
getRealPort(NetworkListener listener)
boolean
hasMapperUpdateListener()
Is there anyMapperUpdateListener
registered?NetworkProxy
lookupNetworkProxy(NetworkListener listener)
LookupGrizzlyProxy
, which corresponds to theNetworkListener
.void
notifyMapperUpdateListeners(NetworkListener networkListener, org.glassfish.grizzly.http.server.util.Mapper mapper)
Notify allMapperUpdateListener
s about update happened.ReentrantReadWriteLock
obtainMapperLock()
Returns HTTPMapper
lock to prevent concurrent access to aMapper
object.void
postConstruct()
The component has been injected with any dependency and will be placed into commission by the subsystem.void
preDestroy()
The component is about to be removed from commissionvoid
registerEndpoint(Endpoint endpoint)
Registers a new endpoint for the given context root at the given port number.void
registerEndpoint(String contextRoot, InetAddress address, int port, Collection<String> vsServers, org.glassfish.grizzly.http.server.HttpHandler endpointAdapter, ApplicationContainer container)
Registers a new endpoint for the given context root at the given port number.void
registerEndpoint(String contextRoot, Collection<String> vsServers, org.glassfish.grizzly.http.server.HttpHandler endpointAdapter, ApplicationContainer container)
Registers a new endpoint (proxy implementation) for a particular context-root.void
registerEndpoint(String contextRoot, org.glassfish.grizzly.http.server.HttpHandler endpointAdapter, ApplicationContainer container)
Registers a new endpoint (proxy implementation) for a particular context-root.void
registerEndpoint(String contextRoot, org.glassfish.grizzly.http.server.HttpHandler endpointAdapter, ApplicationContainer container, String virtualServers)
Registers a new endpoint (proxy implementation) for a particular context-root.protected void
registerMonitoringStatsProviders()
boolean
removeMapperUpdateListener(MapperUpdateListener listener)
RemovesMapperUpdateListener
to listeners queue.boolean
removeNetworkProxy(NetworkProxy proxy)
Remove the proxy from our list of proxies.boolean
removeNetworkProxy(String id)
Remove the proxy from our list of proxies by id.boolean
removeNetworkProxy(NetworkListener listener)
Remove the proxy from our list of proxies by listener.void
restartNetworkListener(String networkListenerName, long timeout, TimeUnit timeUnit)
RestartNetworkListener
.void
restartNetworkListener(NetworkListener networkListener, long timeout, TimeUnit timeUnit)
RestartNetworkListener
.void
unregisterEndpoint(String contextRoot)
Removes the context-root from our list of endpoints.void
unregisterEndpoint(String contextRoot, ApplicationContainer app)
Removes the context-root from our list of endpoints.protected void
unregisterMonitoringStatsProviders()
-
-
-
Method Detail
-
collect
public void collect(fish.payara.monitoring.collect.MonitoringDataCollector collector)
- Specified by:
collect
in interfacefish.payara.monitoring.collect.MonitoringDataSource
-
addNetworkProxy
public void addNetworkProxy(NetworkProxy proxy)
Add the new proxy to our list of proxies.- Parameters:
proxy
- new proxy to be added
-
removeNetworkProxy
public boolean removeNetworkProxy(NetworkListener listener)
Remove the proxy from our list of proxies by listener.- Parameters:
listener
- removes the proxy associated with the specified listener- Returns:
- true, if proxy removed, false if no proxy was associated with the specified listener.
-
removeNetworkProxy
public boolean removeNetworkProxy(String id)
Remove the proxy from our list of proxies by id.- Returns:
- true, if proxy on specified port was removed, false if no proxy was associated with the port.
-
closeNetworkProxy
public boolean closeNetworkProxy(NetworkProxy proxy)
-
removeNetworkProxy
public boolean removeNetworkProxy(NetworkProxy proxy)
Remove the proxy from our list of proxies.- Returns:
- true, if proxy on specified port was removed, false otherwise.
-
lookupNetworkProxy
public NetworkProxy lookupNetworkProxy(NetworkListener listener)
LookupGrizzlyProxy
, which corresponds to theNetworkListener
.- Parameters:
listener
-NetworkListener
.- Returns:
GrizzlyProxy
, or null, if correspondentGrizzlyProxy
wasn't found.
-
restartNetworkListener
public void restartNetworkListener(String networkListenerName, long timeout, TimeUnit timeUnit) throws IOException, TimeoutException
RestartNetworkListener
.- Parameters:
networkListenerName
-timeout
- restart timeout, if timeout value is negative - then no timeout will be applied.timeUnit
- restart timeout unit- Throws:
TimeoutException
- thrown if timeout had expired before server succeeded to restartIOException
-
restartNetworkListener
public void restartNetworkListener(NetworkListener networkListener, long timeout, TimeUnit timeUnit) throws IOException, TimeoutException
RestartNetworkListener
.- Parameters:
networkListener
-NetworkListener
timeout
- restart timeout, if timeout value is negative - then no timeout will be applied.timeUnit
- restart timeout unit- Throws:
TimeoutException
- thrown if timeout had expired before server succeeded to restartIOException
-
hasMapperUpdateListener
public boolean hasMapperUpdateListener()
Is there anyMapperUpdateListener
registered?
-
addMapperUpdateListener
public boolean addMapperUpdateListener(MapperUpdateListener listener)
AddsMapperUpdateListener
to listeners queue.- Parameters:
listener
- the listener to be added.- Returns:
- true, if listener was successfully added, or false otherwise.
-
removeMapperUpdateListener
public boolean removeMapperUpdateListener(MapperUpdateListener listener)
RemovesMapperUpdateListener
to listeners queue.- Parameters:
listener
- the listener to be removed.- Returns:
- true, if listener was successfully removed, or false otherwise.
-
notifyMapperUpdateListeners
public void notifyMapperUpdateListeners(NetworkListener networkListener, org.glassfish.grizzly.http.server.util.Mapper mapper)
Notify allMapperUpdateListener
s about update happened.- Parameters:
networkListener
-NetworkListener
, whichMapper
got changedmapper
- newMapper
value
-
obtainMapperLock
public ReentrantReadWriteLock obtainMapperLock()
Returns HTTPMapper
lock to prevent concurrent access to aMapper
object.
-
getLogger
public Logger getLogger()
Gets the logger.- Returns:
- the logger
-
getHabitat
public org.glassfish.hk2.api.ServiceLocator getHabitat()
Gets the habitat.- Returns:
- the habitat
-
getMonitoring
public GrizzlyMonitoring getMonitoring()
-
event
public void event(EventListener.Event event)
Method is invoked each time Glassfish state changes.- Specified by:
event
in interfaceEventListener
-
postConstruct
public void postConstruct()
The component has been injected with any dependency and will be placed into commission by the subsystem.- Specified by:
postConstruct
in interfaceorg.glassfish.hk2.api.PostConstruct
-
getRealPort
public int getRealPort(NetworkListener listener)
-
getFutures
public List<Future<Result<Thread>>> getFutures()
- Specified by:
getFutures
in interfaceFutureProvider<Result<Thread>>
-
createNetworkProxy
public Future<Result<Thread>> createNetworkProxy(NetworkListener listener)
-
preDestroy
public void preDestroy()
The component is about to be removed from commission- Specified by:
preDestroy
in interfaceorg.glassfish.hk2.api.PreDestroy
-
registerEndpoint
public void registerEndpoint(String contextRoot, org.glassfish.grizzly.http.server.HttpHandler endpointAdapter, ApplicationContainer container) throws EndpointRegistrationException
Description copied from interface:RequestDispatcher
Registers a new endpoint (proxy implementation) for a particular context-root. All request coming with the context root will be dispatched to the proxy instance passed in.- Specified by:
registerEndpoint
in interfaceRequestDispatcher
- Parameters:
contextRoot
- for the proxyendpointAdapter
- servicing requests.- Throws:
EndpointRegistrationException
-
registerEndpoint
public void registerEndpoint(String contextRoot, org.glassfish.grizzly.http.server.HttpHandler endpointAdapter, ApplicationContainer container, String virtualServers) throws EndpointRegistrationException
Description copied from interface:RequestDispatcher
Registers a new endpoint (proxy implementation) for a particular context-root. All request coming with the context root will be dispatched to the proxy instance passed in.- Specified by:
registerEndpoint
in interfaceRequestDispatcher
- Parameters:
contextRoot
- for the proxyendpointAdapter
- servicing requests.virtualServers
- comma separated list of the virtual servers- Throws:
EndpointRegistrationException
-
registerEndpoint
public void registerEndpoint(String contextRoot, Collection<String> vsServers, org.glassfish.grizzly.http.server.HttpHandler endpointAdapter, ApplicationContainer container) throws EndpointRegistrationException
Description copied from interface:RequestDispatcher
Registers a new endpoint (proxy implementation) for a particular context-root. All request coming with the context root will be dispatched to the proxy instance passed in.- Specified by:
registerEndpoint
in interfaceRequestDispatcher
- Parameters:
contextRoot
- for the proxyendpointAdapter
- servicing requests.- Throws:
EndpointRegistrationException
-
registerEndpoint
public void registerEndpoint(String contextRoot, InetAddress address, int port, Collection<String> vsServers, org.glassfish.grizzly.http.server.HttpHandler endpointAdapter, ApplicationContainer container) throws EndpointRegistrationException
Registers a new endpoint for the given context root at the given port number.- Specified by:
registerEndpoint
in interfaceRequestDispatcher
- Throws:
EndpointRegistrationException
-
registerEndpoint
public void registerEndpoint(Endpoint endpoint) throws EndpointRegistrationException
Registers a new endpoint for the given context root at the given port number.- Throws:
EndpointRegistrationException
-
unregisterEndpoint
public void unregisterEndpoint(String contextRoot) throws EndpointRegistrationException
Removes the context-root from our list of endpoints.- Specified by:
unregisterEndpoint
in interfaceRequestDispatcher
- Throws:
EndpointRegistrationException
-
unregisterEndpoint
public void unregisterEndpoint(String contextRoot, ApplicationContainer app) throws EndpointRegistrationException
Removes the context-root from our list of endpoints.- Specified by:
unregisterEndpoint
in interfaceRequestDispatcher
- Throws:
EndpointRegistrationException
-
registerMonitoringStatsProviders
protected void registerMonitoringStatsProviders()
-
unregisterMonitoringStatsProviders
protected void unregisterMonitoringStatsProviders()
-
-