public void notifyCacheInvalidation(SchemaRegistryCacheType schemaRegistryCacheType, String keyAsString) { notify(String.format("api/v1/schemaregistry/cache/%s/invalidate",schemaRegistryCacheType.name()), keyAsString); }
@POST @Path("/cache/{cacheType}/invalidate") @UnitOfWork public Response invalidateCache(@ApiParam(value = "Cache Id to be invalidated", required = true) @PathParam("cacheType") SchemaRegistryCacheType cacheType, String keyString) { try { LOG.debug("Request to invalidate cache : {} with key : {} accepted", cacheType.name(), keyString); schemaRegistry.invalidateCache(cacheType, keyString); return WSUtils.respond(Response.Status.OK); } catch (Exception e) { return WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, e.getMessage()); } }
@POST @Path("/cache/{cacheType}/invalidate") @UnitOfWork public Response invalidateCache(@ApiParam(value = "Cache Id to be invalidated", required = true) @PathParam("cacheType") SchemaRegistryCacheType cacheType, String keyString) { try { LOG.debug("Request to invalidate cache : {} with key : {} accepted", cacheType.name(), keyString); schemaRegistry.invalidateCache(cacheType, keyString); return WSUtils.respond(Response.Status.OK); } catch (Exception e) { return WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, e.getMessage()); } }
@Override public void invalidateCache(SchemaRegistryCacheType schemaRegistryCacheType, String keyAsString) { switch (schemaRegistryCacheType) { case SCHEMA_BRANCH_CACHE: SchemaBranchCache.Key schemaBranchKey; try { schemaBranchKey = ObjectMapperUtils.deserialize(keyAsString, SchemaBranchCache.Key.class); } catch (IOException e) { throw new RuntimeException(String.format("Failed to deserialize keyString : [%s]", keyAsString),e); } schemaBranchCache.invalidateSchemaBranch(schemaBranchKey); break; case SCHEMA_VERSION_CACHE: SchemaVersionInfoCache.Key schemaVersionKey; try { schemaVersionKey = ObjectMapperUtils.deserialize(keyAsString, SchemaVersionInfoCache.Key.class); } catch (IOException e) { throw new RuntimeException(String.format("Failed to deserialize keyString : [%s]", keyAsString),e); } schemaVersionLifecycleManager.invalidateSchemaVersionCache(schemaVersionKey); break; case ALL: schemaBranchCache.invalidateAll(); schemaVersionLifecycleManager.invalidateAllSchemaVersionCache(); break; default: throw new RuntimeException(String.format("Invalid cache type : '%s'",schemaRegistryCacheType.name())); } }