-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathdemo-init.sh
executable file
·53 lines (42 loc) · 1.77 KB
/
demo-init.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
set -e
if ! hash jq 2>/dev/null; then
echo You need JQ installed matey! Please install it first.
echo Once you have done that, run ./demo-init.sh
exit 1
fi
echo Waiting for HBase to become ready...
set +e
until $(docker-compose exec master /bin/sh -c "echo \"status\" | hbase shell" &>/dev/null); do
printf '.'
sleep 1
done
set -e
echo Creating Users table in HBase...
docker-compose exec master /bin/sh -c "echo \"create 'Users', { NAME => 'cf', REPLICATION_SCOPE => '1' }\" | hbase shell"
export WEB="http://127.0.0.1:17007/nifi"
export API="http://127.0.0.1:17007/nifi-api"
echo -n Waiting for NiFi to come up, this can take a minute or two...
set +e
until $(curl --output /dev/null --silent --head --fail $WEB); do
printf '.'
sleep 5
done
set -e
echo ""
echo Creating Templates in NiFi...
export PROCESS_GROUP=$(curl -s $API/flow/process-groups/root | jq .processGroupFlow.id)
export PROCESS_GROUP=$(echo $PROCESS_GROUP | tr -d '"')
echo Process group: $PROCESS_GROUP
curl -s -iv -F template=@config/nifi/users.xml $API/process-groups/$PROCESS_GROUP/templates/upload &>/dev/null
export TEMPLATE_ID=$(curl -s $API/flow/templates | jq .templates | jq '.[]'.id)
export TEMPLATE_ID=$(echo $TEMPLATE_ID | tr -d '"')
echo Template id: $TEMPLATE_ID
export PAYLOAD="{\"templateId\":\"$TEMPLATE_ID\",\"originX\":365,\"originY\":-21}"
curl -s -kH "Content-Type: application/json" -X POST -d $PAYLOAD $API/process-groups/$PROCESS_GROUP/template-instance &>/dev/null
echo Opening NiFi...
echo At this point - you need to enable each of the processors on the left most group
echo and then start the Fetch User Data one.
echo This will import approx 1000 rows every 20 seconds so do not leave it running too long.
echo You can then go and see those rows in HBase.
open $WEB