org.jminor.framework.server
Class EntityConnectionServerAdminImpl

java.lang.Object
  extended by java.rmi.server.RemoteObject
      extended by java.rmi.server.RemoteServer
          extended by java.rmi.server.UnicastRemoteObject
              extended by org.jminor.framework.server.EntityConnectionServerAdminImpl
All Implemented Interfaces:
Serializable, Remote, EntityConnectionServerAdmin

public final class EntityConnectionServerAdminImpl
extends UnicastRemoteObject
implements EntityConnectionServerAdmin

Implements the RemoteEntityServerAdmin interface, providing admin access to a RemoteEntityServer instance.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
EntityConnectionServerAdminImpl(org.jminor.framework.server.EntityConnectionServer server, boolean sslEnabled)
          Instantiates a new RemoteEntityServerAdminImpl
 
Method Summary
 void disconnect(UUID clientID)
          Unregisters the connection from the server, if connection pooling is enabled for the user the connection is pooled.
 int getActiveConnectionCount()
          
 long getAllocatedMemory()
          
 Collection<ClientInfo> getClients()
          
 Collection<ClientInfo> getClients(String clientTypeID)
          
 Collection<ClientInfo> getClients(User user)
          
 Collection<String> getClientTypes()
          
 int getConnectionCount()
          
 int getConnectionLimit()
          
 int getConnectionPoolCleanupInterval(User user)
          
 ConnectionPoolStatistics getConnectionPoolStatistics(User user, long since)
          
 int getConnectionTimeout()
          Returns the connection timeout in ms
 Database.Statistics getDatabaseStatistics()
          
 String getDatabaseURL()
          
 List<User> getEnabledConnectionPools()
          
 Map<String,String> getEntityDefinitions()
          
 ch.qos.logback.classic.Level getLoggingLevel()
          
 int getMaintenanceInterval()
          
 int getMaximumConnectionPoolSize(User user)
          
 int getMaximumPoolCheckOutTime(User user)
          
 int getMaximumPoolRetryWaitPeriod(User user)
          
 long getMaxMemory()
          
 String getMemoryUsage()
          
 int getMinimumConnectionPoolSize(User user)
          
 int getPoolConnectionThreshold(User user)
          
 int getPooledConnectionTimeout(User user)
          
 int getRequestsPerSecond()
          
 int getServerDbPort()
          
 ServerLog getServerLog(UUID clientID)
          
 String getServerName()
          
 int getServerPort()
          
 long getStartDate()
          
 String getSystemProperties()
          
 long getUsedMemory()
          
 Collection<User> getUsers()
          
 int getWarningTimeExceededPerSecond()
          
 int getWarningTimeThreshold()
          
 boolean isCollectFineGrainedPoolStatistics(User user)
          
 boolean isConnectionPoolEnabled(User user)
          
 boolean isLoggingOn(UUID clientID)
          Returns true if logging is enabled for the given connection
 void loadDomainModel(URI location, String domainClassName)
          Loads the domain model found int he given class, at the given location
static void main(String[] arguments)
          Runs a new RemoteEntityServer with a server admin interface exported.
 void performGC()
          Performs garbage collection
 void removeConnections(boolean inactiveOnly)
          Removes connections.
 void resetConnectionPoolStatistics(User user)
          Resets the statistics that have been collected so far
 void setCollectFineGrainedPoolStatistics(User user, boolean value)
          
 void setConnectionLimit(int value)
          
 void setConnectionPoolCleanupInterval(User user, int poolCleanupInterval)
          
 void setConnectionPoolEnabled(User user, boolean enabled)
          
 void setConnectionTimeout(int timeout)
          Sets the connection timeout in ms
 void setLoggingLevel(ch.qos.logback.classic.Level level)
          
 void setLoggingOn(UUID clientID, boolean status)
          Sets the logging status for the given connection
 void setMaintenanceInterval(int interval)
          
 void setMaximumConnectionPoolSize(User user, int value)
          
 void setMaximumPoolCheckOutTime(User user, int value)
          
 void setMaximumPoolRetryWaitPeriod(User user, int value)
          
 void setMinimumConnectionPoolSize(User user, int value)
          
 void setPoolConnectionThreshold(User user, int value)
          
 void setPooledConnectionTimeout(User user, int timeout)
          
 void setWarningTimeThreshold(int threshold)
          
 void shutdown()
          Shuts down the server
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EntityConnectionServerAdminImpl

