org.quartz.spi.SchedulerSignaler#redis.embedded.RedisServer源码实例Demo

下面列出了org.quartz.spi.SchedulerSignaler#redis.embedded.RedisServer 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: incubator-tuweni   文件: RedisServerExtension.java
@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);
}
 
源代码2 项目: cava   文件: RedisServerExtension.java
@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);
}
 
源代码3 项目: fernet-java8   文件: KeyRotationExampleIT.java
@Before
public void setUp() throws IOException {
    initMocks(this);
    final SecureRandom random = new SecureRandom();
    redisServer = new RedisServer();
    redisServer.start();

    pool = new JedisPool();
    repository = new RedisKeyRepository(pool);
    manager = new RedisKeyManager(random, pool, repository);
    manager.setMaxActiveKeys(3);

    clearData();
    manager.initialiseNewRepository();

    resource = new ProtectedResource(repository, random);
}
 
源代码4 项目: distributed-lock   文件: EmbeddedRedis.java
@PostConstruct
public void start() throws IOException {
  // find free port
  final var serverSocket = new ServerSocket(0);
  final var port = serverSocket.getLocalPort();
  serverSocket.close();

  server = RedisServer.builder().setting("bind 127.0.0.1").port(port).build(); // bind to ignore windows firewall popup each time the server starts
  server.start();

  final var connectionFactory = new LettuceConnectionFactory(new RedisStandaloneConfiguration("localhost", port));
  connectionFactory.setDatabase(0);
  connectionFactory.afterPropertiesSet();

  // set the property so that RedisAutoConfiguration picks up the right port
  System.setProperty("spring.redis.port", String.valueOf(port));
}
 
源代码5 项目: conductor   文件: RedisLockTest.java
@BeforeClass
public static void setUp() throws Exception {
    String testServerAddress = "redis://127.0.0.1:6371";
    redisServer = new RedisServer(6371);
    if (redisServer.isActive()) {
        redisServer.stop();
    }
    redisServer.start();

    RedisLockConfiguration redisLockConfiguration = new SystemPropertiesRedisLockConfiguration() {
        @Override
        public String getRedisServerAddress() {
            return testServerAddress;
        }
    };

    Config redissonConfig = new Config();
    redissonConfig.useSingleServer().setAddress(testServerAddress).setTimeout(10000);
    redisLock = new RedisLock((Redisson) Redisson.create(redissonConfig), redisLockConfiguration);

    // Create another instance of redisson for tests.
    config = new Config();
    config.useSingleServer().setAddress(testServerAddress).setTimeout(10000);
    redisson = Redisson.create(config);
}
 
源代码6 项目: spring-cloud-gateway   文件: RedisRule.java
@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);
		}
	}
}
 
源代码7 项目: quartz-redis-jobstore   文件: BaseTest.java
@Before
public void setUpRedis() throws IOException, SchedulerConfigException {
    port = getPort();
    logger.debug("Attempting to start embedded Redis server on port " + port);
    redisServer = RedisServer.builder()
            .port(port)
            .build();
    redisServer.start();
    final short database = 1;
    JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
    jedisPoolConfig.setTestOnBorrow(true);
    jedisPool = new JedisPool(jedisPoolConfig, host, port, Protocol.DEFAULT_TIMEOUT, null, database);

    jobStore = new RedisJobStore();
    jobStore.setHost(host);
    jobStore.setLockTimeout(2000);
    jobStore.setPort(port);
    jobStore.setInstanceId("testJobStore1");
    jobStore.setDatabase(database);
    mockScheduleSignaler = mock(SchedulerSignaler.class);
    jobStore.initialize(null, mockScheduleSignaler);
    schema = new RedisJobStoreSchema();

    jedis = jedisPool.getResource();
    jedis.flushDB();
}
 
源代码8 项目: dyno   文件: RedisAuthenticationIntegrationTest.java
@Test
public void testDynoClient_noAuthSuccess() throws Exception {
    redisServer = new RedisServer(REDIS_PORT);
    redisServer.start();

    Host noAuthHost = new HostBuilder().setHostname("localhost").setPort(REDIS_PORT).setRack(REDIS_RACK).setStatus(Status.Up).createHost();
    TokenMapSupplierImpl tokenMapSupplier = new TokenMapSupplierImpl(noAuthHost);
    DynoJedisClient dynoClient = constructJedisClient(tokenMapSupplier,
            () -> Collections.singletonList(noAuthHost));

    String statusCodeReply = dynoClient.set("some-key", "some-value");
    Assert.assertEquals("OK", statusCodeReply);

    String value = dynoClient.get("some-key");
    Assert.assertEquals("some-value", value);
}
 
