@Test public void testFind() throws Exception { final EndpointForwardingTemplateBySubnet value1 = buildValue(IP_PREFIX_1); final EndpointForwardingTemplateBySubnet value2 = buildValue(IP_PREFIX_2); dao.update(IP_PREFIX_1, value1); dao.update(IP_PREFIX_2, value2); Assert.assertFalse(dao.isEmpty()); Assert.assertTrue(dao.find(IP_PREFIX_1).isPresent()); Assert.assertEquals(value1, dao.find(IP_PREFIX_1).get()); Assert.assertTrue(dao.find(IP_PREFIX_2).isPresent()); Assert.assertEquals(value2, dao.find(IP_PREFIX_2).get()); final IpPrefix key = buildIpPrefix("1.2.3.1/32"); Assert.assertTrue(dao.find(key).isPresent()); Assert.assertEquals(value1, dao.find(key).get()); }
@Override public Optional<EndpointForwardingTemplateBySubnet> find(@Nonnull final IpPrefix key) { final Optional<EndpointForwardingTemplateBySubnet> template; if (EPTemplateUtil.isPlain(key)) { final Optional<EndpointForwardingTemplateBySubnet> fastPlain = Optional.fromNullable(plainCache.get(key)); if (fastPlain.isPresent()) { template = fastPlain; } else { template = lookupSlowSubnet(key.getIpv4Prefix().getValue()); } } else { final SubnetInfoKeyDecorator keyDecorator = EPTemplateUtil.buildSubnetInfoKey(key); final Optional<EndpointForwardingTemplateBySubnet> fastSubnet = Optional.fromNullable(subnetCache.get(keyDecorator)); if (fastSubnet.isPresent()) { template = fastSubnet; } else { template = Optional.absent(); } } return template; }
SimpleCachedDaoEPForwardingTemplateImpl implements SimpleCachedDao<IpPrefix, EndpointForwardingTemplateBySubnet> { @Override public Optional<EndpointForwardingTemplateBySubnet> find(@Nonnull final IpPrefix key) { final Optional<EndpointForwardingTemplateBySubnet> template; if (EPTemplateUtil.isPlain(key)) { final Optional<EndpointForwardingTemplateBySubnet> fastPlain = Optional.fromNullable(plainCache.get(key)); if (fastPlain.isPresent()) { template = fastPlain; } else { template = lookupSlowSubnet(key.getIpv4Prefix().getValue()); } } else { final SubnetInfoKeyDecorator keyDecorator = EPTemplateUtil.buildSubnetInfoKey(key); final Optional<EndpointForwardingTemplateBySubnet> fastSubnet = Optional.fromNullable(subnetCache.get(keyDecorator)); if (fastSubnet.isPresent()) { template = fastSubnet; } else { template = Optional.absent(); } } return template; } }
SimpleCachedDaoEPForwardingTemplateImpl implements SimpleCachedDao<IpPrefix, EndpointForwardingTemplateBySubnet> { @Override public Optional<EndpointForwardingTemplateBySubnet> find(@Nonnull final IpPrefix key) { final Optional<EndpointForwardingTemplateBySubnet> template; if (EPTemplateUtil.isPlain(key)) { final Optional<EndpointForwardingTemplateBySubnet> fastPlain = Optional.fromNullable(plainCache.get(key)); if (fastPlain.isPresent()) { template = fastPlain; } else { template = lookupSlowSubnet(key.getIpv4Prefix().getValue()); } } else { final SubnetInfoKeyDecorator keyDecorator = EPTemplateUtil.buildSubnetInfoKey(key); final Optional<EndpointForwardingTemplateBySubnet> fastSubnet = Optional.fromNullable(subnetCache.get(keyDecorator)); if (fastSubnet.isPresent()) { template = fastSubnet; } else { template = Optional.absent(); } } return template; } SimpleCachedDaoEPForwardingTemplateImpl(); }
SimpleCachedDaoEPForwardingTemplateImpl implements SimpleCachedDao<IpPrefix, EndpointForwardingTemplateBySubnet> { @Override public Optional<EndpointForwardingTemplateBySubnet> find(@Nonnull final IpPrefix key) { final Optional<EndpointForwardingTemplateBySubnet> template; if (EPTemplateUtil.isPlain(key)) { final Optional<EndpointForwardingTemplateBySubnet> fastPlain = Optional.fromNullable(plainCache.get(key)); if (fastPlain.isPresent()) { template = fastPlain; } else { template = lookupSlowSubnet(key.getIpv4Prefix().getValue()); } } else { final SubnetInfoKeyDecorator keyDecorator = EPTemplateUtil.buildSubnetInfoKey(key); final Optional<EndpointForwardingTemplateBySubnet> fastSubnet = Optional.fromNullable(subnetCache.get(keyDecorator)); if (fastSubnet.isPresent()) { template = fastSubnet; } else { template = Optional.absent(); } } return template; } SimpleCachedDaoEPForwardingTemplateImpl(); @Override EndpointForwardingTemplateBySubnet update(@Nonnull final IpPrefix key, @Nullable final EndpointForwardingTemplateBySubnet value); @Override Optional<EndpointForwardingTemplateBySubnet> find(@Nonnull final IpPrefix key); @Override void invalidateCache(); @Override boolean isEmpty(); @Override Iterable<EndpointForwardingTemplateBySubnet> values(); @Override Iterable<IpPrefix> keySet(); }
SimpleCachedDaoEPForwardingTemplateImpl implements SimpleCachedDao<IpPrefix, EndpointForwardingTemplateBySubnet> { @Override public Optional<EndpointForwardingTemplateBySubnet> find(@Nonnull final IpPrefix key) { final Optional<EndpointForwardingTemplateBySubnet> template; if (EPTemplateUtil.isPlain(key)) { final Optional<EndpointForwardingTemplateBySubnet> fastPlain = Optional.fromNullable(plainCache.get(key)); if (fastPlain.isPresent()) { template = fastPlain; } else { template = lookupSlowSubnet(key.getIpv4Prefix().getValue()); } } else { final SubnetInfoKeyDecorator keyDecorator = EPTemplateUtil.buildSubnetInfoKey(key); final Optional<EndpointForwardingTemplateBySubnet> fastSubnet = Optional.fromNullable(subnetCache.get(keyDecorator)); if (fastSubnet.isPresent()) { template = fastSubnet; } else { template = Optional.absent(); } } return template; } SimpleCachedDaoEPForwardingTemplateImpl(); @Override EndpointForwardingTemplateBySubnet update(@Nonnull final IpPrefix key, @Nullable final EndpointForwardingTemplateBySubnet value); @Override Optional<EndpointForwardingTemplateBySubnet> find(@Nonnull final IpPrefix key); @Override void invalidateCache(); @Override boolean isEmpty(); @Override Iterable<EndpointForwardingTemplateBySubnet> values(); @Override Iterable<IpPrefix> keySet();  }