random technical thoughts from the Nominet technical team

ENUM for Google Android

1 Star2 Stars3 Stars4 Stars5 Stars (4 votes, average: 5 out of 5)
Loading ... Loading ...
Posted by ray on Jun 23rd, 2009

I’m pleased to announce the release of enumdroid.

This application adds ENUM (E.164 Number Mapping) support to your Android phone.

Each time you dial a full international number (i.e. starting with a ‘+’) your phone will check the DNS for additional routing information and offer you a list of alternate contact methods.

The application is open source (under the Apache License) and the code is available for download from Google Code.  The application can be downloaded from the Google Market under Applications -> Communication

Here are some screenshots, which show in turn:

  1. Nominet’s switchboard number being dialled
  2. ENUM results being returned
  3. A call being placed over the PSTN to a tel: URI
  4. The ENUM application’s settings page
Dialing ENUM results Calling Settings

Oracle Online Table Redefinition and Data Transformation

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 3 out of 5)
Loading ... Loading ...
Posted by arjan on Feb 20th, 2009

Introduction

Oracle realizes that these days the up-time of applications is critical. Therefore they have developed ways to reduce the downtime for applications during application upgrades. At Nominet we have had some software releases that took longer than expected and we have had some table redefinitions during upgrades that run for several hours. That makes it worthwhile to have a look at Oracle’s methods to limit the disruption for the up-time of applications. This article describes a way to redefine Oracle table structures and data while that table remains online and accessible for reads and writes in its original form for Live applications.

What can you do

Oracle has created a PL/SQL package called DBMS_REDEFINITION that allows you to restructure a table definition and transform the data in a table. That means you can:

  • Add columns
  • Drop columns
  • Change the data type or length of columns
  • Transform the data inside the table using standard and user-written PL/SQL functions

When is this handy

This capacity is very useful when you want to change a big table that is often used by an application. The changes you want to apply will cause an unacceptable amount of downtime by creating many locks on the table or making it inaccessible for the application otherwise.

How does it work

You create an empty table with a different name than the source table and with the new structure that you want to achieve. This table need not have any of the constraints, grants or indexes that the source table has. You then start the redefinition using the PL/SQL package DBMS_REDEFINITION. This creates a materialized view with a materialized view log in the background. These two structures capture all the changes to the source table while you are transforming the data into the empty table you have created before the redefinition started. Once the transformation is finished you can let Oracle copy all the indexes, constraints and grants to the new table with one procedure call. The last step is the renaming of the new table to the original name. This is the only moment that the table will be locked for a millisecond.

Example

Let’s first create a source table and fill it with some data. We’ll also add an index and grant to prove that these will also be copied to the new transformed table.

create table customer(
 id               number      primary key
,name             varchar2(30)
,address          varchar2(30)
,phone_number     varchar2(10)
,country_prefix   varchar2(5)
,county_id        number
,credit           number
);

create index cust_name_idx on customer(name);grant select on customer to public;

truncate table customer;

begin
   for i in 1..3
   loop
      insert into customer values (i, 'ARJAN', 'OXFORD', rpad(i, 10, i), '0044', i, i*1000);
   end loop;
end;
/

commit;

Let’s look at the data before transformation.

select * from customer;

        ID NAME                           ADDRESS                        PHONE_NUMB COUNT  COUNTY_ID     CREDIT
---------- ------------------------------ ------------------------------ ---------- ----- ---------- ----------
         1 ARJAN                          OXFORD                         1111111111 0044           1       1000
         2 ARJAN                          OXFORD                         2222222222 0044           2       2000
         3 ARJAN                          OXFORD                         3333333333 0044           3       3000

3 rows selected.

Now let’s start the redefinition process. First we’ll create a user-defined PL/SQL function to show that you can make customized transformation to your data.

create or replace function transform_credit(p_credit number)
return number
is

begin
   return ((p_credit/3) + 10);
end;
/

At this point we are ready to go through the redefinition process. This entails 3 calls to procedures within the DBMS_REDEFINITION package. The first call starts the process and defines the column mapping between the source and target table.

