Clustopium Server & Client for Linux The next generation in clustered computing |
Leon Yuhanov Groovinator Software Copmany(MSP) 2004 |
|
| Clunix?? | _____Clunix is the next generation of clustered computing models. Its simple, cheap and powerfull. Clunix is the child of the Clustopium Load Balancing Server and Client (CLBS),written in Java. Whilst CLBS offers a simple Java based development interface for clustered systems, Clunix is faster, more efficient, more powerfull and takes advantage of Linux to the max. |
|
| Purpose | _____Imagine a horse pulling a carriage filled with bricks as an analogy for a single computer trying to calculate a large scientific data set. Now immagine instead of one horse, we use 10, the carriage is going to get to its destination much faster. In a similar way, Clunix gives the ability for many computers to work together to achieve a goal. |
|
| Audience | _____Clunix was written primarily for people who had a huge problem and needed a way to solve it fast, cheap, and as simply as possible. That said, Clunix is really open to anyone who has a job for it. It can be used for encoding/decoding large data sets, mathematical and scientific computations, video compression, web services, the list goes on. If this sounds like something u want to do, then read on. | |
Requirements
|
_____A dirty job often requires lots of elbow grease. Whilst elbow grease is great, here is a small list of things you will need to get you started: (on the left is a simplified diagram of the hardware system required for a Clustopium system) 1.A server(Anything good enough to run Linux, keep reading for which version i recomend). The server MUST have a 10/100 Ethernet card, it will really help if it has a Gigabit card but that depends on what you want to do. 2.N clients, nodes. Now N can really be 1 or it can be 50. I personaly started with 8 nodes and 1 server but you do as you like. Once again these can be any machine that can run Linux. They dont all have to be the same machines or running the same version of Linux. The nodes MUST EACH have a 10/100 network card, gigabit cards on each node are a requirement that you can set if you like. 3.Linux on everything, whilst its predesessor, CLBS ran on any OS that suported Java, Clunix is made to take full advatage of multithreading in Linux. I recomend Slackware 9 and up, because of its ease and speed of instalation, but you can use any version you like, theres no difference. We are investigating ways of making Clunix run on Windows but that will be a future release. 4.The Nodes are connecetd to the server via TCP/IP streams and for this reason a good FastEthernet switch is needed. I recommend Cisco Systems 2950 switches, they are relatively cheap for a managed switch and rarely ever have problems with the data that Clunix passes. I have used a Cisco Systems 2950, and 3550 switch in development but have found no problems in using cheaper alternatives like the Dlink DES-1024R+. Its a whole lot cheaper then the Cisco models but it is unmanaged. |
|
| Compiling the Server | _____The source is provided with a makefile. The server is called cserver, for Clustopium Server. To compile the server code place all the files in the distibution in a directory and type in: make _____This will compile the helper classes thet cserver requires and compile cserver itself. A detailed look at each of the helper classes is written about below in "Indepth Look at Individual Components" |
|
| Compiling the Client (Node) | _____The client program, or node program, is called cclient, for Clustopium Client. Place all files except cserver.cpp and rawdata.txt onto a node machie then compile it by typing: make cclient |
|
| Executing the Server | _____The command to launch the server is in the following format: cserver IP_ADDRESS_OF_SERVER eg.. cserver 192.168.0.1 eg.. ./cserver 192.168.0.1 (this also works) |
|
| Executing the Client | _____The command to launch the client is in the following format: cclient IP_ADDRESS_OF_SERVER eg.. cclient 192.168.0.1 eg.. ./cclient 192.168.0.1 (this also works) |
|
| Using Clustopium | _____Clunix uses multithreading, so the server code is complex to someone who has never programmed multithreaded applications, for this reason i will give a brief explanaation and a psuedo run of the server. Clunix is made for everyone to use,from begginer programmers to gurus thats why i want to make sure this is as clear as possible. The Barebones System Clunix is a barebone system, its a tool to help you solve a problem, which is why the barebone code has a small problem to solve as demonstartion for anyone wishing to program with clunix. Clunix reads a data file contaning raw random data, called rawData.txt, It then writes each line to the buffer, sends it to a node and waits for an OK reply.thats all the barebone code does and this is to simplify the explanation. _____Main, Assimilate and Reader. The runtime of the server can be explained by the 3 major functions that exist within its code. Each function is in reality a seperate program that shares the same memory with the others. The main function is where we beggin, its really where the server set up the tcp/ip connection and waits for a node to connect. But before it does this it launches the reader method as a seperate thread. The reader method, dont be confused by the name, is the method that really does all the data work.it reads from a source file processes the data and writes it the lbios buffer. Now back to main, a node has connected to the server, main launches an instance of the assimilate method as a thread and goes back to waiting for a new node to connect. The assimilate method will connect to the node,get any neccesary sratup and id data and when ready will read from the lbios buffer and send the data to its respective node. it then waits for reply,and does this untill its job is complete. The terminating rules for each node, the assimilate method, and for the reader methos have to be defined by you depending on what problem Clunix is trying to solve. The code is the base system, the rest is left up to you. |
|
| Code Examples | _____The following is psuedo code for the main,assimilate and reader methods.Its best to look at this vs the actual code provied in the distrubution. | |
|
||
Main Method Reader Method(SubSystem Thread 1) Assimilate Method(Subsystem Thread N) START -WHILE(some terminating condition) --try to read data from iob --try to send data to node --wait for reply --write reply to ib or terminate -WEND STOP |
||
An
Indepth Look at Individual Components |
||
CData |
CData.cpp and CData.h are the files containing code for the CData class. The CData class is a simple data container, it was originaly used inthe previous version of Clustopium but this version of the class has an encode, and decode method as well as the simple storage members. This class is basicaly the main system for moving data between threads. The class contains 4 data variables, their names are irelivent and are simple kept for historical purposes: int pid - an interger variable int flag1 - an interger variable int flag2 - an interger variable char astring[20] - an char variable sized to fit 20 chars _____Creating a CData object is as easy as this: CData alpha = CData() or CData alpha = CData(0,0,0,"Blah") or (and this one is important) CData alpha = CData(dataBlock) where dataBlock is an chuck of memory encoded with the CData encode(void*) function. This is mainly used to pass the class from the main program to a thread using void* space. eg.. void* args = malloc(32);//create void space in memory CData alpha = CData(1,2,3,"Hello");//create alpha with 1,2,3,"hello" as the variables args = CData.encode(args);//Encode alpha into args //Pass args as the arguments for a clone() thread //In the newly created thread CData beta = CData(args);//decodes the contents of args into beta |
|
| LBios | lbios.cpp and lbios.h are the files containing code for the lbios class. lbios stands for Linear Fisrt In First Out Buffered Input Output System. It is the core communications medium between multitheraded procces in Clunix. lbios allows each node to write and read data form a central source in a syncronized, on time and quick method. To create a lbios object you need 2 things, an array of chars in memory sized to whatever your problem needs and an lbios object that uses that memory. eg.. char* bufferSpace = (char*)malloc(10240);//create a 10kb buffer lbios iob = lbios(buferSpace, 10240, 32);//create a lbios object using bufferSpace as the memory, pass the size of the memory used, in this case 10k(10240) and the size of the data block, which for example sake is 32Bytes. all these sizes will vary according to the problem you have to solve. Reading and Writting to the buffer is as easy as this: iob.write("blah"); int write(char*) will accept a char* as its sole argument, be warned, it will only write blockSize(32 above) chars to the buffer. write() returns 0 if there is no space to write, -1 if the buffer is in use, and any integer greater then and or equal to 0 representing the number of chars it wrote to the buffer, this is usualy the size of the data passed as the argument. char* data = iob.read(); char* read() will return "\0"(null charector) if there is no data to read, "-"(a single - sign) if the buffer is in use or a char* of whatever was the next block of data to read. lbios is synchronized but not perfectly, it has a sentinal boolean variable inUse. if its set to true all of the methods associated with the object will return an inuse signal such as -1, "-" etc... this allows the object to be acces by multiple threads at the same time. |
|
| Download | ||
| Credits | _____Clunix was developed, written and constructed by Leon Yuhanov, Groovinator Software Co.(MSP). _____Jeremy Goldberg assisted in the development of Clunix and is currently developing custom applications for use with the Clustopium system as well as bug reduction and improovements. _____Daniel Aronson assisted with certain convertion routines as well as bug reduction and improovements. _____Jody Sacks assisted with some project ideas and definitions as well as bug reduction and improovements. |
|