490dp Part I: Challenges Intermezzo: Applications Part II: Java Object Serialization Robert Grimm.

Slides:



Advertisements
Similar presentations
COS 461 Fall 1997 Network Objects u first good implementation: DEC SRC Network Objects for Modula-3 u recent implementation: Java RMI (Remote Method Invocation)
Advertisements

Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 Serialization Flatten your object for automated storage or network.
Slide 10.1 Advanced Programming 2004, based on LY Stefanus’s Slides Object Serialization Object serialization: the process of converting an object into.
CSC 243 – Java Programming, Spring 2013 March 26, 2013 Week 8, java.lang.Clonable & java.io.Serializable Interfaces.
The Zebra Striped Network Filesystem. Approach Increase throughput, reliability by striping file data across multiple servers Data from each client is.
CS-550: Distributed File Systems [SiS]1 Resource Management in Distributed Systems: Distributed File Systems.
Distributed Systems 2006 Styles of Client/Server Computing.
Object Serialization in Java Or: The Persistence of Memory…
Serialization, Cont’d Cerealization?. Administrivia Reminders: Swing/events quiz (group/indiv): next Mon, Feb 14 Book text, BUT ALSO try some demo programs.
Computer Science Lecture 16, page 1 CS677: Distributed OS Last Class: Web Caching Use web caching as an illustrative example Distribution protocols –Invalidate.
1 Chapter 7 Inheritance, Polymorphism, and Scope.
EEC-681/781 Distributed Computing Systems Lecture 3 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University
Mutual Consistency Detection of mutual inconsistency in distributed systems (Parker, Popek, et. al.) Distributed system with replication for reliability.
Hands-On Microsoft Windows Server 2003 Administration Chapter 5 Administering File Resources.
Advanced Java Class Serialization. Serialization – what and why? What? –Translating the contents of an Object to a series of bytes that represent it,
Chapter 12 File Management Systems
Concurrency Control & Caching Consistency Issues and Survey Dingshan He November 18, 2002.
70-270, MCSE/MCSA Guide to Installing and Managing Microsoft Windows XP Professional and Windows Server 2003 Chapter Nine Managing File System Access.
Jeff Chheng Jun Du.  Distributed file system  Designed for scalability, security, and high availability  Descendant of version 2 of Andrew File System.
ASP.NET Programming with C# and SQL Server First Edition
490dp Prelude I: Group Membership Prelude II: Team Presentations Tuples Robert Grimm.
CSE 490dp Resource Control Robert Grimm. Problems How to access resources? –Basic usage tracking How to measure resource consumption? –Accounting How.
Distributed Deadlocks and Transaction Recovery.
1 The Google File System Reporter: You-Wei Zhang.
Week 9 Objectives Securing Files and Folders Protecting Shared Files and Folders by Using Shadow Copies Configuring Network Printing.
Mobility in Distributed Computing With Special Emphasis on Data Mobility.
1 Chapter 12 File Management Systems. 2 Systems Architecture Chapter 12.
Java: Chapter 1 Computer Systems Computer Programming II.
Distributed Systems. Interprocess Communication (IPC) Processes are either independent or cooperating – Threads provide a gray area – Cooperating processes.
Distributed File Systems Case Studies: Sprite Coda.
The Java Programming Language
1 CS 430 Database Theory Winter 2005 Lecture 16: Inside a DBMS.
Chapter 14 - Designing Data Access Classes1 Chapter 14 Designing Data Access Classes.
Object Persistence and Object serialization CSNB534 Asma Shakil.
Java Programming: Advanced Topics 1 Input/Output and Serialization Chapter 3.
Object Serialization in Java Or: The Persistence of Memory… Originally from:
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Computer Science Lecture 19, page 1 CS677: Distributed OS Last Class: Fault tolerance Reliable communication –One-one communication –One-many communication.
08 - StructuralCSC4071 Structural Patterns concerned with how classes and objects are composed to form larger structures –Adapter interface converter Bridge.
Fault Tolerance and Replication
Distributed Systems CS Consistency and Replication – Part I Lecture 10, September 30, 2013 Mohammad Hammoud.
Outline  Basic IO  File class  The Stream Zoo  Serialization  Regular Expressions.
Architecture View Models A model is a complete, simplified description of a system from a particular perspective or viewpoint. There is no single view.
IBM TSpaces Lab 2 Customizing tuples and fields. Summary Blocking commands Tuple Expiration Extending Tuples (The SubclassableTuple) Reading/writing user.
©SoftMoore ConsultingSlide 1 Serialization. ©SoftMoore ConsultingSlide 2 Serialization Allows objects to be written to a stream Can be used for persistence.
CS 116 OBJECT ORIENTED PROGRAMMING II LECTURE 12 GEORGE KOUTSOGIANNAKIS Copyright: 2015 Illinois Institute of Technology/ George Koutsogiannakis 1.
The Prototype Pattern (Creational) ©SoftMoore ConsultingSlide 1.
Quick Review of OOP Constructs Classes:  Data types for structured data and behavior  fields and methods Objects:  Variables whose data type is a class.
Bigtable: A Distributed Storage System for Structured Data
Highly Available Services and Transactions with Replicated Data Jason Lenthe.
Author: DoanNX Time: 45’.  OOP concepts  OOP in Java.
1 Copyright © 2011 Tata Consultancy Services Limited TCS Internal.
TEAM FOUNDATION VERSION CONTROL AN OVERVIEW AND WALKTHROUGH By: Michael Mallar.
THE EVOLUTION OF CODA M. Satyanarayanan Carnegie-Mellon University.
Java Programming: Advanced Topics 1 Input/Output and Serialization.
1 CSE 331 Memento Pattern and Serialization slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia
Computer Science Lecture 19, page 1 CS677: Distributed OS Last Class: Fault tolerance Reliable communication –One-one communication –One-many communication.
OBJECT ORIENTED PROGRAMMING II LECTURE 21 GEORGE KOUTSOGIANNAKIS
Behavioral and Structural Patterns
Serialization and Deserialization Bullet points from Head First Java, Ch Dec-18 serialization.ppt.
CSE 451: Operating Systems Winter Module 22 Distributed File Systems
Distributed File Systems
Distributed File Systems
CSE 451: Operating Systems Spring Module 21 Distributed File Systems
Distributed File Systems
CSE 331 Memento Pattern slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia
OBJECT ORIENTED PROGRAMMING II LECTURE 22 GEORGE KOUTSOGIANNAKIS
Podcast Ch23f Title: Serialization
Distributed File Systems
Distributed File Systems
Presentation transcript:

