Skip to content
This repository has been archived by the owner on Jan 29, 2019. It is now read-only.

Commit

Permalink
Merge pull request #165 from cybercongress/158-dev-env
Browse files Browse the repository at this point in the history
Documentation for configure development environment
  • Loading branch information
hleb-albau authored Apr 12, 2018
2 parents 7a46339 + bf403fe commit 524b7e9
Show file tree
Hide file tree
Showing 11 changed files with 172 additions and 3 deletions.
74 changes: 74 additions & 0 deletions dev-environment/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Development environment

## Prestart
* Instal Java 8 JDK
* Install Docker and Docker Compose
* Install Intellij Idea

## Run Kafka, Elassandra, Prometheus and Grafana
### Start containers(required)
For mac:
```bash
docker-compose -f dev-environment/env-mac.yml up -d
```
For linux family:
```bash
docker-compose -f dev-environment/env.yml up -d
```
### Bootstrap Elassandra with keyspaces(required)
```bash
docker cp dev-environment/elassandra-bootstrap.cql elassandra-markets:/elassandra-bootstrap.cql
docker exec -it elassandra-markets bash
cqlsh -f elassandra-bootstrap.cql
```
Then copy paste all content from elassandra-bootstrap.cql to interactive console and press enter. Write twice exit to
exit from container shell.

### Stop kafka and delete kafka data(cheat sheet)
```bash
docker stop fast-data-dev-markets
docker rm fast-data-dev-markets
```
### Stop elassandra and delete elassandra data(cheat sheet)
```bash
docker stop elassandra-markets
docker rm elassandra-markets
```

## Start required chain nodes(Examples)
### Run parity node(cheat sheet)
```bash
sudo docker run -d -p 8545:8545 --name parity_eth \
-v ${REPLACE_IT_BY_HOST_FOLDER}:/cyberdata parity/parity:stable \
--db-path /cyberdata --jsonrpc-hosts all --jsonrpc-interface all --jsonrpc-threads 4
```

### Access chains from remote machine(mars)(cheat sheet)
```bash
ssh -L 18332:localhost:18332 -L 8332:localhost:8332 \
-L 18545:localhost:18545 -L 8545:localhost:8545 \
[email protected] -p 33322
```

## Import project to Intellij Idea
Open Project in idea by selecting: Import Project -> selecting build.gradle file from the repository root
![Select Import Project](images/select-import-project.png)
![Select Build Gradle](images/select-build-gradle.png)
![Import Settings](images/gradle-settings.png)
Wait for dependency downloading and indexation

## Run Exchanges Connector, Tickers, or API from intellij Idea
Go to ExchangesConnectorApplication.kt and press green triangle on left to the code (on example line 16):
![Start Pump](images/start-exchanges-connector.png)

If, you use parity endpoint different rather that localhost:8545, than Etherdelta connector will fail due to lack of environment property PARITY_URL.
Let's define it: Select "Edit Configurations"

![Select Edit Run Configuration](images/select-edit-configurations.png)

Add next properties:

![Add variables](images/add-environment-variables.png)

Now, run exchanges connector one more time then etherdelta connector should start.
You can add environment variables in the same way for Tickers, APIs and etc.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ WITH CLUSTERING ORDER BY (
tradeId DESC
);

CREATE TABLE IF NOT EXISTS markets.order (
CREATE TABLE IF NOT EXISTS "markets"."order" (
exchange text,
pair frozen<tokenpair>,
type text,
Expand All @@ -48,8 +48,8 @@ CREATE TABLE IF NOT EXISTS markets.order (
orderId text,
amount decimal,
price decimal,
PRIMARY KEY ((exchange, pair, epochHour), trdadeId)
PRIMARY KEY ((exchange, pair, epochHour), orderId)
)
WITH CLUSTERING ORDER BY (
tradeId DESC
orderId DESC
);
44 changes: 44 additions & 0 deletions dev-environment/env-mac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
version: '3'
services:

fast-data-dev:
container_name: fast-data-dev-markets
image: landoop/fast-data-dev:latest
ports:
- "3030:3030"
- "9092:9092"
- "2181:2181"
- "9581-9584:9581-9584"
- "8081-8083:8081-8083"
environment:
RUNTESTS: 0
SAMPLEDATA: 0
FORWARDLOGS: 0
ADV_HOST: 127.0.0.1

elassandra:
container_name: elassandra-markets
image: strapdata/elassandra:5.5.0.13
ports:
- "9042:9042"
- "9200:9200"
- "7199:7199"
environment:
CASSANDRA_DC: DEVELOPMENT
CASSANDRA_CLUSTER_NAME: CYBER_SEARCH

prometheus:
container_name: prometheus
restart: on-failure
image: prom/prometheus:v2.1.0
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
ports:
- "9090:9090"

grafana:
container_name: grafana
restart: on-failure
image: grafana/grafana:5.0.4
ports:
- "3000:3000"
42 changes: 42 additions & 0 deletions dev-environment/env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
version: '3'
services:

fast-data-dev:
container_name: fast-data-dev-markets
image: landoop/fast-data-dev:latest
ports:
- "3030:3030"
- "9092:9092"
- "2181:2181"
- "9581-9584:9581-9584"
- "8081-8083:8081-8083"
environment:
RUNTESTS: 0
SAMPLEDATA: 0
FORWARDLOGS: 0
ADV_HOST: 127.0.0.1

elassandra:
container_name: elassandra-markets
image: strapdata/elassandra:5.5.0.13
ports:
- "9042:9042"
- "9200:9200"
- "7199:7199"
environment:
CASSANDRA_DC: DEVELOPMENT
CASSANDRA_CLUSTER_NAME: CYBER_SEARCH

prometheus:
container_name: prometheus
network_mode: host
restart: on-failure
image: prom/prometheus:v2.1.0
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml

grafana:
container_name: grafana
network_mode: host
restart: on-failure
image: grafana/grafana:5.0.4
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dev-environment/images/gradle-settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dev-environment/images/select-build-gradle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dev-environment/images/select-import-project.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions dev-environment/prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
global:
scrape_interval: 5s
scrape_timeout: 5s
evaluation_interval: 5s
scrape_configs:
- job_name: 'markets-monitoring'
metrics_path: '/actuator/prometheus'
static_configs:
- targets: ['localhost:8080','localhost:8081','host.docker.internal:8080','host.docker.internal:8081']

0 comments on commit 524b7e9

Please sign in to comment.