public class TDClient extends Object implements TDClientApi<TDClient>
Modifier and Type | Field and Description |
---|---|
protected com.google.common.base.Optional<String> |
apiKeyCache |
protected TDClientConfig |
config |
protected TDHttpClient |
httpClient |
Modifier | Constructor and Description |
---|---|
|
TDClient(TDClientConfig config) |
protected |
TDClient(TDClientConfig config,
TDHttpClient httpClient,
com.google.common.base.Optional<String> apiKeyCache) |
Modifier and Type | Method and Description |
---|---|
TDClient |
authenticate(String email,
String password)
Perform user email and password based authentication and return a new client that will use apikey based authentication.
|
protected static String |
buildUrl(String urlPrefix,
String... args) |
void |
close() |
void |
commitBulkImportSession(String sessionName) |
void |
createBulkImportSession(String sessionName,
String databaseName,
String tableName) |
void |
createDatabase(String databaseName)
Create a new database
|
void |
createDatabaseIfNotExists(String databaseName) |
void |
createTable(String databaseName,
String tableName)
Create a new table
|
void |
createTableIfNotExists(String databaseName,
String tableName) |
void |
deleteBulkImportPart(String sessionName,
String uniquePartName) |
void |
deleteBulkImportSession(String sessionName) |
void |
deleteDatabase(String databaseName)
Delete a specified database.
|
void |
deleteDatabaseIfExists(String databaseName) |
void |
deleteTable(String databaseName,
String tableName) |
void |
deleteTableIfExists(String databaseName,
String tableName) |
protected <ResultType> |
doGet(String path,
Class<ResultType> resultTypeClass) |
protected String |
doPost(String path) |
protected <ResultType> |
doPost(String path,
Map<String,String> queryParam,
Class<ResultType> resultTypeClass) |
protected <ResultType> |
doPost(String path,
Map<String,String> queryParam,
com.google.common.base.Optional<String> jsonBody,
Class<ResultType> resultTypeClass) |
protected String |
doPut(String path,
File filePath) |
boolean |
existsDatabase(String databaseName) |
boolean |
existsTable(String databaseName,
String tableName) |
void |
freezeBulkImportSession(String sessionName) |
<Result> Result |
getBulkImportErrorRecords(String sessionName,
com.google.common.base.Function<InputStream,Result> resultStreamHandler) |
TDBulkImportSession |
getBulkImportSession(String sessionName) |
static String |
getVersion() |
TDJob |
jobInfo(String jobId) |
<Result> Result |
jobResult(String jobId,
TDResultFormat format,
com.google.common.base.Function<InputStream,Result> resultStreamHandler)
Open an input stream to retrieve the job result.
|
TDJobSummary |
jobStatus(String jobId) |
void |
killJob(String jobId) |
List<String> |
listBulkImportParts(String sessionName) |
List<TDBulkImportSession> |
listBulkImportSessions() |
List<String> |
listDatabaseNames()
Get the list of databases
|
List<TDDatabase> |
listDatabases()
Get the detailed information of databases
|
TDJobList |
listJobs() |
TDJobList |
listJobs(long fromJobId,
long toJobId) |
List<TDTable> |
listTables(String databaseName)
Get the list of the tables in the specified database
|
static TDClientBuilder |
newBuilder() |
static TDClientBuilder |
newBuilder(boolean loadTDConf) |
static TDClient |
newClient() |
TDPartialDeleteJob |
partialDelete(String databaseName,
String tableName,
long from,
long to) |
void |
performBulkImportSession(String sessionName) |
void |
performBulkImportSession(String sessionName,
TDJob.Priority priority) |
void |
renameTable(String databaseName,
String tableName,
String newTableName) |
void |
renameTable(String databaseName,
String tableName,
String newTableName,
boolean overwrite) |
String |
serverStatus() |
String |
startSavedQuery(String name,
Date scheduledTime)
Start a query saved on the cloud.
|
String |
submit(TDJobRequest jobRequest)
Submit a new job request
|
String |
submitExportJob(TDExportJobRequest jobRequest)
Start a table export job.
|
void |
swapTables(String databaseName,
String tableName1,
String tableName2) |
void |
unfreezeBulkImportSession(String sessionName) |
void |
updateTableSchema(String databaseName,
String tableName,
List<TDColumn> newSchema) |
void |
uploadBulkImportPart(String sessionName,
String uniquePartName,
File path) |
TDClient |
withApiKey(String newApiKey)
Create a new TDClient that uses the given api key for the authentication.
|
protected final TDClientConfig config
protected final TDHttpClient httpClient
protected final com.google.common.base.Optional<String> apiKeyCache
public TDClient(TDClientConfig config)
protected TDClient(TDClientConfig config, TDHttpClient httpClient, com.google.common.base.Optional<String> apiKeyCache)
public static String getVersion()
public static TDClient newClient()
public static TDClientBuilder newBuilder()
public static TDClientBuilder newBuilder(boolean loadTDConf)
public TDClient withApiKey(String newApiKey)
withApiKey
in interface TDClientApi<TDClient>
newApiKey
- public void close()
close
in interface AutoCloseable
protected <ResultType> ResultType doGet(String path, Class<ResultType> resultTypeClass) throws TDClientException
TDClientException
protected <ResultType> ResultType doPost(String path, Map<String,String> queryParam, com.google.common.base.Optional<String> jsonBody, Class<ResultType> resultTypeClass) throws TDClientException
TDClientException
protected <ResultType> ResultType doPost(String path, Map<String,String> queryParam, Class<ResultType> resultTypeClass) throws TDClientException
TDClientException
protected String doPost(String path) throws TDClientException
TDClientException
protected String doPut(String path, File filePath) throws TDClientException
TDClientException
public TDClient authenticate(String email, String password)
TDClientApi
TDClientApi.withApiKey(String)
method, closing the returned client will invalidate the current instance.authenticate
in interface TDClientApi<TDClient>
public String serverStatus()
serverStatus
in interface TDClientApi<TDClient>
public List<String> listDatabaseNames() throws TDClientException
TDClientApi
listDatabaseNames
in interface TDClientApi<TDClient>
TDClientException
- if failed to retrieve the database listpublic List<TDDatabase> listDatabases() throws TDClientException
TDClientApi
listDatabases
in interface TDClientApi<TDClient>
TDClientException
- if failed to retrieve the database list.public void createDatabase(String databaseName) throws TDClientException
TDClientApi
createDatabase
in interface TDClientApi<TDClient>
TDClientException
- if the specified database already existspublic void createDatabaseIfNotExists(String databaseName) throws TDClientException
createDatabaseIfNotExists
in interface TDClientApi<TDClient>
TDClientException
public void deleteDatabase(String databaseName) throws TDClientException
TDClientApi
deleteDatabase
in interface TDClientApi<TDClient>
TDClientException
- if no such a database existspublic void deleteDatabaseIfExists(String databaseName) throws TDClientException
deleteDatabaseIfExists
in interface TDClientApi<TDClient>
TDClientException
public List<TDTable> listTables(String databaseName) throws TDClientException
TDClientApi
listTables
in interface TDClientApi<TDClient>
TDClientException
public boolean existsDatabase(String databaseName) throws TDClientException
existsDatabase
in interface TDClientApi<TDClient>
TDClientException
public boolean existsTable(String databaseName, String tableName) throws TDClientException
existsTable
in interface TDClientApi<TDClient>
TDClientException
public void createTable(String databaseName, String tableName) throws TDClientException
TDClientApi
createTable
in interface TDClientApi<TDClient>
TDClientException
public void createTableIfNotExists(String databaseName, String tableName) throws TDClientException
createTableIfNotExists
in interface TDClientApi<TDClient>
TDClientException
public void renameTable(String databaseName, String tableName, String newTableName) throws TDClientException
renameTable
in interface TDClientApi<TDClient>
TDClientException
public void renameTable(String databaseName, String tableName, String newTableName, boolean overwrite) throws TDClientException
renameTable
in interface TDClientApi<TDClient>
TDClientException
public void deleteTable(String databaseName, String tableName) throws TDClientException
deleteTable
in interface TDClientApi<TDClient>
TDClientException
public void deleteTableIfExists(String databaseName, String tableName) throws TDClientException
deleteTableIfExists
in interface TDClientApi<TDClient>
TDClientException
public TDPartialDeleteJob partialDelete(String databaseName, String tableName, long from, long to) throws TDClientException
partialDelete
in interface TDClientApi<TDClient>
TDClientException
public void swapTables(String databaseName, String tableName1, String tableName2)
swapTables
in interface TDClientApi<TDClient>
public void updateTableSchema(String databaseName, String tableName, List<TDColumn> newSchema)
updateTableSchema
in interface TDClientApi<TDClient>
public String submit(TDJobRequest jobRequest) throws TDClientException
TDClientApi
submit
in interface TDClientApi<TDClient>
TDClientException
public TDJobList listJobs() throws TDClientException
listJobs
in interface TDClientApi<TDClient>
TDClientException
public TDJobList listJobs(long fromJobId, long toJobId) throws TDClientException
listJobs
in interface TDClientApi<TDClient>
TDClientException
public void killJob(String jobId) throws TDClientException
killJob
in interface TDClientApi<TDClient>
TDClientException
public TDJobSummary jobStatus(String jobId) throws TDClientException
jobStatus
in interface TDClientApi<TDClient>
TDClientException
public TDJob jobInfo(String jobId) throws TDClientException
jobInfo
in interface TDClientApi<TDClient>
TDClientException
public <Result> Result jobResult(String jobId, TDResultFormat format, com.google.common.base.Function<InputStream,Result> resultStreamHandler) throws TDClientException
TDClientApi
jobResult
in interface TDClientApi<TDClient>
TDClientException
public List<TDBulkImportSession> listBulkImportSessions()
listBulkImportSessions
in interface TDClientApi<TDClient>
public List<String> listBulkImportParts(String sessionName)
listBulkImportParts
in interface TDClientApi<TDClient>
public void createBulkImportSession(String sessionName, String databaseName, String tableName)
createBulkImportSession
in interface TDClientApi<TDClient>
public TDBulkImportSession getBulkImportSession(String sessionName)
getBulkImportSession
in interface TDClientApi<TDClient>
public void uploadBulkImportPart(String sessionName, String uniquePartName, File path)
uploadBulkImportPart
in interface TDClientApi<TDClient>
public void freezeBulkImportSession(String sessionName)
freezeBulkImportSession
in interface TDClientApi<TDClient>
public void unfreezeBulkImportSession(String sessionName)
unfreezeBulkImportSession
in interface TDClientApi<TDClient>
public void performBulkImportSession(String sessionName)
performBulkImportSession
in interface TDClientApi<TDClient>
public void performBulkImportSession(String sessionName, TDJob.Priority priority)
performBulkImportSession
in interface TDClientApi<TDClient>
public void commitBulkImportSession(String sessionName)
commitBulkImportSession
in interface TDClientApi<TDClient>
public void deleteBulkImportSession(String sessionName)
deleteBulkImportSession
in interface TDClientApi<TDClient>
public <Result> Result getBulkImportErrorRecords(String sessionName, com.google.common.base.Function<InputStream,Result> resultStreamHandler)
getBulkImportErrorRecords
in interface TDClientApi<TDClient>
public String startSavedQuery(String name, Date scheduledTime)
TDClientApi
startSavedQuery
in interface TDClientApi<TDClient>
name
- name of the saved queryscheduledTime
- the return time of TD_SCHEDULED_TIMEpublic String submitExportJob(TDExportJobRequest jobRequest) throws TDClientException
TDClientApi
submitExportJob
in interface TDClientApi<TDClient>
TDClientException
Copyright © 2016. All rights reserved.