harcharan kanwal

Ranch Hand
+ Follow
since Jul 02, 2001
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by harcharan kanwal

Hi all,
yeh, Mike ,they should take some time out and let you know why you lost points, it helps candidates to improve their skills
hi sri,
i worked on two design choices
1.I created an remote Interface ,which is implemented by Data class (acts as a server for both local and remote connection) and DataClient class on the client side.
2.I designed a remote Interface, which is implemented by Data class(acts as a sever for the local connection), implemented by a separated class (acts as remote object implementation of this remote interface),and implemented by DataClient class on the client side.
i choose the second design, remote object implementation of this remote interface is a unique instance for a every new client.This implementation instantiated single object of LockManager class(handles locking) and acts as a adapter for single object of Data class.
hope this helps you,you should try to make other design choices as you think, this helps you writing down your essay exam.keep reading this forum.
good luck!
17 years ago
hi all,
thanks to all, thanks to Mike Spritzler and Michael Morris for helping me.
Following are the details
The maximum possible score is 155;
the minimum to pass is 124.
General Considerations (maximum = 58): 45
Documentation (maximum = 20): 20
GUI (maximum = 24): 18
Server (maximum = 53): 51
Should i mail them to find out why so many points were lost in general considerations and gui
thanks,
harcharan
[ December 18, 2002: Message edited by: harcharan kanwal ]
17 years ago
hi HS,

The NullPointerException is raised on the internals of RMI getting to the TreeSet of airports


somewhere above in the TreeSet, you are trying to get a object which is not there in the tree set and you are operating on this null object.put a try and catch around this tree set code and throw a printStackTrace on the server side,hope this solve your problem
harcharan
hi
chech this post ,he is there,email him
https://coderanch.com/t/182282/java-developer-SCJD/certification/Fundamental-Locking
i guess, may be you are looking for the used one
[ November 01, 2002: Message edited by: harcharan kanwal ]
hi

I cannot understand how the following constructor in the posted code work, could someone explain? Thanks
/////////////////////////////////
public FlightInfoTableModel()
throws DatabaseException,RemoteException{
fieldInfo = fbnModel.getFieldInfo();
}


i should have mentioned it.FlightInfoTableModel class is the inner class of FlightInfoPanel ,which is a JPanel class, has fbnModel reference to FBNModel (later i changed this ref. to the DataClient object)is passed as parameter in its constructor body ( FlightInfoPanel)and assigned to the class variable of this enclosing object(FlightInfoPanel),so that fbnModel ref can be useful for the rest of this enclosing object(FlightInfoPanel).
hope this clears things
harcharan
[ October 26, 2002: Message edited by: harcharan kanwal ]
Thanks for Reply Mark,i am coming back to this post little late

Do all databases have a bookFlights method? no they do have a save, but it is generic. bookFlights is more specific to this application so it needs to be in a place that is specific. Like your DataAccessFacade, basically the "middle tier" business logic layer. It is not part of the GUI or the Data, so it is the business logic.


yes,your comments makes sense to me.I am adding bookFlight methos to my DataClient class,which implements all the public methos of the Data.java and supports the local and remote connection, and it has other application and gui specific methods in it.I think this will work.your comments

