Package org.apache.accumulo.minicluster
Class MiniAccumuloCluster
- java.lang.Object
-
- org.apache.accumulo.minicluster.MiniAccumuloCluster
-
- All Implemented Interfaces:
AutoCloseable
public class MiniAccumuloCluster extends Object implements AutoCloseable
A utility class that will create Zookeeper and Accumulo processes that write all of their data to a single local directory. This class makes it easy to test code against a real Accumulo instance. The use of this utility will yield results which closely match a normal Accumulo instance.- Since:
- 1.5.0
-
-
Constructor Summary
Constructors Constructor Description MiniAccumuloCluster(File dir, String rootPassword)
MiniAccumuloCluster(MiniAccumuloConfig config)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
close()
AccumuloClient
createAccumuloClient(String user, AuthenticationToken token)
Utility method to create anAccumuloClient
with connection to the MAC.ClientConfiguration
getClientConfig()
Deprecated.since 2.0.0, replaced bygetClientProperties()
Properties
getClientProperties()
static Properties
getClientProperties(File directory)
Construct clientProperties
using aMiniAccumuloCluster
directoryMiniAccumuloConfig
getConfig()
Connector
getConnector(String user, String passwd)
Deprecated.since 2.0.0, replaced bycreateAccumuloClient(String, AuthenticationToken)
Set<Pair<ServerType,Integer>>
getDebugPorts()
String
getInstanceName()
String
getZooKeepers()
void
start()
Starts Accumulo and Zookeeper processes.void
stop()
Stops Accumulo and Zookeeper processes.
-
-
-
Constructor Detail
-
MiniAccumuloCluster
public MiniAccumuloCluster(File dir, String rootPassword) throws IOException
- Parameters:
dir
- An empty or nonexistent temp directory that Accumulo and Zookeeper can store data in. Creating the directory is left to the user. Java 7, Guava, and Junit provide methods for creating temporary directories.rootPassword
- Initial root password for instance.- Throws:
IOException
-
MiniAccumuloCluster
public MiniAccumuloCluster(MiniAccumuloConfig config) throws IOException
- Parameters:
config
- initial configuration- Throws:
IOException
-
-
Method Detail
-
start
public void start() throws IOException, InterruptedException
Starts Accumulo and Zookeeper processes. Can only be called once.- Throws:
IOException
InterruptedException
-
getDebugPorts
public Set<Pair<ServerType,Integer>> getDebugPorts()
- Returns:
- generated remote debug ports if in debug mode.
- Since:
- 1.6.0
-
getInstanceName
public String getInstanceName()
- Returns:
- Accumulo instance name
-
getZooKeepers
public String getZooKeepers()
- Returns:
- zookeeper connection string
-
stop
public void stop() throws IOException, InterruptedException
Stops Accumulo and Zookeeper processes. If stop is not called, there is a shutdown hook that is setup to kill the processes. However its probably best to call stop in a finally block as soon as possible.- Throws:
IOException
InterruptedException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Throws:
IOException
- Since:
- 2.0.1
-
getConfig
public MiniAccumuloConfig getConfig()
- Since:
- 1.6.0
-
getConnector
@Deprecated(since="2.0.0") public Connector getConnector(String user, String passwd) throws AccumuloException, AccumuloSecurityException
Deprecated.since 2.0.0, replaced bycreateAccumuloClient(String, AuthenticationToken)
Utility method to get a connector to the MAC.- Throws:
AccumuloException
AccumuloSecurityException
- Since:
- 1.6.0
-
createAccumuloClient
public AccumuloClient createAccumuloClient(String user, AuthenticationToken token)
Utility method to create anAccumuloClient
with connection to the MAC. The AccumuloClient object should be closed by user- Since:
- 2.0.0
-
getClientConfig
@Deprecated(since="2.0.0") public ClientConfiguration getClientConfig()
Deprecated.since 2.0.0, replaced bygetClientProperties()
- Since:
- 1.6.0
-
getClientProperties
public Properties getClientProperties()
- Returns:
- A copy of the connection properties for the cluster
- Since:
- 2.0.0
-
getClientProperties
public static Properties getClientProperties(File directory)
Construct clientProperties
using aMiniAccumuloCluster
directory- Parameters:
directory
- MiniAccumuloCluster directory- Returns:
Properties
for that directory- Since:
- 2.0.0
-
-