IBM TSpaces Lab 1 Introduction. Summary TSpaces Overview Basic Definitions Basic primitive operations Reading/writing tuples in tuplespace HelloWorld.

Slides:



Advertisements
Similar presentations
Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
Advertisements

JavaSpaces and TSpaces Theresa Tamash CDA 5937 November 4, 2002.
Introduction To Java Objectives For Today â Introduction To Java â The Java Platform & The (JVM) Java Virtual Machine â Core Java (API) Application Programming.
User Interfaces File I/O and Exceptions (c) IDMS/SQL News
Chapter 7 User-Defined Methods. Chapter Objectives  Understand how methods are used in Java programming  Learn about standard (predefined) methods and.
C# and Windows Programming Application Domains and Remoting.
Introduction to Object-Oriented Programming CS 21a: Introduction to Computing I First Semester,
Java Remote Object Invocation (RMI) Overview of RMI Java RMI allowed programmer to execute remote function class using the same semantics as local functions.
Remote Method Invocation
Client Side Programming Using Java Applet Outcomes: You will be expected to know: – Java Applets and HTML file; –bytecode and platform independent programs;
Road Map Introduction to object oriented programming. Classes
1 Frameworks. 2 Framework Set of cooperating classes/interfaces –Structure essential mechanisms of a problem domain –Programmer can extend framework classes,
Remote Method Invocation Chin-Chih Chang. Java Remote Object Invocation In Java, the object is serialized before being passed as a parameter to an RMI.
Introduction to Java Programming, 4E
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
Classes and Instances. Introduction Classes, Objects, Methods and Instance Variables Declaring a Class with a Method and Instantiating an Object of a.
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
Java Remote Object Invocation (RMI) Overview of RMI Java RMI allowed programmer to execute remote function class using the same semantics as local functions.
Fundamental Programming Structures in Java: Comments, Data Types, Variables, Assignments, Operators.
XML-Tuples & XML-Spaces V0.7 By David “Uncle Dave” Moffat Presented by: Shurug Al-Khalifa.
Web Proxy Server. Proxy Server Introduction Returns status and error messages. Handles http CGI requests. –For more information about CGI please refer.
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
Java 程序设计 Java Programming Fall, Contents for Today Java Program Structure  How to Compile a Java Program  How to Run a Java Program Environment.
220 FINAL TEST REVIEW SESSION Omar Abdelwahab. INHERITANCE AND POLYMORPHISM Suppose you have a class FunClass with public methods show, tell, and smile.
1 Java Programming II Java Network II (Distributed Objects in Java)
Understanding the CORBA Model. What is CORBA?  The Common Object Request Broker Architecture (CORBA) allows distributed applications to interoperate.
CSE 305 Theory of Database Tutorial on Connecting with Sybase from Java program and Developing GUI Jalal Mahmud, TA, CSE 305.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Java Introduction to JNI Prepared by Humaira Siddiqui.
The Java Programming Language
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
Introduction to Java Programming with Forte Y. Daniel Liang.
LAB 1CSIS04021 Briefing on Assignment One & RMI Programming February 13, 2007.
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
1 Java RMI G53ACC Chris Greenhalgh. 2 Contents l Java RMI overview l A Java RMI example –Overview –Walk-through l Implementation notes –Argument passing.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
1 Introduction to Java. 2 What is Java? A programming language. A platform –A virtual machine (JVM) definition. –Runtime environments in diverse hardware.
RMI Remote Method Invocation Distributed Object-based System and RPC Together 2-Jun-16.
Module 5: Implementing Printing. Overview Introduction to Printing in the Windows Server 2003 Family Installing and Sharing Printers Managing Access to.
Java Remote Object Invocation (RMI) Overview of RMI Java RMI allowed programmer to execute remote function class using the same semantics as local functions.
 Remote Method Invocation  A true distributed computing application interface for Java, written to provide easy access to objects existing on remote.
