Scalaris
Date: 2016-02-29

de.zib.scalaris

## Class Scalaris

- java.lang.Object
- - de.zib.scalaris.Scalaris

-     public class Scalaris
      extends Object

  Provides methods to interact with some Scalaris (Erlang) VM.

  Instances of this class can be generated using a given connection to a scalaris node (`Scalaris(Connection)`) or without a connection (`Scalaris()`) in which case a new connection is created using `ConnectionFactory.createConnection()`.

  Since:
    3.10
  Version:
    3.10
  Author:
    Nico Kruber, kruber@zib.de

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Scalaris()` Constructor, uses the default connection returned by `ConnectionFactory.createConnection()`.
    `Scalaris(Connection conn)` Constructor, uses the given connection to an erlang node.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `closeConnection()` Closes the transaction's connection to a scalaris node.
    `List<String>` | `getRandomNodes(int max)` Retrieves random nodes from Scalaris for use by `ConnectionFactory.addNode(String)` or `ScalarisVM`.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Scalaris

          public Scalaris()
                   throws ConnectionException

      Constructor, uses the default connection returned by `ConnectionFactory.createConnection()`.
      Throws:
        `ConnectionException` - if the connection fails

    - #### Scalaris

          public Scalaris(Connection conn)

      Constructor, uses the given connection to an erlang node.
      Parameters:
        `conn` - connection to use for the transaction

  - ### Method Detail

    - #### getRandomNodes

          public List<String> getRandomNodes(int max)
                                      throws ConnectionException,
                                             UnknownException

      Retrieves random nodes from Scalaris for use by `ConnectionFactory.addNode(String)` or `ScalarisVM`.
      Parameters:
        `max` - maximum number of nodes to return (> 0)
      Returns:
        a list of nodes (if an empty node list was returned from Scalaris, the connection's node will be returned here)
      Throws:
        `ConnectionException` - if the connection is not active or a communication error occurs or an exit signal was received or the remote node sends a message containing an invalid cookie
        `UnknownException` - if any other error occurs

    - #### closeConnection

          public void closeConnection()

      Closes the transaction's connection to a scalaris node. Note: Subsequent calls to the other methods will throw `ConnectionException`s!