Posts categorized “Projects”

jsPlot

I’m working on a library for plotting graphs; check it out in the page jsPlot.

jsPlot is a JavaScript library for plotting graphs.
It plots graphs into HTML pages, using jQuery and CSS2 (no canvas).

jsPlot Example

jsPlot Example


Job Scheduler to Network Nodes

Last post I mentioned the topic distributed systems was involved in my new project.
Now here it goes.

After setting up a small (16-machine) cluster at UNIFEI (will post about it soon) for academic experiments, the time has come for running stuff in it.
Since manually submitting and verifying jobs is very inefficient (tedious, sluggish and fail-prone), a job scheduler was required.

There are a many tools for cluster management (special thanks to Walbon) featuring job schedulers, but all too sophisticated for this application.
For this reason and 2 more, I decided to create the job scheduler. The other 2 reasons?

  • It is a not a that-difficult task
  • I’m a C programmer, and as so I like to recreate everything.. (lol)
  • It would be so much fun! (Ok. This would be a third reason.. but actually it is emotion. ;-)

It took between 16 and 20 hours to design, implement and bugfix (see Important in Scheduler).

Design

  • Dispatch a job (shell command) to an available node (using blocking-semantics)
  • Only shell script (ssh, named pipes)
  • Monitor nodes’ current activity (start time, job)

Usage

# Launch Scheduler
$ cd scheduler/
$ mkfifo jobs nodes
$ ./sched.sh
 
# Add nodes to the node pipe
$ echo "10.0.0.1" > nodes &
$ echo "10.0.0.2" > nodes &
 
# Add jobs to the job pipe
$ echo "process /folder/data.txt" > jobs &
$ echo "make -j9" > jobs &
 
# Watch the scheduler :-)

Implementation

  • Dispatcher
#!/bin/bash
 
# dispatch.sh
#
# This is a job dispatcher to network nodes.
#
# (C) Copyright 2010, Mauricio Faria de Oliveira
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2
# as published by the Free Software Foundation;
 
# Variables
node_pipe="nodes"
 
# Parameters
node="$1"
shift
job="$@"
 
# Checks
#	1. Parameters.
if [ "$node" == "" || "$job" == "" ]; then
    echo "Usage: $0 node job"
    exit 1;
fi
 
# Log
echo ".. (dispatch) node '$node': '$job'"
 
# Dispatch job to node via ssh
ssh "$node" "$job" > /dev/null
 
# Put node back into nodes named pipe
echo "$node" > "$node_pipe"
  • Scheduler
#!/bin/bash
 
# sched.sh
#
# This is a 2-fifo-blocking job-scheduler to network nodes.
#
# (C) Copyright 2010, Mauricio Faria de Oliveira
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2
# as published by the Free Software Foundation;
 
# Variables
job_pipe="jobs"
node_pipe="nodes"
dispatcher="./dispatch.sh"
 
# Checks
#	1. Check if named pipes exist.
 
if [ ! -p "$job_pipe" -o \
     ! -p "$node_pipe" ];
then
    echo "Check for the fifos 'jobs' and 'nodes' (mkfifo jobs; mkfifo nodes)"
    exit 1;
fi
 
# Algorithm
#
#	1. For each available job ('jobs' named pipe, blocking),
#	2. For an available node ('nodes' named pipe, blocking),
#	3. Dispatch job to node (asynchronously).
#
# Important
#
#	1. The named pipes are NOT guaranteed to be 'fifo'.
#		Jobs and nodes are added/return asynchronously.
#		Only the blocking behavior is guaranteed.
#
#	2. There is no way to remove a single line from a named pipe, [is it?]
#		Then:
#		1. All lines are removed,
#		2. First line is used,
#		3. Other lines are put back (asynchronously).
#
#	3. If the 'cat <> jobs' hangs for even a little while
#		jobs in this little while are lost. [why?]
#		So things are asynchronous inside this loop.
#
#	4. Never use >> (append) asynchronously with named pipes.
#		It _seems_ append on pipes works as follows:
#		1. Buffer contents
#		2. Add new stuff to buffer
#		3. Overwrite contents with buffer
#
#		If something is removed (i.e. 'cat') between steps 1 and 3,
#		it will be inserted back on step 3, due to content buffering.
#
###############################################################################
# Code                                                                        #
###############################################################################
 
#	1.	For each available job ('jobs' named pipe, blocking),
cat <> "$job_pipe" | while read job; do
 
    echo
    echo "(job): $job"
 
    # 2. For an available node ('nodes' named pipe, blocking),
 
    # 2.1. All lines are removed,
    linecount=0
    cat "$node_pipe" | while read node; do
        echo -n ".. (node): $node (#${linecount}) "
 
        # 2.2. First line is used,
        if [ "$linecount" == "0" ]; then
 
            # 3. Dispatch job to node (asynchronously).
            echo "(dispatch)"
            $dispatcher $node $job &
 
        # 2.3. Other lines are put back.
        else
            echo "(put back)"
            echo "$node" > nodes &
        fi
 
        linecount=$(($linecount + 1))
 
    done
 
    echo
 
done
  • Monitor
    Scheduled for a next post. ;-)

Will be back soon!


Linux on 8-core

There’s a new project comin’ on.
In advance: linux, data structures, distributed systems.

Linux bootscreen displaying 8 penguins

Linux bootscreen displaying 8 penguins (cores)

Gonna post about it soon.
It rocks.. You bet! :-)


Computer Engineer

Today I’ve graduated in Computer Engineering.

I’m a computer engineer now!
July 31, 2009; a date I will remember.

Family, friends, lunch, church, mary’s bar..
Much fun, from much work and fun.

Thanks everyone.


Beginning an Academic Life

I’m really happy,
I’ve been admitted to the master’s program in Computer Science and Technology; poscomp, for short.

There was an exam and an interview.
Thanks God and my teachers’ effort, I passed both.

Passed the exam! Called to interview.

Passed the exam! Called for an interview.

I was admitted!

I was admitted! Yeah!

Now I will continue my education at Unifei,
This place I really enjoy and started loving.

Good friends, good teachers, good living..
I’m glad to keep them, along with my efforts and dedication.
Almost everything continues, but some things change.

I’m rebuilding my commitment.
There’s a totally new way of sharing knowledge and studying.

That lazy undergrad-student is dying; I’m becoming a grad-student.
More than a grad-student, I’m becoming a researcher.

From my point of view
That needs being sensible,
That needs knowledge confidence.

I want to be an academic,
And endeavour to be a good one. ;-)


There’s a new epoch coming,
I feel like starting it.