This tutorial can get you started with the GeoMesa Lambda data store. Note that the Lambda data store
is for advanced use-cases - see Overview of the Lambda Data Store for details on when to use a Lambda store.

In the context of GeoMesa, Kafka is a useful tool for working with
streams of geospatial data. The Lambda data store leverages a transient in-memory
cache of recent updates, powered by Kafka, combined with long-term persistence to
Accumulo. This allows for rapid data updates, alleviating the burden on Accumulo
from constant deletes and writes.

You can use GeoServer to access and visualize the data stored in GeoMesa. In order to use GeoServer,
download and install version 2.12.x. Then follow the instructions in Installing GeoMesa Lambda in GeoServer
to enable GeoMesa.

The quick start operates by writing several thousand feature updates. The same feature identifier is used for
each update, so there will only be a single “live” feature at any one time. After
approximately 30 seconds, the updates stop and the feature is persisted to Accumulo.

The data used is from New York City taxi activity data published by the University
of Illinois. More information about the dataset is available here.

<user> the name of an Accumulo user that has permissions to create, read and write tables

<password> the password for the previously-mentioned Accumulo user

<table> the name of the destination table that will accept these test records. This table should either not exist or should be empty

<brokers> your Kafka broker instances, comma separated. For a local install, this would be localhost:9092

<kafka.zookeepers> your Kafka Zookeeper nodes, comma separated. For a local install, this would be localhost:2181

Warning

If you have set up the GeoMesa Accumulo distributed
runtime to be isolated within a namespace (see
Namespace Install) the value of <table>
should include the namespace (e.g. myNamespace.geomesa).

Optionally, you can also specify that the quick start should delete its data upon completion. Use the
--cleanup flag when you run to enable this behavior.

Once run, the quick start will create the Kafka topic, then pause and prompt you to register the layer in
GeoServer. If you do not want to use GeoServer, you can skip this step. Otherwise, follow the instructions in
the next section before returning here.

Once you continue, the tutorial should run for approximately thirty seconds. You should see the following output:

Loading datastore
Creating schema: taxiId:String,dtg:Date,geom:Point
Feature type created - register the layer 'tdrive-quickstart' in geoserver then hit <enter> to continue
Generating test data
Writing features to Kafka... refresh GeoServer layer preview to see changes
Wrote 2202 features
Waiting for expiry and persistence...
Total features: 1, features persisted to Accumulo: 0
Total features: 0, features persisted to Accumulo: 0
Total features: 1, features persisted to Accumulo: 1
Done

You can use GeoServer to access and visualize the data stored in GeoMesa. In order to use GeoServer,
download and install version 2.12.x. Then follow the instructions in Installing GeoMesa Lambda in GeoServer
to enable GeoMesa.

If you have already run the command to start the tutorial, then GeoServer should recognize the
tdrive-quickstart feature type, and should present that as a layer that can be published. Click on the
“Publish” link. If not, then run the tutorial as described above in Running the Tutorial. When
the tutorial pauses, go to “Layers” and “Add new Layer”. Select the GeoMesa Lambda store you just
created, and then click “publish” on the tdrive-quickstart layer.

You will be taken to the Edit Layer screen. You will need to enter values for the data bounding
boxes. For this demo, use the values MinX: 116.22366, MinY: 39.72925, MaxX: 116.58804, MaxY: 40.09298.

Click on the “Layer Preview” link in the left-hand gutter. If you don’t
see the quick-start layer on the first page of results, enter the name
of the layer you just created into the search box, and press
<Enter>.

At first, there will be no data displayed. Once you have reached this
point, return to the quick start console and hit “<enter>” to continue the tutorial.
As the data is updated in Kafka, you can refresh the layer preview page to see
the feature moving around.

While the quick start is running, all the features should be returned from the transient store (Kafka). After the quick
start finishes, all the feature should be returned from the persistent store (Accumulo). You can play with the
viewparams to see the difference.

The source code is meant to be accessible for this tutorial. The logic is contained in
the generic org.geomesa.example.quickstart.GeoMesaQuickStart in the geomesa-tutorials-common module,
and the Kafka/Accumulo-specific org.geomesa.example.lambda.LambdaQuickStart in the
geomesa-tutorials-accumulo-lambda-quickstart module. Some relevant methods are:

createDataStore get a datastore instance from the input configuration

createSchema create the schema in the datastore, as a pre-requisite to writing data

writeFeatures overridden in the KafkaQuickStart to simultaneously write and read features from Kafka

queryFeatures not used in this tutorial

cleanup delete the sample data and dispose of the datastore instance

Looking at the source code, you can see that normal GeoTools FeatureWriters are used; feature persistence
is managed transparently for you.

The quickstart uses a small subset of taxi data. Code for parsing the data into GeoTools SimpleFeatures is
contained in org.geomesa.example.data.TDriveData:

The quick start relies on not having any existing state when it runs. This can cause issues with older versions
of Kafka, which by default do not delete topics when requested. To re-run the quick start, first ensure that your Kafka
instance will delete topics by setting the configuration delete.topic.enable=true in your server properties.
Then use the Lamdba command-line tools (see Setting up the Lambda Command Line Tools) to remove the quick start schema: