|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.neo4j.kernel.impl.transaction.xaframework.XaDataSource
public abstract class XaDataSource
XaDataSource
is as a factory for creating
XaConnections
.
If you're writing a data source towards a XA compatible resource the
implementation should be fairly straight forward. This will basically be a
factory for your XaConnections
that in turn will wrap
the XA compatible XAResource
.
If you're writing a data source towards a non XA compatible resource use the
XaContainer
and extend the XaConnectionHelpImpl
as your
XaConnection
implementation. Here is an example:
public class MyDataSource implements XaDataSource {
MyDataSource( params ) {
// ... initalization stuff
container = XaContainer.create( myLogicalLogFile, myCommandFactory,
myTransactionFactory );
// ... more initialization stuff
container.openLogicalLog();
}
public XaConnection getXaCo nnection() {
return new MyXaConnection( params );
}
public void close() {
// ... cleanup
container.close();
}
}
Constructor Summary | |
---|---|
XaDataSource(Map<?,?> params)
Constructor used by the Neo4j kernel to create datasources. |
Method Summary | |
---|---|
void |
applyCommittedTransaction(long txId,
ReadableByteChannel transaction)
|
long |
applyPreparedTransaction(ReadableByteChannel transaction)
|
abstract void |
close()
Closes this data source. |
boolean |
deleteLogicalLog(long version)
Deletes a log specific logical log. |
byte[] |
getBranchId()
Returns any assigned or default branch id for this data source. |
long |
getCreationTime()
Returns a timestamp when this data source was created. |
long |
getCurrentLogVersion()
Returns the current version of this data source. |
String |
getFileName(long version)
|
long |
getLastCommittedTxId()
|
LogExtractor |
getLogExtractor(long startTxId,
long endTxIdHint)
|
ReadableByteChannel |
getLogicalLog(long version)
Returns a readable byte channel of the specified logical log. |
long |
getLogicalLogLength(long version)
|
Pair<Integer,Long> |
getMasterForCommittedTx(long txId)
|
String |
getName()
Returns the assigned name of this resource. |
ReadableByteChannel |
getPreparedTransaction(int identifier)
|
void |
getPreparedTransaction(int identifier,
LogBuffer targetBuffer)
|
long |
getRandomIdentifier()
Returns a random identifier that gets generated when the data source is created. |
abstract XaConnection |
getXaConnection()
Creates a XA connection to the resource this data source represents. |
XaContainer |
getXaContainer()
|
boolean |
hasLogicalLog(long version)
Tests if a specific logical log exists. |
boolean |
isLogicalLogKept()
|
void |
keepLogicalLogs(boolean keepLogs)
Sets wether logical logs should be saved upon rotation or not. |
ClosableIterable<File> |
listStoreFiles(boolean includeLogicalLogs)
|
long |
rotateLogicalLog()
Rotates this logical log. |
void |
setAutoRotate(boolean rotate)
Turns off/on auto rotate of logical logs. |
void |
setBranchId(byte[] branchId)
Used by the container/transaction manager in place to assign a branch id for this data source. |
void |
setLastCommittedTxId(long txId)
|
void |
setLogicalLogTargetSize(long size)
Sets the target size of the logical log that will cause a rotation of the log if setAutoRotate(boolean) is set to true . |
void |
setName(String name)
Used by the container to assign a name to this resource. |
boolean |
setRecovered(boolean recovered)
Returns previous value |
protected Boolean |
shouldKeepLog(String config,
String resourceName)
If the config says that logical logs should be kept for the given resourceName this method will return true , otherwise
false . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XaDataSource(Map<?,?> params) throws InstantiationException
params
- A map containing configuration parameters
InstantiationException
Method Detail |
---|
public abstract XaConnection getXaConnection()
public abstract void close()
getXaConnection
after
this method has been invoked is illegal.
public void setBranchId(byte[] branchId)
branchId
- the branch idpublic byte[] getBranchId()
public long getCreationTime()
Creation time together with random identifier can be used to uniqley identify a data source (since it is possible to have multiple sources of same type).
public String getFileName(long version)
public long getRandomIdentifier()
Creation time together with the random identifier can be used to uniquely identify a data source (since it is possible to have multiple sources of the same type).
public long getCurrentLogVersion()
rotateLogicalLog()
when keepLogicalLogs(boolean)
is
set to true
will result in a log with that version created.
public long rotateLogicalLog() throws IOException
keepLogicalLogs(boolean)
is
configured to true the log will be saved and can be retrieved with the
getLogicalLog(long)
method. If not it will be deleted. Active
transactions get copied to a new logical log.
IOException
- if unable to read old log or write to new onepublic ReadableByteChannel getLogicalLog(long version) throws IOException
version
- version of the logical log
IOException
- if no such log existpublic boolean hasLogicalLog(long version)
version
- the version of the logical log
true
if the log existspublic long getLogicalLogLength(long version)
public boolean deleteLogicalLog(long version)
version
- version of log to delete
public void keepLogicalLogs(boolean keepLogs)
false
.
keepLogs
- true
means save, false
means
deletepublic boolean isLogicalLogKept()
public void setName(String name)
name
- name of this resourcepublic String getName()
public void setAutoRotate(boolean rotate)
true
.
rotate
- true
to turn onpublic void setLogicalLogTargetSize(long size)
setAutoRotate(boolean)
is set to true
.
size
- target size in bytesprotected Boolean shouldKeepLog(String config, String resourceName)
resourceName
this method will return true
, otherwise
false
. The format of the configuration value is either:
config
- the configuration value specified by user configuration.resourceName
- the name of the xa data source to check.
resourceName
or not. Or null
if not specified.public ReadableByteChannel getPreparedTransaction(int identifier) throws IOException
IOException
public void getPreparedTransaction(int identifier, LogBuffer targetBuffer) throws IOException
IOException
public void applyCommittedTransaction(long txId, ReadableByteChannel transaction) throws IOException
IOException
public long applyPreparedTransaction(ReadableByteChannel transaction) throws IOException
IOException
public long getLastCommittedTxId()
public void setLastCommittedTxId(long txId)
public XaContainer getXaContainer()
public Pair<Integer,Long> getMasterForCommittedTx(long txId) throws IOException
IOException
public ClosableIterable<File> listStoreFiles(boolean includeLogicalLogs) throws IOException
IOException
public boolean setRecovered(boolean recovered)
public LogExtractor getLogExtractor(long startTxId, long endTxIdHint) throws IOException
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |