public class Sequoiadb extends Object implements Closeable
限定符和类型 | 类和说明 |
---|---|
static class |
Sequoiadb.SptEvalResult
Class for executing stored procedure result.
|
static class |
Sequoiadb.SptReturnType |
限定符和类型 | 字段和说明 |
---|---|
static String |
CATALOG_GROUP_NAME |
static int |
FMP_FUNC_TYPE_C |
static int |
FMP_FUNC_TYPE_INVALID |
static int |
FMP_FUNC_TYPE_JAVA |
static int |
FMP_FUNC_TYPE_JS |
static int |
SDB_LIST_CL_IN_DOMAIN |
static int |
SDB_LIST_COLLECTIONS |
static int |
SDB_LIST_COLLECTIONSPACES |
static int |
SDB_LIST_CONTEXTS |
static int |
SDB_LIST_CONTEXTS_CURRENT |
static int |
SDB_LIST_CS_IN_DOMAIN |
static int |
SDB_LIST_DOMAINS |
static int |
SDB_LIST_GROUPS |
static int |
SDB_LIST_SESSIONS |
static int |
SDB_LIST_SESSIONS_CURRENT |
static int |
SDB_LIST_STORAGEUNITS |
static int |
SDB_LIST_STOREPROCEDURES |
static int |
SDB_LIST_TASKS |
static int |
SDB_LIST_TRANSACTIONS |
static int |
SDB_LIST_TRANSACTIONS_CURRENT |
static int |
SDB_PAGESIZE_16K
specified the package size of the collections in current collection space to be 16K
|
static int |
SDB_PAGESIZE_32K
specified the package size of the collections in current collection space to be 32K
|
static int |
SDB_PAGESIZE_4K
specified the package size of the collections in current collection space to be 4K
|
static int |
SDB_PAGESIZE_64K
specified the package size of the collections in current collection space to be 64K
|
static int |
SDB_PAGESIZE_8K
specified the package size of the collections in current collection space to be 8K
|
static int |
SDB_PAGESIZE_DEFAULT
0 means using database's default pagesize, it 64k now
|
static int |
SDB_SNAP_ACCESSPLANS |
static int |
SDB_SNAP_CATALOG |
static int |
SDB_SNAP_COLLECTIONS |
static int |
SDB_SNAP_COLLECTIONSPACES |
static int |
SDB_SNAP_CONFIGS |
static int |
SDB_SNAP_CONTEXTS |
static int |
SDB_SNAP_CONTEXTS_CURRENT |
static int |
SDB_SNAP_DATABASE |
static int |
SDB_SNAP_HEALTH |
static int |
SDB_SNAP_SESSIONS |
static int |
SDB_SNAP_SESSIONS_CURRENT |
static int |
SDB_SNAP_SYSTEM |
static int |
SDB_SNAP_TRANSACTIONS |
static int |
SDB_SNAP_TRANSACTIONS_CURRENT |
构造器和说明 |
---|
Sequoiadb(List<String> connStrings,
String username,
String password,
ConfigOptions options)
Use a random valid address to connect to database.
|
Sequoiadb(String host,
int port,
String username,
String password) |
Sequoiadb(String host,
int port,
String username,
String password,
ConfigOptions options) |
Sequoiadb(String connString,
String username,
String password) |
Sequoiadb(String connString,
String username,
String password,
ConfigOptions options) |
限定符和类型 | 方法和说明 |
---|---|
void |
activateReplicaGroup(String rgName)
Active replica group by name.
|
void |
analyze()
Analyze all collections and indexes to collect statistics information
|
void |
analyze(BSONObject options)
Analyze collection or index to collect statistics information
|
void |
backupOffline(BSONObject options)
Backup the whole database or specified replica group.
|
void |
beginTransaction()
Begin the transaction.
|
void |
cancelTask(long taskID,
boolean isAsync)
Cancel the specified task.
|
void |
close()
Close the connection.
|
void |
closeAllCursors()
Close all the cursors created in current connection, we can't use those cursors to get
data again.
|
void |
commit()
Commit the transaction.
|
CollectionSpace |
createCollectionSpace(String csName)
Create the named collection space with default SDB_PAGESIZE_64K.
|
CollectionSpace |
createCollectionSpace(String csName,
BSONObject options)
Create collection space.
|
CollectionSpace |
createCollectionSpace(String csName,
int pageSize)
Create collection space.
|
Domain |
createDomain(String domainName,
BSONObject options)
Create a domain.
|
void |
createReplicaCataGroup(String hostName,
int port,
String dbPath,
BSONObject options)
Create the replica Catalog group with the given options.
|
ReplicaGroup |
createReplicaGroup(String rgName)
Create replica group by name.
|
void |
createUser(String username,
String password)
Create an user in current database.
|
void |
crtJSProcedure(String code)
Create a storage procedure.
|
void |
deleteConfig(BSONObject configs,
BSONObject options)
Force the node to delete configs online.
|
void |
dropCollectionSpace(String csName)
Remove the named collection space.
|
void |
dropDomain(String domainName)
Drop a domain.
|
Sequoiadb.SptEvalResult |
evalJS(String code)
Eval javascript code.
|
DBCursor |
exec(String sql)
Execute sql in database.
|
void |
execUpdate(String sql)
Execute sql in database.
|
void |
flushConfigure(BSONObject options)
Flush the options to configuration file.
|
ByteOrder |
getByteOrder() |
ArrayList<String> |
getCollectionNames()
Get all the collection names.
|
CollectionSpace |
getCollectionSpace(String csName)
Get the named collection space.
|
ArrayList<String> |
getCollectionSpaceNames()
Get all the collection space names.
|
Domain |
getDomain(String domainName)
Get the specified domain.
|
String |
getHost() |
String |
getIP() |
long |
getLastUseTime() |
DBCursor |
getList(int listType,
BSONObject query,
BSONObject selector,
BSONObject orderBy)
Get the information of specified type.
|
String |
getNodeName() |
int |
getPort() |
ReplicaGroup |
getReplicaGroup(int rgId)
Get replica group by id.
|
ReplicaGroup |
getReplicaGroup(String rgName)
Get replica group by name.
|
ArrayList<String> |
getReplicaGroupNames()
Get all the replica groups' name.
|
ArrayList<String> |
getReplicaGroupsInfo()
Get the information of the replica groups.
|
BSONObject |
getSessionAttr()
Get the attributes of the current session.
|
DBCursor |
getSnapshot(int snapType,
BSONObject matcher,
BSONObject selector,
BSONObject orderBy)
Get snapshot of the database.
|
DBCursor |
getSnapshot(int snapType,
BSONObject matcher,
BSONObject selector,
BSONObject orderBy,
BSONObject hint,
long skipRows,
long returnRows)
Get snapshot of the database.
|
DBCursor |
getSnapshot(int snapType,
String matcher,
String selector,
String orderBy)
Get snapshot of the database.
|
ArrayList<String> |
getStorageUnits()
Get all the storage units.
|
static void |
initClient(ClientOptions options)
Initialize the configuration options for client.
|
void |
invalidateCache(BSONObject options)
Clear the cache of the nodes (data/coord node).
|
boolean |
isClosed()
Whether the connection has been closed or not.
|
boolean |
isCollectionSpaceExist(String csName)
Verify the existence of collection space.
|
boolean |
isDomainExist(String domainName)
Verify the existence of domain.
|
boolean |
isRelicaGroupExist(String rgName)
whether the replica group exists in the database or not
|
boolean |
isReplicaGroupExist(int rgId)
whether the replica group exists in the database or not
|
boolean |
isValid()
Send a test message to database to test whether the connection is valid or not.
|
DBCursor |
listBackup(BSONObject options,
BSONObject matcher,
BSONObject selector,
BSONObject orderBy)
List the backups.
|
DBCursor |
listCollections()
Get all the collections.
|
DBCursor |
listCollectionSpaces()
Get all the collection spaces.
|
DBCursor |
listDomains(BSONObject matcher,
BSONObject selector,
BSONObject orderBy,
BSONObject hint)
List domains.
|
DBCursor |
listProcedures(BSONObject condition)
List the storage procedures.
|
DBCursor |
listReplicaGroups()
List all the replica group.
|
DBCursor |
listTasks(BSONObject matcher,
BSONObject selector,
BSONObject orderBy,
BSONObject hint)
List the tasks.
|
void |
loadCollectionSpace(String csName,
BSONObject options) |
void |
msg(String message)
Send message to server.
|
void |
releaseResource()
Release the resource of the connection.
|
void |
removeBackup(BSONObject options)
Remove the backups.
|
void |
removeReplicaGroup(String rgName)
Remove replica group by name.
|
void |
removeUser(String username,
String password)
Remove the specified user from current database.
|
void |
renameCollectionSpace(String oldName,
String newName) |
void |
resetSnapshot()
Reset the snapshot.
|
void |
resetSnapshot(BSONObject options)
Reset the snapshot.
|
void |
rmProcedure(String name)
Remove a store procedure.
|
void |
rollback()
Rollback the transaction.
|
void |
setSessionAttr(BSONObject options)
Set the attributes of the current session.
|
void |
sync()
Sync the whole database to disk.
|
void |
sync(BSONObject options)
Sync the database to disk.
|
String |
toString() |
void |
unloadCollectionSpace(String csName,
BSONObject options) |
void |
updateConfig(BSONObject configs,
BSONObject options)
Force the node to update configs online.
|
void |
waitTasks(long[] taskIDs)
Wait the tasks to finish.
|
public static final int FMP_FUNC_TYPE_C
public static final int FMP_FUNC_TYPE_INVALID
public static final int FMP_FUNC_TYPE_JAVA
public static final int FMP_FUNC_TYPE_JS
public static final int SDB_LIST_CL_IN_DOMAIN
public static final int SDB_LIST_COLLECTIONS
public static final int SDB_LIST_COLLECTIONSPACES
public static final int SDB_LIST_CONTEXTS
public static final int SDB_LIST_CONTEXTS_CURRENT
public static final int SDB_LIST_CS_IN_DOMAIN
public static final int SDB_LIST_DOMAINS
public static final int SDB_LIST_GROUPS
public static final int SDB_LIST_SESSIONS
public static final int SDB_LIST_SESSIONS_CURRENT
public static final int SDB_LIST_STORAGEUNITS
public static final int SDB_LIST_STOREPROCEDURES
public static final int SDB_LIST_TASKS
public static final int SDB_LIST_TRANSACTIONS
public static final int SDB_LIST_TRANSACTIONS_CURRENT
public static final int SDB_PAGESIZE_16K
public static final int SDB_PAGESIZE_32K
public static final int SDB_PAGESIZE_4K
public static final int SDB_PAGESIZE_64K
public static final int SDB_PAGESIZE_8K
public static final int SDB_PAGESIZE_DEFAULT
public static final int SDB_SNAP_ACCESSPLANS
public static final int SDB_SNAP_CATALOG
public static final int SDB_SNAP_COLLECTIONS
public static final int SDB_SNAP_COLLECTIONSPACES
public static final int SDB_SNAP_CONFIGS
public static final int SDB_SNAP_CONTEXTS
public static final int SDB_SNAP_CONTEXTS_CURRENT
public static final int SDB_SNAP_DATABASE
public static final int SDB_SNAP_HEALTH
public static final int SDB_SNAP_SESSIONS
public static final int SDB_SNAP_SESSIONS_CURRENT
public static final int SDB_SNAP_SYSTEM
public static final int SDB_SNAP_TRANSACTIONS
public static final int SDB_SNAP_TRANSACTIONS_CURRENT
public Sequoiadb(List<String> connStrings, String username, String password, ConfigOptions options) throws BaseException
connStrings
- The array of the coord's address.username
- The user's name of the account.password
- The password of the account.options
- The options for connection.BaseException
- If error happens.public Sequoiadb(String host, int port, String username, String password) throws BaseException
host
- the address of coordport
- the port of coordusername
- the user's name of the accountpassword
- the password of the accountBaseException
- SDB_NETWORK means network error,
SDB_INVALIDARG means wrong address or the address don't map to the hosts table.public Sequoiadb(String host, int port, String username, String password, ConfigOptions options) throws BaseException
host
- the address of coordport
- the port of coordusername
- the user's name of the accountpassword
- the password of the accountBaseException
- SDB_NETWORK means network error,
SDB_INVALIDARG means wrong address or the address don't map to the hosts table.public Sequoiadb(String connString, String username, String password) throws BaseException
connString
- remote server address "Host:Port"username
- the user's name of the accountpassword
- the password of the accountBaseException
- SDB_NETWORK means network error,
SDB_INVALIDARG means wrong address or the address don't map to the hosts tablepublic Sequoiadb(String connString, String username, String password, ConfigOptions options) throws BaseException
connString
- remote server address "Host:Port"username
- the user's name of the accountpassword
- the password of the accountoptions
- the options for connectionBaseException
- SDB_NETWORK means network error,
SDB_INVALIDARG means wrong address or the address don't map to the hosts table.public void activateReplicaGroup(String rgName) throws BaseException
rgName
- replica group nameBaseException
- If error happens.public void analyze() throws BaseException
BaseException
- If error happens.public void analyze(BSONObject options) throws BaseException
options
- The control options:(can be null)
BaseException
- If error happens.public void backupOffline(BSONObject options) throws BaseException
options
- Contains a series of backup configuration infomations.
Backup the whole cluster if null. The "options" contains 5 options as below.
All the elements in options are optional.
eg: {"GroupName":["rgName1", "rgName2"], "Path":"/opt/sequoiadb/backup",
"Name":"backupName", "Description":description, "EnsureInc":true, "OverWrite":true}
BaseException
- If error happens.public void beginTransaction() throws BaseException
BaseException
- If error happens.public void cancelTask(long taskID, boolean isAsync) throws BaseException
taskID
- The task idisAsync
- The operation "cancel task" is async or not,
"true" for async, "false" for sync. Default sync.BaseException
- If error happens.public void close() throws BaseException
close
在接口中 Closeable
close
在接口中 AutoCloseable
BaseException
- If error happens.public void closeAllCursors() throws BaseException
BaseException
- If error happens.public void commit() throws BaseException
BaseException
- If error happens.public CollectionSpace createCollectionSpace(String csName) throws BaseException
csName
- The collection space nameBaseException
- If error happens.public CollectionSpace createCollectionSpace(String csName, BSONObject options) throws BaseException
csName
- The name of collection spaceoptions
- Contains configuration information for create collection space. The options are as below:
BaseException
- If error happens.public CollectionSpace createCollectionSpace(String csName, int pageSize) throws BaseException
csName
- The name of collection spacepageSize
- The Page Size as below:
BaseException
- If error happens.public Domain createDomain(String domainName, BSONObject options) throws BaseException
domainName
- The name of the creating domainoptions
- The options for the domain. The options are as below:
BaseException
- If error happens.public void createReplicaCataGroup(String hostName, int port, String dbPath, BSONObject options)
hostName
- The host nameport
- The portdbPath
- The database pathoptions
- The configure optionsBaseException
- If error happens.public ReplicaGroup createReplicaGroup(String rgName) throws BaseException
rgName
- replica group's nameBaseException
- If error happens.public void createUser(String username, String password) throws BaseException
username
- The connection user namepassword
- The connection passwordBaseException
- If error happens.public void crtJSProcedure(String code) throws BaseException
code
- The code of storage procedureBaseException
- If error happens.public void deleteConfig(BSONObject configs, BSONObject options) throws BaseException
configs
- The specific configuration parameters to deleteoptions
- Options The control options:(Only take effect in coordinate nodes)
GroupID:INT32,
GroupName:String,
NodeID:INT32,
HostName:String,
svcname:String,
...BaseException
- If error happens.public void dropCollectionSpace(String csName) throws BaseException
csName
- The collection space nameBaseException
- If error happens.public void dropDomain(String domainName) throws BaseException
domainName
- the name of the domainBaseException
- If error happens.public Sequoiadb.SptEvalResult evalJS(String code) throws BaseException
code
- The javascript codeBaseException
- If error happens.public DBCursor exec(String sql) throws BaseException
sql
- the SQL commandBaseException
- If error happens.public void execUpdate(String sql) throws BaseException
sql
- the SQL command.BaseException
- If error happens.public void flushConfigure(BSONObject options) throws BaseException
options
- The param of flush, pass {"Global":true} or {"Global":false}
In cluster environment, passing {"Global":true} will flush data's and catalog's configuration file,
while passing {"Global":false} will flush coord's configuration file
In stand-alone environment, both them have the same behaviourBaseException
- If error happens.public ByteOrder getByteOrder()
public ArrayList<String> getCollectionNames() throws BaseException
BaseException
- If error happens.public CollectionSpace getCollectionSpace(String csName) throws BaseException
csName
- The collection space name.BaseException
- If error happens.public ArrayList<String> getCollectionSpaceNames() throws BaseException
BaseException
- If error happens.public Domain getDomain(String domainName) throws BaseException
domainName
- the name of the domainBaseException
- If the domain not exit, throw BaseException with the error SDB_CAT_DOMAIN_NOT_EXIST.public String getHost()
public String getIP()
public long getLastUseTime()
public DBCursor getList(int listType, BSONObject query, BSONObject selector, BSONObject orderBy) throws BaseException
listType
- The list type as below:
query
- The matching rule, match all the documents if null.selector
- The selective rule, return the whole document if null.orderBy
- The ordered rule, never sort if null.BaseException
- If error happens.public String getNodeName()
public int getPort()
public ReplicaGroup getReplicaGroup(int rgId) throws BaseException
rgId
- replica group idBaseException
- If error happens.public ReplicaGroup getReplicaGroup(String rgName) throws BaseException
rgName
- replica group's nameBaseException
- If error happens.public ArrayList<String> getReplicaGroupNames() throws BaseException
BaseException
- If error happens.public ArrayList<String> getReplicaGroupsInfo() throws BaseException
BaseException
- If error happens.public BSONObject getSessionAttr() throws BaseException
BaseException
- If error happens.public DBCursor getSnapshot(int snapType, BSONObject matcher, BSONObject selector, BSONObject orderBy) throws BaseException
snapType
- The snapshot types are as below:
matcher
- the matching rule, match all the documents if nullselector
- the selective rule, return the whole document if nullorderBy
- the ordered rule, never sort if nullBaseException
- If error happens.public DBCursor getSnapshot(int snapType, BSONObject matcher, BSONObject selector, BSONObject orderBy, BSONObject hint, long skipRows, long returnRows) throws BaseException
snapType
- The snapshot types are as below:
matcher
- the matching rule, match all the documents if nullselector
- the selective rule, return the whole document if nullorderBy
- the ordered rule, never sort if nullhint
- the hint rule, the options provided for specific snapshot type
format:{ '$Options': { skipRows
- skip the first numToSkip documents, never skip if this parameter is 0returnRows
- return the specified amount of documents,
when returnRows is 0, return nothing,
when returnRows is -1, return all the documentsBaseException
- If error happens.public DBCursor getSnapshot(int snapType, String matcher, String selector, String orderBy) throws BaseException
snapType
- The snapshot types are as below:
matcher
- the matching rule, match all the documents if nullselector
- the selective rule, return the whole document if nullorderBy
- the ordered rule, never sort if nullBaseException
- If error happens.public ArrayList<String> getStorageUnits() throws BaseException
BaseException
- If error happens.public static void initClient(ClientOptions options)
options
- the configuration options for clientpublic void invalidateCache(BSONObject options)
options
- The control options:(Only take effect in coordinate nodes).
About the parameter 'options', please reference to the official
website(www.sequoiadb.com) and then search "命令位置参数"
for more details. Some of its optional parameters are as bellow:
public boolean isClosed()
public boolean isCollectionSpaceExist(String csName) throws BaseException
csName
- The collection space name.BaseException
- If error happens.public boolean isDomainExist(String domainName) throws BaseException
domainName
- the name of domainBaseException
- If error happens.public boolean isRelicaGroupExist(String rgName)
rgName
- replica group's namepublic boolean isReplicaGroupExist(int rgId)
rgId
- id of replica grouppublic boolean isValid() throws BaseException
BaseException
- If error happens.public DBCursor listBackup(BSONObject options, BSONObject matcher, BSONObject selector, BSONObject orderBy) throws BaseException
options
- Contains configuration information for listing backups, list all the backups in the default backup path if null.
The "options" contains several options as below. All the elements in options are optional.
eg: {"GroupName":["rgName1", "rgName2"], "Path":"/opt/sequoiadb/backup", "Name":"backupName"}
matcher
- The matching rule, return all the documents if nullselector
- The selective rule, return the whole document if nullorderBy
- The ordered rule, never sort if nullBaseException
- If error happens.public DBCursor listCollections() throws BaseException
BaseException
- If error happens.public DBCursor listCollectionSpaces() throws BaseException
BaseException
- If error happens.public DBCursor listDomains(BSONObject matcher, BSONObject selector, BSONObject orderBy, BSONObject hint) throws BaseException
matcher
- the matching rule, return all the documents if nullselector
- the selective rule, return the whole document if nullorderBy
- the ordered rule, never sort if nullhint
- Specified the index used to scan data. e.g. {"":"ageIndex"} means
using index "ageIndex" to scan data(index scan);
{"":null} means table scan. when hint is null,
database automatically match the optimal index to scan data.BaseException
- If error happens.public DBCursor listProcedures(BSONObject condition) throws BaseException
condition
- The condition of list eg: {"name":"sum"}. return all if nullBaseException
- If error happens.public DBCursor listReplicaGroups() throws BaseException
BaseException
- If error happens.public DBCursor listTasks(BSONObject matcher, BSONObject selector, BSONObject orderBy, BSONObject hint) throws BaseException
matcher
- The matching rule, return all the documents if nullselector
- The selective rule, return the whole document if nullorderBy
- The ordered rule, never sort if nullhint
- Specified the index used to scan data. e.g. {"":"ageIndex"} means
using index "ageIndex" to scan data(index scan);
{"":null} means table scan. when hint is null,
database automatically match the optimal index to scan data.BaseException
- If error happens.public void loadCollectionSpace(String csName, BSONObject options) throws BaseException
csName
- The collection space nameoptions
- The control options:(Only take effect in coordinate nodes, can be null)
BaseException
- If error happens.public void msg(String message)
message
- The message to send to server.public void releaseResource() throws BaseException
BaseException
- If error happens.public void removeBackup(BSONObject options) throws BaseException
options
- Contains configuration information for removing backups, remove all the backups in the default backup path if null.
The "options" contains several options as below. All the elements in options are optional.
eg: {"GroupName":["rgName1", "rgName2"], "Path":"/opt/sequoiadb/backup", "Name":"backupName"}
BaseException
- If error happens.public void removeReplicaGroup(String rgName) throws BaseException
rgName
- replica group's nameBaseException
- If error happens.public void removeUser(String username, String password) throws BaseException
username
- The connection user namepassword
- The connection passwordBaseException
- If error happens.public void renameCollectionSpace(String oldName, String newName) throws BaseException
oldName
- The old collection space namenewName
- The new collection space nameBaseException
- If error happens.public void resetSnapshot() throws BaseException
BaseException
- If error happens.public void resetSnapshot(BSONObject options) throws BaseException
options
- The control options:(can be null)
BaseException
- If error happens.public void rmProcedure(String name) throws BaseException
name
- The name of store procedure to be removedBaseException
- If error happens.public void rollback() throws BaseException
BaseException
- If error happens.public void setSessionAttr(BSONObject options) throws BaseException
options
- The configuration options for the current session.The options are as below:
BaseException
- If error happens.public void sync() throws BaseException
BaseException
- If error happens.public void sync(BSONObject options) throws BaseException
options
- The control options:(can be null)
BaseException
- If error happens.public void unloadCollectionSpace(String csName, BSONObject options) throws BaseException
csName
- The collection space nameoptions
- The control options:(Only take effect in coordinate nodes, can be null)
BaseException
- If error happens.public void updateConfig(BSONObject configs, BSONObject options) throws BaseException
configs
- The specific configuration parameters to updateoptions
- Options The control options:(Only take effect in coordinate nodes)
GroupID:INT32,
GroupName:String,
NodeID:INT32,
HostName:String,
svcname:String,
...BaseException
- If error happens.public void waitTasks(long[] taskIDs) throws BaseException
taskIDs
- The array of task idBaseException
- If error happens.Copyright © 2018. All rights reserved.