public EntityConnectionServerAdminImpl(org.jminor.framework.server.EntityConnectionServer server,
                                       boolean sslEnabled)
                                throws RemoteException
Instantiates a new RemoteEntityServerAdminImpl

Parameters:
server - the server to administer
sslEnabled - true if the server is using SSL connection encryption
Throws:
RemoteException - in case of an exception
Method Detail

getServerName

public String getServerName()

Specified by:
getServerName in interface EntityConnectionServerAdmin
Returns:
the server name

getServerPort

public int getServerPort()
                  throws RemoteException

Specified by:
getServerPort in interface EntityConnectionServerAdmin
Returns:
the server port
Throws:
RemoteException - in case of a communication error

getSystemProperties

public String getSystemProperties()

Specified by:
getSystemProperties in interface EntityConnectionServerAdmin
Returns:
the server system properties

getServerDbPort

public int getServerDbPort()
                    throws RemoteException

Specified by:
getServerDbPort in interface EntityConnectionServerAdmin
Returns:
the port on which db connections are created
Throws:
RemoteException - in case of a communication error

getStartDate

public long getStartDate()

Specified by:
getStartDate in interface EntityConnectionServerAdmin
Returns:
the server startup date

getDatabaseURL

public String getDatabaseURL()

Specified by:
getDatabaseURL in interface EntityConnectionServerAdmin
Returns:
the database URL

getLoggingLevel

public ch.qos.logback.classic.Level getLoggingLevel()
                                             throws RemoteException

Specified by:
getLoggingLevel in interface EntityConnectionServerAdmin
Returns:
the server logging level
Throws:
RemoteException - in case of a communication error

setLoggingLevel

public void setLoggingLevel(ch.qos.logback.classic.Level level)
                     throws RemoteException

Specified by:
setLoggingLevel in interface EntityConnectionServerAdmin
Parameters:
level - the logging level
Throws:
RemoteException - in case of a communication error

getUsers

public Collection<User> getUsers()
                          throws RemoteException

Specified by:
getUsers in interface EntityConnectionServerAdmin
Returns:
the users currently connected to the server
Throws:
RemoteException - in case of a communication error

getClients

public Collection<ClientInfo> getClients(User user)
                                  throws RemoteException

Specified by:
getClients in interface EntityConnectionServerAdmin
Parameters:
user - the user for which to retrieve the client infos
Returns:
the connection keys associated with the given user
Throws:
RemoteException - in case of a communication error

getClients

public Collection<ClientInfo> getClients(String clientTypeID)
                                  throws RemoteException

Specified by:
getClients in interface EntityConnectionServerAdmin
Parameters:
clientTypeID - the client type for which to retrieve the client infos
Returns:
the connection keys associated with the given user
Throws:
RemoteException - in case of a communication error

getClients

public Collection<ClientInfo> getClients()
                                  throws RemoteException

Specified by:
getClients in interface EntityConnectionServerAdmin
Returns:
the info on all clients connected to the server
Throws:
RemoteException - in case of a communication error

getClientTypes

public Collection<String> getClientTypes()
                                  throws RemoteException

Specified by:
getClientTypes in interface EntityConnectionServerAdmin
Returns:
the identifiers of the client types connected to the server
Throws:
RemoteException - in case of an exception

disconnect

public void disconnect(UUID clientID)
                throws RemoteException
Unregisters the connection from the server, if connection pooling is enabled for the user the connection is pooled.

Specified by:
disconnect in interface EntityConnectionServerAdmin
Parameters:
clientID - the ID of the client
Throws:
RemoteException - in case of a communication error

shutdown

public void shutdown()
              throws RemoteException
Shuts down the server

Specified by:
shutdown in interface EntityConnectionServerAdmin
Throws:
RemoteException - in case of a communication error

getActiveConnectionCount

public int getActiveConnectionCount()
                             throws RemoteException

Specified by:
getActiveConnectionCount in interface EntityConnectionServerAdmin
Returns:
the number of active connections
Throws:
RemoteException - in case of a communication error

getMaintenanceInterval

public int getMaintenanceInterval()

Specified by:
getMaintenanceInterval in interface EntityConnectionServerAdmin
Returns:
the number of ms that should pass between maintenance cycles, that is, when inactive clients are purged

setMaintenanceInterval

public void setMaintenanceInterval(int interval)

Specified by:
setMaintenanceInterval in interface EntityConnectionServerAdmin
Parameters:
interval - the number of ms that should pass between maintenance cycles, that is, when inactive clients are purged

