public abstract class AbstractMyrrixServlet
extends javax.servlet.http.HttpServlet
HttpServlets used in the application. All API methods return the following
HTTP statuses in certain situations:
302 Temporary Redirect if, in a distributed environment, another partition should
handle the request400 Bad Request if the arguments are invalid, like a non-numeric ID401 Unauthorized if a username/password is required, but not supplied correctly
in the request via HTTP DIGEST405 Method Not Allowed if an incorrect HTTP method is used, like GET
where POST is required500 Internal Server Error if an unexpected server-side exception occurs503 Service Unavailable if no model is yet available to serve requests| Modifier and Type | Field and Description |
|---|---|
static String |
ALL_PARTITIONS_REF_KEY |
static String |
LOCAL_INPUT_DIR_KEY |
static String |
PARTITION_KEY |
static String |
READ_ONLY_KEY |
static String |
RECOMMENDER_KEY |
static String |
RESCORER_PROVIDER_KEY |
static String |
TIMINGS_KEY |
| Constructor and Description |
|---|
AbstractMyrrixServlet() |
| Modifier and Type | Method and Description |
|---|---|
protected static boolean |
getConsiderKnownItems(javax.servlet.ServletRequest request) |
protected static int |
getHowMany(javax.servlet.ServletRequest request) |
protected net.myrrix.common.MyrrixRecommender |
getRecommender() |
protected static String[] |
getRescorerParams(javax.servlet.ServletRequest request) |
protected RescorerProvider |
getRescorerProvider() |
ServletStats |
getTiming() |
protected Long |
getUnnormalizedPartitionToServe(javax.servlet.http.HttpServletRequest request) |
void |
init(javax.servlet.ServletConfig config) |
protected void |
output(javax.servlet.http.HttpServletRequest request,
javax.servlet.ServletResponse response,
Iterable<org.apache.mahout.cf.taste.recommender.RecommendedItem> items)
Outputs items in CSV or JSON format based on the HTTP
Accept header. |
protected void |
service(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) |
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, servicepublic static final String READ_ONLY_KEY
public static final String RECOMMENDER_KEY
public static final String RESCORER_PROVIDER_KEY
public static final String TIMINGS_KEY
public static final String LOCAL_INPUT_DIR_KEY
public static final String ALL_PARTITIONS_REF_KEY
public static final String PARTITION_KEY
public void init(javax.servlet.ServletConfig config)
throws javax.servlet.ServletException
init in interface javax.servlet.Servletinit in class javax.servlet.GenericServletjavax.servlet.ServletExceptionprotected final void service(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws javax.servlet.ServletException,
IOException
service in class javax.servlet.http.HttpServletjavax.servlet.ServletExceptionIOExceptionprotected Long getUnnormalizedPartitionToServe(javax.servlet.http.HttpServletRequest request)
request - request containing info that may determine which partition needs to serve itnull if any partition may serve, or an integral value that should be used to
determine the partiiton. This is usually an ID value, which will be possibly hashed and
reduced modulo the number of partitions.protected final net.myrrix.common.MyrrixRecommender getRecommender()
protected final RescorerProvider getRescorerProvider()
public final ServletStats getTiming()
protected static int getHowMany(javax.servlet.ServletRequest request)
protected static String[] getRescorerParams(javax.servlet.ServletRequest request)
protected static boolean getConsiderKnownItems(javax.servlet.ServletRequest request)
protected final void output(javax.servlet.http.HttpServletRequest request,
javax.servlet.ServletResponse response,
Iterable<org.apache.mahout.cf.taste.recommender.RecommendedItem> items)
throws IOException
Outputs items in CSV or JSON format based on the HTTP Accept header.
CSV output contains one recommendation per line, and each line is of the form itemID, strength,
like 325, 0.53. Strength is an opaque indicator of the relative quality of the recommendation.
JSON output is an array of arrays, with each sub-array containing an item ID and strength.
Example: [[325, 0.53], [98, 0.499]].
IOExceptionCopyright © 2012-2013. All Rights Reserved.