Class JdbcUserServiceAuditor
java.lang.Object
net.solarnetwork.central.common.dao.jdbc.JdbcNodeServiceAuditor
net.solarnetwork.central.common.dao.jdbc.JdbcUserServiceAuditor
- All Implemented Interfaces:
NodeServiceAuditor,UserServiceAuditor,net.solarnetwork.service.PingTest,net.solarnetwork.service.ServiceLifecycleObserver
JDBC based implementation of
UserServiceAuditor.
This service coalesces updates per user/service/hour in memory and flushes these to the database via a single "writer" thread after a small delay. This design is meant to support better throughput of audit updates, but has the potential to drop some count values if the service is restarted.
The fact that this implementation extends JdbcNodeServiceAuditor is a
convenience only. All references to "nodes" in this implementation can be
thought of as "users".
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.solarnetwork.service.PingTest
net.solarnetwork.service.PingTest.Result -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe default value for thenodeServiceIncrementSqlproperty.Fields inherited from class net.solarnetwork.central.common.dao.jdbc.JdbcNodeServiceAuditor
CALLABLE_STATEMENT_REGEX, DEFAULT_CONNECTION_RECOVERY_DELAY, DEFAULT_FLUSH_DELAY, DEFAULT_NODE_SERVICE_INCREMENT_SQL, DEFAULT_UPDATE_DELAY, log -
Constructor Summary
ConstructorsConstructorDescriptionJdbcUserServiceAuditor(DataSource dataSource) Constructor.JdbcUserServiceAuditor(DataSource dataSource, ConcurrentMap<net.solarnetwork.domain.datum.DatumId, AtomicInteger> userServiceCounters, Clock clock, net.solarnetwork.util.StatTracker statCounter) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidauditUserService(Long userId, String service, int count) Audit a service for a user.Methods inherited from class net.solarnetwork.central.common.dao.jdbc.JdbcNodeServiceAuditor
auditNodeService, disableWriting, enableWriting, getAuditClock, getPingTestId, getPingTestMaximumExecutionMilliseconds, getPingTestName, performPingTest, reconnectWriter, serviceDidShutdown, serviceDidStartup, setConnectionRecoveryDelay, setFlushDelay, setNodeServiceIncrementSql, setStatLogUpdateCount, setUpdateDelayMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.solarnetwork.central.biz.UserServiceAuditor
getAuditClock
-
Field Details
-
DEFAULT_USER_SERVICE_INCREMENT_SQL
The default value for thenodeServiceIncrementSqlproperty.- See Also:
-
-
Constructor Details
-
JdbcUserServiceAuditor
Constructor.- Parameters:
dataSource- the JDBC DataSource- Throws:
IllegalArgumentException- if any argument is null
-
JdbcUserServiceAuditor
public JdbcUserServiceAuditor(DataSource dataSource, ConcurrentMap<net.solarnetwork.domain.datum.DatumId, AtomicInteger> userServiceCounters, Clock clock, net.solarnetwork.util.StatTracker statCounter) Constructor.- Parameters:
dataSource- the JDBC DataSourceuserServiceCounters- the node source counters mapclock- the clock to use- Throws:
IllegalArgumentException- if any argument is null
-
-
Method Details
-
auditUserService
Description copied from interface:UserServiceAuditorAudit a service for a user.- Specified by:
auditUserServicein interfaceUserServiceAuditor- Parameters:
userId- the user IDservice- the service namecount- the amount to add
-