removeConnections

public void removeConnections(boolean inactiveOnly)
                       throws RemoteException
Removes connections.

Specified by:
removeConnections in interface EntityConnectionServerAdmin
Parameters:
inactiveOnly - if true, only inactive connections are removed
Throws:
RemoteException - in case of an exception

resetConnectionPoolStatistics

public void resetConnectionPoolStatistics(User user)
                                   throws RemoteException
Resets the statistics that have been collected so far

Specified by:
resetConnectionPoolStatistics in interface EntityConnectionServerAdmin
Parameters:
user - the pool user
Throws:
RemoteException - in case of an exception

isCollectFineGrainedPoolStatistics

public boolean isCollectFineGrainedPoolStatistics(User user)
                                           throws RemoteException

Specified by:
isCollectFineGrainedPoolStatistics in interface EntityConnectionServerAdmin
Parameters:
user - the pool user
Returns:
true if fine grained statistics should be collected for the given connection pool
Throws:
RemoteException - in case of an exception

setCollectFineGrainedPoolStatistics

public void setCollectFineGrainedPoolStatistics(User user,
                                                boolean value)
                                         throws RemoteException

Specified by:
setCollectFineGrainedPoolStatistics in interface EntityConnectionServerAdmin
Parameters:
user - the pool user
value - true if fine grained statistics should be collected for the given connection pool
Throws:
RemoteException - in case of an exception

getRequestsPerSecond

public int getRequestsPerSecond()
                         throws RemoteException

Specified by:
getRequestsPerSecond in interface EntityConnectionServerAdmin
Returns:
the number of service requests per second
Throws:
RemoteException - in case of an exception

getWarningTimeThreshold

public int getWarningTimeThreshold()
                            throws RemoteException

Specified by:
getWarningTimeThreshold in interface EntityConnectionServerAdmin
Returns:
the request warning time threshold in ms
Throws:
RemoteException - in case of an exception

setWarningTimeThreshold

public void setWarningTimeThreshold(int threshold)
                             throws RemoteException

Specified by:
setWarningTimeThreshold in interface EntityConnectionServerAdmin
Parameters:
threshold - the request warning time threshold in ms
Throws:
RemoteException - in case of an exception

getWarningTimeExceededPerSecond

public int getWarningTimeExceededPerSecond()
                                    throws RemoteException

Specified by:
getWarningTimeExceededPerSecond in interface EntityConnectionServerAdmin
Returns:
the number of service requests exceeding the warning time
Throws:
RemoteException - in case of an exception
See Also:
EntityConnectionServerAdmin.setWarningTimeThreshold(int)

getConnectionPoolStatistics

public ConnectionPoolStatistics getConnectionPoolStatistics(User user,
                                                            long since)
                                                     throws RemoteException

Specified by:
getConnectionPoolStatistics in interface EntityConnectionServerAdmin
Parameters:
user - the pool user
since - the time since from which to retrieve pool statistics
Returns:
the pool statistics
Throws:
RemoteException - in case of an exception

getDatabaseStatistics

public Database.Statistics getDatabaseStatistics()
                                          throws RemoteException

Specified by:
getDatabaseStatistics in interface EntityConnectionServerAdmin
Returns:
usage statistics for the underlying database
Throws:
RemoteException - in case of an exception

getEnabledConnectionPools

public List<User> getEnabledConnectionPools()
                                     throws RemoteException

Specified by:
getEnabledConnectionPools in interface EntityConnectionServerAdmin
Returns:
a list of the usernames behind the active connection pools
Throws:
RemoteException - in case of an exception

isConnectionPoolEnabled

public boolean isConnectionPoolEnabled(User user)
                                throws RemoteException

Specified by:
isConnectionPoolEnabled in interface EntityConnectionServerAdmin
Parameters:
user - the pool user
Returns:
the pool enabled status
Throws:
RemoteException - in case of an exception

setConnectionPoolCleanupInterval

public void setConnectionPoolCleanupInterval(User user,
                                             int poolCleanupInterval)
                                      throws RemoteException

Specified by:
setConnectionPoolCleanupInterval in interface EntityConnectionServerAdmin
Parameters:
user - the pool user
poolCleanupInterval - the pool cleanup interval in ms
Throws:
RemoteException - in case of an exception

setConnectionPoolEnabled

public void setConnectionPoolEnabled(User user,
                                     boolean enabled)
                              throws RemoteException