create table customer_tmp(
 id               number
,name             varchar2(30)
,address          varchar2(30)
,phone_number     varchar2(15)
,county_id        number
,credit           number
);

You can see that we are doing the following transformations:

  • Using 2 Oracle defined functions to change the columns “NAME” and “ADDRESS”
  • Concatenating the country code to the phone number and in effect dropping the column country_prefix
  • Transforming the value in the column credit with our user-defined function

Suppose that this transformation will take several hours and changes are being made by a Live application to the data in the source table that we don’t want to loose. To prove that these data will be in the transformed table we’ll insert some more records into the source table from a different session.

begin
for i in 4..6
loop
   insert into customer values (i, 'JAN', 'AMSTERDAM', rpad(i, 10, i), '0031', 1, i*1000);
end loop;
end;
/
commit;

Once the transformation is finished we can copy all indexes, constraints and grants to the target table with one simple call.

set serveroutput on

declare
   l_errors number;
begin
  dbms_redefinition.copy_table_dependents
  ( user, 'CUSTOMER', 'CUSTOMER_TMP',
    copy_indexes => dbms_redefinition.cons_orig_params,
    num_errors => l_errors );

  dbms_output.put_line('Errors: '||l_errors);
end;
/

During this transformation the source table has been available for reads and writes for the Live application. We are now ready to rename the table so the application can read and write from the new target table.

begin
    dbms_redefinition.finish_redef_table( user, 'CUSTOMER', 'CUSTOMER_TMP' );
end;
/

Let’s look at the result.

select * from customer;
        ID NAME                           ADDRESS                        PHONE_NUMBER     COUNTY_ID     CREDIT
---------- ------------------------------ ------------------------------ --------------- ---------- ----------
         1 Arjan                          Oxford                         00441111111111           1 343.333333
         2 Arjan                          Oxford                         00442222222222           2 676.666667
         3 Arjan                          Oxford                         00443333333333           3       1010
         4 Jan                            Amsterdam                      00314444444444           1 1343.33333
         5 Jan                            Amsterdam                      00315555555555           1 1676.66667
         6 Jan                            Amsterdam                      00316666666666           1       2010

6 rows selected.

As you can see the data have been transformed and all changes made to the source table during the transformation have also been transformed and migrated to the new target table.

Limitations

It would be great if you could add a column and fill it with values selected from a different table (for example when you want to denormalize a table). This is not possible though mainly due to the limits on materialized views in Oracle.

Conclusion

The use of DBMS_REDEFINITION can decrease the downtime of your applications. Its use is quite simple compared to inventing and coding this functionality manually. It cannot be used in all circumstances, but it is certainly a worthwhile addition to the toolkit of any developer or DBA.

Hudson - a good, open source continuous integration server

1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 3 out of 5)
Loading ... Loading ...
Posted by alexd on Feb 3rd, 2009

I’ve used a few Continuous Integration (CI) servers over the years. Basically, a CI server will download your projects source, build and run the tests, and then publish the results (and optionally email you). The trigger can be time-based, VCS-trigger-based, or manual. This allows you constantly to monitor the state of your project’s health.

I used CruiseControl for a while - once I got it working, it worked well. It was pretty clunky to set up, though.

I’ve now been using Hudson for a wee while, and love it. It couldn’t be easier to install (simply run a JAR file), and the configuration is done entirely through a web interface that is a pleasure to interact with. So far, I’ve had no problems with it at all.

I’ve heard grumbles from folks using Teamcity in relation to its preference for using Ant as a build script. Indeed, it seems some folk actually write an Ant harness to call their makefile from Teamcity! I’ve been building and testing Java and Ruby directly from Hudson, with no issues.

Given that Hudson is free and open-source, I’d highly recommend it.

Anoto pens, Moleskine notebooks and OSX

1 Star2 Stars3 Stars4 Stars5 Stars (5 votes, average: 5 out of 5)
Loading ... Loading ...
Posted by jay on Sep 6th, 2008

