Comp Assignment 4: Extendible and Multi-Platform Object (De)Serialization

Similar documents
Comp Assignment 3: Extendible and Multi-Platform Object (De)Serialization in GIPC Date Assigned: October 8, 2015

Voyager Interoperability Guide Version 1.1 for Voyager 8.0

Introduction to Programming Using Java (98-388)

JAVA MOCK TEST JAVA MOCK TEST IV

COP 3330 Final Exam Review

COMP 401 COPY: SHALLOW AND DEEP. Instructor: Prasun Dewan

B2.52-R3: INTRODUCTION TO OBJECT ORIENTATED PROGRAMMING THROUGH JAVA

Compaq Interview Questions And Answers

Comp Assignment 4: Commands and Graphics

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

DOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS

RPC IMPLEMENTATION: BASIC STEPS. Instructor: Prasun Dewan Department of Computer Science University of North Carolina at Chapel Hill

CS555: Distributed Systems [Fall 2017] Dept. Of Computer Science, Colorado State University

Contents. I. Classes, Superclasses, and Subclasses. Topic 04 - Inheritance

Java Persistence API (JPA) Entities

JAVA. Reflection API. Java, summer semester

Array Based Lists. Collections

Comp Assignment 2: Object-Oriented Scanning for Numbers, Words, and Quoted Strings

Object Oriented Programming: In this course we began an introduction to programming from an object-oriented approach.

5. Replicated Objects

1 Shyam sir JAVA Notes

COE318 Lecture Notes Week 8 (Oct 24, 2011)

15CS45 : OBJECT ORIENTED CONCEPTS

1 OBJECT-ORIENTED PROGRAMMING 1

List ADT. Announcements. The List interface. Implementing the List ADT

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub

Introflection. Dave Landers BEA Systems, Inc.

PIC 20A Number, Autoboxing, and Unboxing

Declarations and Access Control SCJP tips

COMP 9024, Assignment 4, 11s2

Lecture 3. COMP1006/1406 (the Java course) Summer M. Jason Hinek Carleton University

M257 Past Paper Oct 2008 Attempted Solution

[Course Overview] After completing this module you are ready to: Develop Desktop applications, Networking & Multi-threaded programs in java.

Exam Questions 1Z0-895

Introduction to Reflection

COE318 Lecture Notes Week 6 (Oct 10, 2011)

CS 200 Objects and ArrayList Jim Williams, PhD

CSC Java Programming, Fall Java Data Types and Control Constructs

Binghamton University. CS-140 Fall Problem Solving. Creating a class from scratch

Table of Contents. Introduction. Section 1

C# and Java. C# and Java are both modern object-oriented languages