源代码9 项目: dyno   文件: RedisAuthenticationIntegrationTest.java
@Test
public void testJedisConnFactory_noAuthSuccess() throws Exception {
    redisServer = new RedisServer(REDIS_PORT);
    redisServer.start();

    Host noAuthHost = new HostBuilder().setHostname("localhost").setPort(REDIS_PORT).setRack(REDIS_RACK).setStatus(Status.Up).createHost();

    JedisConnectionFactory conFactory =
            new JedisConnectionFactory(new DynoOPMonitor("some-application-name"), null);
    ConnectionPoolConfiguration cpConfig = new ConnectionPoolConfigurationImpl("some-name");
    CountingConnectionPoolMonitor poolMonitor = new CountingConnectionPoolMonitor();
    HostConnectionPool<Jedis> hostConnectionPool =
            new HostConnectionPoolImpl<>(noAuthHost, conFactory, cpConfig, poolMonitor);
    Connection<Jedis> connection = conFactory
            .createConnection(hostConnectionPool);

    connection.execPing();
}
 
源代码10 项目: dyno   文件: LocalRedisLockTest.java
@Before
public void setUp() throws IOException {
    redisServer = new RedisServer(REDIS_PORT);
    redisServer.start();
    Assume.assumeFalse(System.getProperty("os.name").toLowerCase().startsWith("win"));
    host = new HostBuilder()
            .setHostname("localhost")
            .setIpAddress("127.0.0.1")
            .setDatastorePort(REDIS_PORT)
            .setPort(REDIS_PORT)
            .setRack(REDIS_RACK)
            .setStatus(Host.Status.Up)
            .createHost();

    tokenMapSupplier = new TokenMapSupplierImpl(host);
    dynoLockClient = constructDynoLockClient();
}
 
源代码11 项目: dubbo-2.6.5   文件: RedisProtocolTest.java
@Before
public void setUp() throws Exception {
    int redisPort = NetUtils.getAvailablePort();
    if (name.getMethodName().equals("testAuthRedis") || name.getMethodName().equals("testWrongAuthRedis")) {
        String password = "123456";
        this.redisServer = RedisServer.builder().port(redisPort).setting("requirepass " + password).build();
        this.registryUrl = URL.valueOf("redis://username:"+password+"@localhost:"+redisPort+"?db.index=0");
    } else {
        this.redisServer = RedisServer.builder().port(redisPort).build();
        this.registryUrl = URL.valueOf("redis://localhost:" + redisPort);
    }
    this.redisServer.start();
}
 
源代码12 项目: dubbo-2.6.5   文件: RedisRegistryTest.java
@Before
public void setUp() throws Exception {
    int redisPort = NetUtils.getAvailablePort();
    this.redisServer = new RedisServer(redisPort);
    this.redisServer.start();
    this.registryUrl = URL.valueOf("redis://localhost:" + redisPort);

    redisRegistry = (RedisRegistry) new RedisRegistryFactory().createRegistry(registryUrl);
}
 
源代码13 项目: apm-agent-java   文件: LettuceBenchmark.java
@Override
public void setUp(Blackhole blackhole) throws IOException {
    super.setUp(blackhole);
    int redisPort = getAvailablePort();
    server = RedisServer.builder()
        .setting("bind 127.0.0.1")
        .port(redisPort)
        .build();
    server.start();
    RedisClient client = RedisClient.create(RedisURI.create("localhost", redisPort));
    connection = client.connect();
    sync = connection.sync();
    sync.set("foo", "bar");
}
 
@Before
@BeforeEach
public final void initRedis() throws IOException {
    redisPort = getAvailablePort();
    server = RedisServer.builder()
        .setting("bind 127.0.0.1")
        .port(redisPort)
        .build();
    server.start();
}
 
源代码15 项目: java-specialagent   文件: RedissonTest.java
@BeforeClass
public static void beforeClass() throws Exception {
  redisServer = new RedisServer();
  TestUtil.retry(new Callable<Void>() {
    @Override
    public Void call() throws Exception {
      redisServer.start();
      return null;
    }
  }, 10);
}
 
源代码16 项目: java-specialagent   文件: JedisTest.java
@BeforeClass
public static void beforeClass() throws Exception {
  redisServer = new RedisServer();
  TestUtil.retry(new Callable<Void>() {
    @Override
    public Void call() throws Exception {
      redisServer.start();
      return null;
    }
  }, 10);
}
 
源代码17 项目: java-specialagent   文件: RedissonITest.java
public static void main(final String[] args) throws Exception {
  final RedisServer redisServer = new RedisServer();
  TestUtil.retry(new Runnable() {
    @Override
    public void run() {
      redisServer.start();
    }
  }, 10);

  try {
    final Config config = new Config();
    config.useSingleServer().setAddress("redis://127.0.0.1:6379");
    final RedissonClient redissonClient = Redisson.create(config);
    try {
      final RMap<String,String> map = redissonClient.getMap("map");
      map.put("key", "value");
      if (!"value".equals(map.get("key")))
        throw new AssertionError("ERROR: failed to get key value");
    }
    finally {
      redissonClient.shutdown();
    }
  }
  finally {
    redisServer.stop();
    TestUtil.checkSpan(new ComponentSpanCount("java-redis", 2));
    // RedisServer process doesn't exit on 'stop' therefore call System.exit
    System.exit(0);
  }
}
 