490dp Part I: Challenges Intermezzo: Applications Part II: Java Object Serialization Robert Grimm

Challenges Pervasive computing –Vision: Focus on users and their tasks –Enabled by ubiquitous smart devices Central question –How can devices get users’ tasks done? They need to work together!

Distributed State “Information retained in one place that describes something, or is determined by something, somewhere else in the system” Examples –Association between addresses and names –Sequence number to identify most recent data –File block cached in memory of client –List of clients caching a file

Why is Distributed State Good? Performance –Not going over the network saves time –Example: Local cache of files Coherency –Easier to coordinate based on knowledge –Example: Server notification when cache expires Reliability –Replication makes it possible to tolerate failures –Example: Same files stored on two servers

Why is Distributed State Bad? Consistency Crash sensitivity Time and space overheads Complexity

Consistency Problem: Keep copies consistent Approaches –Detect stale data on use Treat copy as hint Example: name-to-address map –Prevent inconsistency Require exclusive ownership before modifying Example: all operations go through one node –Tolerate inconsistency Make window of inconsistency small Example: delays in network games

Crash Sensitivity Problem: Mask failures Approaches –Reconstruct state Example: reopening files in Sprite FS –Limit degree of distribution / affected state Example: partition files according to usage –Fully replicate state Example: Coda file system

Time and Space Overheads Time –Go across the network Space –Distributed copies –Tracking distributed copies Overheads depend on –Degree of sharing –Degree of modification

Complexity Distributed state requires –Maintaining consistency –Masking of failures Distributed state makes it harder to –Debug –Tune

Trade-offs Consistency Availability Scalability Complexity

No Perfect Solution Solution needs to be “good enough” NFSSprite FS ConsistencyLimited  AvailabilityLimited ScalabilityLimited (Baseline OK) ComplexityLowHigh

What Means “Good Enough” Depends on application domain –Make an informed trade-off Examples –Cluster-based services Porcupine Distributed Data Structures –Disconnected storage services Epidemic replication Two-tier replication

Porcupine Cluster-based server Assumptions – typically doesn’t get modified –Deleted s may reappear (temporarily) Eventual consistency But, availability and scalability [Saito et al. 99]

Distributed Data Structures Cluster-based hash table Assumptions –Network is fast and doesn’t partition –Nodes fail infrequently –OK to return failure at storage layer Consistency, availability, and scalability [Gribble et al. 00]