Advanced MEIC. (Lesson #18)

IBD Intergiciels et Bases de Données

Java Threads and intrinsic locks

Interview Questions I received in 2017 and 2018

Today: Distributed Objects. Distributed Objects

Java Training JAVA. Introduction of Java

ArrayLists. COMP1400 Week 8. Wednesday, 12 September 12

COMP 250. Lecture 6. doubly linked lists. Sept. 20/21, 2017

From Java Code to Java Heap Understanding the Memory Usage of Your Application

Project 1: Remote Method Invocation CSE 291 Spring 2016

CMSC131. Inheritance. Object. When we talked about Object, I mentioned that all Java classes are "built" on top of that.

Basic I/O - Stream. Java.io (stream based IO) Java.nio(Buffer and channel-based IO)

EECS168 Exam 3 Review

Avro Specification

Lesson 10A OOP Fundamentals. By John B. Owen All rights reserved 2011, revised 2014

COMP-202: Foundations of Programming. Lecture 26: Review; Wrap-Up Jackie Cheung, Winter 2016

Distributed Systems Theory 4. Remote Procedure Call. October 17, 2008

1.Which four options describe the correct default values for array elements of the types indicated?

Distributed Systems Lecture 2 1. External Data Representation and Marshalling (Sec. 4.3) Request reply protocol (failure modes) (Sec. 4.

Inf1-OP. Inf1-OP Exam Review. Timothy Hospedales, adapting earlier version by Perdita Stevens and Ewan Klein. March 20, School of Informatics

ECE 122. Engineering Problem Solving with Java

Object Explorer. Atacama Large Millimeter Array

F1 A Java program. Ch 1 in PPIJ. Introduction to the course. The computer and its workings The algorithm concept

Generics. IRS W-9 Form

CS 1316 Exam 1 Summer 2009

Class, Variable, Constructor, Object, Method Questions

Tail Calls. CMSC 330: Organization of Programming Languages. Tail Recursion. Tail Recursion (cont d) Names and Binding. Tail Recursion (cont d)

Subclass Gist Example: Chess Super Keyword Shadowing Overriding Why? L10 - Polymorphism and Abstract Classes The Four Principles of Object Oriented

Spring Interview Questions

Review sheet for Final Exam (List of objectives for this course)

Java Language Features

CSCI-142 Exam 1 Review September 25, 2016 Presented by the RIT Computer Science Community

I/O streams. Byte Streams Character Streams InputStream ByteArrayInputStream FileInputStream FilterInputStream

Syllabus & Curriculum for Certificate Course in Java. CALL: , for Queries

COMP 202 Recursion. CONTENTS: Recursion. COMP Recursion 1

Working with arrays. ArrayLists. Abstraction. Arrays

Contents. Java RMI. Java RMI. Java RMI system elements. Example application processes/machines Client machine Process/Application A

SSJ User s Guide. Package rng Random Number Generators. Version: December 17, 2014

Announcements. Prelude (2) Prelude (1) Data Structures and Information Systems Part 1: Data Structures. Lecture 6: Lists.

Introduction to JPA. Fabio Falcinelli

Avro Specification

CMSC131. Library Classes

9 Working with the Java Class Library

STUDENT LESSON A15 ArrayList

CS 146 Spring 2017 Homework 4 Sections 5 and 6. The homework assignment is available at:

JPA. Java persistence API

Distributed Collaboration - Assignment 1: Multi-View 1-User IM

Comp Intermediate Programming EXAM #1 February 16, 2004 Rice University - Instructors: Cox & Nguyen

WA1278 Introduction to Java Using Eclipse

Frequently Asked Questions

CS164: Programming Assignment 5 Decaf Semantic Analysis and Code Generation

The Object clone() Method

ECE 122. Engineering Problem Solving with Java

How to be a Good Bean

INHERITANCE. Spring 2019

COMP-202. Recursion. COMP Recursion, 2011 Jörg Kienzle and others

Lab 4. Since this lab has several components in it, I'm providing some guidance to keep everyone

COMP-202: Foundations of Programming. Lecture 26: Image Manipulation; Wrap-Up Jackie Cheung, Winter 2015

Goal. Generic Programming and Inner classes. Minor rewrite of linear search. Obvious linear search code. Intuitive idea of generic linear search

Transcription:

Comp 734 - Assignment 4: Extendible and Multi-Platform Object (De)Serialization Date Assigned: October 24, 2013 Part 1 Completion Date: Tue Oct 29, 2013 Part 2 Target Date: Thu Oct 31, 2013 Part 2 and 3 Completion Date: Tue Thu Nov 57, 2013 The assignment is divided into three parts to make it easiery. In the first part, you will simply convert your previous assignment to GIPC. In the second part, you will build an extensible (de) serialization mechanism, which requires you to set up a complex recursive scheme involving objects of different classes. The third part will allow non-tree data structures to be serialized and de-serialized. In addition, it will support a reflection-based scheme that is more flexible than Java s and can support heterogeneous-platforms. Only the reflection-based scheme requires you to learn material the remaining components can be done on your own. Part 1: RMI GIPC Port your custom replication system of the previous assignment to GIPC duplex RPC. In converting to GIPC, none of your remote objects or proxies should change, ideally. All you should be doing is writing client and server launchers. Compare the timings you get for the 4-person synchronous session with RMI and GIPC and submit a document containing these timings. You do not have to submit a new video as I assume nothing will change in the UI. You may find that the number of outstanding writes allowed by GIPC by default is small. This value used to be a constant. In the version you have, you can call the method: public static void setmax_outstanding_writes(int max_outstanding_writes) in the class AScatterGatherSelectionManager to set this number. Make it as small as you need as Java gave me a memory overflow error when it was in thousands. As we saw in class, proxies for remote objects do not involve communication with a server. This means they can be generated before the client port is connected. Connection is required, however, before a method is invoked on the proxy. You know the port is connected when the createui() or dopostconnectasyncoperations() method is called in the launcher.

You can pass remote callback objects in GIPC-RMI as you would do in RMI. Pass the remote objects directly, do not try and create proxies for them, as GIPC automatically creates the proxies. Part 2: Serializer Interface, Factory and Interface In this part you will define a class that implements the following GIPC interface: package serialization; import java.nio.bytebuffer; public interface Serializer { public ByteBuffer outputbufferfromobject(object object); public Object objectfrominputbuffer(bytebuffer inputbuffer) ; } The first method serializes an object into a byte buffer, and the second does the reverse. As you have seen, a bytebuffer is a wrapper around an array, with markers indicating the position, limit and capacity. Both methods should access these markers in an appropriate fashion. In particular, the second method should not assume that the first byte to be read is the first byte in the array. This means you might have to make a flip() call after writing to the buffer. To minimize copying and data structure allocation, ideally a serializer should use a single byte buffer for all serializations. This means that in each recursive step, the same byte buffer should be used. Also even two independent calls to outputbufferfromobject should return the same byte buffer. This makes your implementation more difficult do this optimization as the last step and in your document indicate if you make it. You should also define a factory that instantiates your class and implements the following interface: package serialization; public interface SerializerFactory { Serializer createserializer (); } Your serializer will be used by GIPC when you register an instance of this factory by calling the setter method of serialization. SerializerSelector You will not be able to serialize (and deserialize) arbitrary objects. The objects you can handle will be called serializable objects. For part 12, serializable objects include the following base objects: Integer, Double, String, null, Boolean In other words, they include the null value and the Integer, Double, Boolean and String objects. In addition to these base types, serializable objects, include the following composite objects: java.util.collection whose elements are (base or composite) serializable objects java.util.map whose key and values are (base or composite) serializable objects

As Java automatically converts between primitive and wrapper values, you will also be able to handle int and double primitive values. To serialize a non-null serializable object of class C, you will need to send the name of the class in a byte buffer sequence followed by a byte buffer sequence representing the object value. Thus the full serialization of an object consists of its class name serialization and its value serialization. To de-serialize an object you will convert the class name to a class and then instantiate the class based on the value serialization. For a null value you will need some variation of this scheme. The method getclass() can be invoked on any object to get the class of an object, and the method getname() can be invoked on a class to get its name. The static method Class.forName(String) can be used to convert a class name to a class, and the method newinstance() can be invoked on a class to create a new instance of the class. The instantiated class must have a null constructor, which will be assumed for classes of all composite objects. ByteBuffer provides putint(), getint(), putdouble(), getdouble() for encoding and decoding value serializations of base integer and double values, and we have seen methods for doing the same for String values. Part 3: Extendible Full Serializer and External Value Serializers To send and receive the class name and null value, you can hardwire some scheme for serializing and de-serializing these values. For other values, you must allow external serializers to be registered, which encode and decode value serializations of these objects. You must write a full serializer that calls (and is called by) the registered value serializers. The exact form of the registration scheme is up to you. It should allow the programmer to associate a class with a serializer object that creates a value serialization of the class. Multiple classes can be associated with an instance of the same serializer class or even the same instance. In addition, you must register value serializers for the three base classes (String, Integer, Double, Boolean), three implementations of java.util.colllection (java.util.hashset, java.util.arraylist, and java.util.vector) two implementations of java.util.map (java.util.hashtable, java.util.hashmap). To illustrate, you must support equivalents of the following registrations supported by my implementation: ACustomSerializer.registerSerializer(Integer.class, new AnIntegerSerializer()); ACustomSerializer.registerSerializer(Boolean.class, new ABooleanSerializer()); ACustomSerializer.registerSerializer(Double.class, new ADoubleSerializer()); ACustomSerializer.registerSerializer(String.class, new AStringSerializer()); ACustomSerializer.registerSerializer(HashSet.class, new ACollectionSerializer()); ACustomSerializer.registerSerializer(ArrayList.class,

new ACollectionSerializer()); ACustomSerializer.registerSerializer(Vector.class, new ACollectionSerializer()); ACustomSerializer.registerSerializer(HashMap.class, new AMapSerializer()); ACustomSerializer.registerSerializer(Hashtable.class, new AMapSerializer()); Alternate Serialization Allow an object implementing an interface to be de-serialized as an instance of another class that implements the same interface. For instance, allow an ArrayList to be deserialized as a Vector. The alternate class is registered by giving the classes of the serialized and deserialized objects, as in: ACustomSerializer.registerDeserializingClass(ArrayList.class, Vector.class) Non Tree Data Structures Using the composite types, it is possible to create structures that are general graphs rather than trees. In a tree, a node has a single parent, while a graph allows multiple parents. This means that in a graph, the same node may be visited multiple times in a descent through the serialized/de-serialized structure. The de-serialized object should be isomorphic to the serialized object. This means that the serialization should contain a reference rather than a value when a component is visited again, and this reference should be converted to a memory address at the destination. If you ensure that the serialization and deserialization traversals serialize and de-serialize corresponding objects in the same order, this scheme can be easily and efficiently implemented. Arrays, List Patterns, and Beans The scheme, as described above, does not extend to classes for which serializers have not been registered, and for a serializer to handle types about which it does not know. Extend this scheme to support serialization of arrays, and objects that follow the Bean and list patterns described in class. We will refer to these serializers as type-independent serializers. You must define three new registration methods to handle these three kinds of objects, as illustrated below: ACustomSerializer.registerArraySerializer(new AnArraySerializer()); ACustomSerializer.registerBeanSerializer(new ABeanSerializer()); ACustomSerializer.registerListPatternSerializer( new AListPatternSerializer()); In addition, you should implement these three serializers. It is possible for an object to be serialized both by a type-dependent serializer and a typedependent one. Your serializers should allow only instances of java.io.serializer to be serialized. Encountering some other kind of object should throw the exception java.io.notserializableexception. You should make an exception for null, which is not a Serializable. Thus, you should allow null to be sent.

You can call the isarray() method on the class of an object to determine if it is an array. You can call Array.newInstance(Class componentclass, int size) to instantiate a new array. Array.length(Object array), Array.get(Object array, int index)and Array.set(Object array, int index, Object value) can be used to read and write and elements of instantiated arrays. To handle beans, you should use the java.beans.beaninfo class and invoke the invoke the getpropertydescriptors() method in it to get each property and its read and write method. It is possible to get the BeanInfo of a class, invoke the method Introspector.getBeanInfo(class) method. To support list pattern, use the GIPC oe class util.misc.remotereflectionutilitycommon. ReflectionUtlity. The methods islist(), listget(), listadd(), and listsize() methods. Alternate serialization along with type-independent serializers makes your scheme multi - platform. Do not die when bean get read/write methods misbehave, but to just skip them in serialization. Do print the error, if any. A missing write method (e.g. for the class property) s not an error. such a property is inherently transient. Transients and Init Serialized Objects You should not serialize objects whose read methods are associated with the util.misc.transient annotation (not be confused the Java beans annotation with the same name), which is checked by invoking RemoteReflectionUtility.isTransient(Method) call. After an object is serialized, invoke the method initserializedobject() in it, if such a method exists, which can be done by invoking RemoteReflectionUtility. invokeinitserializedobject(object ) Testing and Writeup The GIPC class serialization.examples.serializationtester includes a main method that has test cases with a comment delineating the two parts. Execute this in debug mode because in run mode it throws exceptions. (The new version of GIPC does not have this problem) After performing this test, modify your part 1 to use your serializer and compare the performance of 4-person synchronous GIPC-implemented session using the GIPC serializer and yours. Remember you have to change the setter type in AnRPCReturnValue from Serializable to Object (The new version of GIPC has this fix). For part 2, explain how you handle serialization and de-serialization of various kinds of objects including the null value. Also describe the interface of registered serializers. For part 3, extend the explanation to describe how you handle graph data structures and type-independent serializers. Be sure to describe any modifications to the interface of the registered serializers. As always include traces proving your program works. Use the tracer to show the important various steps of your algorithm. Formatted: Font: Italic

You will have to modify your launchers to (a) enable tracing and (b) set the serializer factory. It will be best to override the inherited launcher method: protected void initportlauchersupports() to perform these steps. This method sets the default tracing and factories. This method should call the inherited method and then execute your (tracing and factory) overriding code. Submission (a) Create a YouTube video demonstrating your code running serialization.examples.serializationtester. Show traces and debugger variable values to convince me that the method runs correctly with your code. (b) Create a Youtube video demonstrating 4-user GIPC synchronous case of Part 1 in which your serializers is used instead of the GIPC serializer. In this video, convince me me through traces and/or the debugger that it is your serializer that is running. (c) Submit a handout in which you (i) submit the traces produced by (a) and (b); (ii) compare the timings of the two serializer as indicated above; and (iii) explain the workings of parts 2 and 3 as indicated above. (d) Some of you will modify your code in response to what you learnt in class and some you will not as I suggested. Even though I recommended to not fix something that is not broken, I do want to reward those of you who do change. So in your write up, indicate how you handled all of the issues we discussed in class (including logical vs physical) and also indicate how you would have liked to have handled them. If you are handling physical structures, it should be in addition to logical structures and not in place of them. Formatted: Font: Italic (e) Submit your code on Sakai. Formatted: Font: Calibri, 11 pt, Italic, Font color: Auto The tester is sufficient to test some but not all cases. In particular, it does not test alternate serialization. Formatted: Normal