...
Create a new directory, let's call it "local-dmaap, and go into the directory
Code Block language bash mkdir <path-to>/local-dmaap cd <path-to>/local-dmaap
Clone the DMaaP msgrtr and messageservice repositories
Code Block language bash git clone https://gerrit.onap.org/r/dmaap/messagerouter/msgrtr git clone https://gerrit.onap.org/r/dmaap/messagerouter/messageservice
Check out the Amsterdam branches of the DMaaP repos
Code Block cd msgrtr git co amsterdam cd ../messageservice git co amsterdam cd ..
In order to remove the need to install A&AI, comment out as follows in msgrtr src/main/java/com/att/nsa/cambria/service/impl/TopicServiceImpl.java:
Code Block language java diff --git a/src/main/java/com/att/nsa/cambria/service/impl/TopicServiceImpl.java b/src/main/java/com/att/nsa/cambria/service/impl/TopicServiceImpl.java index c12be2f..3ceeca0e5ca1fc 100644 --- a/src/main/java/com/att/nsa/cambria/service/impl/TopicServiceImpl.java +++ b/src/main/java/com/att/nsa/cambria/service/impl/TopicServiceImpl.java @@ -196,7 +196,7 @@ public class TopicServiceImpl implements TopicService { String appName=dmaapContext.getRequest().getHeader("AppName"); String enfTopicName= com.att.ajsc.beans.PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop,"enforced.topic.name.AAF"); - if(user != null) + /*if(user != null) { key = user.getKey(); @@ -211,10 +211,10 @@ public class TopicServiceImpl implements TopicService { if(user != null) + throw new DMaaPAccessDeniedException(errRes); /*if(user != null) { key = user.getKey(); } - @@ } + -214,7 +214,7 @@ public class TopicServiceImpl implements TopicService { } //else if (user==null && (null==dmaapContext.getRequest().getHeader("Authorization") && null == dmaapContext.getRequest().getHeader("cookie")) ) { - else if (user == null && null==dmaapContext.getRequest().getHeader("Authorization") && + else */ if (user == null && null==dmaapContext.getRequest().getHeader("Authorization") && (null == appName && null == dmaapContext.getRequest().getHeader("cookie"))) { LOGGER.error("Failed to create topic"+topicBean.getTopicName()+", Authentication failed."); @@ -243,7 +243,7 @@ public class TopicServiceImpl implements TopicService { permission = mrFactoryVal+nameSpace+"|create"; DMaaPAAFAuthenticator aaf = new DMaaPAAFAuthenticatorImpl(); - if(!aaf.aafAuthentication(dmaapContext.getRequest(), permission)) + /*if(!aaf.aafAuthentication(dmaapContext.getRequest(), permission)) { LOGGER.error("Failed to create topic"+topicBean.getTopicName()+", Authentication failed."); @@ -254,7 +254,7 @@ public class TopicServiceImpl implements TopicService { LOGGER.info(errRes.toString()); throw new DMaaPAccessDeniedException(errRes); - }else{ + }else{*/ // if user is null and aaf authentication is ok then key should be "" //key = ""; /** @@ -264,7 +264,7 @@ public class TopicServiceImpl implements TopicService { key = dmaapContext.getRequest().getUserPrincipal().getName().toString(); LOGGER.info("key ==================== "+key); - } + /*}*/ } try { @@ -311,7 +311,7 @@ public class TopicServiceImpl implements TopicService { LOGGER.info("Deleting topic " + topicName); final NsaApiKey user = DMaaPAuthenticatorImpl.getAuthenticatedUser(dmaapContext); - if (user == null && null!=dmaapContext.getRequest().getHeader("Authorization")) { + /*if (user == null && null!=dmaapContext.getRequest().getHeader("Authorization")) { LOGGER.info("Authenticating the user, as ACL authentication is not provided"); // String permission = "com.att.dmaap.mr.topic"+"|"+topicName+"|"+"manage"; String permission = ""; @@ -331,7 +331,7 @@ public class TopicServiceImpl implements TopicService { } - } + }*/ final Broker metabroker = getMetaBroker(dmaapContext); final Topic topic = metabroker.getTopic(topicName);
Build the msgrtr, skipping tests if you wish. Once the build completes, we're finished in msgrtr.
Code Block language bash cd msgrtr mvn clean install -DskipTests
In messageservice, the start-kafka.sh script breaks with the latest version of Scala and Kafka unless a new line is added to the end of the server.properties file. Edit the messageservice src/main/resources/docker-compose/start-kafka.sh as follows:
Code Block language bash cd ../messageservice diff --git a/src/main/resources/docker-compose/start-kafka.sh b/src/main/resources/docker-compose/start-kafka.sh index 87047ad..e1bf99c 100644 --- a/src/main/resources/docker-compose/start-kafka.sh +++ b/src/main/resources/docker-compose/start-kafka.sh @@ -47,6 +47,9 @@ if [[ -z "$KAFKA_ADVERTISED_HOST_NAME" && -n "$HOSTNAME_COMMAND" ]]; then export KAFKA_ADVERTISED_HOST_NAME=$(eval $HOSTNAME_COMMAND) fi +# The replacement below fails if there is not a new line at the end of the $KAFKA_HOME/config/server.properties file +echo "" >> $KAFKA_HOME/config/server.properties + for VAR in `env` do if [[ $VAR =~ ^KAFKA_ && ! $VAR =~ ^KAFKA_HOME ]]; then
Ensure that the version of msgrtr dependency used in messageservice pom.xml is the local one created above, check your pom.xml in messageservice, specifically you must specify if msgrtr is a SNAPSHOT version. for example, see below:
Code Block language bash <dependency> <groupId>org.onap.dmaap.messagerouter.msgrtr</groupId> <artifactId>msgrtr</artifactId> <version>1.1.1-SNAPSHOT</version>
Build the message service.
Code Block language bash mvn clean install -DskipTests
Ensure Docker is running on your machine. Clear down all relevant containers and images in your docker that might interfere with DMaaP. Use the commands below WITH CARE!
Code Block docker ps -a | cut -f1 -d' ' | awk '{printf("docker rm %s\n", $1)}' docker images | cut -c45-60 | grep -v ubuntu | awk '{printf("docker rmi --force %s\n", $1)}'
In messageservice, copy the "appl" directory to target/classes/docker. This copies the configuration for DMaaP into the location in which we will build the docker images and the docker-compose setup.
Code Block pwd local-dmaap/messageservice cp -pr target/swm/package/nix/dist_files/appl target/classes/docker
If /var/tmp/MsgRtr.properties file or directory exists on /var/tmp,delete it. This is the file where we will specify the local properties for Kafka/Zookeeper for DMaaP.
Code Block language bash rm -fr /var/tmp/MsgRtrApi.properties
Copy the template MsgRtr properties to /var/tmp
Code Block language bash cp bundleconfig-local/etc/appprops/MsgRtrApi.properties /var/tmp
Edit /var/tmp/MsgRtrApi.properties as follows to put in the host names and ports for Kafka and Zookeeper in our docker-compose setup:
Code Block language bash 0c40 < config.zk.servers=<zookeeper_host> --- > config.zk.servers=zookeeper 52c52 < kafka.metadata.broker.list=<kafka_host>:<kafka_port> --- > kafka.metadata.broker.list=kafka:9092
Now we prepare to build the Docker image for the DMaaP message service. Edit the messageservice startup.sh script as shown below, replacing all occurrences of "${project.artifactId}" with "dmaapMR1" and all occurrences of "${ajscRuntimeVersion}" with "2.0.0"
Code Block language bash cd target/classes/docker diff startup.sh.orig startup.sh 22,24c22,24 < root_directory="/appl/${project.artifactId}" < config_directory="/appl/${project.artifactId}/bundleconfig" < runner_file="appl/${project.artifactId}/lib/ajsc-runner-${ajscRuntimeVersion}.jar" --- > root_directory="/appl/dmaapMR1" > config_directory="/appl/dmaapMR1/bundleconfig" > runner_file="appl/dmaapMR1/lib/ajsc-runner-2.0.0.jar"
Build the adapted DMaaP docker image, it will be tagged as dmaap:localadapt
Code Block language bash docker build -t dmaap:localadapt .
Now we prepare the docker-compose setup for DMaaP. Go to messageservice/target/classes/docker-compose and edit Dockerfile, changing the KAFKA_VERSION to 1.0.0 and the SCALA_VERSION to 2.12
Code Block cd ../docker-compose diff Dockerfile.orig Dockerfile 7c7 < ENV KAFKA_VERSION="0.8.1.1" SCALA_VERSION="2.9.2" --- > ENV KAFKA_VERSION="1.0.0" SCALA_VERSION="2.12"
Edit docker-compose.yml to change the name of th DMaaP docker image to use our locally adapted DMaaP image:
Code Block language bash diff docker-compose.yml.orig docker-compose.yml 21c21 < image: attos/dmaap --- > image: dmaap:localadapt
On macOS only, edit docker-compose.yml to change var/tmp to /private/var/tmp (ensure you have /private/var/tmp shared with Docker on macOS).
Start DMaaP, crossing your fingers really tightly!
Code Block language bash docker-compose up
...