@Test public void getChannel() throws ChannelNotFoundException { final RedisDataStore store = newRedisDataStore(); final Channel channel = newChannel2(); store.saveChannel(channel); final Channel retreived = store.getChannel(channel.getChannelId()); assertThat(retreived.getChannelId(), equalTo(channel.getChannelId())); assertThat(retreived.getEndpointToken(), equalTo(channel.getEndpointToken())); }
@Override public Channel getChannel(final String channelId) throws ChannelNotFoundException { final Jedis jedis = jedisPool.getResource(); try { final List<String> endpointTokenAndUaid = jedis.hmget(chidLookupKey(channelId), TOKEN_KEY, UAID_KEY); if (!endpointTokenAndUaid.isEmpty()) { final String endpointToken = endpointTokenAndUaid.get(0); final String uaid = endpointTokenAndUaid.get(1); if (endpointToken == null || uaid == null) { throw channelNotFoundException(channelId); } return new DefaultChannel(uaid, channelId, Long.valueOf(jedis.get(endpointToken)), endpointToken); } throw channelNotFoundException(channelId); } finally { jedisPool.returnResource(jedis); } }
RedisDataStore implements DataStore { @Override public Channel getChannel(final String channelId) throws ChannelNotFoundException { final Jedis jedis = jedisPool.getResource(); try { final List<String> endpointTokenAndUaid = jedis.hmget(chidLookupKey(channelId), TOKEN_KEY, UAID_KEY); if (!endpointTokenAndUaid.isEmpty()) { final String endpointToken = endpointTokenAndUaid.get(0); final String uaid = endpointTokenAndUaid.get(1); if (endpointToken == null || uaid == null) { throw channelNotFoundException(channelId); } return new DefaultChannel(uaid, channelId, Long.valueOf(jedis.get(endpointToken)), endpointToken); } throw channelNotFoundException(channelId); } finally { jedisPool.returnResource(jedis); } } }
RedisDataStore implements DataStore { @Override public Channel getChannel(final String channelId) throws ChannelNotFoundException { final Jedis jedis = jedisPool.getResource(); try { final List<String> endpointTokenAndUaid = jedis.hmget(chidLookupKey(channelId), TOKEN_KEY, UAID_KEY); if (!endpointTokenAndUaid.isEmpty()) { final String endpointToken = endpointTokenAndUaid.get(0); final String uaid = endpointTokenAndUaid.get(1); if (endpointToken == null || uaid == null) { throw channelNotFoundException(channelId); } return new DefaultChannel(uaid, channelId, Long.valueOf(jedis.get(endpointToken)), endpointToken); } throw channelNotFoundException(channelId); } finally { jedisPool.returnResource(jedis); } } RedisDataStore(final String host, final int port); }
RedisDataStore implements DataStore { @Override public Channel getChannel(final String channelId) throws ChannelNotFoundException { final Jedis jedis = jedisPool.getResource(); try { final List<String> endpointTokenAndUaid = jedis.hmget(chidLookupKey(channelId), TOKEN_KEY, UAID_KEY); if (!endpointTokenAndUaid.isEmpty()) { final String endpointToken = endpointTokenAndUaid.get(0); final String uaid = endpointTokenAndUaid.get(1); if (endpointToken == null || uaid == null) { throw channelNotFoundException(channelId); } return new DefaultChannel(uaid, channelId, Long.valueOf(jedis.get(endpointToken)), endpointToken); } throw channelNotFoundException(channelId); } finally { jedisPool.returnResource(jedis); } } RedisDataStore(final String host, final int port); @Override void savePrivateKeySalt(final byte[] salt); @Override byte[] getPrivateKeySalt(); @Override boolean saveChannel(final Channel channel); @Override void removeChannels(final Set<String> channelIds); @Override Channel getChannel(final String channelId); @Override Set<String> getChannelIds(final String uaid); @Override void removeChannels(final String uaid); @Override String updateVersion(final String endpointToken, final long newVersion); @Override String saveUnacknowledged(final String channelId, final long version); @Override Set<Ack> getUnacknowledged(final String uaid); @Override Set<Ack> removeAcknowledged(final String uaid, final Set<Ack> acks); }
RedisDataStore implements DataStore { @Override public Channel getChannel(final String channelId) throws ChannelNotFoundException { final Jedis jedis = jedisPool.getResource(); try { final List<String> endpointTokenAndUaid = jedis.hmget(chidLookupKey(channelId), TOKEN_KEY, UAID_KEY); if (!endpointTokenAndUaid.isEmpty()) { final String endpointToken = endpointTokenAndUaid.get(0); final String uaid = endpointTokenAndUaid.get(1); if (endpointToken == null || uaid == null) { throw channelNotFoundException(channelId); } return new DefaultChannel(uaid, channelId, Long.valueOf(jedis.get(endpointToken)), endpointToken); } throw channelNotFoundException(channelId); } finally { jedisPool.returnResource(jedis); } } RedisDataStore(final String host, final int port); @Override void savePrivateKeySalt(final byte[] salt); @Override byte[] getPrivateKeySalt(); @Override boolean saveChannel(final Channel channel); @Override void removeChannels(final Set<String> channelIds); @Override Channel getChannel(final String channelId); @Override Set<String> getChannelIds(final String uaid); @Override void removeChannels(final String uaid); @Override String updateVersion(final String endpointToken, final long newVersion); @Override String saveUnacknowledged(final String channelId, final long version); @Override Set<Ack> getUnacknowledged(final String uaid); @Override Set<Ack> removeAcknowledged(final String uaid, final Set<Ack> acks);  }