# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
# NOTE: To use this example, you will need to modify `src/main/resources/hbase-site.xml`
# to point to your HBase instance, and then repackage with `mvn package`.
# This is a known issue.

# topology definition
# name to be used when submitting
name: "hbase-persistent-wordcount"

# Components
components:
  - id: "columnFields"
    className: "org.apache.storm.tuple.Fields"
    constructorArgs:
      - ["word"]

  - id: "counterFields"
    className: "org.apache.storm.tuple.Fields"
    constructorArgs:
      - ["count"]

  - id: "mapper"
    className: "org.apache.storm.hbase.bolt.mapper.SimpleHBaseMapper"
    configMethods:
      - name: "withRowKeyField"
        args: ["word"]
      - name: "withColumnFields"
        args: [ref: "columnFields"]
      - name: "withCounterFields"
        args: [ref: "counterFields"]
      - name: "withColumnFamily"
        args: ["cf"]

# topology configuration
# this will be passed to the submitter as a map of config options
config:
  topology.workers: 1
  hbase.conf:
    hbase.rootdir: "${hbase.rootdir}"
    hbase.zookeeper.quorum: "${hbase.zookeeper.quorum}"

# spout definitions
spouts:
  - id: "word-spout"
    className: "org.apache.storm.testing.TestWordSpout"
    parallelism: 1

# bolt definitions

bolts:
  - id: "count-bolt"
    className: "org.apache.storm.flux.examples.WordCounter"
    parallelism: 1

  - id: "hbase-bolt"
    className: "org.apache.storm.hbase.bolt.HBaseBolt"
    constructorArgs:
      - "WordCount" # HBase table name
      - ref: "mapper"
    configMethods:
      - name: "withConfigKey"
        args: ["hbase.conf"]
    parallelism: 1

streams:
  - name: "" # name isn't used (placeholder for logging, UI, etc.)
    from: "word-spout"
    to: "count-bolt"
    grouping:
      type: SHUFFLE

  - name: "" # name isn't used (placeholder for logging, UI, etc.)
    from: "count-bolt"
    to: "hbase-bolt"
    grouping:
      type: FIELDS
      args: ["word"]
