@Path(value="cache") @Singleton public class DimensionCacheLoaderServlet extends Object
| Constructor and Description |
|---|
DimensionCacheLoaderServlet(DimensionDictionary dimensionDictionary,
DataCache<?> dataCache,
ObjectMappersSuite objectMappers)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
javax.ws.rs.core.Response |
addReplaceDimensionRows(String dimensionName,
String json)
Endpoint to add/replace dimension rows.
|
javax.ws.rs.core.Response |
addUpdateDimensionRows(String dimensionName,
String json)
Endpoint to add/update dimension rows, with update semantics.
|
javax.ws.rs.core.Response |
deleteDataCache()
clears cache.
|
javax.ws.rs.core.Response |
getDimensionLastUpdated(String dimensionName)
Get the lastUpdated date for a particular dimension.
|
javax.ws.rs.core.Response |
getMsg()
Get the status of the cache.
|
javax.ws.rs.core.Response |
updateDimensionLastUpdated(String json)
Endpoint to update cache status.
|
javax.ws.rs.core.Response |
updateDimensionLastUpdated(String dimensionName,
String json)
Endpoint to update a dimensions lastUpdated field.
|
@Inject public DimensionCacheLoaderServlet(DimensionDictionary dimensionDictionary, @NotNull DataCache<?> dataCache, ObjectMappersSuite objectMappers)
dimensionDictionary - Set of dimensions to be aware ofdataCache - A cache that we can clear if told toobjectMappers - Shares mappers for dealing with JSON@POST
@Timed
@Path(value="/dimensions/{dimensionName}")
@Consumes(value="application/json")
public javax.ws.rs.core.Response updateDimensionLastUpdated(@PathParam(value="dimensionName")
String dimensionName,
String json)
dimensionName - name of the dimension whose lastUpdated is to be modified. (path parameter)json - post data json containing the lastUpdated datetime. Expected JSON string:
{
"name":" <dimensionName>",
"lastUpdated":" <ISO_8601_datetime_string>"
}
@GET
@Timed
@Path(value="/dimensions/{dimensionName}")
@Consumes(value="application/json")
public javax.ws.rs.core.Response getDimensionLastUpdated(@PathParam(value="dimensionName")
String dimensionName)
dimensionName - Name of the dimension to get the last updated date for.
{
"name":" <dimensionName>",
"lastUpdated":" <ISO_8601_datetime_string>"
}
@POST
@Timed
@Path(value="/dimensions/{dimensionName}/dimensionRows")
@Consumes(value="application/json; charset=utf-8")
public javax.ws.rs.core.Response addReplaceDimensionRows(@PathParam(value="dimensionName")
String dimensionName,
String json)
If a row having the same ID already exists, it will be overwritten.
dimensionName - name of the dimension whose dimension rows are to be modified. (path parameter)json - post data json containing a list of json objects which describe dimension rows
{
"dimensionRows": [
{ "id":"usa", "description":"United_States_of_America" },
{ "id":"can", "description":"Canada" }
]
}
@Timed
@Path(value="/dimensions/{dimensionName}/dimensionRows")
@Consumes(value="application/json")
public javax.ws.rs.core.Response addUpdateDimensionRows(@PathParam(value="dimensionName")
String dimensionName,
String json)
If (by ID) a given row doesn't exist, this acts like POST above. If (by ID) a given row *does* exist, this will perform a merge of the new row into the old row. Given the two existing rows
{
"dimensionRows": [
{ "id":"usa", "description":"States_United_of_America", "population":"320", "gdp":"" },
{ "id":"can", "description":"Canada", "population":"35", "gdp":"" }
]
}
a PATCH with
{
"dimensionRows": [
{ "id":"usa", "description":"United_States_of_America", "gdp":"16.77" },
{ "id":"can", "description":"Canada", "gdp":"1.83" },
{ "id":"uk", "description":"United Kingdom", "gdp":"2.68" }
]
}
will result in
{
"dimensionRows": [
{ "id":"usa", "description":"United_States_of_America", "population":"320", "gdp":"16.77" },
{ "id":"can", "description":"Canada", "population":"35", "gdp":"1.83" },
{ "id":"uk", "description":"United Kingdom", "population":"", "gdp":"2.68" }
]
}
Notice that the population field is not touched, that description and gdp are both updated, and that
United Kingom is added (with an empty population).dimensionName - name of the dimension whose dimension rows are to be modified. (path parameter)json - post data json containing a list of json objects which describe dimension rows
{
"dimensionRows": [
{ "id":"usa", "description":"United_States_of_America" },
{ "id":"can", "description":"Canada" }
]
}
@PUT @Timed @Path(value="/cacheStatus") @Consumes(value="application/json") public javax.ws.rs.core.Response updateDimensionLastUpdated(String json)
json - post data json containing the lastUpdated datetime.
Expected JSON string:
{"lastUpdated":" <ISO_8601_datetime_string>"}
@GET @Timed @Path(value="/cacheStatus") public javax.ws.rs.core.Response getMsg()
@DELETE @Timed @Path(value="/data") public javax.ws.rs.core.Response deleteDataCache()
curl -X DELETE "http://localhost:4080/v1/cache/data"
Copyright © 2016–2018 Yahoo! Inc.. All rights reserved.