public interface TxContext extends AutoCloseable
TxContext
represents a runtime context used by tasks that uses
MD-SAL datastore.TxTask
Modifier and Type | Method and Description |
---|---|
void |
addPostSubmitHook(TxHook hook)
Add the given transaction post-submit hook to this context.
|
void |
addPreSubmitHook(TxHook hook)
Add the given transaction pre-submit hook to this context.
|
void |
cancelTransaction()
Cancel current transaction for MD-SAL datastore.
|
void |
close()
Close this transaction context.
|
VTNManagerProvider |
getProvider()
Return a
VTNManagerProvider service instance. |
<T> T |
getReadSpecific(Class<T> type)
Return read-only data specific to the current transaction.
|
org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction |
getReadWriteTransaction()
Return read/write transaction for MD-SAL datastore.
|
<T> T |
getSpecific(Class<T> type)
Return writable data specific to the current transaction.
|
org.opendaylight.controller.md.sal.binding.api.ReadTransaction |
getTransaction()
Return read-only transaction for MD-SAL datastore.
|
void |
log(org.slf4j.Logger logger,
VTNLogLevel level,
String msg)
Log the specified message.
|
void |
log(org.slf4j.Logger logger,
VTNLogLevel level,
String format,
Object... args)
Log a message according to the specified format string and arguments.
|
void |
log(org.slf4j.Logger logger,
VTNLogLevel level,
String msg,
Throwable t)
Log the specified message and exception.
|
void |
log(org.slf4j.Logger logger,
VTNLogLevel level,
Throwable t,
String format,
Object... args)
Log the specified throwable and a message according to the given
format string and arguments.
|
org.opendaylight.controller.md.sal.binding.api.ReadTransaction getTransaction()
ReadTransaction
instance.org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction getReadWriteTransaction()
ReadWriteTransaction
instance.void cancelTransaction()
<T> T getReadSpecific(Class<T> type)
If an object specified by the given class is not associated with the current transaction, a new object is instantiated and it is associated with the current transaction. All the transaction specific data will be discarded when the transaction is closed.
T
- The type of the transaction specific data.type
- A class that specifies the type of data.
Note that the class must have a public constructor that
takes one ReadTransaction
instance.<T> T getSpecific(Class<T> type)
If an object specified by the given class is not associated with the current transaction, a new object is instantiated and it is associated with the current transaction. All the transaction specific data will be discarded when the transaction is closed.
T
- The type of the transaction specific data.type
- A class that specifies the type of data.
Note that the class must have a public constructor that
takes one TxContext
instance.void addPreSubmitHook(TxHook hook)
TxHook.run(TxContext, TxTask)
on the given hook instance will
be invoked just before the transaction is submitted.
Note that all the registered hooks are removed from this context when the transaction is closed.
hook
- A hook to be invoked when the transaction is going to be
submitted.void addPostSubmitHook(TxHook hook)
TxHook.run(TxContext, TxTask)
on the given hook instance will
be invoked just after the successful completion of the transaction.
Note that all the registered hooks are removed from this context when the transaction is closed.
hook
- A hook to be invoked after the successful completion of
the transaction.VTNManagerProvider getProvider()
VTNManagerProvider
service instance.VTNManagerProvider
instance.void log(org.slf4j.Logger logger, VTNLogLevel level, String msg)
If the MD-SAL transaction associated with this context is writable, the specified message will be logged when the transaction completes. Note that the specified message will be discarded when the transaction is restarted due to data confliction.
logger
- A Logger
instance.level
- A VTNLogLevel
instance that specifies the
logging level.msg
- A message to be logged.void log(org.slf4j.Logger logger, VTNLogLevel level, String format, Object... args)
This method constructs a message using SLF4J log format.
If the MD-SAL transaction associated with this context is writable, the specified message will be logged when the transaction completes. Note that the specified message will be discarded when the transaction is restarted due to data confliction.
logger
- A Logger
instance.level
- A VTNLogLevel
instance that specifies the
logging level.format
- A format string used to construct log message.args
- An object array used to construct log message.void log(org.slf4j.Logger logger, VTNLogLevel level, String msg, Throwable t)
If the MD-SAL transaction associated with this context is writable, the specified message will be logged when the transaction completes. Note that the specified message will be discarded when the transaction is restarted due to data confliction.
logger
- A Logger
instance.level
- A VTNLogLevel
instance that specifies the
logging level.msg
- A message to be logged.t
- A Throwable
to be logged.void log(org.slf4j.Logger logger, VTNLogLevel level, Throwable t, String format, Object... args)
Note that this method constructs a log message using
String.format(String, Object[])
.
If the MD-SAL transaction associated with this context is writable, the specified message will be logged when the transaction completes. Note that the specified message will be discarded when the transaction is restarted due to data confliction.
logger
- A Logger
instance.level
- A VTNLogLevel
instance that specifies the
logging level.t
- A Throwable
to be logged.format
- A format string used to construct log message.args
- An object array used to construct log message.void close()
Note that this method discards unsubmitted data in the transaction.
close
in interface AutoCloseable
Copyright © 2018 OpenDaylight. All rights reserved.