Skip to content

Commit

Permalink
#185 Added ScheduledCloudwatch to HostsListener
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosmiranda committed Jul 4, 2014
1 parent 79be026 commit bd4c8bd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,6 @@
* @author Yegor Bugayenko ([email protected])
* @version $Id$
* @since 0.0.1
* @todo #173 Due to the large cost of having very many small CloudWatch
* requests, we changed the implementation of DefaultResource so that it now
* retains information to a local H2 database instead of directly making
* CloudWatch API requests. However, we still don't have a way to post it to
* CloudWatch. Let's create a way to do this, such as a cron job that runs
* every hour. It should post aggregated traffic metrics to Amazon CloudWatch
* per domain, and also perform cleanup of old data after it manages to post
* the information.
*/
@EqualsAndHashCode(of = { "bucket", "key", "range" })
@Loggable(Loggable.DEBUG)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.jcabi.manifests.Manifests;
import com.s3auth.hosts.DynamoHosts;
import com.s3auth.hosts.Hosts;
import com.s3auth.hosts.ScheduledCloudWatch;
import com.s3auth.hosts.SyslogHosts;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
Expand Down Expand Up @@ -61,6 +62,11 @@ public final class HostsListener implements ServletContextListener {
*/
private transient Hosts hosts;

/**
* The Scheduled CloudWatch data sender.
*/
private transient ScheduledCloudWatch cloudwatch;

/**
* {@inheritDoc}
*
Expand All @@ -73,6 +79,7 @@ public void contextInitialized(final ServletContextEvent event) {
try {
Manifests.append(event.getServletContext());
this.hosts = new SyslogHosts(new DynamoHosts());
this.cloudwatch = new ScheduledCloudWatch();
} catch (final java.io.IOException ex) {
Logger.error(
this,
Expand All @@ -94,6 +101,7 @@ public void contextDestroyed(final ServletContextEvent event) {
} else {
try {
this.hosts.close();
this.cloudwatch.close();
} catch (final java.io.IOException ex) {
Logger.error(
this,
Expand Down

0 comments on commit bd4c8bd

Please sign in to comment.