Package org.yamcs.yarch
Class YarchDatabaseInstance
- java.lang.Object
-
- org.yamcs.yarch.YarchDatabaseInstance
-
public class YarchDatabaseInstance extends Object
Handles tables and streams for one Yamcs InstanceSynchronisation policy: to avoid problems with stream disappearing when clients connect to them, all the creation/closing/subscription to streams/tables shall be done while acquiring a lock on the YarchDatabase object. This is done in the StreamSqlStatement.java
Delivery of tuples does not require locking, this means subscription can change while delivering (for that a concurrent list is used in Stream.java)
-
-
Method Summary
-
-
-
Method Detail
-
getPartitionManager
public PartitionManager getPartitionManager(TableDefinition tblDef)
-
getTablespaceName
public String getTablespaceName()
Tablespaces are used byRdbStorageEngine
to store data. Returns the default tablespace name that is used by all tables and also the parameter archive of this yamcs instance
-
getName
public String getName()
- Returns:
- the instance name
-
getYamcsInstance
public String getYamcsInstance()
-
createTable
public void createTable(TableDefinition tbldef) throws YarchException
add a table to the dictionary throws exception if a table or a stream with the same name already exist- Parameters:
tbldef
- - table definition- Throws:
YarchException
- - thrown in case a table or a stream with the same name already exists or if there was an error in creating the table
-
addStream
public void addStream(Stream stream) throws YarchException
Adds a stream to the dictionary making it "official"- Parameters:
stream
-- Throws:
YarchException
-
getTable
public TableDefinition getTable(String name)
-
streamOrTableExists
public boolean streamOrTableExists(String name)
-
dropTable
public void dropTable(String tblName)
-
removeStream
public void removeStream(String name)
-
getStorageEngine
public StorageEngine getStorageEngine(TableDefinition tbldef)
-
getStreams
public Collection<Stream> getStreams()
-
getTableDefinitions
public Collection<TableDefinition> getTableDefinitions()
-
getRoot
public String getRoot()
Returns the root directory for this database instance. It is usually home/instance_name.
-
createStatement
public StreamSqlStatement createStatement(String query, Object... args) throws StreamSqlException, ParseException
- Throws:
StreamSqlException
ParseException
-
execute
public void execute(StreamSqlStatement stmt, ResultListener resultListener, long limit) throws StreamSqlException
- Throws:
StreamSqlException
-
execute
public void execute(StreamSqlStatement stmt, ResultListener resultListener) throws StreamSqlException
- Throws:
StreamSqlException
-
execute
public StreamSqlResult execute(StreamSqlStatement stmt) throws StreamSqlException
- Throws:
StreamSqlException
-
execute
public StreamSqlResult execute(String query, Object... args) throws StreamSqlException, ParseException
Executes a query and returns a result.If the result contains streaming data (select from table or stream) you have to close the result
- Parameters:
query
-args
-- Returns:
- Throws:
StreamSqlException
ParseException
-
executeDiscardingResult
public void executeDiscardingResult(String query, Object... args) throws StreamSqlException, ParseException
- Throws:
StreamSqlException
ParseException
-
close
public void close()
-
getTagDb
public TagDb getTagDb() throws YarchException
- Throws:
YarchException
-
getProtobufDatabase
public ProtobufDatabase getProtobufDatabase() throws YarchException
- Throws:
YarchException
-
getDefaultPartitioningSchema
public TimePartitionSchema getDefaultPartitioningSchema()
-
getBucket
public Bucket getBucket(String bucketName) throws IOException
- Throws:
IOException
-
createBucket
public Bucket createBucket(String bucketName) throws IOException
- Throws:
IOException
-
addFileSystemBucket
public FileSystemBucket addFileSystemBucket(String bucketName, Path location) throws IOException
Adds a bucket that maps to the file system. This is a transient operation that has to be done on each server restart.- Parameters:
bucketName
- the name of the bucketlocation
- the path to the bucket contents- Returns:
- the created bucket
- Throws:
IOException
- on I/O issues
-
listBuckets
public List<Tablespace.BucketProperties> listBuckets() throws IOException
- Throws:
IOException
-
deleteBucket
public void deleteBucket(String bucketName) throws IOException
- Throws:
IOException
-
getSequence
public Sequence getSequence(String name) throws YarchException
- Throws:
YarchException
-
-