What I mean by last object to synchronize, I am talking about the HashMap, in the lock or unlock methods, not in modify.[/QUOTE

The following is my LockManager class

Lock manager class get instantiated in the Data class,and lock and unlock methods are implemented as it is in the topmost post of this thread.

i have the following confusion
what is multiple clients access
1.is it when i synchronized the bookFlight method , and allow only one client at a time to enter to lock ,read ,modify and unlock operation.but then i think where is the need for to lock the record ,when i am not allowing another client to even enter the method body of bookFlight.
2.if i do not synchronized on the bookFlight at the method level, then i am allowing multiple clients to enter the in the methods,but then with each client enterance ,it brings in different values of clientID,numberOfSeatsToBeBooked,recordNumber.This will cause the corruption of the data or deadLock,no matter what part of the method is synchronized.
The only thing that works right now is the solution number 1 i.e synchronized at the method level,but then to me it does not seems like multiclient opertion or it is.
put some light on it, i am stuck thinking of it.
thanks
harcharan

Where is your bookFlights method. It should not be in your Data class


it is in Data.java.i think of it as a basic database operation that a client like to perform in this applicaion.

And you only wnat to synchronize on the last object possible to keep deadlocks from happening


what exactly do you mean by last possible object,is it modify(),if it is , then in the second choice that i mentioned one post above will get multiple clients , and they all will carry different values of the parameters of this method and cause the deadlock situation

In our FBN case that is the Collection that holds the list of the locked records, and when you synchronize on that it keeps it for a short time, either through completion or Thread.wait().


yes, i have implemented hashMap to hold key value pair of recordNumber and clientID hashMap .
thanks mark
harcharan
[ October 22, 2002: Message edited by: harcharan kanwal ]
hi all,
i have read lot of posts on lock and unlock
my question is still at large,
1.As long as bookFlight methos is synchronized at the method level,only one client can enter the method and does its work and leave,there is no need to even have a lock at the lock manager.
2.If bookFlight mehod is not synchronized,you allow multiple clients to enter in the method,they all will have different values of
recordNumber
numberOfSeatsToBeBooked
clientID
So the second approach will not work,no matter if you synchronized on lockManager or synchronize on any part of the code of this mehtod (synchronize on the part of the code is not recomended)

please respond.
correct me what i am missing. need to know ,if there is any hidden role of lock and unlock methods
thanks,
harcharan
[ October 22, 2002: Message edited by: harcharan kanwal ]
thanks guys,
recordNumber
noOfSeats
clientID
i think all above three are required in the server to perform bookflight operation and locking a record to per client connection.could you please elaborate more on your suggestion of having client code on the server side.i can change the Random object to some int object for the clientID.please respond
thanks
[ October 21, 2002: Message edited by: harcharan kanwal ]
[ October 22, 2002: Message edited by: harcharan kanwal ]
HI all,
This is my current bookflight method in my Data.java
public synchronized boolean bookFlight(int recordNumber,Object clientID,int seatsToBeBooked){
this.clientID = clientID;

lock(recordNumber);
seek(recordNumber);
read();
modify(dataInfo);
unlock(recordNumber);
if success return true else return false;
}
This is my lock() in Data.java

public void lock(int recordNumber){
synchronized(lockManager){
lockMagager.lock(recordNumber,clientID);
}
}

public void unlock(int recordNumber){
synchronized(lockManager){
lockManager.unlock(recordNumber,clientID);
}
}

I LockManager class is implemented also.
The above code works great to handle multiple clients trying to book seats in one flight.Even if i am not synchronizing on lock manager object, since the bookflight method is synchronized and allows only one client at a time to do lock,read,modify,unlock operation, we have no danger of second client even get into the book flight method,until the first finishes up its work and release the lock.i understand that according to the requirements ,lock and unlock
has to be implemented,i am trying to figure out their exact usage for this application,because with the above approach,only one client operates in this method, there is no need to lock and unlock the record in the above code.i am missing some thing here, need some comments.
thanks
harcharan
[ October 21, 2002: Message edited by: harcharan kanwal ]
[ October 21, 2002: Message edited by: harcharan kanwal ]
[ October 22, 2002: Message edited by: harcharan kanwal ]
hi
i read in the rmi forum at java.sun.com that registry will be holding the reference to a client and acting as a client,eventhough the client is crashed.may be we have to run the registry in the separate console window and shut this console window running registry and the one running the client, to invoke the unreferenced method.need to do more research on it
http://forum.java.sun.com/thread.jsp?forum=58&thread=172926
hi pervej,
i think you are adding the Jpanel into the contentPane of your JFrame,make sure you remove the old search reference of your Jpanel from the contentpane,before you add new search reference of JPanel to the contentpane of this JFrame.
hope this helps
harcharan
hi prathiban
this should work for you
dialog.setLocationRelativeTo(frame);
harcharan
hi torgny,
i have this line in my server class to create the registry
LocateRegistry.createRegistry(this.port_no);
i am binding this server object to the registry without having implemented the security manager and with security manager both.

harcharan
hi,
did you install security manager both on client and server side along with the policy file,i think i had this problem , i found out that you have to install your security manager both on the server and client side.
hope this solve the problem
harcharan