@Override protected void before() throws IOException { try { this.server = new RedisServer(this.port); this.server.start(); } catch (Exception e) { if (!suppressExceptions) { throw e; } } }
@Override protected void after() { try { this.server.stop(); } catch (Exception e) { if (!suppressExceptions) { throw e; } } } }
@Override protected void before() { try { redisServer = RedisServer.builder().port(port).setting("maxmemory 16MB").build(); redisServer.start(); } catch (final Exception e) { if (port == DEFAULT_REDIS_PORT && ignoreDefaultPortFailure) { log.info("Unable to start embedded Redis on default port. Ignoring error. Assuming redis is already running."); } else { throw new RuntimeException(format("Error while initializing the Redis server" + " on port %d", port), e); } } }
@Component public class EmbededRedis { @Value("${spring.redis.port}") private int redisPort; private RedisServer redisServer; @PostConstruct public void startRedis() throws IOException { redisServer = new RedisServer(redisPort); redisServer.start(); } @PreDestroy public void stopRedis() { redisServer.stop(); } }
@PostConstruct public void init() throws IOException { logger.info("Enabled Dew Test"); redisServer = new RedisServer(); if (!redisServer.isActive()) { try { redisServer.start(); redisTemplate.getConnectionFactory().getConnection(); } catch (Exception e) { logger.error("Start embedded redis error.", e); } } }
@Test public void testAutoReconnect() throws Exception { RedisStorageClient client = createClient(); // Issue a command to create a connection assertTrue(client.add("key1", 0, toBytes("foo")).get()); assertEquals("foo", toString(client.get("key1"))); // Stop and start server to close all connections if (!redisProvided) { embeddedRedisServer.stop(); embeddedRedisServer.start(); } // If we now issue commands, the old connection is defunct and will be replaced assertTrue(client.add("key1", 0, toBytes("foo")).get()); assertEquals("foo", toString(client.get("key1"))); client.shutdown(); }
@PostConstruct public void startRedis() throws IOException { if (WINDOWS == getOS()) { redisServer = RedisServer.builder().setting("maxheap 512Mb").port(redisPort).build(); } else { redisServer = new RedisServer(redisPort); } redisServer.start(); }
public void start() throws IOException { redisServer.start(); jedisPool = new JedisPool(new JedisPoolConfig(), getConnectString(), getPort()); }
EmbeddedRedis() throws IOException, URISyntaxException { redisServer = new RedisServer(); }
@Override public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException { if (redisServer == null) { String localhost = InetAddress.getLoopbackAddress().getHostAddress(); redisServer = RedisServer .builder() .setting("bind " + localhost) .setting("maxmemory 128mb") .setting("maxmemory-policy allkeys-lru") .setting("appendonly no") .setting("save \"\"") .port(findFreePort()) .build(); Runtime.getRuntime().addShutdownHook(shutdownThread); redisServer.start(); } return redisServer.ports().get(0); }
private RedisServer createRedisServer() { final RedisServerBuilder redisServerBuilder = RedisServer.builder() .port(redisPort) .setting("appendonly yes") .setting("appendfsync everysec"); settings.stream().forEach(s -> redisServerBuilder.setting(s)); final RedisServer redisServer = redisServerBuilder.build(); return redisServer; }
public boolean isActive() { return redisServer.isActive(); }
@PostConstruct public void init() throws IOException { log.info("======================= Enabled Devx Test ======================="); redisServer = new RedisServer(); if (!redisServer.isActive()) { try { redisServer.start(); redisTemplate.getConnectionFactory().getConnection(); } catch (Exception e) { log.error("Start embedded redis error.", e); } } }
public EmailEmbeddedRedis start() { log.info("Started Embedded Redis Server on port {}.", redisPort); redisServer.start(); return this; }
EmbeddedRedis() throws IOException, URISyntaxException { redisServer = new RedisServer(); }
private RedisServer createRedisServer() { final RedisServerBuilder redisServerBuilder = RedisServer.builder() .port(redisPort) .setting("appendonly yes") .setting("appendfsync everysec"); settings.stream().forEach(s -> redisServerBuilder.setting(s)); final RedisServer redisServer = redisServerBuilder.build(); return redisServer; }
public boolean isActive() { return redisServer.isActive(); }
@BeforeSuite(alwaysRun = true) public void globalBeforeSuite() { if (Boolean.valueOf(System.getProperty("killbill.test.redis", "false"))) { redisServer = new RedisServer(56379); redisServer.start(); redissonClient = new RedissonCacheClientProvider("redis://127.0.0.1:56379", 1).get(); theRealClock = new DistributedClockMock(); ((DistributedClockMock) theRealClock).setRedissonClient(redissonClient); extraPropertiesForTestSuite = ImmutableMap.<String, String>of("org.killbill.cache.config.redis", "true", "org.killbill.cache.config.redis.url", "redis://127.0.0.1:56379"); } else { theRealClock.resetDeltaFromReality(); extraPropertiesForTestSuite = ImmutableMap.<String, String>of(); } // The clock needs to be setup early in @BeforeSuite, as it is needed when starting the server, but see below clock = theRealClock; }