Monitoring serialization of big objects.

I'm building a comunications architecture for a project that involves the exchange of objects between a client and server (with the usual main+worker threads design). The exchanged messages are sort-of agents that deal with a particular aspect of the application protocol.
The problem is that sometimes we have to send big objects (or send them through a slow link) and I was wondering if there's a way to monitor how many bytes were written to the ObjectOutputStream to generate a progress bar ? (right now we have one in indeterminate mode).
Thanks in advance.

I could re-use Count[I/O]Stream from Jakarta Commons Net.
The serialization of the objets is almost trivial. Even with the complicated messages we never ran into any problems. In fact we have an object that holds a compressed image of another serialized object that gets decompressed whenever a message is sent to the wrapper. It works pretty well.
I guess I'll just keep the current "Doin' something really slow, go get a coffee or something" dialog box :)

Similar Messages

  • How to  Serialize a very big Object??

    Please help me !

    I misread that as sterilize for a moment. Buckets and buckets of dettol! And that's the clean answer.
    As Athena indicates you Serialize a very big Object in exactly the same way that you Serialize a very small object.
    Are you encountering a problem, and if so what is it?
    Dave.

  • Serialization big object(100k--2M) into MYSQL database

    Hi all !
    I have a big object need to be persisted into MYSQL database in my application.
    I use two method to meet this request
    1 ---- the object implement interface Serializable, but there is serializationVersionID is not same Exception
    sometimes.
    2 ---- Use XMLEncoder to save my object, the XMLEncoder generate the object XML text about 200k -- 3 M
    , but another problem occur :
    when I call flush method of XMLEncoder, my application will full ocuppy CPU time, and memory usage will increase to 90M, sometimes will ocurr "Not enough memory" Error.
    Why?
    can some one help me?
    Thanks in advanced

    1. You are modifying the signature of one or more of your classes that alters the (system generated) serializationVersionUID and then recompiling. You can declare this for yourself to get control to some extent. See the serialization spec for details.
    2. Your object graph is very large, which might be a problem using native or xml formats. Again, the specification details ways in which you can control the serialized form of your objects.
    On the information you've provided there's not much more that can be said.

  • Serialization error for object  (IDOC error 51)

    hello,
    Can Somebody help me with this??? this is what it gives me when the IDOC comes to the receiver instance (SAP R/3). The error code is 51.
    Serialization error for object 01,S,12000677 . Expected counter 000001 < 000044 in IDoc
    Message no. 5-300
    Diagnosis
    A serialization error has occurred for the HR object 01,S,12000677 that was received from the logical system E3B.
    The expected serialization counter has the value 000001. However, the serialization counter in the IDoc has the value 000044 and is therefore too big. There are therefore older IDocs with this HR object with the serialization counter values in between. These IDocs have either not yet been posted, or have been posted incorrectly.
    Procedure
    Post all IDocs that have not yet been posted or that were posted incorrectly.
    Thank you very much
    PM

    Hi David,
    Please take a look at these threads..
    Status code 51
    IDOC Status 51
    IDoc cannot be opened Error 51 (Inbound)
    InfoPackage loading giving IDOC Error: Status 51
    cheers,
    Prashanth

  • Is possible to make Serializable a Connection object?

    Hi I would like to know if is possible to make Serializable a Connection Object, I would like to save the Connection object into a text file so other class can read it and execute a proper query. If is possible how can I do it?.
    Thanks.

    Actually, if a class isn't already Serializable, you can't make it become Serializable reliably. Consider the following case:
    class A
        int x = 0;
        public void setX(int new_x) { x = new_x; }
        public int getX() { return x; }
    class B extends A implements Serializable
        int y = 0;
        public void setY(int new_y) { y = new_y; }
        public int getY() { return y; }
    public static void main(String arg[]) throws Exception
        B b = new B();
        b.setX(10);
        b.setY(12);
        someObjectOutputStream.writeObject(b);
    }The problem with this is that the implementation of Serializable by class B does not affect class A. In the above example, the ObjectInputStream that obtains the instance of B will have a y value of 12, but an x value of 0 (not 10).
    Thus, unless the Connection object implemented Serializable to begin with, it can't become Serializable. And, as the above post has described, the implementers of the Connection object would not make it Serializable as the local Connection object uses underlying O/S resources which cannot simply be transformed into a byte array.

  • Serialization custom Class Object

    Hi,
    I'm kind of stuck with a problem.
    I've been writing a servlet and applet that are communicating over
    internet using a socket connection and Object Serialization.
    The objects that are passed are custom:
    public class mcuComObj implements Serializable{
        static final long  serialVersionUID = 2222;
        private String name;
        private Vector attributes;
        ...There are some more functions but those are not of any interest.
    In the vector attributes, I've planted a jPanel (swing).
    The weird thing is that this morning, it worked a few times...after that
    I'm getting the:
    javax.swing.JComponent; local class incompatible: stream classdesc serialVersionUID = 6954663636822719621, local class serialVersionUID = 5896976265092562486 ERROR message.
    The send code:
    Vector v = new Vector();
    Object objButton = (Object) jButton1;
    v.add(objButton);
    obj.setAttributes(v);  //obj = mcuComObj
    con.sendObject(obj);   //con = socket connection threadThe receive code:
    Object input= (Object) objInpStr.readObject();When I serialize the mcuComObj class, does it also serialize the
    embedded objects (in this case that are in the Vector)?
    The main question is...how can I solve this? I can not guarantee that
    both Servlet and Applet have the same JDK running...!
    Have anyone of you got any ideas?
    Thanks in advance,
    Chris van Diemen

    If the "magic numbers" (sent at the beginning of any writeObject() call) on the sending and receiving JDK differ, the object will not de-serialize properly on the receiving end.
    The easist solution would be to use a common format to transmit the data. Say! That sounds like XML.
    - Saish
    "My karma ran over your dogma." - Anon

  • Serialization vs remote object.

    hi, all
    come to a crosspoint of selecting which one to use : serialization vs remote object. want to get your inputs. thx for your feedback in advance.
    when defining objects like passing parameters or accepting a return value in RMI, there are 2 choices: serialization and remote object. what's criteria to pick up? which choice is the prefered one in industry?
    Some use cases:
    #1: RMI client needs to create instances of those objects and passes to RMI server
    #2: RMI server returnes instances of those objects also.
    For case #1, RMI client can't create instance of remote object, right?
    thx for help
    Tim

    #1: RMI client needs to create instances of those
    objects and passes to RMI server
    For case #1, RMI client can't create instance of
    remote object, right?Depends what you want. If you want the methods of the object
    to execute on the RMIClient, then you are effectively reversing roles
    and the server is acting as a client and you need a remote object.
    If you simply want to create an object and pass it to the server
    from the client, it just needs to be Serializable.

  • Reading in memory big objects

    Hi
    how to read realy big objects (300-500 MB) in memory part by part (better say dynamicaly) - I mean, that you dont have ANY POSSIBILITY read him fully.
    Maby it should be buffering, or not - I dont know.
    THANK YOU

    Out of curiosity, how long would it take someone
    to read 500 MB of text?I slaved on the answer, and not so much as a thank
    you, go figure. : )
    hey drlazlojamf, just out of curiosity, how long
    would it take someone
    to thank someone else for satiating their incessant
    curiosity?Well, let me get out my slide rule. Hmmm... 300 cubits per hogshead...
    About now! Thank you TP, you have enlightened all our lives.
    The OP seems unrepentant; I thought he'd come back with at least
    a "but my manager says its a design requirement". But I guess the
    shame was too great. And for that we give thanks.

  • Could you serialize ANY ObjC object, even those created from scratch ?

    I would like to create a custom object that holds a UIImage, CLLocation, two ints and to serialize that single object that wraps all these. Can this be done ? Or serialization of this "container" will fail because this object include ints which cannot be serialized.
    Message was edited by: Bracer-J
    Message was edited by: Bracer-J

    The NSCoder class defines some methods for scalar archiving, for example -encodeInt:forKey:

  • Need help serialize a collection object

    I have a class that's going to manage a list of paths stored as strings as "ArrayList<String> fileList = null;". I can't figure out how to serialize the fileList object. The class that contains the fileList implements Externalizable. here are the read and write functions:
         public void readExternal(ObjectInput in) throws IOException
              fileList = (ArrayList)in.readObject();
         public void writeExternal(ObjectOutput out)  throws IOException//, ClassNotFoundException
              out.writeObject(fileList);
         }I've tried lots of different things and nothing works. Anybody know how to serialize an ArrayList? Is ArrayList the best class for the job?

    I have a class that's going to manage a list of paths
    stored as strings as "ArrayList<String> fileList =
    null;". I can't figure out how to serialize the
    fileList object. You don't have to do anything to serialize ArrayList, it is already Serializable.
    The class that contains the fileList
    implements Externalizable. here are the read and
    write functions:I will assume there is a good reason this class (that contains the fileList) can itself not be Serializable and needs to be Externelizable.
    >
    public void readExternal(ObjectInput in) throws
    s IOException
              fileList = (ArrayList)in.readObject();
    public void writeExternal(ObjectOutput out)  throws
    s IOException//, ClassNotFoundException
              out.writeObject(fileList);
         }I've tried lots of different things and nothing
    works. Anybody know how to serialize an ArrayList? Is
    ArrayList the best class for the job?I tried the same example -- with code to make it compilable and testable -- and it works as expected.
    What exactly do you mean when you say "nothing works"?

  • Monitor State of an Object

    Is there a way to check the monitor state of an object? For example,
    before entering a synchronized block I want to check if there is a monitor on the object and skip the block so the thread is not forced to wait. Thanks in advance.

    I don't think so...
    But you can use higher-level concurrency constructs to do this. For example, you could design a lock which allowed you to attempt to lock, or give up. Doug Lea has written an excellent book on concurrency, and also has a library of concurrency utilities called "util.concurrent" available online. His page is at:
    http://gee.cs.oswego.edu/dl/cpj/
    In particular, he has a Semaphore object with a method public boolean attempt(long msecs). You'll also need to use try/finally to make sure you release any locks you acquire.
    The book is a great read -- I recommend it.

  • Serialization of JTree Object

    i need to serialize the JTree object .
    1) i used XMLEncoder and XMLDecoder
    2)and i used ObjectOutputStream and ObjectInputStream
    Please help me with sample program
    Solution would be really helpful.

    krish1985 wrote:
    i need to generate the JTree dynamically.for that i need to save the
    object in a file(Serialization)Why? I very much doubt you do. The JTree is simply a view on some data. It's that data you want to serialize in some way

  • Serialization of Vector Object

    I have an Message class that is something like
    public class Messsage implements Serializable{
    int messageCode;
    Object payload;
    public class dataObject implements Serializable{
    int code;
    Object referenceObject;
    Object other refObject;
    The payload is
    Vector<Object> testPayload = new Vector<Object> ();
    testPayload.add(payloadDescriptionString);
    testPayload.add(datadataObject);
    msgCode =1;
    msg.payload = testPayload;
    I am trying to send a vector of different object types in a message through socket streams. I was able to send the Message object through sockets when I didn't set the payload to the vector. Now, I get a NotSerializableExcpetion. Are Vectors not serializable? Is it because my Object Vector has Objects of two or more class types like String and my class? In short what would make a class unserializable? What are the requirements for making it serializable? Any help would greatly appreciated.

    Just a footnote. I may have inadvertently solved my problem. I still don't understand it though. In the constructor of my dataObject I instantiated the object to a new object ie
    referenceObject = new Object();
    otherrefObject = new Object();
    Originally, I instantiated them so I could extend this class. I changed the code in the constructor to.
    referenceObject = null;
    otherrefObject = null;
    Serialization appears to be working now. Why does it not serializable in the first place?

  • Trying to serialize a simple object

    Hi,
    I can't seem to create an ObjectInputStream. The error is noted in the code below. I also noticd that the output file where I seemingly wrote the object without problems is empty.
    import java.io.*;
    //Class from which an object is serialized:
    class MyClass implements Serializable
         private int num;
         private String str;
         public MyClass(int num, String str)
              this.num = num;
              this.str = str;
         public MyClass()
              num = 0;
              str = null;
         public void show()
              System.out.println(num);
              System.out.println(str);
    public class DemoSerialization
         public static void main(String[] args)
              MyClass A = new MyClass(50, "hello serialization");
              A.show();
    /*Create output file:*****************/
              File myFile = new File("C:\\TestData\\javaIO.txt");
              try
                   myFile.createNewFile();
              catch(IOException exc)
                   System.out.println("couldn't create output file");
                   System.exit(1);
    /*Create output stream:*************/
              ObjectOutputStream out = null;
              FileDescriptor fd = null;     //FileDescriptor represents a connection to a file.  Then,
                                                           //you don't have to do all the file checking, etc, when
                                                           //you move the data in the other direction(see below)
              try
                   FileOutputStream fos = new FileOutputStream(myFile);
                   fd = fos.getFD();
                   out =      new ObjectOutputStream(
                                  new BufferedOutputStream(fos));
              catch(FileNotFoundException exc)
                   System.out.println("couldn't find the file while during creation of file output stream");
                   System.exit(1);
              catch(IOException exc)
                   System.out.println("io error creating output file stream");
    /**/     System.out.println("test1: " + fd); // "java.io.FileDescriptor@df6ccd"
    /*Serialize the object:***************/
              try
                   out.writeObject(A); 
              catch(InvalidClassException exc)
                   System.out.println("class definition of object being written to a file has a problem");
              catch(NotSerializableException exc)
                   System.out.println("class of the object did not implement Serializable");
              catch(IOException exc)
                   System.out.println("general file output error occurred");
    /*Create input file stream:***********/
              FileInputStream fis = new FileInputStream(fd);
              BufferedInputStream bis = new BufferedInputStream(fis);
    /**/     System.out.println("test2: " + bis);  // "java.io.BufferedInputStream@b89838"
              ObjectInputStream in = null;
              try
                   in = new ObjectInputStream(bis);      /*****ERROR--throws exception*****/
              catch(IOException exc     )
                   System.out.println("ObjectInputStream error");
    /**/     System.out.println("test3: " + in);  // "null"
    /*Read in the object:****************/
              MyClass B = null;
              try
                   B = (MyClass) in.readObject();  /***ERROR--NullPointerExecption(see above)***/
              catch(ClassNotFoundException exc)
                   System.out.println("no class definition exists in this program for the object read in");
              catch(InvalidClassException exc)
                   System.out.println("class def is present but there is something wrong with it");
              catch(StreamCorruptedException exc)
                   System.out.println("control info in stream is corrupt");
              catch(OptionalDataException exc)
                   System.out.println("attempted to read in a basic data type--not an object");
              catch(IOException exc)
                   System.out.println("general stream error occurred during read");
              B.show();
    }

    Your originaly source did not include the call to the
    close method of ObjectOutputStream which is why your
    file was created but empty. I assumed you added it
    after the call to writeObject.
    Well, that isn't the case. I posted that I added flush().
    Read the API docs on the FilterDescriptor class.
    This class basically represents an opened file (or
    r other open streams) in either an inputstream OR
    outputstream. So when you close the outputstream.
    The file is not open anymore and thus the
    e FileDescriptor object is no longer valid because it
    represents and open stream.
    I didn't have to read the API docs because to me that seemed like common sense: if I have an object that represents a connection to a file, and I close the connection, it makes sense to me that the object would no longer be valid. Therefore, I didn't use close() in my program.
    As far as avoiding lots of try blocks, why not wrap
    the whole program in a try block? I assume you're
    using all those System.out.println commands to help
    debug. It'd be more helpful if you called
    printStackTrace on the thrown exception when an error
    occurs.
    Ok, thanks.
    I've done some more tests, and the problem isn't specific to serialization. I'm also unable to use a FileDescriptor when reading a char from a file. I get the same "access denied" error:
    import java.io.*;
    class  DemoFileDescriptor
        public static void main(String[] args)
            //Create a file:
            File myfile = new File("C:\\TestData\\javaIO.txt");
            try
                myfile.createNewFile(); 
            catch(IOException exc)
                System.out.println(exc);
                System.out.println("io exception createNewFile()");
            //Create a FileInputStream:
            FileOutputStream out = null;
            try
                out = new FileOutputStream(myfile);
            catch(FileNotFoundException exc)
                System.out.println(exc);
                System.out.println("error creating FileOutputStream");
            //Get the FileDescriptor:
            FileDescriptor fd = null;
            try
                fd = out.getFD(); //a file connection
            catch(IOException exc)
                System.out.println(exc);
                System.out.println("trouble getting FileDescriptor");
            //Output something to the file:
            char ch = 'a';
            try
                out.write((int) ch);
            catch(IOException exc)
                System.out.println(exc);
                System.out.println("io error writing to file");
            //Create a FileInputStream using the FileDescriptor:
            FileInputStream in = new FileInputStream(fd);
            //Read back from the file:
            char input = ' ';
            try
                input = (char) in.read();  /**ERROR-access denied**/
            catch(IOException exc)
                System.out.println(exc);
                System.out.println("problem reading");
                exc.printStackTrace();
            System.out.println(input);
    } Here is the output and stack trace:
    ---------- java ----------
    java.io.IOException: Access is denied
    problem reading
    java.io.IOException: Access is denied
         at java.io.FileInputStream.read(Native Method)
         at DemoFileDescriptor.main(DemoFileDescriptor.java:69)
    Output completed (2 sec consumed) - Normal Termination

  • Serialization, agents sending objects, possible?

    writing objects to a stream is mostly a straight forward task, but what happens if you don't have a stream to write to? This is a sample code from aglets, but it doesn't work any suggestions ? (Anyone know if I should use Jini instead?) :
    // The class I want to transfer... How can I serialize this class properly?
    public class TransferObject implements java.io.Serializable{
    private String name;
    private int age;
    /** Creates a new instance of TransferObject */
    public TransferObject(String name, int age) {
    this.name = name;
    this.age = age;
    public String getName() {
    return name;
    public int getAge() {
    return age;
    // The mother aglet, that will create a child aglet
    public class MotherAglet extends Aglet{   
    public void run()
    URL codebase;
    try{           
    codebase = new URL("atp://PC06");
         TransferObject tO = new TransferObject("This is transferobject", 1);
         // createing a ChildAglet , sending the tO refernce
    getAgletContext().createAglet(codebase, "ChildAglet", tO);
    }catch(Exception e) {
    System.out.println(e.getMessage() + "Creation went wrong");
    public class ChildAglet extends Aglet{
    public void onCreation(Object init) {
    TransferObject tO = null;
    try{
    tO = (TransferObject)init;
    }catch(Exception e) {           
    System.out.println(tO.getName());
    If I had added the properties of TransferableObject reference in a Vector and re - initiated a new Object at ChildAglet this will work, but it would be easier to just transfer the object directly. Is there a way of doing this ?

    I had a problem with this Aglet.
    import com.ibm.aglet.*;
    import com.ibm.aglet.util.*;
    import com.ibm.agletx.util.SeqPlanItinerary;
    import java.util.* ;
    public class GatherInfo extends Aglet {
    StringBuffer buffer;
    SeqPlanItinerary itinerary;
    public void onCreation(Object ini) {
    itinerary = new SeqPlanItinerary(this);
    itinerary.addPlan("atp://marcus:500/", "getLocalInfo");
    itinerary.addPlan("atp://marcus:501/", "getLocalInfo");
    // return to host and print result
    itinerary.addPlan(getAgletContext().getHostingURL().toString(),"pr
    intResult");
    this.start() ;
    public boolean handleMessage(Message msg) {
    if (msg.sameKind("getLocalInfo")) {
    getLocalInfo(msg);
    return true;
    } else if (msg.sameKind("printResult")) {
    System.out.println(buffer);
    return true;
    return false;
    public void run() {
    System.out.println("Hello, just visiting...") ;
    public void oncemore() {
    try {
    itinerary.startTrip();
    } catch (Exception ex) {
    ex.printStackTrace();
    public void start() {
    buffer = new StringBuffer();
    oncemore();
    public void getLocalInfo(Message msg) {
    AgletContext ac = getAgletContext();
    setText("Here I am about to gather info, and waiting ...") ;
    // waitMessage(2 * 1000);
    buffer.append("I've been to " + ac.getHostingURL().toString() +
    "\n") ;
    buffer.append(new LocalInfo().getAll()) ;
    buffer.append("\n") ;
    When execute this code show me the next error
    java.io.exception: FileNotFound c:\aglets-2.02\public\[Ljava\lang\objec; .class
    I need help, what is this?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Maybe you are looking for

  • Programming Java 4 a cellphone

    Does anyone know what programing language and compiler to use to write a program that will work on a cellphone. I have a cellphone that has a motorcycle game that was supposedly "powered by java". If I write the program in Java what should I use to c

  • Content Player / Policy Configuration component login modules

    Problem using Content Player u2013 HTTP 401 errors, not authorized Because of security concerns, we have modified our login Policy Configuration component, u201Cticketu201D to no longer use the login module u201CBasicPasswordLoginModuleu201D. We use

  • Windows Server 2012 very slow performance executing files

    Hello, I am running windows server 2012 as dc with 2 clients connected running win7 pro x64, this is a new setup. Whenever i try to open a large file from the client or an application from the client it takes forever to startup or to load. The perfor

  • Imovie 9.0.7 keeps crashing. Can anyone help?

    I have tried three times to open imovie. It starts to process and crashes before it's done.

  • I can´t update firefox in my MacBook

    I have been having many problems trying to update Firefox in my MacBook. Finally I tried to re-load it, but when I drag the icon into the apps folder it keeps telling me: No se puede completar la operación porque no dispone de permiso para acceder a