Specified by:
setConnectionPoolEnabled in interface EntityConnectionServerAdmin
Parameters:
user - the pool user
enabled - the pool enabled status
Throws:
RemoteException - in case of an exception

getConnectionPoolCleanupInterval

public int getConnectionPoolCleanupInterval(User user)
                                     throws RemoteException

Specified by:
getConnectionPoolCleanupInterval in interface EntityConnectionServerAdmin
Parameters:
user - the pool user
Returns:
the pool cleanup interval in ms
Throws:
RemoteException - in case of an exception

getMaximumConnectionPoolSize

public int getMaximumConnectionPoolSize(User user)
                                 throws RemoteException

Specified by:
getMaximumConnectionPoolSize in interface EntityConnectionServerAdmin
Parameters:
user - the pool user
Returns:
the maximum connection pool size
Throws:
RemoteException - in case of an exception

getMinimumConnectionPoolSize

public int getMinimumConnectionPoolSize(User user)
                                 throws RemoteException

Specified by:
getMinimumConnectionPoolSize in interface EntityConnectionServerAdmin
Parameters:
user - the pool user
Returns:
the minimum connection pool size
Throws:
RemoteException - in case of an exception

getPooledConnectionTimeout

public int getPooledConnectionTimeout(User user)
                               throws RemoteException

Specified by:
getPooledConnectionTimeout in interface EntityConnectionServerAdmin
Parameters:
user - the pool user
Returns:
the pooled connection timeout in ms
Throws:
RemoteException - in case of an exception

setMaximumConnectionPoolSize

public void setMaximumConnectionPoolSize(User user,
                                         int value)
                                  throws RemoteException

Specified by:
setMaximumConnectionPoolSize in interface EntityConnectionServerAdmin
Parameters:
user - the pool user
value - the maximum connection pool size
Throws:
RemoteException - in case of an exception

setMinimumConnectionPoolSize

public void setMinimumConnectionPoolSize(User user,
                                         int value)
                                  throws RemoteException

Specified by:
setMinimumConnectionPoolSize in interface EntityConnectionServerAdmin
Parameters:
user - the pool user
value - the minimum connection pool size
Throws:
RemoteException - in case of an exception

getPoolConnectionThreshold

public int getPoolConnectionThreshold(User user)
                               throws RemoteException

Specified by:
getPoolConnectionThreshold in interface EntityConnectionServerAdmin
Throws:
RemoteException

setPoolConnectionThreshold

public void setPoolConnectionThreshold(User user,
                                       int value)
                                throws RemoteException

Specified by:
setPoolConnectionThreshold in interface EntityConnectionServerAdmin
Throws:
RemoteException

setPooledConnectionTimeout

public void setPooledConnectionTimeout(User user,
                                       int timeout)
                                throws RemoteException

Specified by:
setPooledConnectionTimeout in interface EntityConnectionServerAdmin
Parameters:
user - the pool user
timeout - the pooled connection timeout in ms
Throws:
RemoteException - in case of an exception

getMaximumPoolRetryWaitPeriod

public int getMaximumPoolRetryWaitPeriod(User user)
                                  throws RemoteException

Specified by:
getMaximumPoolRetryWaitPeriod in interface EntityConnectionServerAdmin
Parameters:
user - the pool user
Returns:
the maximum time to wait between check out retries in ms
Throws:
RemoteException - in case of an exception

setMaximumPoolRetryWaitPeriod

public void setMaximumPoolRetryWaitPeriod(User user,
                                          int value)
                                   throws RemoteException

Specified by:
setMaximumPoolRetryWaitPeriod in interface EntityConnectionServerAdmin
Parameters:
user - the pool user
value - the maximum time to wait between check out retries in ms
Throws:
RemoteException - in case of an exception

getMaximumPoolCheckOutTime

public int getMaximumPoolCheckOutTime(User user)
                               throws RemoteException

Specified by:
getMaximumPoolCheckOutTime in interface EntityConnectionServerAdmin
Parameters:
user - the pool user
Returns:
the maximum time in ms to retry checking out a connection before throwing an exception
Throws:
RemoteException - in case of an exception

setMaximumPoolCheckOutTime

public void setMaximumPoolCheckOutTime(User user,
                                       int value)
                                throws RemoteException

Specified by:
setMaximumPoolCheckOutTime in interface EntityConnectionServerAdmin
Parameters:
user - the pool user
value - the maximum time in ms to retry checking out a connection before throwing an exception
Throws:
RemoteException - in case of an exception