Anoto

If you’ve never heard of it before, Anoto is a company with a clever piece of technology that enables digital note taking. It starts with a special paper printed with a pattern of tiny (0.1 mm) dots on it. The pattern is based on a grid, but each dot is slightly off centre of from the grid intersections:

They then have an algorithm that can produce squares of this grid, where each square is 2×2 mm and has 36 dots on it, each with a unique pattern. The total surface area they can cover with this unique pattern is 1.8 million square miles.

Then they have a pen, which has a miniature camera built into it that takes 50 or so photographs of the nearby dots every second. From that the pen can tell exactly where you are, where your stroke was going and where it has gone, basically recording everything you write. Most importantly, if you raise the pen and then lower it to the paper, it can tell immediately where it is.

The other clever thing about this pen is the ink. The dots themselves are printed in black and are visible in the infrared (IR) portion of the spectrum, which is how the camera sees them. But in order to ensure that the ink you write does not obscure the dots they have developed IR transparent ink.

That’s the technology, which is easy enough but Anoto then complicate things drastically by their business model and appalling web site. They don’t sell anything direct but work through partners, on whom they provide precious little information. These partners then develop products and, in many cases, buy a section of the virtual Anoto paper to use for their applications.

Most of these partners have developed “business applications” such as pre-printed forms for recording medical questionnaires. All very interesting I’m sure, but no use to me and by definition a niche product.

Moleskine notebooks

This brings me onto to Moleskine notebooks. I love these. They have a way of making me feel I can create anything and anything I do write looks good.

But that’s not enough. I want a digital Moleskine, or something very similar so I get the same feeling of productivity and yet have it all digitally recorded.

OSX and sharing my data

The final thing I want is a way of getting the data off the pen onto my Mac and from there outputting it to my note taking program (SOHO Notes) or a wiki (Confluence) or even to ebook format.

The requirements

It appears that most of the Anoto partners have inherited the same “give your customer only half the information” attitude to web sites as Anoto so finding out exactly how it all fits together was painful to say the least. Even now I still don’t have some crucial answers.

Just to be clear, the three things I am after are:

  • An Anoto-enabled pen.
  • OSX software to talk to the pen above that outputs in a way I can actually use. It would be nice if it did character recognition as well but I guess that is pushing it.
  • An Anoto printed notebook that feels like a Moleskine.

I’ve found the last one quite easily, made by Livescribe. They also seem to make great pens, complete with built-in audio recording and and OLED display. Unfortunately they don’t make OSX software though they are developing some. Even with their Windows software I can’t tell what formats you can output to, they say so little about it. Sigh.

I’ve also come across two separate providers of OSX software, Pen-It and Paperium. The Paperium software claims to output in lots of ways. Both of these come with their own pens to link to their software, which gives me my first major question:

Can any Anoto-enabled pen work with any pen software or is software unique to a specific pen and vice versa?

Pen-It, who resell the Maxell pen make it clear their software only works with that pen and they don’t sell it differently. Given just how little information there is on their web site I am amazed that nugget slipped through.

If the answer is ‘no’ across the board then I’ll have to buy the Paperium pen.

The next question is:

Will any pen work any Anoto paper product?

Again, I would have hoped this answer is yes but Pen-It again say their pen doesn’t.
Until I get that one answered I won’t be able to buy anything!

The products

To save you having to search for hours like I did, here is a roughly useful set of links.

Pens:

  • Maxell DP-201. This is also branded as Pen-It (not the same as the people above). They only sell through the channel but there appear to be plenty of people who resell it.
  • Nokia SU-27W. They do sell direct and lots of others sell it. This is the latest version of the discontinued Nokia SU-1B.
  • Destiny io. This was formerly the Logitech io pen (and io2) but they sold the business. This is possibly the least informative web site I have ever come across.
  • Magicomm g303. I’m not sure this is actually an Anoto-enabled pen. They are listed as a partner by Anoto but they don’t mention anything about it.
  • Livescribe Pulse. This is easily the pen with the highest features and can also come in a 2GB variant.
  • Paperium. I’m pretty sure this pen is just another pen rebadged but I haven’t looked at the pictures closely enough to be sure.
  • Flypen”. This is a version especially for kids

