org.apache.hcatalog.templeton
Class Server

Object
  extended by Server

public class Server
extends Object

The Templeton Web API server.


Field Summary
static Pattern DDL_ID
           
protected static ExecService execService
           
static Map<String,String> STATUS_OK
          The status message.
static Map<String,Object> SUPPORTED_FORMATS
          The list of supported return formats.
static Map<String,Object> SUPPORTED_VERSIONS
          The list of supported api versions.
static String VERSION
           
 
Constructor Summary
Server()
           
 
Method Summary
 Response addOneColumn(String db, String table, String column, ColumnDesc desc)
          Create a column in an hcat table.
 Response addOnePartition(String db, String table, String partition, PartitionDesc desc)
          Create a partition in an hcat table.
 Response addOneTableProperty(String db, String table, String property, TablePropertyDesc desc)
          Add a single property on an hcat table.
 CompleteBean completeJob(String jobid)
          Notify on a completed job.
 Response createDatabase(String db, DatabaseDesc desc)
          Create a database
 Response createTable(String db, String table, TableDesc desc)
          Create a new table.
 Response createTableLike(String db, String existingTable, String newTable, TableLikeDesc desc)
          Create a new table like another table.
 ExecBean ddl(String exec, String group, String permissions)
          Execute an hcat ddl expression on the local box.
 QueueStatusBean deleteQueueId(String jobid)
          Kill a job in the queue.
 Response descColumn(String db, String table, String column)
          Describe a single column in an hcat table.
 Response descDatabase(String db, String format)
          Describe a database
 Response descOneTableProperty(String db, String table, String property)
          Describe a single property on an hcat table.
 Response descPartition(String db, String table, String partition)
          Describe a single partition in an hcat table.
 Response descTable(String db, String table, String format)
          Describe an hcat table.
 Response dropDatabase(String db, boolean ifExists, String option, String group, String permissions)
          Drop a database
 Response dropPartition(String db, String table, String partition, boolean ifExists, String group, String permissions)
          Drop a partition in an hcat table.
 Response dropTable(String db, String table, boolean ifExists, String group, String permissions)
          Drop an hcat table.
 String getCompletedUrl()
          The callback url on this server when a task is completed.
 String getUser()
          Get the user name from the security context.
 EnqueueBean hive(String execute, String srcFile, List<String> defines, String statusdir, String callback)
          Run a Hive job.
 Response listColumns(String db, String table)
          List the columns in an hcat table.
 Response listDatabases(String dbPattern)
          List all databases, or those that match a pattern.
 Response listPartitions(String db, String table)
          List all the partitions in an hcat table.
 Response listTableProperties(String db, String table)
          List all the properties on an hcat table.
 Response listTables(String db, String tablePattern)
          List all the tables in an hcat database.
 EnqueueBean mapReduceJar(String jar, String mainClass, String libjars, String files, List<String> args, List<String> defines, String statusdir, String callback)
          Run a MapReduce Jar job.
 EnqueueBean mapReduceStreaming(List<String> inputs, String output, String mapper, String reducer, List<String> files, List<String> defines, List<String> cmdenvs, List<String> args, String statusdir, String callback)
          Run a MapReduce Streaming job.
 EnqueueBean pig(String execute, String srcFile, List<String> pigArgs, String otherFiles, String statusdir, String callback)
          Run a Pig job.
 Response renameTable(String db, String oldTable, String newTable, String group, String permissions)
          Rename an hcat table.
 Map<String,Object> requestFormats()
          Check the supported request formats of this server.
 QueueStatusBean showQueueId(String jobid)
          Return the status of the jobid.
 List<String> showQueueList()
          Return all the known job ids for this user.
 Map<String,String> status()
          Check the status of this server.
 void verifyDdlParam(String param, String name)
          Verify that the parameter exists and is a simple DDL identifier name.
 void verifyParam(List<String> param, String name)
          Verify that the parameter exists.
 void verifyParam(String param, String name)
          Verify that the parameter exists.
 void verifyUser()
          Verify that we have a valid user.
 Map<String,Object> version()
          Check the version(s) supported by this server.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION

public static final String VERSION
See Also:
Constant Field Values

STATUS_OK