Bayou Epidemic replication [Demers et al. 87] –Two nodes periodically synchronize state –Only pair-wise connectivity Structured storage (database) Eventually consistent But, always available [Petersen et al. 97]

Coda First-tier nodes –Fully connected –Store all data Second-tier nodes –Often disconnected –Store subset of data Limited consistency, but greater availability [Kistler & Satya 92, Mummert et al. 95]

Conflicts Caused by competing updates Detected “after the fact” Need to be resolved automatically

Conflict Resolution Techniques Based on data –Timestamps –Heuristics –Programs [Kumar & Satya 95, Reiher et al. 94] Part of update: Bayou [Terry et al. 95] –Dependency check –Merge procedure

Morals No perfect solution –Need to exploit application domain Complexity grows very quickly –Beware of special case code (recovery)

Intermezzo: Applications Team 1: Cluster-based application –Scalable Napster / Gnutella repository –Scalable document repository Leased storage Customizable actions when leases expire Team 2: Roving application –Personal jukebox –PIM on steroids –Universal inbox

Break

Java Object Serialization Problem –Turn graph of objects into byte string –Turn byte string back into graph of objects A BC D A BC D

The Basic Idea Write a description of each object Keep track of each written object > > A BC D A BC DD

All Things Serializable Not everything is serializable –java.lang.Object –java.lang.Thread Serializable objects implement java.io.Serializable –An empty marker interface

Default Serialization Writes out all fields –Independent of their access controls (private, package private, protected, public) Good style to document invariants Must not be null

Default Deserialization Allocates memory for new object –No constructor invoked –Fields initialized to their default values Reads in all fields –Independent of their access controls

Transient Fields Some fields shouldn’t or can’t be serialized private Object lock; How to prevent default serialization from trying to write them out? –Declare such fields as “transient” private transient Object lock; –Restored to defaults during deserialization null in above example

Overriding Serialization Customize serialization by implementing private void writeObject(ObjectOutputStream) throws IOException; Good style to document customization tag

Overriding Serialization Example: Thread-safe serialization private void writeObject(ObjectOutputStream out) throws IOException { synchronized (lock) { out.defaultWriteObject(); } }

Overriding Serialization Example: Filter elements from a list –Declare list to be transient –In writeObject() Invoke default serialization Iterate over list, writing filtered elements out.writeObject(el); Write end-of-list marker out.writeObject(Boolean.FALSE); Alternatively, write length & elements

Overriding Deserialization Customize deserialization by implementing private void readObject(ObjectInputStream) throws IOException, ClassNotFoundException;

Overriding Deserialization Example: Restore lock private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); lock = new Object(); }

Overriding Deserialization Example: Restore list In readObject() –Invoke default deserialization –Read filtered elements until end-of-list marker –Alternatively, read length & elements

Notes on Customization Don’t perform operations that take a long time –No I/O besides accessing object stream Swing UI elements are serializable –But are not designed for long-term storage –Declare them transient –Restore UI in application logic

The Replacements Example: Symbols — there can only be one private Object readResolve() throws ObjectStreamException { return intern(name); } Done after object graph has been restored –Embedded self references are not replaced!

Inheritance If a superclass implements Serializable, all subclasses are also serializable –Each class in such a hierarchy serializes only its own state –Classes can control all state by implementing java.io.Externalizable If superclass is not Serializable, a serializable subclass must handle the superclass’s state

Inheritance To make a subclass of a serializable class not serializable private void writeObject( ObjectOutputStream o) throws IOException { throw new NotSerializableException( getClass().getName()); } This indicates a semantic problem!

Versioning Problem –Classes can change –While instance is in serialized form Solution –Let classes declare their version –Define what are compatible changes

Stream Unique Identifier (SUID) Hash of the class –Determined by serialver tool –Accessible in Java through ObjectStreamClass.getSerialVersionUID() Modified version declares same SUID as original version private static final long serialVersionUID = …;

Incompatible Changes Deleting fields Moving classes up or down in the hierarchy Changing non-static fields to static Changing non-transient fields to transient Changing the declared type of a field Adding / removing access to default fields from writeObject() / readObject() See specification!

Compatible Changes Adding fields Adding / removing classes Adding Serializable Adding / removing writeObject() / readObject() Changing static fields to non-static Changing transient fields to non-transient

Security Serialized objects expose their internal state If that state is sensitive it must be protected –Don’t serialize sensitive state –Encrypt sensitive state –Encrypt serialized objects

There’s More serialPersistentFields to declare the serialized format –Useful for backwards compatibility ObjectInputValidation to validate deserialized objects Class descriptors –Serialized form of a class Two versions of serialization protocol