源代码18 项目: java-specialagent   文件: JedisITest.java
public static void main(final String[] args) throws Exception {
  final RedisServer redisServer = new RedisServer();
  TestUtil.retry(new Runnable() {
    @Override
    public void run() {
      redisServer.start();
    }
  }, 10);

  try (final Jedis jedis = new Jedis()) {
    try {
      if (!"OK".equals(jedis.set("key", "value")))
        throw new AssertionError("ERROR: failed to set key/value");

      if (!"value".equals(jedis.get("key")))
        throw new AssertionError("ERROR: failed to get key value");

      TestUtil.checkSpan(new ComponentSpanCount("java-redis", 2));
    }
    finally {
      jedis.shutdown();
    }
  }
  finally {
    redisServer.stop();
    // RedisServer process doesn't exit on 'stop' therefore call System.exit
    System.exit(0);
  }
}
 
源代码19 项目: dew   文件: DewTestAutoConfiguration.java
/**
 * Init.
 *
 * @throws IOException the io exception
 */
@PostConstruct
public void init() throws IOException {
    logger.info("Load Auto Configuration : {}", this.getClass().getName());
    logger.info("Enabled Dew Test");
    redisServer = new RedisServer();
    if (!redisServer.isActive()) {
        try {
            redisServer.start();
            redisTemplate.getConnectionFactory().getConnection();
        } catch (Exception e) {
            logger.warn("Start embedded redis error.");
        }
    }
}
 
源代码20 项目: java-redis-client   文件: TracingLettuce52Test.java
@Before
public void before() {
  mockTracer.reset();

  redisServer = RedisServer.builder().setting("bind 127.0.0.1").build();
  redisServer.start();
}
 
源代码21 项目: java-redis-client   文件: TracingLettuce50Test.java
@Before
public void before() {
  mockTracer.reset();

  redisServer = RedisServer.builder().setting("bind 127.0.0.1").build();
  redisServer.start();
}
 
源代码22 项目: java-redis-client   文件: TracingLettuce51Test.java
@Before
public void before() {
  mockTracer.reset();

  redisServer = RedisServer.builder().setting("bind 127.0.0.1").build();
  redisServer.start();
}
 
@Before
public void before() {
  mockTracer.reset();

  redisServer = RedisServer.builder().build();
  redisServer.start();
  redisSentinel = RedisSentinel.builder().port(Protocol.DEFAULT_PORT + 1).build();
  redisSentinel.start();
}
 
源代码24 项目: java-redis-client   文件: TracingJedisPoolTest.java
@Before
public void before() {
  mockTracer.reset();

  redisServer = RedisServer.builder().setting("bind 127.0.0.1").build();
  redisServer.start();
}
 
源代码25 项目: java-redis-client   文件: TracingJedisTest.java
@Before
public void before() throws Exception {
  mockTracer.reset();

  redisServer = RedisServer.builder().setting("bind 127.0.0.1").build();
  redisServer.start();
}
 
@Before
public void before() {
  mockTracer.reset();

  redisServer = RedisServer.builder().build();
  redisServer.start();
  redisSentinel = RedisSentinel.builder().port(Protocol.DEFAULT_PORT + 1).build();
  redisSentinel.start();
}
 
源代码27 项目: java-redis-client   文件: TracingJedisPoolTest.java
@Before
public void before() {
  mockTracer.reset();

  redisServer = RedisServer.builder().setting("bind 127.0.0.1").build();
  redisServer.start();
}
 
源代码28 项目: java-redis-client   文件: TracingJedisTest.java
@Before
public void before() throws Exception {
  mockTracer.reset();

  redisServer = RedisServer.builder().setting("bind 127.0.0.1").build();
  redisServer.start();
}
 
源代码29 项目: java-redis-client   文件: TracingRedissonTest.java
@BeforeClass
public static void beforeClass() {
  redisServer = RedisServer.builder().setting("bind 127.0.0.1").build();
  redisServer.start();

  Config config = new Config();
  config.useSingleServer().setAddress("redis://127.0.0.1:6379");

  client = new TracingRedissonClient(Redisson.create(config),
      new TracingConfiguration.Builder(tracer).build());
}
 
源代码30 项目: sshd-shell-spring-boot   文件: ConfigTest.java
@PostConstruct
void init() {
    try {
        redisServer = new RedisServer(6379);
        redisServer.start();
    } catch (Exception ex) {
        System.out.println(ex);
    }
}