@Override public void store(final ProgramId serviceId, final RouteConfig routeConfig) { Transactionals.execute(transactional, context -> { getRouteTable(context).write(ServiceDiscoverable.getName(serviceId), GSON.toJson(routeConfig.getRoutes())); }); }
@Override public void store(final ProgramId serviceId, final RouteConfig routeConfig) { Transactionals.execute(transactional, context -> { getRouteTable(context).write(ServiceDiscoverable.getName(serviceId), GSON.toJson(routeConfig.getRoutes())); }); }
@Override public RouteConfig fetch(final ProgramId serviceId) { return Transactionals.execute(transactional, context -> { byte[] value = getRouteTable(context).read(ServiceDiscoverable.getName(serviceId)); if (value == null) { return new RouteConfig(Collections.emptyMap()); } return new RouteConfig(GSON.fromJson(Bytes.toString(value), MAP_STRING_INTEGER_TYPE)); }); }
@Override public RouteConfig fetch(final ProgramId serviceId) { return Transactionals.execute(transactional, context -> { byte[] value = getRouteTable(context).read(ServiceDiscoverable.getName(serviceId)); if (value == null) { return new RouteConfig(Collections.emptyMap()); } return new RouteConfig(GSON.fromJson(Bytes.toString(value), MAP_STRING_INTEGER_TYPE)); }); }
@Override public void delete(final ProgramId serviceId) throws NotFoundException { Transactionals.execute(transactional, context -> { byte[] key = Bytes.toBytes(ServiceDiscoverable.getName(serviceId)); KeyValueTable kvTable = getRouteTable(context); if (kvTable.read(key) == null) { throw new NotFoundException(String.format("Route Config for Service %s was not found.", serviceId)); } kvTable.delete(key); }, NotFoundException.class); }
@Override public void delete(final ProgramId serviceId) throws NotFoundException { Transactionals.execute(transactional, context -> { byte[] key = Bytes.toBytes(ServiceDiscoverable.getName(serviceId)); KeyValueTable kvTable = getRouteTable(context); if (kvTable.read(key) == null) { throw new NotFoundException(String.format("Route Config for Service %s was not found.", serviceId)); } kvTable.delete(key); }, NotFoundException.class); }