getMemoryUsage

public String getMemoryUsage()
                      throws RemoteException

Specified by:
getMemoryUsage in interface EntityConnectionServerAdmin
Returns:
a string containing memory usage information
Throws:
RemoteException - in case of a communication error

getAllocatedMemory

public long getAllocatedMemory()
                        throws RemoteException

Specified by:
getAllocatedMemory in interface EntityConnectionServerAdmin
Returns:
the total amount of memory allocated by the server process
Throws:
RemoteException - in case of a communication error

getUsedMemory

public long getUsedMemory()
                   throws RemoteException

Specified by:
getUsedMemory in interface EntityConnectionServerAdmin
Returns:
the amount of memory being used by the server process
Throws:
RemoteException - in case of a communication error

getMaxMemory

public long getMaxMemory()
                  throws RemoteException

Specified by:
getMaxMemory in interface EntityConnectionServerAdmin
Returns:
the maximum amount of memory available to the server process
Throws:
RemoteException - in case of a communication error

performGC

public void performGC()
               throws RemoteException
Performs garbage collection

Specified by:
performGC in interface EntityConnectionServerAdmin
Throws:
RemoteException - in case of a communication error

getConnectionCount

public int getConnectionCount()

Specified by:
getConnectionCount in interface EntityConnectionServerAdmin
Returns:
the number of active connections

getConnectionLimit

public int getConnectionLimit()
                       throws RemoteException

Specified by:
getConnectionLimit in interface EntityConnectionServerAdmin
Returns:
the maximum number of concurrent connections this servers accepts
Throws:
RemoteException - in case of a communication error

setConnectionLimit

public void setConnectionLimit(int value)
                        throws RemoteException

Specified by:
setConnectionLimit in interface EntityConnectionServerAdmin
Parameters:
value - the maximum number of concurrent connections this servers accepts
Throws:
RemoteException - in case of a communication error

getServerLog

public ServerLog getServerLog(UUID clientID)

Specified by:
getServerLog in interface EntityConnectionServerAdmin
Parameters:
clientID - the ID of the client for which to retrieve the log
Returns:
the log for the given connection

isLoggingOn

public boolean isLoggingOn(UUID clientID)
                    throws RemoteException
Returns true if logging is enabled for the given connection

Specified by:
isLoggingOn in interface EntityConnectionServerAdmin
Parameters:
clientID - the ID of the client
Returns:
true if logging is on for the given connection
Throws:
RemoteException - in case of a communication error

setLoggingOn

public void setLoggingOn(UUID clientID,
                         boolean status)
Sets the logging status for the given connection

Specified by:
setLoggingOn in interface EntityConnectionServerAdmin
Parameters:
clientID - the ID of the client
status - the new logging status

getConnectionTimeout

public int getConnectionTimeout()
                         throws RemoteException
Returns the connection timeout in ms

Specified by:
getConnectionTimeout in interface EntityConnectionServerAdmin
Returns:
the connection timeout in ms
Throws:
RemoteException - in case of a communication error

setConnectionTimeout

public void setConnectionTimeout(int timeout)
                          throws RemoteException
Sets the connection timeout in ms

Specified by:
setConnectionTimeout in interface EntityConnectionServerAdmin
Parameters:
timeout - the timeout in ms
Throws:
RemoteException - in case of a communication error

loadDomainModel

public void loadDomainModel(URI location,
                            String domainClassName)
                     throws RemoteException,
                            ClassNotFoundException,
                            IllegalAccessException
Loads the domain model found int he given class, at the given location

Specified by:
loadDomainModel in interface EntityConnectionServerAdmin
Parameters:
location - the classpath URI
domainClassName - the domain class name
Throws:
RemoteException - in case of an exception
ClassNotFoundException - in case the domain class in not found
IllegalAccessException - in case the class loader access is denied

getEntityDefinitions

public Map<String,String> getEntityDefinitions()
                                        throws RemoteException

Specified by:
getEntityDefinitions in interface EntityConnectionServerAdmin
Returns:
a map containing all entityIDs, with their respective table names as an associated value
Throws:
RemoteException - in case of an exception

main

public static void main(String[] arguments)
                 throws RemoteException
Runs a new RemoteEntityServer with a server admin interface exported.

Parameters:
arguments - no arguments required
Throws:
RemoteException - in case of a remote exception during service export