Hi there. I just found out yet another way to install the Oracle JDK on your Debian. There's a nice article in the Debian Wiki and you only have to follow the five steps that are listed under the "Process" section. After you have installed the new .deb package, you can simply change from OpenJDK to Oracle JDK by using the update-java-alternatives command. In my case, its the following:
# update-java-alternatives --set jdk-8-oracle-x64
Saturday, August 8, 2015
Thursday, April 16, 2015
Scala Future Callback for Apache HTTP Async Client
In a recent project, I needed an asynchronous HTTP client and due to some other requirements, I decided to use the Apache Async HTTP Client. The problem is, that the Async HTTP Client uses Java's Future implementation:
After I discussed the problem with a collegue, he came up with a pretty cool solution that prepares the ground for Scala Futures. The trick is to implement the FutureCallback interface by using a Scala Promise:
class ScalaFutureCallbackImpl[T] extends FutureCallback[T] {
private val promise: Promise[T] = Promise()
def cancelled(): Unit =
promise.failure(new RuntimeException("cancelled!"))
def completed(result: T): Unit = promise.success(result)
def failed(ex: Exception): Unit = promise.failure(ex)
def getScalaFuture: Future[T] = promise.future
}
Its interesting to see, how perfect the methods from the interface can be mapped to the corresponding Promise methods. The additional method getScalaFuture is necessary to give the caller access to the underlying Scala Future. With the new implementation, we are now able to use the Apache Async HTTP Client in a more convenient way:
val httpclient = HttpAsyncClients.createDefault()
val callback = new ScalaFutureCallbackImpl[HttpResponse]
httpClient.execute(host, request, context, callback)
for {
httpResponse <- callback.getScalaFuture
}
yield httpResponse
"The result can only be retrieved using method get when the computation has completed, blocking if necessary until it is ready." [Java Futures]An example code snippet demonstrates how to send an asynchronous HTTP request. To make a long story short: accessing the result of the Future means we block the current thread. An alternative solution is to use the Apache FutureCallback interface, which also lacks the ability to access the result of the future in a non-blocking way (see example). Hence: the provided functionality does not scale well in highly concurrent environments.
After I discussed the problem with a collegue, he came up with a pretty cool solution that prepares the ground for Scala Futures. The trick is to implement the FutureCallback interface by using a Scala Promise:
class ScalaFutureCallbackImpl[T] extends FutureCallback[T] {
private val promise: Promise[T] = Promise()
def cancelled(): Unit =
promise.failure(new RuntimeException("cancelled!"))
def completed(result: T): Unit = promise.success(result)
def failed(ex: Exception): Unit = promise.failure(ex)
def getScalaFuture: Future[T] = promise.future
}
Its interesting to see, how perfect the methods from the interface can be mapped to the corresponding Promise methods. The additional method getScalaFuture is necessary to give the caller access to the underlying Scala Future. With the new implementation, we are now able to use the Apache Async HTTP Client in a more convenient way:
val httpclient = HttpAsyncClients.createDefault()
val callback = new ScalaFutureCallbackImpl[HttpResponse]
httpClient.execute(host, request, context, callback)
for {
httpResponse <- callback.getScalaFuture
}
yield httpResponse
Thursday, January 8, 2015
Thinkpad T410 Wireless (Intel Centrino Advanced-N 6200 AGN) and Debian Wheezy
It might happen that your T410 wireless doesn't work after installing Debian, because you didn't have the non-free firmware at hand.
You'll find the missing firmware at the packages site. After you downloaded and decompressed the tarball put the file iwlwifi-6000-4.ucode-9.221.4.1 into /lib/firmware and create a symlink:
# ln -s iwlwifi-6000-4.ucode-9.221.4.1 iwlwifi-6000-4.ucode
Now, its time to reboot!
You'll find the missing firmware at the packages site. After you downloaded and decompressed the tarball put the file iwlwifi-6000-4.ucode-9.221.4.1 into /lib/firmware and create a symlink:
# ln -s iwlwifi-6000-4.ucode-9.221.4.1 iwlwifi-6000-4.ucode
Now, its time to reboot!
Friday, December 19, 2014
Scala Maven Project including Specs2
Since I found no up-to-date Maven Project for Scala that includes everything I want (especially Specs2), I created my own one on GitHub. There's a problem with some versions of Specs2, because org.scalaz.stream cannot be found. Due to that issue, the project currenty uses Specs 2.4 (for Scala 2.11).
Labels:
Maven,
org.scalaz.stream,
Scala,
Scala 2.11,
Specs 2
Tuesday, December 16, 2014
Updating Adobe Flash Plugin on Debian Wheezy
After my Iceweasel (Firefox) was telling me several times that the Adobe Flash Plugin is vulnerable and needs to be updated (Chromium wasn't complaining at all), I was wondering why no update is being installed when running APT?
Fortunately, the Debian Wiki explains how to update the Adobe Flash Plugin:
~# update-flashplugin-nonfree --install
Fortunately, the Debian Wiki explains how to update the Adobe Flash Plugin:
~# update-flashplugin-nonfree --install
Labels:
Adobe Flash Plugin,
Debian,
Iceweasel,
Update,
Vulnerable
Thursday, December 11, 2014
Published 'admintools' on GitHub
Some helpful scripts for system administrators are now available on GitHub.
Wednesday, December 3, 2014
IMAP over SSLv2 - Evolution Mail does not work on Debian 7.7 Wheezy: Enable TLS over port 993
After my email provider disabled SSLv3 for IMAP due to that security problem known as Poodle, Evolution Mail 3.4.4 on my Debian 7.7 Wheezy stopped working. Since there's no "ready-to-install" patch available yet, I rolled my own solution. [1] describes a patch that needs to be applied to the evolution-data-server and therefore we need to build evolution-data-server from the sources available through APT. In [2] there's a step-by-step howto, that explains how to build a APT package. I augmented those steps with the steps that were missing to build a patched evolution-data-server.
[1] evolution-data-server-3.10.4-poodle-enable-tls-for-ssl.patch for bug #1153052
[2] Re: [Evolution] my Evolution 3.6.2 backport to Ubuntu 10.12
- su -
- create a new directory and cd into it
- apt-get build-dep evolution-data-server
- apt-get source evolution-data-server
- cd evolution-data-server-3.4.4
- apply patch as described in [1]
- dpkg-source --commit (e.g. "Enable TLS over port 993)
- maybe: install fakeroot and dpkg-dev
- apt-get install fakeroot
- apt-get install dpkg-dev
- dpkg-buildpackage -rfakeroot
- cd ..
- dpkg -i *.deb
[1] evolution-data-server-3.10.4-poodle-enable-tls-for-ssl.patch for bug #1153052
[2] Re: [Evolution] my Evolution 3.6.2 backport to Ubuntu 10.12
Subscribe to:
Posts (Atom)