Category Archives: Coding

Eclipse: IWAE0010E An internal error occurred

I sometimes get this error in the J2EE (or JEE) module settings in the project options when changing modules. The settings will not even show what modules are chosen.

Nothing really helped much, only sometimes out of luck it started to work again. To fix it, I have updated my eclipse to 3.3.1.1. Now it works :)

Clearcase Dynamic Views: Probleme

  • Ich sitze seit knapp einer Stunde da und kann mit meiner Arbeit nicht wirklich weitermachen, weil die Clearcase-Server hier Probleme haben und ich deswegen keine neuen Dateien oeffnen kann.
  • Immer wieder aergert man sich zwischendurch, weil man durch Aenderungen im Repository selbst keinen kompilierenden Code mehr hat.

Java as native code

I consider checking out GCJ (with or without SwingWT) for the Windows-Version of one of the next p300 releases. But first I’d have to see which licensing issues this would bring up :)

Why only the Windows Version? OS X users can be happy to have Java per installed default, Linux users are used to installing things (in this case a JVM).

Implementing the Downloader (2)

(Part 1)

I had problems with moving files after their downloading has been finished. These problems did not occur on Unix-like operating systems like my OS X and Linux but only with Windows. I just was not able to move the file with file.renameTo of the Java API.

After some researching on the web and especially the Sun forums I saw that I am not alone with this problem. The solution is stupid but logical: Before using file.delete() or file.renameTo():

  • Of course, make sure to close the file :)
  • Call System.gc() and then System.runFinalization(). Sleep a second and run System.gc() again. This makes sure that the Sun Java VM really closes the file and frees resources associated with it.
  • For temporary files, also use file.deleteOnExit()

Implementing the Downloader

I am currently implementing a downloader into p300. This may sound easy since the HTTP-Server part of p300 is already written, but since I want to implement multi source downloading (and later swarming/partial file sharing) it is a bit more complicated.

My original goal was to use fixed-size chunks of 256 KB and request each chunk after another with a single HTTP Request. After having received a complete chunk, I store it in the output file (I am using memory mapped files here). I was using a new thread for each request, the request itself is done via a java.net.URLConnection object. I had to sacrifice Keep-Alive connections here because of some bug in the Java libraries (this was some months ago, I had to pause development until a few days ago).

This worked well with bandwidths in my VPN but drives my CPU insane when using it on a LAN, both on the server-side p300 and on the client-side p300. So I changed both sides to use a thread pool and this made it a bit better, but not optimal. Also, if you want to achieve high bandwidths with TCP, you need to have it running for some time so the send and receive windows will grow. The bandwidth with my approach was not higher than 300 KB/sec, caused because of the re-Negotiation of the TCP-Connection and the HTTP-Request.

To make it short: my current approach of receiving (small) chunks sequentially did not work out.

I thought of multiple things, inclung HTTP Pipelining (which does not play well with URLConnection i suppose) and increasing the chunk size or sacrificing chunking altogether but I think I have a solution that requires only minimal changes:

Instead of requesting a single chunk, I request from the chunk start to the end of the file. Then I read all the bytes, and everytime I am on a (virtual) chunk boundary I check if we already have that chunk. If yes, disconnect, if no, continue and mark the previous/current chunk as loaded.

I’ll try to do this in the next days (No, this does not take days, but I don’t have much time for it each day).

I hope it works out :)

(Part 2)

WordPress: Zwei Sidebars in Theme einbauen

In functions.php:

if ( function_exists('register_sidebar')) {
        register_sidebar(array(
        'before_widget' => '<div id="%1$s" class="widget %2$s">',
        'after_widget' => '</div>',
        'before_title' => '',
        'after_title' => '',
        'name' => 'Left'
    ));
        register_sidebar(array(
         'before_widget' => '<div id="%1$s" class="widget %2$s">',
         'after_widget' => '</div>',
         'before_title' => '',
         'after_title' => '',
         'name' => 'Right'
   ));
}

Datei right_sidebar.php:

<!-- begin sidebar -->
<div id="RightSidebar">
<?php if ( !function_exists('dynamic_sidebar')
        || !dynamic_sidebar('Right') ) : ?>
        This theme needs dynamic sidebars
<?php endif; ?>
</div>
<!-- end sidebar -->

Datei left_sidebar.php:

<!-- begin sidebar -->
<div id="LeftSidebar">
<?php if ( !function_exists('dynamic_sidebar')
        || !dynamic_sidebar('Left') ) : ?>
        This theme needs dynamic sidebars
<?php endif; ?>
</div>
<!-- end sidebar -->

Einbauen in z.B. header.php oder footer.php mit:

<? include (TEMPLATEPATH . '/right_sidebar.php'); ?>