|
1 | 1 | package com.redislabs.university.RU102J; |
2 | 2 |
|
3 | | -import com.redislabs.redistimeseries.RedisTimeSeries; |
4 | 3 | import com.redislabs.university.RU102J.command.LoadCommand; |
5 | 4 | import com.redislabs.university.RU102J.command.RunCommand; |
6 | | -import com.redislabs.university.RU102J.dao.*; |
| 5 | +import com.redislabs.university.RU102J.dao.CapacityDaoRedisImpl; |
| 6 | +import com.redislabs.university.RU102J.dao.FeedDaoRedisImpl; |
| 7 | +import com.redislabs.university.RU102J.dao.MetricDaoRedisZsetImpl; |
| 8 | +import com.redislabs.university.RU102J.dao.SiteGeoDaoRedisImpl; |
| 9 | +import com.redislabs.university.RU102J.dao.SiteStatsDaoRedisImpl; |
7 | 10 | import com.redislabs.university.RU102J.health.RediSolarHealthCheck; |
8 | | -import com.redislabs.university.RU102J.resources.*; |
| 11 | +import com.redislabs.university.RU102J.resources.CapacityResource; |
| 12 | +import com.redislabs.university.RU102J.resources.MeterReadingResource; |
| 13 | +import com.redislabs.university.RU102J.resources.MetricsResource; |
| 14 | +import com.redislabs.university.RU102J.resources.SiteGeoResource; |
| 15 | + |
9 | 16 | import io.dropwizard.Application; |
10 | 17 | import io.dropwizard.assets.AssetsBundle; |
11 | 18 | import io.dropwizard.setup.Bootstrap; |
|
15 | 22 |
|
16 | 23 | public class RediSolarApplication extends Application<RediSolarConfiguration> { |
17 | 24 |
|
18 | | - public static void main(final String[] args) throws Exception { |
19 | | - new RediSolarApplication().run(args); |
20 | | - } |
| 25 | + public static void main( final String[] args ) throws Exception { |
| 26 | + new RediSolarApplication().run( args ); |
| 27 | + } |
| 28 | + |
| 29 | + @Override |
| 30 | + public String getName() { |
| 31 | + return "RediSolar"; |
| 32 | + } |
21 | 33 |
|
22 | | - @Override |
23 | | - public String getName() { |
24 | | - return "RediSolar"; |
25 | | - } |
| 34 | + @Override |
| 35 | + public void initialize( final Bootstrap<RediSolarConfiguration> bootstrap ) { |
| 36 | + bootstrap.addBundle( new AssetsBundle( "/dashboard/dist", "/", "index.html" ) ); |
| 37 | + bootstrap.addCommand( new LoadCommand() ); |
| 38 | + bootstrap.addCommand( new RunCommand() ); |
| 39 | + } |
26 | 40 |
|
27 | | - @Override |
28 | | - public void initialize(final Bootstrap<RediSolarConfiguration> bootstrap) { |
29 | | - bootstrap.addBundle(new AssetsBundle("/dashboard/dist", "/", "index.html")); |
30 | | - bootstrap.addCommand(new LoadCommand()); |
31 | | - bootstrap.addCommand(new RunCommand()); |
32 | | - } |
| 41 | + @Override |
| 42 | + public void run( final RediSolarConfiguration configuration, final Environment environment ) { |
| 43 | + RedisConfig redisConfig = configuration.getRedisConfig(); |
| 44 | + JedisPool jedisPool; |
33 | 45 |
|
34 | | - @Override |
35 | | - public void run(final RediSolarConfiguration configuration, |
36 | | - final Environment environment) { |
37 | | - RedisConfig redisConfig = configuration.getRedisConfig(); |
38 | | - JedisPool jedisPool; |
39 | | - |
40 | | - String password = redisConfig.getPassword(); |
| 46 | + String password = redisConfig.getPassword(); |
41 | 47 |
|
42 | | - if (password.length() > 0) { |
43 | | - jedisPool = new JedisPool(new JedisPoolConfig(), redisConfig.getHost(), |
44 | | - redisConfig.getPort(), 2000, redisConfig.getPassword()); |
45 | | - } else { |
46 | | - jedisPool = new JedisPool(redisConfig.getHost(), redisConfig.getPort()); |
47 | | - } |
| 48 | + if ( password.length() > 0 ) { |
| 49 | + jedisPool = new JedisPool( new JedisPoolConfig(), redisConfig.getHost(), redisConfig.getPort(), 2000, redisConfig.getPassword() ); |
| 50 | + } else { |
| 51 | + jedisPool = new JedisPool( redisConfig.getHost(), redisConfig.getPort() ); |
| 52 | + } |
48 | 53 |
|
49 | | - // To use the geospatial features, replace the following lines with: |
50 | | - // SiteGeoResource siteResource = |
51 | | - // new SiteGeoResource(new SiteGeoDaoRedisImpl(jedisPool)); |
52 | | - SiteResource siteResource = |
53 | | - new SiteResource(new SiteDaoRedisImpl(jedisPool)); |
54 | | - environment.jersey().register(siteResource); |
| 54 | + // To use the geospatial features, replace the following lines with: |
| 55 | + SiteGeoResource siteResource = new SiteGeoResource( new SiteGeoDaoRedisImpl( jedisPool ) ); |
| 56 | + //SiteResource siteResource = new SiteResource( new SiteDaoRedisImpl( jedisPool ) ); |
| 57 | + environment.jersey().register( siteResource ); |
55 | 58 |
|
56 | | - // For RedisTimeSeries: replace the next lines with |
57 | | - // MetricsResource metricsResource = |
58 | | - // new MetricsResource(new MetricDaoRedisTSImpl(jedisPool)); |
59 | | - MetricsResource metricsResource = |
60 | | - new MetricsResource(new MetricDaoRedisZsetImpl(jedisPool)); |
61 | | - environment.jersey().register(metricsResource); |
| 59 | + // For RedisTimeSeries: replace the next lines with |
| 60 | + // MetricsResource metricsResource = |
| 61 | + // new MetricsResource(new MetricDaoRedisTSImpl(jedisPool)); |
| 62 | + MetricsResource metricsResource = new MetricsResource( new MetricDaoRedisZsetImpl( jedisPool ) ); |
| 63 | + environment.jersey().register( metricsResource ); |
62 | 64 |
|
63 | | - CapacityResource capacityResource = |
64 | | - new CapacityResource(new CapacityDaoRedisImpl(jedisPool)); |
65 | | - environment.jersey().register(capacityResource); |
| 65 | + CapacityResource capacityResource = new CapacityResource( new CapacityDaoRedisImpl( jedisPool ) ); |
| 66 | + environment.jersey().register( capacityResource ); |
66 | 67 |
|
67 | | - MeterReadingResource meterResource = |
68 | | - new MeterReadingResource(new SiteStatsDaoRedisImpl(jedisPool), |
69 | | - new MetricDaoRedisZsetImpl(jedisPool), |
70 | | - // For RedisTimeSeries: new MetricDaoRedisTSImpl(jedisPool), |
71 | | - new CapacityDaoRedisImpl(jedisPool), |
72 | | - new FeedDaoRedisImpl(jedisPool)); |
73 | | - environment.jersey().register(meterResource); |
| 68 | + MeterReadingResource meterResource = new MeterReadingResource( new SiteStatsDaoRedisImpl( jedisPool ), new MetricDaoRedisZsetImpl( jedisPool ), |
| 69 | + // For RedisTimeSeries: new MetricDaoRedisTSImpl(jedisPool), |
| 70 | + new CapacityDaoRedisImpl( jedisPool ), new FeedDaoRedisImpl( jedisPool ) ); |
| 71 | + environment.jersey().register( meterResource ); |
74 | 72 |
|
75 | | - RediSolarHealthCheck healthCheck = new RediSolarHealthCheck(redisConfig); |
76 | | - environment.healthChecks().register("healthy", healthCheck); |
77 | | - } |
| 73 | + RediSolarHealthCheck healthCheck = new RediSolarHealthCheck( redisConfig ); |
| 74 | + environment.healthChecks().register( "healthy", healthCheck ); |
| 75 | + } |
78 | 76 | } |
0 commit comments