This is the repositoy of the MarkovShield Engine, the backend of MarkovShield. If you would like to try out MarkovShield, please have a look at the https://github.com/MarkovShield/install repository. The following documentation is only needed, if you would like to run the MarkovShield Engine jobs the manual way.
- MarkovShield Engine
If you run any of the down here provided commands outside of the provided MarkovShield Engine job containers, ensure you have the following host entries set in your local hostfile:
127.0.0.1 zookeeper
127.0.0.1 broker
127.0.0.1 jobmanagerTo run the commands down here you will need the following packages installes on your system:
mavenflinkjava-jdk
Note: flink is only needed to submit the job JAR file to the MarkovShield Engine.
Please have a look at the Settings documentation in order to see all possible configuration options.
To build the Kafka Stream and Flink JAR files:
mvn -am --projects kafka-stream clean install
mvn -am --projects flink clean installHint: If you run into any problems, try to run these commands with the parameter -DskipTests.
Here are the commands listed which are needed to run the MarkovShield Engine.
Start the Kafka Stream application:
java -cp kafka-stream\target\kafka-stream-2.0-jar-with-dependencies.jar ch.hsr.markovshield.kafkastream.application.MarkovShieldClickstreamsAfterwards start the Apache Flink jobs, which are needed to analyse a clickstream and update the user models:
bin\flink run -c ch.hsr.markovshield.flink.MarkovShieldAnalyser --jobmanager jobmanager:6123 C:\Users\<USER>\Documents\architecture_prototype\flink\target\flink-2.0-jar-with-dependencies.jar
bin\flink run -c ch.hsr.markovshield.flink.MarkovShieldModelUpdater --jobmanager jobmanager:6123 C:\Users\<USER>\Documents\architecture_prototype\flink\target\flink-2.0-jar-with-dependencies.jarHint: Perhaps you need to change the path of the flink application depending on your setup.
The following commands can be used to generate some sample data:
java -cp kafka-stream\target\kafka-stream-2.0-jar-with-dependencies.jar ch.hsr.markovshield.kafkastream.development_tools.generators.MarkovModelGenerator
java -cp kafka-stream\target\kafka-stream-2.0-jar-with-dependencies.jar ch.hsr.markovshield.kafkastream.development_tools.generators.MarkovClickAndLoginGeneratorStart the Kafka Stream application:
java -cp kafka-stream/target/kafka-stream-2.0-jar-with-dependencies.jar ch.hsr.markovshield.kafkastream.application.MarkovShieldClickstreamsAfterwards start the Apache Flink jobs, which are needed to analyse a clickstream and update the user models:
flink run -c ch.hsr.markovshield.flink.MarkovShieldAnalyser --jobmanager jobmanager:6123 flink/target/flink-2.0-jar-with-dependencies.jar
flink run -c ch.hsr.markovshield.flink.MarkovShieldModelUpdater --jobmanager jobmanager:6123 flink/target/flink-2.0-jar-with-dependencies.jarHint: Perhaps you need to change the path of the flink application depending on your setup.
The following commands can be used to generate some sample data:
java -cp kafka-stream/target/kafka-stream-2.0-jar-with-dependencies.jar ch.hsr.markovshield.kafkastream.development_tools.generators.MarkovModelGenerator
java -cp kafka-stream/target/kafka-stream-2.0-jar-with-dependencies.jar ch.hsr.markovshield.kafkastream.development_tools.generators.MarkovClickAndLoginGeneratordocker exec -u 0 -it deployment_broker_1 /bin/bashTo create Kafka topics, use the following commands:
kafka-topics --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 1 --topic MarkovLogins
kafka-topics --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 1 --topic MarkovClicks
kafka-topics --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 1 --topic MarkovUserModels
kafka-topics --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 1 --topic MarkovClickStreams
kafka-topics --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 1 --topic MarkovClickStreamAnalysis
kafka-topics --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 1 --topic MarkovValidatedClickStreamTo consume Kafka messages from a specific topic (e.g. MarkovValidatedClickStream) use:
kafka-console-consumer --zookeeper zookeeper:2181 --topic MarkovValidatedClickStream --from-beginning --property print.key=trueIf you want to produce a sample click entry into a Kafka topic (e.g. MarkovClicks) use:
echo '61631#{"sessionUUID":"61631","clickUUID":"1000","url":"my-secret-url","urlRiskLevel":2,"timeStamp":1495602498740,"validationRequired":true}' | kafka-console-producer --broker-list localhost:9092 --topic MarkovClicks --property "parse.key=true" --property "key.separator=#";This command is only meant to be used for breaking changes:
FOR /f "tokens=*" %i IN ('docker ps -a -q') DO docker rm %iTo build the MarkovShield Docker images and publish them to a registry (e.g. the Docker Hub), change the HUBPREFIX inside the Makefile to your Docker Hub username/organisation name and hit make publish.
Download http://mirror.synyx.de/apache/avro/avro-1.8.1/java/avro-tools-1.8.1.jar
java -cp avro-tools-1.8.1.jar org.apache.avro.tool.Main compile schema TypeReuseTest.avsc CompoundSubTypeExtended.avsc DirWithOtherAvscFiles OutputDir