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

public class JdbcUserServiceAuditor extends JdbcNodeServiceAuditor implements UserServiceAuditor
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".

  • Field Details

    • DEFAULT_USER_SERVICE_INCREMENT_SQL

      public static final String DEFAULT_USER_SERVICE_INCREMENT_SQL
      The default value for the nodeServiceIncrementSql property.
      See Also:
  • Constructor Details

    • JdbcUserServiceAuditor

      public JdbcUserServiceAuditor(DataSource dataSource)
      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 DataSource
      userServiceCounters - the node source counters map
      clock - the clock to use
      Throws:
      IllegalArgumentException - if any argument is null
  • Method Details

    • auditUserService

      public void auditUserService(Long userId, String service, int count)
      Description copied from interface: UserServiceAuditor
      Audit a service for a user.
      Specified by:
      auditUserService in interface UserServiceAuditor
      Parameters:
      userId - the user ID
      service - the service name
      count - the amount to add