Class JDBCSequentialFileFactoryDriver
- java.lang.Object
-
- org.apache.activemq.artemis.jdbc.store.drivers.AbstractJDBCDriver
-
- org.apache.activemq.artemis.jdbc.store.file.JDBCSequentialFileFactoryDriver
-
- Direct Known Subclasses:
Db2SequentialFileDriver,PostgresSequentialSequentialFileDriver
public class JDBCSequentialFileFactoryDriver extends AbstractJDBCDriver
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringappendToLargeObjectprotected java.lang.IntegerappendToLargeObjectResultSetConcurrencyprotected java.lang.IntegerappendToLargeObjectResultSetTypeprotected java.lang.StringcopyFileRecordprotected java.lang.StringcreateFileprotected intcreateFileAutogeneratedKeysprotected java.lang.String[]createFileColumnNamesprotected java.lang.StringdeleteFileprotected java.lang.StringreadLargeObjectprotected java.lang.StringrenameFileprotected java.lang.StringselectFileByFileNameprotected java.lang.StringselectFileNamesByExtension-
Fields inherited from class org.apache.activemq.artemis.jdbc.store.drivers.AbstractJDBCDriver
connectionProvider, sqlProvider
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longcalculateReadLength(long objectLength, int bufferSpace, long readPosition)voidcopyFileData(JDBCSequentialFile fileFrom, JDBCSequentialFile fileTo)Copy the data content of FileFrom to FileTovoidcreateFile(JDBCSequentialFile file)Creates a new database row representing the supplied file.protected voidcreateSchema()voiddeleteFile(JDBCSequentialFile file)Deletes the associated row in the database.voiddestroy()Drop all tables and datalongfileExists(JDBCSequentialFile file)Checks to see if a file with filename and extension exists.longgetMaxSize()java.util.List<java.lang.String>listFiles(java.lang.String extension)voidloadFile(JDBCSequentialFile file)Loads an existing file.voidopenFile(JDBCSequentialFile file)Opens the supplied file.protected voidprepareStatements()intreadFromFile(JDBCSequentialFile file, java.nio.ByteBuffer bytes)Reads data from the file (at file.readPosition) into the byteBuffer.voidrenameFile(JDBCSequentialFile file, java.lang.String newFileName)Updates the fileName field to the new value.intwriteToFile(JDBCSequentialFile file, byte[] data)intwriteToFile(JDBCSequentialFile file, byte[] data, boolean append)Persists data to this files associated database mapping.-
Methods inherited from class org.apache.activemq.artemis.jdbc.store.drivers.AbstractJDBCDriver
createTable, getJdbcConnectionProvider, setJdbcConnectionProvider, setSqlProvider, start, stop
-
-
-
-
Field Detail
-
deleteFile
protected java.lang.String deleteFile
-
createFile
protected java.lang.String createFile
-
createFileColumnNames
protected java.lang.String[] createFileColumnNames
-
createFileAutogeneratedKeys
protected int createFileAutogeneratedKeys
-
selectFileByFileName
protected java.lang.String selectFileByFileName
-
copyFileRecord
protected java.lang.String copyFileRecord
-
renameFile
protected java.lang.String renameFile
-
readLargeObject
protected java.lang.String readLargeObject
-
appendToLargeObject
protected java.lang.String appendToLargeObject
-
appendToLargeObjectResultSetType
protected java.lang.Integer appendToLargeObjectResultSetType
-
appendToLargeObjectResultSetConcurrency
protected java.lang.Integer appendToLargeObjectResultSetConcurrency
-
selectFileNamesByExtension
protected java.lang.String selectFileNamesByExtension
-
-
Method Detail
-
createSchema
protected void createSchema() throws java.sql.SQLException- Specified by:
createSchemain classAbstractJDBCDriver- Throws:
java.sql.SQLException
-
prepareStatements
protected void prepareStatements()
- Specified by:
prepareStatementsin classAbstractJDBCDriver
-
listFiles
public java.util.List<java.lang.String> listFiles(java.lang.String extension) throws java.lang.Exception- Throws:
java.lang.Exception
-
openFile
public void openFile(JDBCSequentialFile file) throws java.sql.SQLException
Opens the supplied file. If the file does not exist in the database it will create a new one.- Parameters:
file-- Throws:
java.sql.SQLException
-
fileExists
public long fileExists(JDBCSequentialFile file) throws java.sql.SQLException
Checks to see if a file with filename and extension exists. If so returns the ID of the file or returns -1.- Parameters:
file-- Returns:
- Throws:
java.sql.SQLException
-
loadFile
public void loadFile(JDBCSequentialFile file) throws java.sql.SQLException
Loads an existing file.- Parameters:
file-- Throws:
java.sql.SQLException
-
createFile
public void createFile(JDBCSequentialFile file) throws java.sql.SQLException
Creates a new database row representing the supplied file.- Parameters:
file-- Throws:
java.sql.SQLException
-
renameFile
public void renameFile(JDBCSequentialFile file, java.lang.String newFileName) throws java.sql.SQLException
Updates the fileName field to the new value.- Parameters:
file-newFileName-- Throws:
java.sql.SQLException
-
deleteFile
public void deleteFile(JDBCSequentialFile file) throws java.sql.SQLException
Deletes the associated row in the database.- Parameters:
file-- Throws:
java.sql.SQLException
-
writeToFile
public int writeToFile(JDBCSequentialFile file, byte[] data) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
writeToFile
public int writeToFile(JDBCSequentialFile file, byte[] data, boolean append) throws java.sql.SQLException
Persists data to this files associated database mapping.- Parameters:
file-data-- Returns:
- Throws:
java.sql.SQLException
-
readFromFile
public int readFromFile(JDBCSequentialFile file, java.nio.ByteBuffer bytes) throws java.sql.SQLException
Reads data from the file (at file.readPosition) into the byteBuffer.- Parameters:
file-bytes-- Returns:
- Throws:
java.sql.SQLException
-
copyFileData
public void copyFileData(JDBCSequentialFile fileFrom, JDBCSequentialFile fileTo) throws java.sql.SQLException
Copy the data content of FileFrom to FileTo- Parameters:
fileFrom-fileTo-- Throws:
java.sql.SQLException
-
destroy
public void destroy() throws java.sql.SQLExceptionDrop all tables and data- Overrides:
destroyin classAbstractJDBCDriver- Throws:
java.sql.SQLException
-
calculateReadLength
public long calculateReadLength(long objectLength, int bufferSpace, long readPosition)
-
getMaxSize
public long getMaxSize()
-
-