org.apache.lens.server.session
Class SessionResource

java.lang.Object
  extended by org.apache.lens.server.session.SessionResource

@Path(value="/session")
public class SessionResource
extends Object

Session resource api

This provides api for all things in session.


Field Summary
static org.apache.commons.logging.Log LOG
          The Constant LOG.
 
Constructor Summary
SessionResource()
          Instantiates a new session resource.
 
Method Summary
 APIResult addResource(LensSessionHandle sessionid, String type, String path)
          Add a resource to the session to all LensServices running in this Lens server

 APIResult closeSession(LensSessionHandle sessionid)
          Close a Lens server session.
 APIResult deleteResource(LensSessionHandle sessionid, String type, String path)
          Delete a resource from sesssion from all the @{link LensService}s running in this Lens server
 String getMessage()
          API to know if session service is up and running
 StringList getParams(LensSessionHandle sessionid, boolean verbose, String key)
          Get a list of key=value parameters set for this session.
 StringList listResources(LensSessionHandle sessionid, String type)
          Lists resources from the session for a given resource type.
 LensSessionHandle openSession(String username, String password, String database, LensConf sessionconf)
          Create a new session with Lens server.
 APIResult setParam(LensSessionHandle sessionid, String key, String value)
          Set value for a parameter specified by key

The parameters can be a hive variable or a configuration.

 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

public static final org.apache.commons.logging.Log LOG
The Constant LOG.

Constructor Detail

SessionResource

public SessionResource()
                throws LensException
Instantiates a new session resource.

Throws:
LensException - the lens exception
Method Detail

getMessage

@GET
@Produces(value="text/plain")
public String getMessage()
API to know if session service is up and running

Returns:
Simple text saying it up

openSession

@POST
@Consumes(value="multipart/form-data")
@Produces(value={"application/json","application/xml","text/plain"})
public LensSessionHandle openSession(String username,
                                                            String password,
                                                            @DefaultValue(value="")
                                                            String database,
                                                            LensConf sessionconf)
Create a new session with Lens server.

Parameters:
username - User name of the Lens server user
password - Password of the Lens server user
database - Set current database to the supplied value, if provided
sessionconf - Key-value properties which will be used to configure this session
Returns:
A Session handle unique to this session

closeSession

@DELETE
@Produces(value={"application/json","application/xml","text/plain"})
public APIResult closeSession(@QueryParam(value="sessionid")
                                              LensSessionHandle sessionid)
Close a Lens server session.

Parameters:
sessionid - Session handle object of the session to be closed
Returns:
APIResult object indicating if the operation was successful (check result.getStatus())

addResource

@PUT
@Path(value="resources/add")
@Consumes(value="multipart/form-data")
@Produces(value={"application/json","application/xml","text/plain"})
public APIResult addResource(LensSessionHandle sessionid,
                                                        String type,
                                                        String path)
Add a resource to the session to all LensServices running in this Lens server

The returned @{link APIResult} will have status SUCCEEDED only if the add operation was successful for all services running in this Lens server.

Parameters:
sessionid - session handle object
type - The type of resource. Valid types are 'jar', 'file' and 'archive'
path - path of the resource
Returns:
APIResult with state APIResult.Status.SUCCEEDED, if add was successful. APIResult with state APIResult.Status.PARTIAL, if add succeeded only for some services. APIResult with state APIResult.Status.FAILED, if add has failed

listResources

@GET
@Path(value="resources/list")
@Produces(value={"application/json","application/xml","text/plain"})
public StringList listResources(@QueryParam(value="sessionid")
                                                  LensSessionHandle sessionid,
                                                  @QueryParam(value="type")
                                                  String type)
Lists resources from the session for a given resource type.

Parameters:
sessionid - session handle object
type - resource type. It can be jar, file or null
Returns:
Lists all resources for a given resource type Lists all resources if the resource type is not specified

deleteResource

@PUT
@Path(value="resources/delete")
@Consumes(value="multipart/form-data")
@Produces(value={"application/json","application/xml","text/plain"})
public APIResult deleteResource(LensSessionHandle sessionid,
                                                           String type,
                                                           String path)
Delete a resource from sesssion from all the @{link LensService}s running in this Lens server

Similar to addResource, this call is successful only if resource was deleted from all services.

Parameters:
sessionid - session handle object
type - The type of resource. Valid types are 'jar', 'file' and 'archive'
path - path of the resource to be deleted
Returns:
APIResult with state APIResult.Status.SUCCEEDED, if delete was successful. APIResult with state APIResult.Status.PARTIAL, if delete succeeded only for some services. APIResult with state APIResult.Status.FAILED, if delete has failed

getParams

@GET
@Path(value="params")
@Produces(value={"application/json","application/xml","text/plain"})
public StringList getParams(@QueryParam(value="sessionid")
                                              LensSessionHandle sessionid,
                                              @DefaultValue(value="false")@QueryParam(value="verbose")
                                              boolean verbose,
                                              @DefaultValue(value="")@QueryParam(value="key")
                                              String key)
Get a list of key=value parameters set for this session.

Parameters:
sessionid - session handle object
verbose - If true, all the parameters will be returned. If false, configuration parameters will be returned
key - if this is empty, output will contain all parameters and their values, if it is non empty parameters will be filtered by key
Returns:
List of Strings, one entry per key-value pair

setParam

@PUT
@Path(value="params")
@Produces(value={"application/json","application/xml","text/plain"})
public APIResult setParam(LensSessionHandle sessionid,
                                            String key,
                                            String value)
Set value for a parameter specified by key

The parameters can be a hive variable or a configuration. To set key as a hive variable, the key should be prefixed with 'hivevar:'. To set key as configuration parameter, the key should be prefixed with 'hiveconf:' If no prefix is attached, the parameter is set as configuration.

Parameters:
sessionid - session handle object
key - parameter key
value - parameter value
Returns:
APIResult object indicating if set operation was successful


Copyright © 2014–2015 Apache Software Foundation. All rights reserved.