Playing with Some Java Concurrency Classes

So I used Spring Boot to bang out a REST service which I call a “delay service” which simply sleeps for the amount of time (in seconds) given as a path parameter like this:  http://<host>/delay/{timeInSeconds}.  I created this to actually see my web services client call the service many times in parallel to see an ExecutorService work as advertised.  The ExecutorService implementation I chose was a simple fixed-size thread pool.

As expected, when I used the client to call the delay service several times in parallel with varying delay times, the entire time spent was roughly the same as the longest delay time.

Kinda neat.  Later I ran into the RxJava project which seems to allow you to do the same thing in a “reactive” manner (and much, much more) and I’ll be looking at that soon.

Spring Boot and Docker

I went through this Spring Framework page describing running a Spring Boot application in a Docker container.  Pretty cool.  I will investigate Spring Boot some more and also the Dockerfile used to create the image being used.  There are a couple of new items I’ve never seen, including “ENTRYPOINT” and “VOLUME”.

What I’d like to do is add a bit of database access to this skeletal project.  Maybe utilize the MySQL Docker image I downloaded a few days ago with this new Spring Boot image to make a CRUD-type application with the two images.

I got a Spring Data JPA project going and working against my Docker MySQL image.  One difficulty I ran into was the port on which MySQL is running.  I’m already running MySQL on this machine, so 3306 is in use.  And when I fire up the image, it’s just grabbing a random port which makes it difficult to configure the Spring app’s datasource.  Not sure how much I’ll work on that for now…

Continuing with Docker

Today I’m continuing to look at Docker.  I am going to look into creating my own images and playing with some existing ones.  I’ve pulled the MySQL image and I’m going to poke around on it.  I might also look at securing a container or the daemon with some keys.

Hold on!  It seems there’s something I don’t quite get about images and containers.  I tried to remove one of the images I downloaded during the tutorial, but I was told it was in use by a container.  I ran “docker ps” and didn’t see any running.  Why are these containers hanging around?  I’ve gotta investigate that.

I found a couple relevant pages.  Here and here.

Looking at Docker (Again)

I downloaded and installed the new Netbeans IDE (version 8.2) and noticed that it had Docker support.  It’s been a while since I looked at Docker, so today I’m going to revisit it.

Got Docker upgraded and running by following the online tutorial.  When I tried to add the Docker instance to Netbeans, I noticed I’d have to change the daemon’s configuration to listen on a TCP port (instead of a Unix socket that I think it runs on by default).  After modifying /etc/default/docker and adding the instance to Netbeans, I could no longer use the client commands like “docker images”.  After sorting through the docs for a while, I found out that the Docker client will use the “DOCKER_HOST” environment variable to set the “-H” option (for “host”).

I also set up a Docker Hub account while going through the tutorial.

In any case, I’ve got a few ideas I’d like to try to exercise Docker a little bit and hopefully I’ll be able to get to it and log what I do on this blog.

Investigating Some New Java Tools

I was looking around java.net – somewhere I haven’t been for a while – and noticed an article discussing a few new Java tools.  I cloned the project and poked around a bit.  I found reference to the Retrofit project and did a deeper dive.  It looks like it’s most popular on the Android, but I see no reason why it couldn’t be used in a regular ol’ Java SE-type of application.  Basically, Retrofit supplies an abstraction for accessing RESTful web services.

To put it to the test, I found a public API called “Brewery DB” and used an online tool to churn out some POJOs based on the sample JSON for the web service.  Unfortunately, it looks like the RESTful service I chose has died on the vine.  In any case, I was able to query the API for its list of beers and get populated Java objects out of it.  I hope to revisit Retrofit again in the near future.

Looking at Firefox WebExtensions

So apparently the Add-On SDK for Firefox extension development is being put to rest.  WebExtensions are where it’s at.  This is probably old news to many, but I’ve not been paying close attention.  The new method is modeled after Chrome’s extension stuff and supposedly even Edge has a similar method.

Anyway, I spent Thursday and Friday of this week working on a little Firefox WebExtension.  I’ve added a toolbar button with a popup dialog and some code to communicate with a background script.  The next step is to use the “storage” part of the API.