Topic 1 Object Oriented Programming. 1-2 Objectives To review the concepts and terminology of object-oriented programming To discuss some features of.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
IBM TSpaces Lab 3 Transactions Event Registration.
1 Creating Web Services Presented by Ashraf Memon Hands-on Ghulam Memon, Longjiang Ding.
Java Remote Method Invocation (RMI) Overview of RMI Java RMI allowed programmer to execute remote function class using the same semantics as local functions.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
Introduction to Java Chapter 7 - Classes & Object-oriented Programming1 Chapter 7 Classes and Object-Oriented Programming.
M1G Introduction to Programming 2 5. Completing the program.
IBM TSpaces Lab 2 Customizing tuples and fields. Summary Blocking commands Tuple Expiration Extending Tuples (The SubclassableTuple) Reading/writing user.
Eclipse Project. Installing Visit to download a copy for your home computerhttp:// –Get Release version 3.0 (or.
Chapter 5 Introduction To Form Builder. Lesson A Objectives  Display Forms Builder forms in a Web browser  Use a data block form to view, insert, update,
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Classes, Interfaces and Packages
Creating Web Services Presented by Ashraf Memon Presented by Ashraf Memon.
 Java RMI Distributed Systems IT332. Outline  Introduction to RMI  RMI Architecture  RMI Programming and a Sample Example:  Server-Side RMI programming.
3/5/2002e-business and Information Systems1 Java Java Java Virtual Machine (JVM) Java Application Program Interface (API) HW Kernel API Application Programs.
UMBC Distributed Computing with Objects RMI/Corba CMSC 432 Shon Vick.
Khoa CNTT 1/37 PHẠM VĂN TÍNH   Java RMI (Remote Method Invocation)
1 Lecture 15 Remote Method Invocation Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung Institute of Technology.
RMI1 Remote Method Invocation Adapted from “Core Java 2” by Cay Horstmann.
Introduction to Java Programming, 4E Y. Daniel Liang.
SESSION 1 Introduction in Java. Objectives Introduce classes and objects Starting with Java Introduce JDK Writing a simple Java program Using comments.
Comp1004: Introduction III Java. Content How Java Works: The JVM Writing a Class in Java – Class – Member Variables – Method – Statement Magic incantations.
Information and Computer Sciences University of Hawaii, Manoa
The need for Programming Languages
Remote Method Invocation
Subroutines Idea: useful code can be saved and re-used, with different data values Example: Our function to find the largest element of an array might.
Classes, Objects and Methods
Presentation transcript:

IBM TSpaces Lab 1 Introduction

Summary TSpaces Overview Basic Definitions Basic primitive operations Reading/writing tuples in tuplespace HelloWorld program Installing TSpaces Compiling/running programs in TSpaces

TSpaces Overview TSpaces is a Java implementation of the Linda coordination model. It enables communication between applications and devices in a network of heterogeneous computers and operating systems.

Basic Definitions Field – Most basic component of Tuplespace data structure. It contains: Type (i.e. "java.lang.String" or "com.company.appl.EmployeeObject") Value Field Name (optional): Specifying a field name implies that this field will be indexed (and searched).

Basic Definitions (2) Tuple – A Tuple object is an ordered sequence of Fields. – Implemented by SuperTuple class (abstract class) – Clients should create objects of either Tuple or SubclassableTuple classes. – A template tuple is a Tuple that is used for matching. One or more of the Fields in a template may be "wildcards" and consist of only the class type with no value.

Basic Definitions (3) TupleSpace – A class implementing a space where tuples can be added/removed – It is stored and administered across a network on one or more "TSpace Servers“. A TSpace server may contain many Tuplespaces. – Several threads on the same or different machines can be accessing the space simultaneously. – For each different TupleSpace a client wishes to access, it requires a separate instance of this class, even if they are managed by the same server. – In order to obtain an instance of a specific tuplespace you need the name of the space, and the name of a server that manages that space.

Basic primitive operations write ( tuple ): Adds a tuple to the space. take( template_tuple ): Searches for a tuple that matches the template. When found, the tuple is removed from the space and returned. If none is found, returns null. waitToTake(template_tuple ): Searches for a tuple that matches the template. Blocks until match is found. Removes and returns the matched tuple from the space. read( template_tuple ): Like "take" above, except that the tuple is not removed from the tuple space.

Basic primitive operations (2) waitToRead( template_tuple ): Like "waitToTake" above, except that the tuple is not removed from the tuple space. scan( template_tuple ): Like "read" above, except that it returns the entire set of tuples that match. countN( template_tuple ): Like "scan" above, except that it returns the number of matching tuples rather than the set of tuples itself. There are also numerous other more specialized commands and there is an ability to define your own specialized commands.

