Class AntidoteClient


  • public class AntidoteClient
    extends java.lang.Object
    An 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(), and newBatchRead().

    • 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 for AntidoteClient(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 -
      • 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