Skip to main content


Persisting a Key Value in etcd using jetcd for Java

etcd is a distributed key-value store which can be used for storing configuration information needed by the applications like database urls, driver etc. This is essential when we have applications running in a cluster that need to share information. For example, in microservices architecture, we can have multiple instances of an application running across different machines. So when a new instance spawns up it is essential to that the new instance should have the configuration information it needed. For example, if the instance connects to a database, it needs to know how to connect to the database (the configuration) which must be stored somewhere and is accessible across the cluster, no matter in which machine the instance spawns up. This means that you cannot have configuration information residing in just a single machine! Because if the machine fails, or is down, new instances simply cannot work because the lack the configuration information needed for them to start because the m…
Recent posts

Apache Camel+Snmp Hello World

The following article helps you to get started with the Camel Snmp. Required Jars: I personally did not use Maven for executing this program. I have downloaded all the jars required for this and then executed it. Note: I had to download some jars separately. Not all of them are required.
The following steps should work in most cases: Download camel zip file ( may additionally need snmp4j jar. ( P.S: Make sure you download the binaries, not the sources ;) Programimport java.util.Date; import java.util.Objects; import org.apache.camel.Exchange; import org.apache.camel.Message; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.main.Main; import org.apache.camel.main.MainSupport; import org.apache.camel.main.MainListenerSupport; import org.apache.camel.Processor; import org.apache.camel.component.snmp.*; import org.apache.camel.impl.DefaultCamelContext; import org.apache.camel.CamelCont…

Running multiple shells in the same docker container

The exec way First run a containerdocker run -it test Next, you can use the execGet the docker container id docker ps Run exec on the container id docker exec -it 0ec2333ec307 /bin/bash/ In this way, you can execute multiple commands in the docker container. Alternatively, you can also directly execute the commands you want instead of /bin/bash I have encountered a use case where I have to run two Java programs in the same container. So, I started an interactive shell, which could also be done by directly executing the java command instead of /bin/bash The sshd way, You can have the sshd service up and running so that you can directly start an ssh session to your container. This is a bit more complex method compared to the aforementioned, but you can find it useful if you want access the container from outside of your host machine where there is no docker client. For CentOS, RHELyum install openssh-server systemctl enable sshd systemctl start sshd If you want to have root access, yo…

Method References Example

/* * More can be found at */importjava.util.*;publicclassMethodReferencesDemo{publicstaticvoidmain(Stringargs[]){List<String>namesList=newArrayList<String>();namesList.add("Rama");namesList.add("Sita");namesList.add("Lakshmana");namesList.add("Bharatha");namesList.add("Sathrugna");// call the println() method of System.out object namesList.forEach(System.out::println);// call the static printString method of MethodReferencesDemo class namesList.forEach(MethodReferencesDemo::printString);}publicstaticvoidprintString(Stringst){System.out.println(st);}}

Running Docker apps in VM which need proxy to connect to Internet

For systems, which can't connect to Internet without a proxy Note: If your computer or VM in which you are about to install docker is not connected to Internet directly, then you can use a http(s) proxy. This is the case with most development VMs in the corporates which are generally not exposed to the Internet. Check with your IT team and get a proxy. Once you get a proxy, set it to your VM using the following guide.
Add the following lines to your ~/.bashrc file, so that they will be set when you startup.
vi ~/.bashrc export https_proxy=https://x.x.x.x:3128 export http_proxy=http://x.x.x.x:3128
Sometimes, (as it happened to me), the yum.conf also needs a proxy. Otherwise, you might get a timeout error. Though the curl works, you will face the issue with yum. So add the following line to your /etc/yum.conf file proxy=http://x.x.x.x:3128 Note: Mostly, the port will be 3128. If not, check with your IT team.
Installing Docker CE on CentOS 7.5
It is recommended to do a …