Paper:

  • Oxford easy book. These notebooks appear everywhere and again are sold through resellers not direct.
  • Orignote. These are supplied by Magicomm and again I don’t know if these are Anoto-enabled or not.
  • Livescribe notebooks. These are the nice ones that look like Moleskine books.
  • Paperium notebooks. Again these are probably rebadged but I can’t tell.

And finally …

Confused? I certainly am.

Microsoft System Center Operations Manager 2007 Install

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 4 out of 5)
Loading ... Loading ...
Posted by brettcarr on Aug 15th, 2008

We had some issues in getting an MS SCOM 2007 (formerly Microsoft Operations Manager) install up and running this week. This product has a fairly heavy set of pre-requisites before it will install and amongst these is asp.net. Try as we could myself and a fellow sysadmin could not get the install to recognise that asp.net (which is included in the .net framework) was installed. Luckily after a little search I stumbled upon MS KB article 934759 (http://support.microsoft.com/?kbid=934759) which states that this problem can occur if you install IIS after the .net framework as asp.net does not then get registered in the IIS metabase, it goes on to recommend that you run the ASPNet_RegIIS.exe command to register asp.net, however this command seems to be 32 bit only and would not run on our 64 bit installation of Windows, the only options were to modify the IIS metabase manually or re-install from scratch, in the interests of application stability we opted for the latter, when we then ensured that IIS was added before the .net framework the SCOM 2007 went through without any issues.

GPS tracking

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...
Posted by ian on Jul 28th, 2008

I like cycling and walking. What I also like to do is record where I have been. My Nokia N95 has built-in GPS, but it is pretty poor reception. Besides, the software I use to record where I have been, AFTrack, doesn’t work with the internal GPS. So I now use a GPS receiver.

AFTRack is fine as a mechanism for recording GPS tracks, but I wanted to have a way of viewing them after the event. Of the various formats available for export I have only played with KML and GPX so far. Google Earth is the natural app for viewing KML files, and very good it is too. But there is a great site, Trailguru, which accepts GPX uploads and shows you altitude and speed profiles for the whole track. The intention of the site’s creator, Tim Park, is to build a database of tracks through a wiki interface. This will enable you to plan routes based on existing track segments, and to average over repeated track uploads, reducing the effects of GPS ‘jitter’.

You can see my first upload, a Sunday bike ride with my son, here.

The evil of threads

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 2 out of 5)
Loading ... Loading ...
Posted by alexd on Jul 24th, 2008

For some time now, I’ve been convinced of the inherent evil of threads. I’ve gone to some lengths to mitigate their use in projects over the last few years. For example, my dnsjnio package uses java.nio to conduct many thousands of concurrent DNS queries in just a couple of threads. This package has been pretty stable for the last couple of years, and I know that it is in reasonably heavy use at several sites (at least).

So, I was very surprised to discover it has a nasty race condition!

I was alerted to this by a very helpful user. I’m still in the discovery phase, so certainly no fix yet, I’m afraid. However, the problem seems to be a race condition between a timer thread (which looks after query timeouts), and the select thread, which handles the I/O. A separate thread is used for timers because so many queries may be outstanding at any one time - and the select thread is busy enough handling I/O to worry about ordering timeouts. If a timeout is generated immediately after data has been received, but not yet promulgated to the user, then a connection can be closed twice, leading a NullPointerException (oops!).

Of course, some sort of lightweight Actors implementation would have been ideal here - in Erlang, I would have an Erlang process maintain the timeout queue, and the select() function ask it for the next timeout before starting the loop. And with a message-passing system, it would be simple to detect that the close had already been processed, as messages are processed sequentially.

Away from the details of this particular issue, I think there’s a broader point to make. It seems that even a relatively simple project, with lots of use, that has been designed to avoid the evils of threading, is still likely to contain some nasty threading bugs.

