-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·148 lines (120 loc) · 4.12 KB
/
run.sh
File metadata and controls
executable file
·148 lines (120 loc) · 4.12 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/usr/bin/env bash
#########################################################################
# Config vars
#########################################################################
# Set to the names of the Docker images you want to use
PROXY_IMAGE=hyoung/haystack_proxy
WEBFRONT_IMAGE=hyoung/haystack_webfront
DIRECTORY_IMAGE=hyoung/haystack_directory
CACHE_IMAGE=hyoung/haystack_cache
STORAGE_IMAGE=hyoung/haystack_storage
# DATA_IMAGE=hyoung/haystack_data
# Set the names of the Docker containers for corresponding images
PROXY_CONTAINER=h_proxy
WEBFRONT_CONTAINER=h_webfront
DIRECTORY_CONTAINER=h_directory
CACHE_CONTAINER=h_cache
STORAGE_CONTAINER1=h_storage1
STORAGE_CONTAINER2=h_storage2
# DATA_CONTAINER=h_data
# Set the name of the bridge network
NETWORK=haystack_network
# Set the local directories to the components
LOCAL_PROXY_DIR=$(pwd)'/proxy'
LOCAL_WEBFRONT_DIR=$(pwd)'/webfront'
LOCAL_DIRECTORY_DIR=$(pwd)'/directory'
LOCAL_CACHE_DIR=$(pwd)'/cache'
LOCAL_STORAGE_DIR=$(pwd)'/storage'
# LOCAL_DATA_DIR=$(pwd)'/data'
# Set the ip4 address for each component
SUBNET=172.20.0.0/16
GATEWAY=172.20.0.1
PROXY_IP=172.20.0.2
WEBFRONT_IP=172.20.0.3
DIRECTORY_IP=172.20.0.4
CACHE_IP=172.20.0.5
STORAGE_IP1=172.20.0.6
STORAGE_IP2=172.20.0.7
# Set the image directories
# WORK_DIR='/root/network'
# DATA='/data/string.txt'
# Set the port
PROXY_SERVER_PORT=80
CACHE_SERVER_PORT=8080 # cache server
STORAGE_SERVER_PORT1=8081 #storage server1
STORAGE_SERVER_PORT2=8082 #storage server2
STORAGE_INTERNAL_PORT=8080 # storage internal port
#########################################################################
# Build images:
#########################################################################
echo "-----------------------------------------------------------"
echo "Building images"
echo "-----------------------------------------------------------"
# Build the Haystack Images
docker build -t $PROXY_IMAGE $LOCAL_PROXY_DIR
docker build -t $WEBFRONT_IMAGE $LOCAL_WEBFRONT_DIR
docker build -t $DIRECTORY_IMAGE $LOCAL_DIRECTORY_DIR
docker build -t $CACHE_IMAGE $LOCAL_CACHE_DIR
docker build -t $STORAGE_IMAGE $LOCAL_STORAGE_DIR
# Build the data volume container Image
# docker build -t $DATA_IMAGE $LOCAL_DATA_DIR
#########################################################################
# Start running Haystack prototype
#########################################################################
echo "-----------------------------------------------------------"
echo "Start running Haystack prototype"
echo "-----------------------------------------------------------"
# Create a bridge network for the components
docker network create \
--driver bridge \
--subnet $SUBNET \
--gateway $GATEWAY \
$NETWORK
# Create a data volumn container to simulate Distributed File System
# docker run -d --name $DATA_CONTAINER $DATA_IMAGE
# Create the Cache server container
# Currently use a Docker data volume to simulate Distributed File System
# indicated by flag '-v'
docker run -itd \
--name $CACHE_CONTAINER \
--network $NETWORK \
--ip $CACHE_IP \
-p $CACHE_SERVER_PORT:$CACHE_SERVER_PORT \
-v $LOCAL_CACHE_DIR/imgs:/root/app/imgs \
$CACHE_IMAGE
# Create the Directory server container
docker run -itd \
--name $DIRECTORY_CONTAINER \
--network $NETWORK \
--ip $DIRECTORY_IP \
$DIRECTORY_IMAGE
# Create a tiny table
sleep 30 # wait for Cassandra initialization
docker exec -d $DIRECTORY_CONTAINER cqlsh -f /root/init_table.txt
sleep 30 # wait for Cassandra table creation
# Create the web front server container
docker run -itd \
--name $WEBFRONT_CONTAINER \
--network $NETWORK \
--ip $WEBFRONT_IP \
$WEBFRONT_IMAGE
# Create the proxy container
docker run -itd \
--name $PROXY_CONTAINER \
--network $NETWORK \
--ip $PROXY_IP \
-p $PROXY_SERVER_PORT:$PROXY_SERVER_PORT \
$PROXY_IMAGE
# Create the storage container
docker run -itd \
--name $STORAGE_CONTAINER1 \
--network $NETWORK \
--ip $STORAGE_IP1 \
-p $STORAGE_SERVER_PORT1:$STORAGE_INTERNAL_PORT \
$STORAGE_IMAGE
docker run -itd \
--name $STORAGE_CONTAINER2 \
--network $NETWORK \
--ip $STORAGE_IP2 \
-p $STORAGE_SERVER_PORT2:$STORAGE_INTERNAL_PORT \
$STORAGE_IMAGE