public class ClusterFixtureBuilder extends Object
Designed primarily for unit tests: the builders provide control over all aspects of the Drillbit or cluster. Can also be used to create an embedded Drillbit, use the zero-argument constructor which will omit creating set of test-only directories and will skip creating the test-only storage plugins and other configuration. In this mode, you should configure the builder to read from a config file, or specify all the non-default config options needed.
| Modifier and Type | Class and Description |
|---|---|
static class |
ClusterFixtureBuilder.RuntimeOption |
| Modifier and Type | Field and Description |
|---|---|
protected int |
bitCount |
protected String[] |
bitNames |
protected Properties |
clientProps |
protected ConfigBuilder |
configBuilder |
static int |
DEFAULT_ZK_REFRESH |
protected BaseDirTestWatcher |
dirTestWatcher |
protected int |
localZkCount |
protected List<ClusterFixtureBuilder.RuntimeOption> |
sessionOptions |
protected List<ClusterFixtureBuilder.RuntimeOption> |
systemOptions |
protected boolean |
usingZk |
protected ZookeeperHelper |
zkHelper |
| Constructor and Description |
|---|
ClusterFixtureBuilder() |
ClusterFixtureBuilder(BaseDirTestWatcher dirTestWatcher) |
| Modifier and Type | Method and Description |
|---|---|
ClusterFixture |
build()
Create the embedded Drillbit and client, applying the options set
in the builder.
|
ClusterMockStorageFixture |
buildCustomMockStorage() |
ClusterFixtureBuilder |
clusterSize(int n)
The number of Drillbits to start in the cluster.
|
ConfigBuilder |
configBuilder()
The configuration builder which this fixture builder uses.
|
ClusterFixtureBuilder |
configClientProperty(String key,
Object value)
Add an additional property for the client connection URL.
|
ClusterFixtureBuilder |
configProperty(String key,
Object value)
Add an additional boot-time property for the embedded Drillbit.
|
ClusterFixtureBuilder |
configResource(String configResource)
Use the given configuration file, stored as a resource, to start the
embedded Drillbit.
|
ClusterFixtureBuilder |
maxParallelization(int n)
Set the maximum parallelization (max width per node).
|
ClusterFixtureBuilder |
putDefinition(OptionDefinition definition) |
ClusterFixtureBuilder |
saveProfiles()
Enable saving of query profiles.
|
ClusterFixtureBuilder |
sessionOption(String key,
Object value)
Provide a session option to be set once the Drillbit
is started.
|
ClusterFixtureBuilder |
setOptionDefault(String key,
Object value) |
ClusterFixtureBuilder |
systemOption(String key,
Object value)
Provide a system option to be set once the Drillbit
is started.
|
ClusterFixtureBuilder |
withBits(String... bitNames)
Define a cluster by providing names to the Drillbits.
|
ClusterFixtureBuilder |
withLocalZk()
By default the embedded Drillbits use an in-memory cluster coordinator.
|
ClusterFixtureBuilder |
withLocalZk(int count) |
ClusterFixtureBuilder |
withRemoteZk(String connStr) |
ClusterFixtureBuilder |
withZk(ZookeeperHelper zk)
Run the cluster using a Zookeeper started externally.
|
public static final int DEFAULT_ZK_REFRESH
protected ConfigBuilder configBuilder
protected List<ClusterFixtureBuilder.RuntimeOption> sessionOptions
protected List<ClusterFixtureBuilder.RuntimeOption> systemOptions
protected int bitCount
protected String[] bitNames
protected int localZkCount
protected ZookeeperHelper zkHelper
protected boolean usingZk
protected Properties clientProps
protected final BaseDirTestWatcher dirTestWatcher
public ClusterFixtureBuilder()
public ClusterFixtureBuilder(BaseDirTestWatcher dirTestWatcher)
public ConfigBuilder configBuilder()
public ClusterFixtureBuilder configResource(String configResource)
drill.exec.sys.store.provider.local.write : false,
drill.exec.http.enabled : false
It may be more convenient to add your settings to the default
config settings with configProperty(String, Object).configResource - path to the file that contains the
config file to be read#configProperty(String, Object)}public ClusterFixtureBuilder setOptionDefault(String key, Object value)
public ClusterFixtureBuilder configProperty(String key, Object value)
key - config property namevalue - property valuepublic ClusterFixtureBuilder putDefinition(OptionDefinition definition)
public ClusterFixtureBuilder configClientProperty(String key, Object value)
key - config property namevalue - property valuepublic ClusterFixtureBuilder sessionOption(String key, Object value)
key - the name of the session optionvalue - the value of the session optionpublic ClusterFixtureBuilder systemOption(String key, Object value)
key - the name of the system optionvalue - the value of the system optionpublic ClusterFixtureBuilder maxParallelization(int n)
n - the "max width per node" parallelization option.public ClusterFixtureBuilder clusterSize(int n)
n - the desired cluster sizepublic ClusterFixtureBuilder withBits(String... bitNames)
bitNames - array of (unique) Drillbit namespublic ClusterFixtureBuilder withLocalZk()
public ClusterFixtureBuilder withLocalZk(int count)
public ClusterFixtureBuilder withRemoteZk(String connStr)
public ClusterFixtureBuilder withZk(ZookeeperHelper zk)
zk - the global Zookeeper to usepublic ClusterFixtureBuilder saveProfiles()
public ClusterFixture build()
FixtureBuilder builder = ClientFixture.newBuilder()
.property(...)
.sessionOption(...)
;
try (ClusterFixture cluster = builder.build();
ClientFixture client = cluster.clientFixture()) {
// Do the test
}
Note that you use a single cluster fixture to create any number of
drillbits in your cluster. If you want multiple clients, create the
first as above, the others (or even the first) using the
ClusterFixture.clientBuilder(). Using the client builder
also lets you set client-side options in the rare cases that you
need them.public ClusterMockStorageFixture buildCustomMockStorage()
Copyright © 2021 The Apache Software Foundation. All rights reserved.