I will be coding future projects to avoid threading altogether. Well, that’s maybe a bit extreme. But I’d certainly want to design all my threads around blocking queues, with no other means of interaction.

My favoured design for my next project involves a collaboration of many communicating sequential processes - one on each core. Each process may be written in whatever language is best for the functionality of that process - C for speed-critical areas and the JVM or Erlang for most others. Of course, once you design your system like this, it’s then easy to move some components onto the network.

Some might invoke the generic tenth rule, and say that I may as well use Erlang for all of the nodes. I would agree, if there weren’t such a small amount of communication required between the nodes (for this project). And if my need for speed in certain areas wasn’t so acute.

I shall also be looking for other ways to learn from the functional languages - for example, enforcing immutability (perhaps with something like this).

If anyone is particularly interested in this, I’d recommend this paper which I was pointed to recently. I agree with almost everything in it - especially the recommendation to avoid C where at all possible.

Anyway, enough rambling - I’d better get back to fixing my nasty threading bug!

Using Dnsruby for an authoritative nameserver

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5 out of 5)
Loading ... Loading ...
Posted by alexd on Jul 21st, 2008

A third person has now asked me about using Dnsruby to write an authoritative nameserver. It seemed worth jotting some notes here.

A nameserver at its most basic simply provides a mapping service between names and addresses. Of course, the RFCs that specify DNS have more than that to say on the subject, even at the start. And, in the 25 years since the first DNS specifications, there’s been a whole load more! For example, an authoritative nameserver might support views, ACLs, different flavours of zone transfers, dynamic updates, etc. And then there’s the cryptographic extensions : TSIG, DNSSEC and so on.

If you want the latest, fully RFC-compliant authoritative nameserver, then your best bet is definitely just to download BIND or NSD. It will run a lot faster than anything you can do with Ruby, and will support most of the currently fashionable DNS features. You won’t even need to debug it! ;0)

However, I don’t think that the people asking about Dnsruby are necessarily after a fully-featured nameserver : “I would like to get some kind of simple ruby dns server running, authoritative-only, for development purposes as it can interact nicely with existing ruby infrastructure and i have no need for high volume”

Of course, you could ask why you’d need to use Dnsruby at all - after all, if only an A record is to be requested, how much DNS functionality is required to respond? I guess there are two reasons :

1) Code reuse. Even if only a few lines of the parser in Dnsruby are used, it still beats re-implementing (and debugging) them.

2) Future extensions. You might not think you’ll want that fancy new feature, but who knows how things will change in the future? The Dnsruby library already provides support for may DNS features (most notably those related to security).

One issue is that I wrote Dnsruby as a client-side library. So, although it supports zone transfers, it only supports initiating and receiving them - not serving them. Currently, support is only there for verifying DNSSEC signatures (although very little code would be needed in order to support signing packets). Similarly, there is currently only support for sending queries; there is no listening server. And there is certainly no data store (or cache).

Anyway, the question was : “If I could have dnsruby sit on a machine (using EM - awesome!) and receive dns requests, and I could put some hook code in there somewhere to look it up in a DB or YAML file or whatever, it sounds like I could do that, but I just can’t find where to begin.”

I think most of the answer is in the question! The main tasks would be to write a server to listen for incoming queries, and some kind of storage to hold the data you want to serve (be that in memory or on disk).

I’d use EventMachine to sit on (presumably) port 53 listening for incoming UDP queries. You should really also listen for TCP queries (especially if you want to support zone transfer). When you receive something, call Dnsruby to decode it, and look up the response in your data store.

As for the storage, you’d need to decide if it should support updates, or whether it can be read-only. You could use the Dnsruby::RRSet class to hold resource records which have the same label, class and type. When your server receives a DNS request, do something like :