Reading and writing tuples Step 1: Create a new tuplespace or get access to an already created tuplespace String host = "tserver1.company.com";... TupleSpace ts = new TupleSpace("Example1",host); The above will contact the TSpaces server that is running on a machine with hostname "tserver1.company.com" and return a handle to the TupleSpace that is named "Example1". If the "Example1" TupleSpace does not exist, it will be created at this time.

Reading and writing tuples (2) Step 2: Create and write tuples to tuplespace Tuple t1 = new Tuple("Key1","Data1"); ts.write(t1); Tuple t2 = new Tuple("Key2",new Integer(999),"Data2"); ts.write(t2); Tuple t3 = new Tuple("Key2","Data3"); ts.write(t3); The above will create and write 3 Tuples to the TupleSpace allocated previously. Tuples can contain any number and any type of fields.

Reading and writing tuples (3) Other ways to create and write a tuple are the following: Field f1 = new Field("Key1"); Field f2 = new Field("Data1"); Tuple t1 = new Tuple(); t1.add(f1); t1.add(f2); ts.write(t1); -or- ts.write("Key1","Data1");.

Reading and writing tuples (4) Step 3: Reading tuples from tuplespace In order to read a tuple you must create a template Tuple. Template Tuple is a Tuple that is used to select matching Tuples. It will contain 0 or more Fields that are either Actual Fields or Formal Fields. Actual fields have a value that must be matched exactly against the corresponding Fields in the tuples that are in the TupleSpace. Formal fields have a class but no value and only describe the type of value that is to be returned. Basically they act as wildcards.

Reading and writing tuples (5) Tuple template = new Tuple("Key2", new Field(String.class)); Tuple tuple = ts.read(template); String data = (String)tuple.getField(1).getValue(); The above code creates a template that matches any tuple having two fields of type String. The first field must contain the value "Key2". The second field can match any field of String type. In order to read the matching Tuples from Tuplespace we use the command read. The command take can also be used but it will remove the matching Tuples from the TupleSpace database and return it to the caller.

HelloWorld Example import com.ibm.tspaces.*; import java.io.Serializable; public class HelloWorld { public static void main(String[] args) { String myName = "World"; boolean needReply = false; if ( args.length > 0) myName = args[0]; try { TupleSpace space = new TupleSpace(); Tuple template = new Tuple(myName, new Field(String.class),new Field(Serializable.class));

HelloWorld Example (2) System.out.println("Checking for message in tuplespace..."); Tuple msg = space.take(template); if ( msg == null) { System.out.println("No message for me!\n Sending message to World..."); msg = new Tuple("World", myName,"Hello World"); needReply = true; space.write(msg); } else { System.out.println("Message received is: "+ msg); System.out.println("Sending reply message to : "+ (String)msg.getField(1).getValue());

HelloWorld Example (3) msg = new Tuple((String)msg.getField(1).getValue(), myName,"Hi"); space.write(msg); } if (needReply) { // Wait for a reply System.out.println("Waiting for reply..."); msg = space.waitToTake(template); System.out.println("Message received is: "+msg); } } catch (Exception e) { System.out.println(e); }

Installing Tspaces Download TSpaces package (tspaces212.zip) from herehere Unzip package to a directory tspaces Exit to dos command window and change directory to tspaces In order to start a TSpaces Server execute command: bin\tspaces If server is started successfully the prompt TSServer:> is appeared In order to stop the TSpaces Server execute command exit

Compiling/running programs In order to compile and run TSpaces programs you need to include the jar files tspaces_client.jar and tspaces.jar in your CLASSPATH. These files are located in the tspaces_dir\lib (where tspaces_dir is the path to the directory where TSpaces is installed). Compile: javac -classpath.;tspaces_dir\lib\tspaces_client.jar; tspaces_dir\lib\tspaces.jar yourfile.java Run: java -cp.;tspaces_dir\lib\tspaces_client.jar; tspaces_dir\lib\tspaces.jar yourfile Replace tspaces_dir with the path to the directory where TSpaces is installed. Compile and run the HelloWorld ExampleHelloWorld Example

HTTP Server Interface The TSpaces Server contains a light built-in HTTP Server. You can use this interface to determine the status of TSpaces or obtain debug information. In order to obtain this information access HTTP server at where hostname is the name of the machine that TSpaces server runs.