public class Server extends Object
Modifier and Type | Field and Description |
---|---|
static Pattern |
DDL_ID |
static String |
DO_AS_PARAM |
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 and Description |
---|
Server() |
Modifier and Type | Method and Description |
---|---|
javax.ws.rs.core.Response |
addOneColumn(String db,
String table,
String column,
ColumnDesc desc)
Create a column in an hcat table.
|
javax.ws.rs.core.Response |
addOnePartition(String db,
String table,
String partition,
PartitionDesc desc)
Create a partition in an hcat table.
|
javax.ws.rs.core.Response |
addOneTableProperty(String db,
String table,
String property,
TablePropertyDesc desc)
Add a single property on an hcat table.
|
CompleteBean |
completeJob(String jobid,
String jobStatus)
Notify on a completed job.
|
javax.ws.rs.core.Response |
createDatabase(String db,
DatabaseDesc desc)
Create a database
|
javax.ws.rs.core.Response |
createTable(String db,
String table,
TableDesc desc)
Create a new table.
|
javax.ws.rs.core.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 |
deleteJobId(String jobid)
Kill a job in the queue.
|
javax.ws.rs.core.Response |
descColumn(String db,
String table,
String column)
Describe a single column in an hcat table.
|
javax.ws.rs.core.Response |
descDatabase(String db,
String format)
Describe a database
|
javax.ws.rs.core.Response |
descOneTableProperty(String db,
String table,
String property)
Describe a single property on an hcat table.
|
javax.ws.rs.core.Response |
descPartition(String db,
String table,
String partition)
Describe a single partition in an hcat table.
|
javax.ws.rs.core.Response |
descTable(String db,
String table,
String format)
Describe an hcat table.
|
javax.ws.rs.core.Response |
dropDatabase(String db,
boolean ifExists,
String option,
String group,
String permissions)
Drop a database
|
javax.ws.rs.core.Response |
dropPartition(String db,
String table,
String partition,
boolean ifExists,
String group,
String permissions)
Drop a partition in an hcat table.
|
javax.ws.rs.core.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.
|
javax.ws.rs.core.Response |
hadoopVersion()
Get version of hadoop software being run by this WebHCat server
|
EnqueueBean |
hive(String execute,
String srcFile,
List<String> hiveArgs,
String otherFiles,
List<String> defines,
String statusdir,
String callback,
boolean enablelog,
Boolean enablejobreconnect)
Run a Hive job.
|
javax.ws.rs.core.Response |
hiveVersion()
Get version of hive software being run by this WebHCat server
|
javax.ws.rs.core.Response |
listColumns(String db,
String table)
List the columns in an hcat table.
|
javax.ws.rs.core.Response |
listDatabases(String dbPattern)
List all databases, or those that match a pattern.
|
javax.ws.rs.core.Response |
listPartitions(String db,
String table)
List all the partitions in an hcat table.
|
javax.ws.rs.core.Response |
listTableProperties(String db,
String table)
List all the properties on an hcat table.
|
javax.ws.rs.core.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,
boolean usesHcatalog,
boolean enablelog,
Boolean enablejobreconnect)
Run a MapReduce Jar job.
|
EnqueueBean |
mapReduceStreaming(List<String> inputs,
String inputreader,
String output,
String mapper,
String reducer,
String combiner,
List<String> fileList,
String files,
List<String> defines,
List<String> cmdenvs,
List<String> args,
String statusdir,
String callback,
boolean enablelog,
Boolean enablejobreconnect)
Run a MapReduce Streaming job.
|
EnqueueBean |
pig(String execute,
String srcFile,
List<String> pigArgs,
String otherFiles,
String statusdir,
String callback,
boolean usesHcatalog,
boolean enablelog,
Boolean enablejobreconnect)
Run a Pig job.
|
javax.ws.rs.core.Response |
pigVersion()
Get version of pig software being run by this WebHCat server
|
javax.ws.rs.core.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 |
showJobId(String jobid)
Return the status of the jobid.
|
List<JobItemBean> |
showJobList(String fields,
boolean showall,
String jobid,
String numrecords)
Return all the known job ids for this user based on the optional filter conditions.
|
EnqueueBean |
sqoop(String command,
String optionsFile,
String libdir,
String otherFiles,
String statusdir,
String callback,
boolean enablelog,
Boolean enablejobreconnect)
Run a Sqoop job.
|
javax.ws.rs.core.Response |
sqoopVersion()
Get version of sqoop software being run by this WebHCat server
|
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.
|
public static final String VERSION
public static final String DO_AS_PARAM
public static final Map<String,Object> SUPPORTED_VERSIONS
public static final Map<String,Object> SUPPORTED_FORMATS
protected static ExecService execService
public static final Pattern DDL_ID
public Map<String,Object> requestFormats()
public javax.ws.rs.core.Response hadoopVersion() throws IOException
IOException
public javax.ws.rs.core.Response hiveVersion() throws IOException
IOException
public javax.ws.rs.core.Response sqoopVersion() throws IOException
IOException
public javax.ws.rs.core.Response pigVersion() throws IOException
IOException
public ExecBean ddl(String exec, String group, String permissions) throws NotAuthorizedException, BusyException, BadParam, org.apache.commons.exec.ExecuteException, IOException
NotAuthorizedException
BusyException
BadParam
org.apache.commons.exec.ExecuteException
IOException
public javax.ws.rs.core.Response listTables(String db, String tablePattern) throws HcatException, NotAuthorizedException, BusyException, BadParam, org.apache.commons.exec.ExecuteException, IOException
HcatException
NotAuthorizedException
BusyException
BadParam
org.apache.commons.exec.ExecuteException
IOException
public javax.ws.rs.core.Response createTable(String db, String table, TableDesc desc) throws SimpleWebException, NotAuthorizedException, BusyException, BadParam, org.apache.commons.exec.ExecuteException, IOException
SimpleWebException
NotAuthorizedException
BusyException
BadParam
org.apache.commons.exec.ExecuteException
IOException
public javax.ws.rs.core.Response createTableLike(String db, String existingTable, String newTable, TableLikeDesc desc) throws SimpleWebException, NotAuthorizedException, BusyException, BadParam, org.apache.commons.exec.ExecuteException, IOException
SimpleWebException
NotAuthorizedException
BusyException
BadParam
org.apache.commons.exec.ExecuteException
IOException
public javax.ws.rs.core.Response descTable(String db, String table, String format) throws HcatException, NotAuthorizedException, BusyException, BadParam, org.apache.commons.exec.ExecuteException, IOException
HcatException
NotAuthorizedException
BusyException
BadParam
org.apache.commons.exec.ExecuteException
IOException
public javax.ws.rs.core.Response dropTable(String db, String table, boolean ifExists, String group, String permissions) throws HcatException, NotAuthorizedException, BusyException, BadParam, org.apache.commons.exec.ExecuteException, IOException
HcatException
NotAuthorizedException
BusyException
BadParam
org.apache.commons.exec.ExecuteException
IOException
public javax.ws.rs.core.Response renameTable(String db, String oldTable, String newTable, String group, String permissions) throws HcatException, NotAuthorizedException, BusyException, BadParam, org.apache.commons.exec.ExecuteException, IOException
HcatException
NotAuthorizedException
BusyException
BadParam
org.apache.commons.exec.ExecuteException
IOException
public javax.ws.rs.core.Response descOneTableProperty(String db, String table, String property) throws HcatException, NotAuthorizedException, BusyException, BadParam, org.apache.commons.exec.ExecuteException, IOException
HcatException
NotAuthorizedException
BusyException
BadParam
org.apache.commons.exec.ExecuteException
IOException
public javax.ws.rs.core.Response listTableProperties(String db, String table) throws HcatException, NotAuthorizedException, BusyException, BadParam, org.apache.commons.exec.ExecuteException, IOException
HcatException
NotAuthorizedException
BusyException
BadParam
org.apache.commons.exec.ExecuteException
IOException
public javax.ws.rs.core.Response addOneTableProperty(String db, String table, String property, TablePropertyDesc desc) throws HcatException, NotAuthorizedException, BusyException, BadParam, org.apache.commons.exec.ExecuteException, IOException
HcatException
NotAuthorizedException
BusyException
BadParam
org.apache.commons.exec.ExecuteException
IOException
public javax.ws.rs.core.Response listPartitions(String db, String table) throws HcatException, NotAuthorizedException, BusyException, BadParam, org.apache.commons.exec.ExecuteException, IOException
HcatException
NotAuthorizedException
BusyException
BadParam
org.apache.commons.exec.ExecuteException
IOException
public javax.ws.rs.core.Response descPartition(String db, String table, String partition) throws HcatException, NotAuthorizedException, BusyException, BadParam, org.apache.commons.exec.ExecuteException, IOException
HcatException
NotAuthorizedException
BusyException
BadParam
org.apache.commons.exec.ExecuteException
IOException
public javax.ws.rs.core.Response addOnePartition(String db, String table, String partition, PartitionDesc desc) throws HcatException, NotAuthorizedException, BusyException, BadParam, org.apache.commons.exec.ExecuteException, IOException
HcatException
NotAuthorizedException
BusyException
BadParam
org.apache.commons.exec.ExecuteException
IOException
public javax.ws.rs.core.Response dropPartition(String db, String table, String partition, boolean ifExists, String group, String permissions) throws HcatException, NotAuthorizedException, BusyException, BadParam, org.apache.commons.exec.ExecuteException, IOException
HcatException
NotAuthorizedException
BusyException
BadParam
org.apache.commons.exec.ExecuteException
IOException
public javax.ws.rs.core.Response listDatabases(String dbPattern) throws HcatException, NotAuthorizedException, BusyException, BadParam, org.apache.commons.exec.ExecuteException, IOException
HcatException
NotAuthorizedException
BusyException
BadParam
org.apache.commons.exec.ExecuteException
IOException
public javax.ws.rs.core.Response descDatabase(String db, String format) throws HcatException, NotAuthorizedException, BusyException, BadParam, org.apache.commons.exec.ExecuteException, IOException
HcatException
NotAuthorizedException
BusyException
BadParam
org.apache.commons.exec.ExecuteException
IOException
public javax.ws.rs.core.Response createDatabase(String db, DatabaseDesc desc) throws HcatException, NotAuthorizedException, BusyException, BadParam, org.apache.commons.exec.ExecuteException, IOException
HcatException
NotAuthorizedException
BusyException
BadParam
org.apache.commons.exec.ExecuteException
IOException
public javax.ws.rs.core.Response dropDatabase(String db, boolean ifExists, String option, String group, String permissions) throws HcatException, NotAuthorizedException, BusyException, BadParam, org.apache.commons.exec.ExecuteException, IOException
HcatException
NotAuthorizedException
BusyException
BadParam
org.apache.commons.exec.ExecuteException
IOException
public javax.ws.rs.core.Response listColumns(String db, String table) throws HcatException, NotAuthorizedException, BusyException, BadParam, org.apache.commons.exec.ExecuteException, IOException
HcatException
NotAuthorizedException
BusyException
BadParam
org.apache.commons.exec.ExecuteException
IOException
public javax.ws.rs.core.Response descColumn(String db, String table, String column) throws SimpleWebException, NotAuthorizedException, BusyException, BadParam, org.apache.commons.exec.ExecuteException, IOException
SimpleWebException
NotAuthorizedException
BusyException
BadParam
org.apache.commons.exec.ExecuteException
IOException
public javax.ws.rs.core.Response addOneColumn(String db, String table, String column, ColumnDesc desc) throws HcatException, NotAuthorizedException, BusyException, BadParam, org.apache.commons.exec.ExecuteException, IOException
HcatException
NotAuthorizedException
BusyException
BadParam
org.apache.commons.exec.ExecuteException
IOException
public EnqueueBean mapReduceStreaming(List<String> inputs, String inputreader, String output, String mapper, String reducer, String combiner, List<String> fileList, String files, List<String> defines, List<String> cmdenvs, List<String> args, String statusdir, String callback, boolean enablelog, Boolean enablejobreconnect) throws NotAuthorizedException, BusyException, BadParam, QueueException, org.apache.commons.exec.ExecuteException, IOException, InterruptedException
callback
- URL which WebHCat will call when the hive job finishesNotAuthorizedException
BusyException
BadParam
QueueException
org.apache.commons.exec.ExecuteException
IOException
InterruptedException
public EnqueueBean mapReduceJar(String jar, String mainClass, String libjars, String files, List<String> args, List<String> defines, String statusdir, String callback, boolean usesHcatalog, boolean enablelog, Boolean enablejobreconnect) throws NotAuthorizedException, BusyException, BadParam, QueueException, org.apache.commons.exec.ExecuteException, IOException, InterruptedException
usesHcatalog
- if true
, means the Jar uses HCat and thus needs to access
metastore, which requires additional steps for WebHCat to perform in a secure cluster.callback
- URL which WebHCat will call when the hive job finishesNotAuthorizedException
BusyException
BadParam
QueueException
org.apache.commons.exec.ExecuteException
IOException
InterruptedException
TempletonControllerJob
public EnqueueBean pig(String execute, String srcFile, List<String> pigArgs, String otherFiles, String statusdir, String callback, boolean usesHcatalog, boolean enablelog, Boolean enablejobreconnect) throws NotAuthorizedException, BusyException, BadParam, QueueException, org.apache.commons.exec.ExecuteException, IOException, InterruptedException
pigArgs, usesHcatalog
,
is interpreted as true.usesHcatalog
- if true
, means the Pig script uses HCat and thus needs to access
metastore, which requires additional steps for WebHCat to perform in a secure cluster.
This does nothing to ensure that Pig is installed on target node in the cluster.callback
- URL which WebHCat will call when the hive job finishesNotAuthorizedException
BusyException
BadParam
QueueException
org.apache.commons.exec.ExecuteException
IOException
InterruptedException
TempletonControllerJob
public EnqueueBean sqoop(String command, String optionsFile, String libdir, String otherFiles, String statusdir, String callback, boolean enablelog, Boolean enablejobreconnect) throws NotAuthorizedException, BusyException, BadParam, QueueException, IOException, InterruptedException
optionsFile
- name of option file which contains Sqoop command to runotherFiles
- additional files to be shipped to the launcher, such as option
files which contain part of the Sqoop commandlibdir
- dir containing JDBC jars that Sqoop will need to interact with the databasestatusdir
- where the stderr/stdout of templeton controller job goescallback
- URL which WebHCat will call when the sqoop job finishesenablelog
- whether to collect mapreduce log into statusdir/logsenablejobreconnect
- whether to reconnect to a running child job on templeton
controller job retryNotAuthorizedException
BusyException
BadParam
QueueException
IOException
InterruptedException
public EnqueueBean hive(String execute, String srcFile, List<String> hiveArgs, String otherFiles, List<String> defines, String statusdir, String callback, boolean enablelog, Boolean enablejobreconnect) throws NotAuthorizedException, BusyException, BadParam, QueueException, org.apache.commons.exec.ExecuteException, IOException, InterruptedException
execute
- SQL statement to run, equivalent to "-e" from hive command linesrcFile
- name of hive script file to run, equivalent to "-f" from hive
command linehiveArgs
- additional command line argument passed to the hive command line.
Please check https://cwiki.apache.org/Hive/languagemanual-cli.html
for detailed explanation of command line argumentsotherFiles
- additional files to be shipped to the launcher, such as the jars
used in "add jar" statement in hive scriptdefines
- shortcut for command line arguments "--define"statusdir
- where the stderr/stdout of templeton controller job goescallback
- URL which WebHCat will call when the hive job finishesenablelog
- whether to collect mapreduce log into statusdir/logsenablejobreconnect
- whether to reconnect to a running child job on templeton
controller job retryNotAuthorizedException
BusyException
BadParam
QueueException
org.apache.commons.exec.ExecuteException
IOException
InterruptedException
public QueueStatusBean showJobId(String jobid) throws NotAuthorizedException, BadParam, IOException, InterruptedException
public QueueStatusBean deleteJobId(String jobid) throws NotAuthorizedException, BadParam, IOException, InterruptedException
public List<JobItemBean> showJobList(String fields, boolean showall, String jobid, String numrecords) throws NotAuthorizedException, BadParam, IOException, InterruptedException
Example usages: 1. curl -s 'http://localhost:50111/templeton/v1/jobs?user.name=hsubramaniyan' Return all the Job IDs submitted by hsubramaniyan 2. curl -s 'http://localhost:50111/templeton/v1/jobs?user.name=hsubramaniyan&showall=true' Return all the Job IDs that are visible to hsubramaniyan 3. curl -s 'http://localhost:50111/templeton/v1/jobs?user.name=hsubramaniyan&jobid=job_201312091733_0003' Return all the Job IDs for hsubramaniyan after job_201312091733_0003. 4. curl -s 'http://localhost:50111/templeton/v1/jobs? user.name=hsubramaniyan&jobid=job_201312091733_0003&numrecords=5' Return the first 5(atmost) Job IDs submitted by hsubramaniyan after job_201312091733_0003. 5. curl -s 'http://localhost:50111/templeton/v1/jobs?user.name=hsubramaniyan&numrecords=5' Return the first 5(atmost) Job IDs submitted by hsubramaniyan after sorting the Job ID list lexicographically.
Supporting pagination using "jobid" and "numrecords" parameters: Step 1: Get the start "jobid" = job_xxx_000, "numrecords" = n Step 2: Issue a curl command by specifying the user-defined "numrecords" and "jobid" Step 3: If list obtained from Step 2 has size equal to "numrecords", retrieve the list's last record and get the Job Id of the last record as job_yyy_k, else quit. Step 4: set "jobid"=job_yyy_k and go to step 2.
fields
- If "fields" set to "*", the request will return full details of the job.
If "fields" is missing, will only return the job ID. Currently the value can only
be "*", other values are not allowed and will throw exception.showall
- If "showall" is set to "true", the request will return all jobs the user
has permission to view, not only the jobs belonging to the user.jobid
- If "jobid" is present, the records whose Job Id is lexicographically greater
than "jobid" are only returned. For example, if "jobid" = "job_201312091733_0001",
the jobs whose Job ID is greater than "job_201312091733_0001" are returned. The number of
records returned depends on the value of "numrecords".numrecords
- If the "jobid" and "numrecords" parameters are present, the top #numrecords
records appearing after "jobid" will be returned after sorting the Job Id list
lexicographically.
If "jobid" parameter is missing and "numrecords" is present, the top #numrecords will
be returned after lexicographically sorting the Job Id list. If "jobid" parameter is present
and "numrecords" is missing, all the records whose Job Id is greater than "jobid" are returned.NotAuthorizedException
BadParam
IOException
InterruptedException
public CompleteBean completeJob(String jobid, String jobStatus) throws CallbackFailedException, IOException
CallbackFailedException
IOException
public void verifyUser() throws NotAuthorizedException
NotAuthorizedException
public void verifyParam(String param, String name) throws BadParam
BadParam
public void verifyParam(List<String> param, String name) throws BadParam
BadParam
public void verifyDdlParam(String param, String name) throws BadParam
BadParam
public String getCompletedUrl()
Copyright © 2017 The Apache Software Foundation. All rights reserved.