public static final Map<String,String> STATUS_OK
The status message. Always "ok"


SUPPORTED_VERSIONS

public static final Map<String,Object> SUPPORTED_VERSIONS
The list of supported api versions.


SUPPORTED_FORMATS

public static final Map<String,Object> SUPPORTED_FORMATS
The list of supported return formats. Always json.


execService

protected static ExecService execService

DDL_ID

public static final Pattern DDL_ID
Constructor Detail

Server

public Server()
Method Detail

status

public Map<String,String> status()
Check the status of this server. Always OK.


requestFormats

public Map<String,Object> requestFormats()
Check the supported request formats of this server.


version

public Map<String,Object> version()
Check the version(s) supported by this server.


ddl

public ExecBean ddl(String exec,
                    String group,
                    String permissions)
             throws NotAuthorizedException,
                    BusyException,
                    BadParam,
                    ExecuteException,
                    IOException
Execute an hcat ddl expression on the local box. It is run as the authenticated user and rate limited.

Throws:
NotAuthorizedException
BusyException
BadParam
ExecuteException
IOException

listTables

public Response listTables(String db,
                           String tablePattern)
                    throws HcatException,
                           NotAuthorizedException,
                           BusyException,
                           BadParam,
                           ExecuteException,
                           IOException
List all the tables in an hcat database.

Throws:
HcatException
NotAuthorizedException
BusyException
BadParam
ExecuteException
IOException

createTable

public Response createTable(String db,
                            String table,
                            TableDesc desc)
                     throws SimpleWebException,
                            NotAuthorizedException,
                            BusyException,
                            BadParam,
                            ExecuteException,
                            IOException
Create a new table.

Throws:
SimpleWebException
NotAuthorizedException
BusyException
BadParam
ExecuteException
IOException

createTableLike

public Response createTableLike(String db,
                                String existingTable,
                                String newTable,
                                TableLikeDesc desc)
                         throws SimpleWebException,
                                NotAuthorizedException,
                                BusyException,
                                BadParam,
                                ExecuteException,
                                IOException
Create a new table like another table.

Throws:
SimpleWebException
NotAuthorizedException
BusyException
BadParam
ExecuteException
IOException

descTable

public Response descTable(String db,
                          String table,
                          String format)
                   throws HcatException,
                          NotAuthorizedException,
                          BusyException,
                          BadParam,
                          ExecuteException,
                          IOException
Describe an hcat table. This is normally a simple list of columns (using "desc table"), but the extended format will show more information (using "show table extended like").

Throws:
HcatException
NotAuthorizedException
BusyException
BadParam
ExecuteException
IOException

dropTable

public Response dropTable(String db,
                          String table,
                          boolean ifExists,
                          String group,
                          String permissions)
                   throws HcatException,
                          NotAuthorizedException,
                          BusyException,
                          BadParam,
                          ExecuteException,
                          IOException
Drop an hcat table.

Throws:
HcatException
NotAuthorizedException
BusyException
BadParam
ExecuteException
IOException

renameTable

public Response renameTable(String db,
                            String oldTable,
                            String newTable,
                            String group,
                            String permissions)
                     throws HcatException,
                            NotAuthorizedException,
                            BusyException,
                            BadParam,
                            ExecuteException,
                            IOException
Rename an hcat table.

Throws:
HcatException
NotAuthorizedException
BusyException
BadParam
ExecuteException
IOException

descOneTableProperty

public Response descOneTableProperty(String db,
                                     String table,
                                     String property)
                              throws HcatException,
                                     NotAuthorizedException,
                                     BusyException,
                                     BadParam,
                                     ExecuteException,
                                     IOException
Describe a single property on an hcat table.

Throws:
HcatException
NotAuthorizedException
BusyException
BadParam
ExecuteException
IOException

listTableProperties

public Response listTableProperties(String db,
                                    String table)
                             throws HcatException,
                                    NotAuthorizedException,
                                    BusyException,
                                    BadParam,
                                    ExecuteException,
                                    IOException
List all the properties on an hcat table.

Throws:
HcatException
NotAuthorizedException
BusyException
BadParam
ExecuteException
IOException

addOneTableProperty

