21.6.15

Play with Play Framework within Docker

1. Installation

https://www.playframework.com/documentation/2.4.x/Installing

I ran a Java 8 docker container and copied typesafe-activator-1.3.5.zip to the target container. Thanks to boot2docker, /Users director in Mac has already been mount to boot2docker host, and I could simply do a cp command between my Mac host system and the container file system.

2. Port forwarding

https://github.com/boot2docker/boot2docker/blob/master/doc/WORKAROUNDS.md

According to this link, I ran the following command to forward port 8888 on my Mac to my target container's port 8888.

Firstly I need to find out the IP address of the target container:

boot2docker ssh docker inspect <container name> | grep Address

        "MacAddress": "",
        "GlobalIPv6Address": "",
        "IPAddress": "172.17.0.42",
        "LinkLocalIPv6Address": "fe80::42:acff:fe11:2a",

        "MacAddress": "02:42:ac:11:00:2a",

172.17.0.42 was the one I needed.

boot2docker ssh -vnNTL 8888:172.17.0.42:8888

Done

3. Start activator and have it listen on 0.0.0.0:8888 instead of 127.0.0.1:8888


According to this post:

$activator -Dhttp.address=0.0.0.0 -Dhttp.port=8888 ui


Experiencing ZooKeeper in Docker

Build a Docker Image for ZK Server

Installing ZK server is simple, so as building a docker image for it. You can simple use the Dockerfile from the following github project:


I create a very simple one for just using Standalone ZK server:


It is good enough for developing zk clients.

Using nc Command from a Client Container

The simplest way to try a zk Server is to use the "nc" command.

Step1: Run a container with --link to the zk Server

docker run -t -i --name zkc --link zk:zk ubuntu:14.04 /bin/bash

Step2: Use the four-letter-word command to test the zk Server

http://zookeeper.apache.org/doc/r3.4.6/zookeeperAdmin.html#sc_zkCommands

Using zkCli.sh from Client Containers

Although the four-letter-commands are convenient, they are just for quickly testing the server. zkCli is the shell command line tool to explore the server more.

Step1: Install zk binary

curl -fsSL http://mirrors.sonic.net/apache/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz | tar -C /opt -xz 

But you can actually run the zk Server image as a client container.

$./bin/zkCli.sh -server zk:2181

[zk: zk:2181(CONNECTED) 0] \h
ZooKeeper -server host:port cmd args
connect host:port
get path [watch]
ls path [watch]
set path data [version]
rmr path
delquota [-n|-b] path
quit 
printwatches on|off
create [-s] [-e] path data acl
stat path [watch]
close 
ls2 path [watch]
history 
listquota path
setAcl path acl
getAcl path
sync path
redo cmdno
addauth scheme auth
delete path [version]
setquota -n|-b val path








18.6.15

Apache Kafka源码分析 – Broker Server


How to fix Eclipse's problem when importing Kafka project


I saw this:

Description Resource Path Location Type
scalatest_2.10-1.9.1.jar of core build path is cross-compiled with an incompatible version of Scala (2.10.0). In case this report is mistaken, this check can be disabled in the compiler preference page. core Unknown Scala Version Problem

Fixing:

1. Right click on project core.
2. Properties
3. Scala compiler
4. Click on "Use project settings"
5. Select Use Latest 2.10 bundle(dynamic)