Interface DatasetManager

All Superinterfaces:
AutoCloseable

public interface DatasetManager extends AutoCloseable
This is the entry point into the Terracotta store API. It provides methods to create embedded or clustered DatasetManager which then allow creating, retrieving and destroying Dataset.
  • Method Details

    • clustered

      static ClusteredDatasetManagerBuilder clustered(URI uri)
      Creates a ClusteredDatasetManagerBuilder for configuring the interaction with a cluster. The passed in URI takes the form terracotta://server1:port,server2:port,...,serverN:port.
      Parameters:
      uri - the URI for the cluster
      Returns:
      a ClusteredDatasetManagerBuilder that can be used to configure the interaction with the cluster
    • clustered

      Creates a ClusteredDatasetManagerBuilder for configuring the interaction with a cluster.
      Parameters:
      servers - an Iterable of InetSocketAddresses of the servers in the cluster
      Returns:
      a ClusteredDatasetManagerBuilder that can be used to configure the interaction with the cluster
    • secureClustered

      static ClusteredDatasetManagerBuilder secureClustered(URI uri, Path securityRootDirectory)
      Creates a ClusteredDatasetManagerBuilder for configuring the interaction with a cluster where the network communication is secured using SSL/TLS. The passed in URI takes the form "terracotta://server1:port,server2:port,...,serverN:port
      Parameters:
      uri - the URI for the cluster
      securityRootDirectory - path to a directory containing security configuration information. The contents of the directory must follow the well-defined structure.
      Returns:
      a ClusteredDatasetManagerBuilder that can be used to configure the interaction with the cluster
    • secureClustered

      static ClusteredDatasetManagerBuilder secureClustered(Iterable<InetSocketAddress> servers, Path securityRootDirectory)
      Creates a ClusteredDatasetManagerBuilder for configuring the interaction with a cluster where the network communication is secured using SSL/TLS. The passed in URI takes the form "terracotta://server1:port,server2:port,...,serverN:port
      Parameters:
      servers - an Iterable of InetSocketAddresses of the servers in the cluster
      securityRootDirectory - path to a directory containing security configuration information. The contents of the directory must follow the well-defined structure.
      Returns:
      a ClusteredDatasetManagerBuilder that can be used to configure the interaction with the cluster
    • embedded

      static EmbeddedDatasetManagerBuilder embedded()
      Creates an EmbeddedDatasetManagerBuilder for configuring the interaction with embedded Dataset instances.

      An embedded Dataset is hosted in-process, possibly with a local persistence layer.

      Returns:
      an EmbeddedDatasetManagerBuilder that can be used to configure the interaction with embedded Dataset instances.
    • using

      static DatasetManager using(DatasetManagerConfiguration datasetManagerConfiguration) throws StoreException
      Creates a DatasetManager using the given DatasetManagerConfiguration and default ConfigurationMode ConfigurationMode.VALIDATE
      Parameters:
      datasetManagerConfiguration - DatasetManager configuration
      Returns:
      a clustered or embedded DatasetManager instance
      Throws:
      StoreException - if the creation of the DatasetManager fails or creation/validation fails using ConfigurationMode ConfigurationMode.VALIDATE
    • using

      static DatasetManager using(DatasetManagerConfiguration datasetManagerConfiguration, ConfigurationMode configurationMode) throws StoreException
      Creates a DatasetManager using the given DatasetManagerConfiguration and create/validate Datasets as per given ConfigurationMode
      Parameters:
      datasetManagerConfiguration - DatasetManager configuration
      configurationMode - configurationMode to use
      Returns:
      a clustered or embedded DatasetManager instance
      Throws:
      StoreException - if the creation of the DatasetManager fails or creation/validation fails as per given ConfigurationMode
    • getDatasetManagerConfiguration

      DatasetManagerConfiguration getDatasetManagerConfiguration()
      Returns:
      DatasetManagerConfiguration for this DatasetManager
    • newDataset

      <K extends Comparable<K>> boolean newDataset(String name, Type<K> keyType, DatasetConfiguration configuration) throws StoreException
      Create a new persistent Dataset with the given name and key type.

      Note that if the Dataset already exists, only the validity of the key type will be checked. The rest of the configuration is not checked for compatibility.

      A DatasetManager does not provide any namespacing to the Datasets created with it. Multiple DatasetManager instances connected to the same cluster are equivalent and hence a clustered dataset created by one would be visible to all others.

      Type Parameters:
      K - the class of the key of the Dataset
      Parameters:
      name - the name of the Dataset
      keyType - the type of the key of the Dataset
      configuration - the configuration for the creation of the Dataset
      Returns:
      true if the Dataset was created, false if it existed already
      Throws:
      DatasetKeyTypeMismatchException - if the named Dataset exists but with a different key type
      StoreException - if an error occurs creating the Dataset
    • newDataset

      default <K extends Comparable<K>> boolean newDataset(String name, Type<K> keyType, DatasetConfigurationBuilder configurationBuilder) throws StoreException
      Create a new persistent Dataset with the given name and key type.

      Note that if the Dataset already exists, only the validity of the key type will be checked. The rest of the configuration is not checked for compatibility.

      Type Parameters:
      K - the class of the key of the Dataset
      Parameters:
      name - the name of the Dataset
      keyType - the type of the key of the Dataset
      configurationBuilder - the configuration builder for the creation of the Dataset
      Returns:
      true if the Dataset was created, false if it existed already
      Throws:
      DatasetKeyTypeMismatchException - if the named Dataset exists but with a different key type
      StoreException - if an error occurs creating the Dataset
    • getDataset

      <K extends Comparable<K>> Dataset<K> getDataset(String name, Type<K> keyType) throws StoreException
      Gets a Dataset with the specified name and key type.
      Type Parameters:
      K - the class of the key of the Dataset
      Parameters:
      name - the name of the Dataset to get
      keyType - the type of the key of the Dataset
      Returns:
      the Dataset matching name and keyType
      Throws:
      DatasetKeyTypeMismatchException - if the named Dataset exists but with a different key type
      DatasetMissingException - if the named Dataset does not exist
      StoreException - if an error is encountered while retrieving the Dataset
    • listDatasets

      Map<String,Type<?>> listDatasets() throws StoreException
      List all existing Datasets known to this DatasetManager.

      For an embedded DatasetManager this means all Dataset that were created through it. For a clustered DatasetManager this means all Dataset that are known to the cluster it connects to.

      Returns:
      a Map with one entry per Dataset, each entry having the Dataset name as key and the Dataset type as value.
      Throws:
      StoreException - if anything goes wrong while retrieving the list
    • destroyDataset

      boolean destroyDataset(String name) throws StoreException
      Permanently removes the Dataset and all the data it contains.
      Parameters:
      name - the name of the Dataset to destroy
      Returns:
      true if the Dataset was destroyed, false if it did not exist
      Throws:
      StoreException - if the Dataset is in use by another client so could not be destroyed.
    • close

      void close()
      Closes the DatasetManager. In a clustered topology, closes connection to remote server. In an embedded topology, disposes all datasets.
      Specified by:
      close in interface AutoCloseable
    • datasetConfiguration

      DatasetConfigurationBuilder datasetConfiguration()
      Creates a DatasetConfigurationBuilder for configuring which resources a Dataset can use.
      Returns:
      a DatasetConfigurationBuilder that can be used to configure a Dataset.