Package eu.antidotedb.client
Class AntidoteClient
- java.lang.Object
-
- eu.antidotedb.client.AntidoteClient
-
public class AntidoteClient extends java.lang.ObjectAn AntidoteClient manages the connection to one or more Antidote servers.It is the main entry point for working with the client, in particular it is the source of transactions. Every operation has to be executed in the context of a transaction. See:
startTransaction(),createStaticTransaction(),noTransaction(), andnewBatchRead().
-
-
Constructor Summary
Constructors Constructor Description AntidoteClient(PoolManager poolManager)Instantiates a new antidote client.AntidoteClient(java.net.InetSocketAddress... inetAddrs)Initializes an AntidoteClient with the given hosts.AntidoteClient(java.util.List<TransformerFactory> transformerFactories, java.net.InetSocketAddress... inetAddrs)Initializes an AntidoteClient.AntidoteClient(java.util.List<TransformerFactory> transformerFactories, java.util.List<java.net.InetSocketAddress> inetAddrs)Initializes an AntidoteClient.AntidoteClient(java.util.List<java.net.InetSocketAddress> inetAddrs)Initializes an AntidoteClient with the given hosts.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static booleanconnectToDCs(java.net.InetSocketAddress managerNode, java.util.List<com.google.protobuf.ByteString> descriptors)static booleancreateDC(java.net.InetSocketAddress managerNode, java.util.List<java.lang.String> nodeNames)AntidoteStaticTransactioncreateStaticTransaction()Creates a static transaction.AntidoteStaticTransactioncreateStaticTransaction(CommitInfo timestamp)Creates a static transaction.static com.google.protobuf.ByteStringgetConnectionDescriptor(java.net.InetSocketAddress managerNode)PoolManagergetPoolManager()Get the pool manager.protected voidinit(java.util.List<TransformerFactory> transformerFactories, java.util.List<java.net.InetSocketAddress> inetAddrs)initializes the client.BatchReadnewBatchRead()Starts a new batch read, which allows to read several objects at once.NoTransactionnoTransaction()Use this for executing updates and reads without a transaction context.NoTransactionnoTransaction(CommitInfo timestamp)Use this for executing updates and reads without a transaction context.InteractiveTransactionstartTransaction()Starts an interactive transactions.InteractiveTransactionstartTransaction(CommitInfo timestamp)Starts an interactive transactions.
-
-
-
Constructor Detail
-
AntidoteClient
public AntidoteClient(java.net.InetSocketAddress... inetAddrs)
Initializes an AntidoteClient with the given hosts.- Parameters:
inetAddrs- The addresses of the Antidote hosts
-
AntidoteClient
public AntidoteClient(java.util.List<java.net.InetSocketAddress> inetAddrs)
Initializes an AntidoteClient with the given hosts.- Parameters:
inetAddrs- The addresses of the Antidote hosts
-
AntidoteClient
public AntidoteClient(java.util.List<TransformerFactory> transformerFactories, java.net.InetSocketAddress... inetAddrs)
Initializes an AntidoteClient.- Parameters:
transformerFactories- transformers for factories (the last transformer will be at the top of the stack, so applied first)inetAddrs- The addresses of the Antidote hosts
-
AntidoteClient
public AntidoteClient(java.util.List<TransformerFactory> transformerFactories, java.util.List<java.net.InetSocketAddress> inetAddrs)
Initializes an AntidoteClient.- Parameters:
transformerFactories- transformers for factories (the last transformer will be at the top of the stack, so applied first)inetAddrs- The addresses of the Antidote hosts
-
AntidoteClient
public AntidoteClient(PoolManager poolManager)
Instantiates a new antidote client.- Parameters:
poolManager- defines where to find Antidote hosts
-
-
Method Detail
-
init
protected void init(java.util.List<TransformerFactory> transformerFactories, java.util.List<java.net.InetSocketAddress> inetAddrs)
initializes the client. Called by every constructor except forAntidoteClient(PoolManager).
-
startTransaction
public InteractiveTransaction startTransaction()
Starts an interactive transactions. Interactive transactions allow to mix several reads and writes in a single atomic unit.Since an interactive transaction uses database resources, you should ensure that the transaction is closed in any case. The recommended pattern is to use a try-with-resource statement and commit the transaction at the end of it:
try (InteractiveTransaction tx = antidoteClient.startTransaction()) { // updates and reads here tx.commitTransaction(); }
-
startTransaction
public InteractiveTransaction startTransaction(CommitInfo timestamp)
Starts an interactive transactions. Interactive transactions allow to mix several reads and writes in a single atomic unit.Since an interactive transaction uses database resources, you should ensure that the transaction is closed in any case. The recommended pattern is to use a try-with-resource statement and commit the transaction at the end of it:
try (InteractiveTransaction tx = antidoteClient.startTransaction()) { // updates and reads here tx.commitTransaction(); }- Parameters:
timestamp- The minimal timestamp that this transaction should be based on. Use the CommitInfo from the commit of a previous transaction if you want to guarantee that the new transaction sees the former one.
-
createStaticTransaction
public AntidoteStaticTransaction createStaticTransaction()
Creates a static transaction. Static transactions can be used to execute a set of updates atomically.
-
createStaticTransaction
public AntidoteStaticTransaction createStaticTransaction(CommitInfo timestamp)
Creates a static transaction. Static transactions can be used to execute a set of updates atomically.- Parameters:
timestamp-
-
newBatchRead
public BatchRead newBatchRead()
Starts a new batch read, which allows to read several objects at once. TheBatchReadcan be committed usingBatchRead.commit(eu.antidotedb.client.TransactionWithReads)orBatchRead.commit(TransactionWithReads).
-
getPoolManager
public PoolManager getPoolManager()
Get the pool manager. This can be used to configure connections at runtime.
-
noTransaction
public NoTransaction noTransaction()
Use this for executing updates and reads without a transaction context.
-
noTransaction
public NoTransaction noTransaction(CommitInfo timestamp)
Use this for executing updates and reads without a transaction context.
-
createDC
public static boolean createDC(java.net.InetSocketAddress managerNode, java.util.List<java.lang.String> nodeNames) throws java.io.IOException- Throws:
java.io.IOException
-
getConnectionDescriptor
public static com.google.protobuf.ByteString getConnectionDescriptor(java.net.InetSocketAddress managerNode) throws java.io.IOException- Throws:
java.io.IOException
-
connectToDCs
public static boolean connectToDCs(java.net.InetSocketAddress managerNode, java.util.List<com.google.protobuf.ByteString> descriptors) throws java.io.IOException- Throws:
java.io.IOException
-
-