public Response addOneTableProperty(String db,
                                    String table,
                                    String property,
                                    TablePropertyDesc desc)
                             throws HcatException,
                                    NotAuthorizedException,
                                    BusyException,
                                    BadParam,
                                    ExecuteException,
                                    IOException
Add a single property on an hcat table.

Throws:
HcatException
NotAuthorizedException
BusyException
BadParam
ExecuteException
IOException

listPartitions

public Response listPartitions(String db,
                               String table)
                        throws HcatException,
                               NotAuthorizedException,
                               BusyException,
                               BadParam,
                               ExecuteException,
                               IOException
List all the partitions in an hcat table.

Throws:
HcatException
NotAuthorizedException
BusyException
BadParam
ExecuteException
IOException

descPartition

public Response descPartition(String db,
                              String table,
                              String partition)
                       throws HcatException,
                              NotAuthorizedException,
                              BusyException,
                              BadParam,
                              ExecuteException,
                              IOException
Describe a single partition in an hcat table.

Throws:
HcatException
NotAuthorizedException
BusyException
BadParam
ExecuteException
IOException

addOnePartition

public Response addOnePartition(String db,
                                String table,
                                String partition,
                                PartitionDesc desc)
                         throws HcatException,
                                NotAuthorizedException,
                                BusyException,
                                BadParam,
                                ExecuteException,
                                IOException
Create a partition in an hcat table.

Throws:
HcatException
NotAuthorizedException
BusyException
BadParam
ExecuteException
IOException

dropPartition

public Response dropPartition(String db,
                              String table,
                              String partition,
                              boolean ifExists,
                              String group,
                              String permissions)
                       throws HcatException,
                              NotAuthorizedException,
                              BusyException,
                              BadParam,
                              ExecuteException,
                              IOException
Drop a partition in an hcat table.

Throws:
HcatException
NotAuthorizedException
BusyException
BadParam
ExecuteException
IOException

listDatabases

public Response listDatabases(String dbPattern)
                       throws HcatException,
                              NotAuthorizedException,
                              BusyException,
                              BadParam,
                              ExecuteException,
                              IOException
List all databases, or those that match a pattern.

Throws:
HcatException
NotAuthorizedException
BusyException
BadParam
ExecuteException
IOException

descDatabase

public Response descDatabase(String db,
                             String format)
                      throws HcatException,
                             NotAuthorizedException,
                             BusyException,
                             BadParam,
                             ExecuteException,
                             IOException
Describe a database

Throws:
HcatException
NotAuthorizedException
BusyException
BadParam
ExecuteException
IOException

createDatabase

public Response createDatabase(String db,
                               DatabaseDesc desc)
                        throws HcatException,
                               NotAuthorizedException,
                               BusyException,
                               BadParam,
                               ExecuteException,
                               IOException
Create a database

Throws:
HcatException
NotAuthorizedException
BusyException
BadParam
ExecuteException
IOException

dropDatabase

public Response dropDatabase(String db,
                             boolean ifExists,
                             String option,
                             String group,
                             String permissions)
                      throws HcatException,
                             NotAuthorizedException,
                             BusyException,
                             BadParam,
                             ExecuteException,
                             IOException
Drop a database

Throws:
HcatException
NotAuthorizedException
BusyException
BadParam
ExecuteException
IOException

listColumns

public Response listColumns(String db,
                            String table)
                     throws HcatException,
                            NotAuthorizedException,
                            BusyException,
                            BadParam,
                            ExecuteException,
                            IOException
List the columns in an hcat table. Currently the same as describe table.

Throws:
HcatException
NotAuthorizedException
BusyException
BadParam
ExecuteException
IOException

descColumn

public Response descColumn(String db,
                           String table,
                           String column)
                    throws SimpleWebException,
                           NotAuthorizedException,
                           BusyException,
                           BadParam,
                           ExecuteException,
                           IOException
Describe a single column in an hcat table.

Throws:
SimpleWebException
NotAuthorizedException
BusyException
BadParam
ExecuteException
IOException

addOneColumn

public Response addOneColumn(String db,
                             String table,
                             String column,
                             ColumnDesc desc)
                      throws HcatException,
                             NotAuthorizedException,
                             BusyException,
                             BadParam,
                             ExecuteException,
                             IOException
