public class LightningClientBuilder extends Object
This is a builder class to create an instance of LightningClient with
all required dependencies.
The default implementation of LightningClient returned submits task
to one of the many stand alone instances of lightning core through Rest API.
One or many lightning core instances has to be registered with the lightning
client via setSeeds(List) method before calling the build()
method.
List<String> seeds = new ArrayList<String>();
seeds.add("hostname1");
seeds.add("hostname2");
LightningClient client = new LightningClientBuilder()..addSeed("hostname1").setCorePort(8989).build();
The lightning core instance can be run in embedded mode by calling
setEmbeddedMode(boolean) before invoking the build()
method.
LightningClient client = new LightningClientBuilder().setEmbeddedMode(true).build();
LightningClient| Constructor and Description |
|---|
LightningClientBuilder() |
| Modifier and Type | Method and Description |
|---|---|
LightningClientBuilder |
addSeed(String seed)
Adds a single stand alone lightning core instances to the existing Seed
List.
|
LightningClient |
build()
Creates an instance of
LightningClient with all required dependencies. |
LightningClientBuilder |
setAllowCrossRegionInteraction(boolean allowCrossRegionInteraction)
Set the lightning core to run in embedded mode.
|
LightningClientBuilder |
setAuditApiUrlTemplate(String auditApiUrl)
Set the API URL template for audit data.
|
LightningClientBuilder |
setAuditJsonApiUrlTemplate(String auditJsonApiUrl)
Set the API URL template for audit data in JSON format.
|
LightningClientBuilder |
setAuditSummaryUrlTemplate(String auditSummaryUrl)
Set the API URL template for audit summary data.
|
LightningClientBuilder |
setCorePort(int corePort)
Set the lightning core port.
|
LightningClientBuilder |
setCrossRegionSeeds(List<String> crossRegionSeeds)
Set the list of stand alone lightning core instances from different colocations.
|
LightningClientBuilder |
setEmbeddedMode(boolean mode)
Set the lightning core to run in embedded mode.
|
LightningClientBuilder |
setLightningStatsUrlTemplate(String lightningStatsUrl)
Set the API URL template to get lightning statistics.
|
LightningClientBuilder |
setPollApiUrlTemplate(String pollApiUrl)
Set the API URL template for polling response.
|
LightningClientBuilder |
setReserveApiUrlTemplate(String reserveApiUrl)
Set the API URL template for Reservation.
|
LightningClientBuilder |
setSeeds(List<String> seeds)
Set the list of stand alone lightning core instances.
|
LightningClientBuilder |
setSubmitApiUrlTemplate(String submitApiUrl)
Set the API URL template for submitting request.
|
LightningClientBuilder |
setSystemConfigUpdateUrlTemplate(String systemConfigUpdateUrl)
Set the API URL template to update system configuration.
|
LightningClientBuilder |
setSystemConfigUrlTemplate(String systemConfigUrl)
Set the API URL template to get system configuration.
|
LightningClientBuilder |
setUrlUtils(com.ebay.lightning.core.utils.UrlUtils urlUtils)
Set the
UrlUtils |
public LightningClient build()
LightningClient with all required dependencies.LightningClient based on the configuration parameters before calling this method.
REST API based LightningClient is returned if embeddedMode is set to false.
An embedded LightningClient is returned if embeddedMode is set to truepublic LightningClientBuilder setUrlUtils(com.ebay.lightning.core.utils.UrlUtils urlUtils)
UrlUtilsurlUtils - the URL utils object to make http/https callspublic LightningClientBuilder setPollApiUrlTemplate(String pollApiUrl)
Format: http://{hostname}:[port]/[some/poll/url]
Example: http://{host}:{port}/l/poll
pollApiUrl - the URL template for polling responsepublic LightningClientBuilder setReserveApiUrlTemplate(String reserveApiUrl)
Format: http://{hostname}:[port]/[some/reservation/url]
Example: http://{host}:{port}/l/reserve
reserveApiUrl - the URL template for making reservationpublic LightningClientBuilder setSeeds(List<String> seeds)
embeddedMode is set to false.seeds - the list of host names running lightning corepublic LightningClientBuilder addSeed(String seed)
embeddedMode is set to
false.seed - name of running lightning core instancepublic LightningClientBuilder setCrossRegionSeeds(List<String> crossRegionSeeds)
allowCrossRegionInteraction is set to truecrossRegionSeeds - the list of host names on different colocations running lightning core.public LightningClientBuilder setSubmitApiUrlTemplate(String submitApiUrl)
Format: http://{hostname}:[port]/[some/submit/url]
Example: http://{host}:{port}/l/submit
submitApiUrl - the URL template for submitting taskspublic LightningClientBuilder setAuditApiUrlTemplate(String auditApiUrl)
Format: http://{hostname}:[port]/[some/audit/url]
Example: http://{host}:{port}/l/audit
auditApiUrl - the URL template to get compressed audit datapublic LightningClientBuilder setAuditJsonApiUrlTemplate(String auditJsonApiUrl)
Format: http://{hostname}:[port]/[some/audit/url]
Example: http://{host}:{port}/l/audit/json
auditJsonApiUrl - the URL template to get audit data in JSON formatpublic LightningClientBuilder setLightningStatsUrlTemplate(String lightningStatsUrl)
Format: http://{hostname}:[port]/[lightningStatsUrl]
Example: http://{host}:{port}/l/lightningStats
lightningStatsUrl - the URL template to get lightning statisticspublic LightningClientBuilder setAuditSummaryUrlTemplate(String auditSummaryUrl)
Format: http://{hostname}:[port]/[some/auditSummary/url]
Example: http://{host}:{port}/l/auditSummary
auditSummaryUrl - the URL template to get audit summary datapublic LightningClientBuilder setSystemConfigUrlTemplate(String systemConfigUrl)
Format: http://{hostname}:[port]/[getSystemConfigUrl]
Example: http://{host}:{port}/l/getSystemConfig
systemConfigUrl - the URL template to get system configurationpublic LightningClientBuilder setSystemConfigUpdateUrlTemplate(String systemConfigUpdateUrl)
Format: http://{hostname}:[port]/[updateSystemConfigUrl]
Example: http://{host}:{port}/l/updateSystemConfig
systemConfigUpdateUrl - the URL template to update system configurationpublic LightningClientBuilder setEmbeddedMode(boolean mode)
true, the lightning core will run in embedded mode.
If set to false, lightning core will run in standalone mode and has to be registered with client by calling setSeeds(List) method.mode - to run lightning core in embedded mode or standalone modepublic LightningClientBuilder setAllowCrossRegionInteraction(boolean allowCrossRegionInteraction)
false, tasks will only be submitted to lightning core running on the same colocation.
If set to true, tasks will be submitted to lightning core running on different colocation,
if all the lightning core instances running in the local colocations are busy.allowCrossRegionInteraction - to allow submitting task to lightning core running on different colocationpublic LightningClientBuilder setCorePort(int corePort)
corePort - port on which lightning core is runningCopyright © 2017. All rights reserved.