def NameServer.createResponseToIncoming(packet)
    message = Dnsruby::Message.decode(packet)
    question = message.question()[0]

    # If the question is a Dnsruby::Update or an AXFR/IXFR transfer request then deal with it separately
    # if (message.header.opcode != Dnsruby::OpCode.Query) ....

    # Find the records which were requested
    rrset = DataStore.findRrsetsWithNameClassType(question.qname, question.qclass, question.qtype)
    rrset.each {|rr| message.add_answer(rr)}

    # And get the NS records for the authority section
    nsrrset = DataStore.findRrsetsWithNameClassType(question.qname, question.qclass, Dnsruby::Types.NS)
    rrset.each {|rr| message.add_authority(rr)}

    # We also want the NS A records for the additional section
    nsrrset.each do |ns|
         rr = DataStore.findArecord ForNS(ns)
         message.add_additional(rr)
    end

    # Make sure that we are authoritative for the response! Otherwise, return REFUSED
    message.header.rcode = Dnsruby::RCode.NoError # Or Refused

    # Now encode the packet and return it for the server to respond with
    response = Dnsruby::Message.encode(message)
    return response
 end

[As you can see, Dnsruby is not doing a great deal for you here. Indeed, it would be possible to do away with most of the requirement for understanding DNS : you could store the data in wire format, thus removing the need to decode/encode the message. However, you’d still need to construct the encoded data store, and you’d have problems if you decided to secure your zone with DNSSEC with this approach]

If anybody does end up implementing a namserver with Dnsruby, I’d be happy to consider adding the code to the Dnsruby library! ;0)

Working with Iris Explorer

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5 out of 5)
Loading ... Loading ...
Posted by oliver on Jul 9th, 2008

Over the past few months I have been working with Iris Explorer to develop visualisation applications. Iris Explorer uses a module based approach to application development, where tasks are split into individual modules which can be then wired together. The modules represent processes on the data and the wires between them represent the flow of the data between the modules. A simple drag and drop interface is provided for adding and linking the components of an application, or map, together.

Iris Explorer is distributed with a set of standard modules for accomplishing a wide variety of standard tasks such as, reading data, writing images, and standard visualisation techniques, such as plotting histograms. An example of an Iris Explorer map is shown below:

I have been working on creating a 3D graph to represent the volume of queries to our WHOIS system for each hour of a given date, or range of dates. This could largely be accomplished using the standard module set avaialble with Iris Explorer, however there were no modules for the labelling of the axes of graphs which were particularly suited to the task, which meant I had to write my own custom module.

Iris Explorer provides the ability to write your own modules, so it is entirely possible to add custom processes and functionality to an application. The method for developing these custom modules is a two step process, first of all the the layout of the module is defined using the Iris Module Builder, secondly a user function, written in C/C++, is added.

The Module Builder provides a GUI to creating the module window, its data input and output ports and specifying the flow of data through the module internally. This is a logical process where you simply specify the type of input data which is accepted as well as the format of the output data. The appearance of the module itself and the user interface of the module are also specified using a drag and drop WYSIWYG style editor.

The second stage, the user function, controls the processing of the data. So in the case of the Graph Labelling module I have written this would extract the number of dimensions in the data set and number bars of the graph accordingly, as well as creating and positioning axis text labels.

The Iris Explorer Map produced collects data for a given date range, and split this into hourly segments to give a clear picture of the volume of queries to our systems at any given hour of the day. An example of the results of this are shown below:

WHOIS Graph Example

Decision Making

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...
Posted by ian on Jun 20th, 2008

Need a quick way to decide who does something:

http://www.youdrawstraws.com/index.cfm

There are two modes:

  1. An instant on-screen version, useful if everyone is in the same room.
  2. A group session for use when working remotely. These sessions are time-limited.

We used the on-screen version to decide who would go to a remote site to install servers next week. It saved me the job of picking on someone! All it required was to give the session a name, enter how many people there are to choose from, name them, then let the application choose at random.

The group session is a bit more involved. Those involved in the draw can add categories, and options within categories. Once everyone has given input, or the deadline for choosing has been reached, the options are selected at random.

Next »

Recent Posts

Highest Rated

Categories

Archives

Meta: