Arun Subramanian

Ranch Hand
+ Follow
since Oct 30, 2002
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Arun Subramanian

Greetings -

I am executing the EJB 3 in Action examples under a Eclipse 3.3.2/ Weblogic 10.0 / Pointbase 5.1 environment.

In my ShippingRequestProcessor MDB, if I retrieve a DB connection in the , my MDB consumes the message fine for the first time but for subsequent runs, throws the following Exception:



If I move the getConnection call to the actual business method (), everything works fine but then I am getting and closing DB connections for every invocation.

Seems like the connection can't be re-used once a message is inserted into the DB. Can someone please explain the scope of the connection and it's transaction context.

Regards,
Arun.
Greetings ranchers-

After a long hiatus, I decided to take up this certification and prepared for a month approx. The exam (taken today), given the preparation outlined below, was fairly straight-forward. Just was surprised by a couple of picky API questions and a couple of ambiguous ones (per me).

My study recipe:

  • Read HFSJ (first edition) twice
  • Read Manning's SCWCD Exam Study Kit (second edition) once - great for some of the finer points wrt tag file directives, tag dynamic attributes
  • Cross-linked w/ the J2EE, JSTL, J2SE APIs whenever in doubt
  • HFSJ first edition mock exam one day before the test (scored 78% on the mock).


  • Regards,
    Arun

    [ May 31, 2008: Message edited by: Arun Subramanian ]
    [ May 31, 2008: Message edited by: Arun Subramanian ]
    16 years ago


    Caching is fine but you may need to persist the data in filesystem at regular intervals(?)
    Note:According to the specs 'the data must continue to be manipulated for reports using another custom-written application


    My bad in probably not explaining it well. I try to keep the file and the cache in sync. I should have said:
  • Data's read method reads "only" from the cache while update, delete and create methods update the file and then update the cache. In other words, of the CRUD operations, R is a cache only operation while C, U and D first modify the file and then sync the cache.


  • Thanks.
    Howdy all -
    After a very long hiatus, I have started working on my assignment once more. Please comment on my BS design and code reached thus far on Data, CacheManager and RecordNotFoundException. I would really like to hear if any others have similar approaches for preloading cache etc. To give context to some of the code snippets below, a brief description of some relevant components is in order:
  • Each client gets its own Data object.
  • There's a LockManager singleton and a CacheManager singleton in the JVM.
  • The CacheManager's collection object (map) will be preloaded by the first data instance that gets to it. CacheManager's cache collection caches all the records available in the db file.
  • Data's read method reads "only" from the cache while update, delete and create methods update the cache.
  • RecordNotFoundException is thrown when a record doesn't exist in the cache or is a deleted record.
  • The readRecordFromCache method is synchronized while isRecordInCache is not.
  • The Record class encapsulates the data in the record and whether it's an active record.



  • Thank you for your time.

    Thanks,
    Arun.

    [ March 23, 2006: Message edited by: Arun Subramanian ]
    [ March 24, 2006: Message edited by: Arun Subramanian ]
    And here's a good explanation of the addShutDownHook() usage by Andrew...
    Hi Matt-

    I've just implemented a RAF Pool.


    Glad to see you doing the RAF pool as well...

    Right now, I have the RAF pool code (methods) in my RMIFactory class and the closeDescriptors() method that closes the RAFs inside the finalize() of the RMIFactory. Later on, I might also have this (and probably any other cleanup code) inside a Thread class that would be passed as an argument to the Runtime.getRuntime().addShutdownHook(Thread hook) method.

    I've implemented a read/write lock on the file level.


    Can you share your physical and logical locking strategies with some code (pseudocode?). I have run against a wall wrt addressing physical locking as now, in our design, each client can operate with it's own RAF and it's own Data instance.

    Thanks,
    Arun.
    Greetings all-
    I am thinking of using a RAF pool for the database I/O operations. I am modelling the RAF pool on the more common JDBC connection pool. In this design, since each networked client will get its own RAF instance besides its own Data instance, I am unsure whether there needs to be any physical locking for the Data CRUD methods. Will logical locking be the solution for all my Data access methods as well as my Business methods?

    Any inputs would be much appreciated.

    Thanks,
    Arun.
    Hi Paul-
    Based on the suggestions by Conan, Frans in this thread and also the observation from other threads in this forum that this indeed is a very popular design, I have changed my design to hand off each client their own RemoteObject. I specially need to do this because my locking methods don't have a provision for a "client ID" parameter in the parameter list.

    When you say a RemoteObject and DataAccessObject for each client is that a newly registered and binded object for each client then?


    No, you register and bind only 1 object or service w/ the RMI registry i.e. the RMIFactory object. The RMIFactory has a method that the clients call and which returns the RemoteObject (In this method, I create the RemoteObject and I return an interface to the client that the RemoteObject implements. Fyi, in my design, the LocalObject which is returned in the stand alone mode also implements the same interface so that client call to return the local/remote object is generic irrespective of the mode). So, the RemoteObject and the RMIFactory both extend UnicastRemoteObject and implement Remote but it's only the RMIFactory that's registered and bound.

    Also, this is a good read...Link to thread w/ the RMI Factory link

    Thanks,
    Arun.
    Hi Cleverson-

    Therefore I gave up the syncronizing on RAF solution and now I'm starting to think in providing a Data instance to each client. This will certainly solve the multiple RAF accesses problem as each client will have its own Data instance and so a file pointer.


    This might not be a feasible solution for large number of clients (leading to large number of RAF instances) because of the OS limits on file descriptors and which has been mentioned atleast a few times in this forum.

    Is it possible to provide a new remote object (RemoteServicesImpl ) to each client? Or all clients are handled by the same object? How can I provide one Data object to each Client?


    You might want to use an RMIFactory that you register w/ the RMI registry and which in turn hands off the RemoteObject (and the DataAccessObject) on a per client basis. The following link which has been passed around quite a bit gives a nice description of the Factory Pattern as it would apply to RMI.
    RMI Factory Pattern

    Thanks,
    Arun.

    3. To provide one of two additional method in the DataAdaptor: getRecordCount() or getAllRecords()
    But i am not sure if it is right.



    I am using a "getRecordCount()" approach which is defined in my implementation of the SUN provided Data Interface. This gives my TableModel the number of rows for initial display. I also have a "getSchemaDescription()" method (again defined in the same above implementation) for storing the database file schema information and which gives my TableModel the number of columns for initial display.

    Thanks,
    Arun.

    To summarize: You have one remote object that is a factory, one instance of some file access class that is on the server side and which does not implement Remote, and for each client there is one other remote object obtained by the remote factory.



    Thanks, Conan. So, if I understood you correctly, the above design entails each client having it's own RemoteObject and it's own DataAccessObject? Hmmm...that would be a reasonably big change in my design considering I would now have to think about how it affects my Data methods (which are currently synchronized), LockManager etc. In my current design, on the RMI Server JVM, I only have 1 instance of the RemoteObject thereby 1 instance of Data and thereby 1 instance of the LockManager (RemoteObject has Data as a private field and Data has LockManager as a private field). I would still be interested in knowing if anyone implemented a similar design as mine and were able to identify the clients uniquely given the lock methods w/ only 1 argument.


    Note that when an object returned by a Remote object implements Remote itself it is not serialized back to the client: It becomes a remote object on the server side. Use a remote factory that creates the remote objects to access the database.



    I think I understood this. The unique RemoteObject for each client returned by the RemoteFactory call that the client makes still sits very much on the RMI Server JVM but a stub to that RemoteObject is returned to the client JVM. Right?

    Fyi, right now, I do have an RemoteFactory that's registered w/ the RMI Registry. But instead of returning the RemoteObject when the clients call the RemoteFactory method "getInterface()", I return a serializable Proxy object to the client. Each Proxy object has a reference to the one single instance of the RemoteObject. Each Proxy object also has a copy of the database file schema of the database file on the RMI Server and so a client doesn't have to do a network operation if it's interested in knowing the schema description. So, in my design, the clients invoke the methods on their Proxy objects which in turn invoke the methods on that 1 RemoteObject on the RMI Server.


    Thanks,
    Arun.

    What is the method signature of your lock and unlock methods in the interface provided by Sun? I ask because there are two different strategies, depending on whether or not your interface uses lock cookies...



    Good question, Paul. Sorry, I should have mentioned that in my initial post itself. I have a single argument viz. "record number" and hence no place for a "client ID" in my lock methods.



    Thanks,
    Arun.
    Greetings all-
    I have a single instance of Data being shared by all the networked clients. (I have a Proxy object that is unique to each client and exists on the client JVM and each proxy holds a reference to the same single RemoteObject which in turn has the Data instance). What would be a good way to identify the clients uniquely (client JVMs uniquely) on the RMI server JVM for my locking operations.

    I could use java.rmi.server.RemoteServer.getClientHost() on the RMI server JVM but then I would have to specify in my choices.txt that 2 clients cannot be launched as network clients from the same machine.

    Alternatively, I am thinking about callbacks but am a little stuck. I can quite easily send a generealized update to all the clients using callbacks by registering each client with the RMI server. But then using callbacks, how do I execute a method on a specific client to get the client's unique information if that client is executing the lock method.

    Any help/advice would be appreciated.

    Thanks,
    Arun.
    Terry-
    Super job

    I was also in the same shoes as you wrt no prior real-world EJB experience. That does make the SCBCD journey quite interesting.

    Arun.
    20 years ago
    Greetings fellow ranchers-
    Real pleased to let everyone know the result. My study recipe:
  • read HF EJB 2 times - my foundation
  • read the DD portion in Valentin's cheat sheets - great for revision
  • used softSCBCD mock simulator - worth every penny
  • used ejbcertificate web site - some great questions
  • followed fellow ranchers' success stories and their observations/experiences - priceless


  • I will most probably head into the SCJD arena where the brain trust is amazing.

    Regards,
    Arun
    [ September 07, 2004: Message edited by: Arun Subramanian ]
    20 years ago