|
16 | 16 | */
|
17 | 17 | package feast.serving.configuration;
|
18 | 18 |
|
19 |
| -import feast.core.StoreProto.Store; |
20 |
| -import feast.core.StoreProto.Store.RedisConfig; |
21 | 19 | import feast.core.StoreProto.Store.StoreType;
|
| 20 | +import feast.serving.FeastProperties; |
22 | 21 | import feast.serving.service.JobService;
|
23 | 22 | import feast.serving.service.NoopJobService;
|
24 | 23 | import feast.serving.service.RedisBackedJobService;
|
25 | 24 | import feast.serving.specs.CachedSpecService;
|
| 25 | +import java.util.Map; |
26 | 26 | import org.springframework.context.annotation.Bean;
|
27 | 27 | import org.springframework.context.annotation.Configuration;
|
28 |
| -import redis.clients.jedis.Jedis; |
| 28 | +import redis.clients.jedis.JedisPool; |
| 29 | +import redis.clients.jedis.JedisPoolConfig; |
29 | 30 |
|
30 | 31 | @Configuration
|
31 | 32 | public class JobServiceConfig {
|
32 | 33 |
|
| 34 | + public static final String DEFAULT_REDIS_MAX_CONN = "8"; |
| 35 | + public static final String DEFAULT_REDIS_MAX_IDLE = "8"; |
| 36 | + public static final String DEFAULT_REDIS_MAX_WAIT_MILLIS = "50"; |
| 37 | + |
33 | 38 | @Bean
|
34 |
| - public JobService jobService(Store jobStore, CachedSpecService specService) { |
| 39 | + public JobService jobService(FeastProperties feastProperties, CachedSpecService specService) { |
35 | 40 | if (!specService.getStore().getType().equals(StoreType.BIGQUERY)) {
|
36 | 41 | return new NoopJobService();
|
37 | 42 | }
|
38 |
| - |
39 |
| - switch (jobStore.getType()) { |
| 43 | + StoreType storeType = StoreType.valueOf(feastProperties.getJobs().getStoreType()); |
| 44 | + Map<String, String> storeOptions = feastProperties.getJobs().getStoreOptions(); |
| 45 | + switch (storeType) { |
40 | 46 | case REDIS:
|
41 |
| - RedisConfig redisConfig = jobStore.getRedisConfig(); |
42 |
| - Jedis jedis = new Jedis(redisConfig.getHost(), redisConfig.getPort()); |
43 |
| - return new RedisBackedJobService(jedis); |
| 47 | + JedisPoolConfig jedisPoolConfig = new JedisPoolConfig(); |
| 48 | + jedisPoolConfig.setMaxTotal( |
| 49 | + Integer.parseInt(storeOptions.getOrDefault("max-conn", DEFAULT_REDIS_MAX_CONN))); |
| 50 | + jedisPoolConfig.setMaxIdle( |
| 51 | + Integer.parseInt(storeOptions.getOrDefault("max-idle", DEFAULT_REDIS_MAX_IDLE))); |
| 52 | + jedisPoolConfig.setMaxWaitMillis( |
| 53 | + Integer.parseInt( |
| 54 | + storeOptions.getOrDefault("max-wait-millis", DEFAULT_REDIS_MAX_WAIT_MILLIS))); |
| 55 | + JedisPool jedisPool = |
| 56 | + new JedisPool( |
| 57 | + jedisPoolConfig, |
| 58 | + storeOptions.get("host"), |
| 59 | + Integer.parseInt(storeOptions.get("port"))); |
| 60 | + return new RedisBackedJobService(jedisPool); |
44 | 61 | case INVALID:
|
45 | 62 | case BIGQUERY:
|
46 | 63 | case CASSANDRA:
|
47 | 64 | case UNRECOGNIZED:
|
48 | 65 | default:
|
49 | 66 | throw new IllegalArgumentException(
|
50 |
| - String.format( |
51 |
| - "Unsupported store type '%s' for job store name '%s'", |
52 |
| - jobStore.getType(), jobStore.getName())); |
| 67 | + String.format("Unsupported store type '%s' for job store", storeType)); |
53 | 68 | }
|
54 | 69 | }
|
55 | 70 | }
|
0 commit comments