Create a column in an hcat table.

Throws:
HcatException
NotAuthorizedException
BusyException
BadParam
ExecuteException
IOException

mapReduceStreaming

public EnqueueBean mapReduceStreaming(List<String> inputs,
                                      String output,
                                      String mapper,
                                      String reducer,
                                      List<String> files,
                                      List<String> defines,
                                      List<String> cmdenvs,
                                      List<String> args,
                                      String statusdir,
                                      String callback)
                               throws NotAuthorizedException,
                                      BusyException,
                                      BadParam,
                                      QueueException,
                                      ExecuteException,
                                      IOException,
                                      InterruptedException
Run a MapReduce Streaming job.

Throws:
NotAuthorizedException
BusyException
BadParam
QueueException
ExecuteException
IOException
InterruptedException

mapReduceJar

public EnqueueBean mapReduceJar(String jar,
                                String mainClass,
                                String libjars,
                                String files,
                                List<String> args,
                                List<String> defines,
                                String statusdir,
                                String callback)
                         throws NotAuthorizedException,
                                BusyException,
                                BadParam,
                                QueueException,
                                ExecuteException,
                                IOException,
                                InterruptedException
Run a MapReduce Jar job.

Throws:
NotAuthorizedException
BusyException
BadParam
QueueException
ExecuteException
IOException
InterruptedException

pig

public EnqueueBean pig(String execute,
                       String srcFile,
                       List<String> pigArgs,
                       String otherFiles,
                       String statusdir,
                       String callback)
                throws NotAuthorizedException,
                       BusyException,
                       BadParam,
                       QueueException,
                       ExecuteException,
                       IOException,
                       InterruptedException
Run a Pig job.

Throws:
NotAuthorizedException
BusyException
BadParam
QueueException
ExecuteException
IOException
InterruptedException

hive

public EnqueueBean hive(String execute,
                        String srcFile,
                        List<String> defines,
                        String statusdir,
                        String callback)
                 throws NotAuthorizedException,
                        BusyException,
                        BadParam,
                        QueueException,
                        ExecuteException,
                        IOException,
                        InterruptedException
Run a Hive job.

Throws:
NotAuthorizedException
BusyException
BadParam
QueueException
ExecuteException
IOException
InterruptedException

showQueueId

public QueueStatusBean showQueueId(String jobid)
                            throws NotAuthorizedException,
                                   BadParam,
                                   IOException,
                                   InterruptedException
Return the status of the jobid.

Throws:
NotAuthorizedException
BadParam
IOException
InterruptedException

deleteQueueId

public QueueStatusBean deleteQueueId(String jobid)
                              throws NotAuthorizedException,
                                     BadParam,
                                     IOException,
                                     InterruptedException
Kill a job in the queue.

Throws:
NotAuthorizedException
BadParam
IOException
InterruptedException

showQueueList

public List<String> showQueueList()
                           throws NotAuthorizedException,
                                  BadParam,
                                  IOException,
                                  InterruptedException
Return all the known job ids for this user.

Throws:
NotAuthorizedException
BadParam
IOException
InterruptedException

completeJob

public CompleteBean completeJob(String jobid)
                         throws CallbackFailedException,
                                IOException
Notify on a completed job.

Throws:
CallbackFailedException
IOException

verifyUser

public void verifyUser()
                throws NotAuthorizedException
Verify that we have a valid user. Throw an exception if invalid.

Throws:
NotAuthorizedException

verifyParam

public void verifyParam(String param,
                        String name)
                 throws BadParam
Verify that the parameter exists. Throw an exception if invalid.

Throws:
BadParam

verifyParam

public void verifyParam(List<String> param,
                        String name)
                 throws BadParam
Verify that the parameter exists. Throw an exception if invalid.

Throws:
BadParam

verifyDdlParam

public void verifyDdlParam(String param,
                           String name)
                    throws BadParam
Verify that the parameter exists and is a simple DDL identifier name. Throw an exception if invalid. Bug: This needs to allow for quoted ddl identifiers.

Throws:
BadParam

getUser

public String getUser()
Get the user name from the security context.


getCompletedUrl

public String getCompletedUrl()
The callback url on this server when a task is completed.