aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Multiple Instances of Standalone Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Multiple Instances of Standalone" Watch "Multiple Instances of Standalone" New topic
Author

Multiple Instances of Standalone

Ray Dawson
Ranch Hand

Joined: Sep 16, 2011
Posts: 75
I have searched the forums & came up with a similar thread by wei liang liang.
But here I wanted to know that how does the standalone mode exactly works when tackling with real time concurrent requests ?

I'm a total newbie, but as far as I understood

In Standalone Mode,
There is just ONE JVM running. It has 1 server & 1 client application.
The user opens the .jar file which creates the server & the client on the single JVM.
The user can't open multiple instances of the same .jar file as it will create multiple JVM having several instances of Server-Client, which means each client as its own server which I believe is wrong.
So basically the sever tackles at most ONE client request, when running in Standalone mode. Yes definitely the servers updates dynamically when tackling these requests, which are from ONE client only.

In Networking Mode,
There can be multiple instances of the client, but only one server running at a particular place.
So say server running on Computer A in 1 JVM, then client_1 running on Computer A in a separate JVM, then client_2 running on Computer B & client_3 running on Computer C each in its own JVM & so on....
So the server tackles concurrent requests from these individual clients & updates itself accordingly.
Say at
Time 00:00 Client A & Client B are both accessing Record # 5 from the server
Time 00:01 Client B books Record # 5
Time 00:02 Client A tries to book the same Record # 5 but gets an error that this has already been booked
Time 00:03 Client C accesses say Record #9
Time 00:04 Client A accesses say Record #9 & immediately books it
Time 00:05 Client C wants to book the Record #9 but gets an error that this has already been booked
This goes on...


So is this how the whole thing works ?


Locking

Your server must be capable of handling multiple concurrent requests, and as part of this capability, must provide locking functionality as specified in the interface provided above. You may assume that at any moment, at most one program is accessing the database file; therefore your locking system only needs to be concerned with multiple concurrent clients of your server. Any attempt to lock a resource that is already locked should cause the current thread to give up the CPU, consuming no CPU cycles until the desired resource becomes available.


In Network mode, does the server allows multiple client to access same data, but only allows the first one to book that data & update the other clients accordingly
or
is it atmost 1 client which can only access a single data, while anyone trying to access that data cant even see it as the server says some client already is accessing it ?

So which one is first-come-first-serve feature: access or lock ?


Thanks!



P.S
Yet again, due to my lack of knowledge I have another question
How do the client running on a particular JVM specify which DB is it accessing ?
What I have done so far is that I have kept two options for the client when its started i.e. Networking Mode or Standalone Mode
When user clicks Networking Mode he's asked to enter the location of the server ip addr etc.
When user clicks Standalone it asks for db path on the same computer.
I have given a default starting db location for the both i.e Standalone is say samedirectoryasclient\db-3x3.db or in Networking mode localhost\somepath\db-3x3.db
The user can change the paths whenever he wants.

Am I doing something wrong
Sean Keane
Ranch Hand

Joined: Nov 03, 2010
Posts: 581

In standalone mode there is only one client accessing the database. So there is no concurrent requests.

You're description of networking mode sounds good to me.

First person to lock the record gets to carry out whatever operation they want. That's the whole point of locking.

Client running in network mode does not specify any DB file.


SCJP (1.4 | 5.0), OCJP (6.0), OCMJD
Ray Dawson
Ranch Hand

Joined: Sep 16, 2011
Posts: 75
Sean Keane wrote:

Client running in network mode does not specify any DB file.


In the standalone mode, I have given the ability to the user to specify which db to use.

Then shall I hard code the location of the db file for the networking mode ? If so then what should I provide as the permanent server address ?

How do I allow the user to switch between modes ?
Jeff Philp
Greenhorn

Joined: Jun 04, 2011
Posts: 12
There are three modes as described in your instructions for running the application:
  • "alone" - Stand alone mode where the client connects directly to the database
  • "server" - Starts up a Network server which accepts connections from network clients
  • "" (no argument) - Starts up a network client which talks to a network server for database requests.


  • So that is essentially three different configuration screens you have. So in network mode the client needs to parameters required to talk to the server, and the server needs to parameters allowing it to listen for connections, and the physical database it will be using.

    There should be no hard coded database locations, or server addresses. (disclaimer: unless your instructions tell you to)


    Ray Dawson
    Ranch Hand

    Joined: Sep 16, 2011
    Posts: 75
    When you submit your assignment, each part (client and server) must be executable using a command of this exact form:

    java -jar <path_and_filename> [<mode>]

    Your programs must not require use of command line arguments other than the single mode flag, which must be supported. Your programs must not require use of command line property specifications. All configuration must be done via a GUI, and must be persistent between runs of the program. Such configuration information must be stored in a file called suncertify.properties which must be located in the current working directory.

    The mode flag must be either "server", indicating the server program must run, "alone", indicating standalone mode, or left out entirely, in which case the network client and gui must run.

    You must not require manual editing of any files by the examiners.


    How does the sever supposed to take any parameters ?
    The Client is supposed to specify which <mode> does it needs to run on.
    Like,

    if mode is server
    my clientgui starts up & then connects to a default ip & port no., but the user can always change the ip & port no. in the gui which will be saved to the properties file.
    Here the user doesnt specify any db location, so how does the user know which db is it accessing ? I guess each server on a different pc is expected to have a different db thats why we're connecting them though net

    if mode is alone
    my clientgui starts up & then connects to default db location, but the user can always change the db location.

    if mode is not specified i.e. no parameters are passed
    the client starts up the default network location mode is started while notifying the user

    Am I doing wrong ?
    Jeff Philp
    Greenhorn

    Joined: Jun 04, 2011
    Posts: 12
    Maybe a fictional scenario is a good way of explaining this:

    Situation 1:
    There is only one computer in the office which has the database on it, the user is also using that machine.
    In this situation the user would type java -jar [] alone
    and specify on a configuration screen the required settings for accessing the database on the local machine

    Situation 2:
    There are many computers in the office, and 1 server which has the database on it.

    On the server you would type:
    java -jar [] server
    and specify on a configuration screen the required settings

    All the users would type
    java -jar [] (no argument)
    and specify on a configuration screen the required settings

    Hopefully I have not confused you more.

    Ray Dawson
    Ranch Hand

    Joined: Sep 16, 2011
    Posts: 75
    Jeff Philp wrote:Maybe a fictional scenario is a good way of explaining this:

    Situation 1:
    There is only one computer in the office which has the database on it, the user is also using that machine.
    In this situation the user would type java -jar [] alone
    and specify on a configuration screen the required settings for accessing the database on the local machine

    Situation 2:
    There are many computers in the office, and 1 server which has the database on it.

    On the server you would type:
    java -jar [] server
    and specify on a configuration screen the required settings

    All the users would type
    java -jar [] (no argument)
    and specify on a configuration screen the required settings


    java -jar <path_and_filename> [<mode>]
    Here the path_and_filename is say somefolder/runme or is it somefolder/runme/client (or server)
    jar file on its own or specific file inside the jar ??

    Jeff Philp wrote:
    Hopefully I have not confused you more.



    Jeff Philp
    Greenhorn

    Joined: Jun 04, 2011
    Posts: 12
    There is a single jar file which needs to contain both the client and server code. As jar files can only have a single point of entry you need a single main method which can interpret the command line argument and launch the appropriate application.

    At the command line you would be typing

    java -jar runme.jar alone For standalone mode
    java -jar runme.jar For network client mode
    java -jar runme.jar server For the server
    Ray Dawson
    Ranch Hand

    Joined: Sep 16, 2011
    Posts: 75
    Jeff Philp wrote:There is a single jar file which needs to contain both the client and server code. As jar files can only have a single point of entry you need a single main method which can interpret the command line argument and launch the appropriate application.

    At the command line you would be typing

    java -jar runme.jar alone For standalone mode
    java -jar runme.jar For network client mode
    java -jar runme.jar server For the server



    Ray Dawson
    Ranch Hand

    Joined: Sep 16, 2011
    Posts: 75
    I was so confused as to how can I run specific files inside jar, cause I never heard of it before.
    Thank you so much
    Sean Keane
    Ranch Hand

    Joined: Nov 03, 2010
    Posts: 581

    Ray Dawson wrote:
    Sean Keane wrote:

    Client running in network mode does not specify any DB file.


    In the standalone mode, I have given the ability to the user to specify which db to use.

    Then shall I hard code the location of the db file for the networking mode ? If so then what should I provide as the permanent server address ?

    How do I allow the user to switch between modes ?


    I would suggest you read up on what a traditional client-server application entails.

    Your answer here tells me you don't know what this is. I told you that in network mode that the client does not specify any db file. You reply telling us that you will hard code the db file location?

    Being a "newbie" is no excuse for not doing your own research.

    Being a "newbie" is no excuse for not reading your instructions provided by Oracle. They contain all the information that another member provided you with on how to start the application.

    Before doing any further work I would suggest you do the following.

    * Firstly read up on client-server, 2-tier, and 3-tier architecture.
    *Then read the amazing paper written by Roberto that I told you about a good while ago.
    * Then read your instructions provided by Oracle and more importantly make sure that you understand then.

    At the moment it is quite obvious that you have started developing without understanding the instructions and without creating a design.

    That is why you are having so many problems - because you haven't bothered to do the above and instead post on here to get the answers.

    I would suggest that continuing with this approach will annoy people and you may not get the assistance that you want going forward.

    Hopefully my three pieces of advice above will help you help yourself :-)
    Ray Dawson
    Ranch Hand

    Joined: Sep 16, 2011
    Posts: 75
    I'm kind of rushing through the assignment to submit it before 1st oct so that I dont have to pay for the course.

    I never worked with any network based program, simply did core level stuff.

    I'm working on the networking part right now, I hope I can pull-it-off before 1st oct. & as far as things am concerned with right now is the RMI thing in which I have no clue.
    It would be great if you could help me with RMI & how to get started
    Sean Keane
    Ranch Hand

    Joined: Nov 03, 2010
    Posts: 581

    Ray Dawson wrote:I'm kind of rushing through the assignment to submit it before 1st oct so that I dont have to pay for the course.

    I never worked with any network based program, simply did core level stuff.


    I know. I understand. You don't have the skills required for the certification. You don't have the time to learn them. So you want others to do the thinking for you.

    You are missing the point of the certification. Getting the certification should not be your goal. Learning and displaying the skills required to get the certification should be your goal.

    Good luck nonetheless
    Ray Dawson
    Ranch Hand

    Joined: Sep 16, 2011
    Posts: 75
    I agree with you that I'm missing few of the skills required for the certification, but I don't want you guys to be thinking for me, I just need some quick tips on problems am having.

    I dont know how you look at me right now, may be douchbag or something worse. But anyways I'm a high school student who started this certification in his first semester of learning Java.

    Thanks for all the help
    Sean Keane
    Ranch Hand

    Joined: Nov 03, 2010
    Posts: 581

    Ray Dawson wrote:I agree with you that I'm missing few of the skills required for the certification.


    Most people doing this certification would not have all the skills required to complete it when they start it. So that is not a problem. Everyone has to start somewhere

    The key difference is that most other people use this certification as a means of developing those skills and learning areas they have no experience in. You should do the same.

    If you put some effort into researching areas you are unfamiliar with. If you put some effort into searching the forum and using the various resources that people point you at. If you can display this in your posts. Then you are more likely to get a more favourable response.

    Rushing to get this assignment completed before the 1st Oct is no excuse for not doing all of the above. Look at it from someone else's point of view - why would anyone else give their free time to help you get a certification that you aren't willing to put the effort into getting off your own back?


    Ray Dawson
    Ranch Hand

    Joined: Sep 16, 2011
    Posts: 75
    Well I don't know where this thread is heading anyway.

    I generally don't post till the time I feel I feel I have to post it otherwise I wont be able to complete before the deadline. Trust me its because of the 1st oct deadline.
    If I dont complete before that I dont have the money to go through training & thus my cert run ends here


    BTW, I need some help in RMI if you can help me in that please do
    I keep getting this error


    As you said do some research before asking stupid stuff. I did that.
    I gave the ip as my ip addr, localhost, 127.0.0.1 & a couple of ips. And my firewalls is turned off still i get this error.

    Can you help ? Or shall I open a new thread ?
    Sean Keane
    Ranch Hand

    Joined: Nov 03, 2010
    Posts: 581

    Ray Dawson wrote:If I dont complete before that I dont have the money to go through training & thus my cert run ends here


    If you don't put the effort in to read your instructions, to design your solution, and to learn skills\technology required, then you probably won't get a working application before the 1st Oct. Hopefully my advice above will help get you on the right track. Keep at it, you will get to there eventually
    Roel De Nijs
    Bartender

    Joined: Jul 19, 2004
    Posts: 4908
        
      10

    I don't get it the topic of this thread is "multiple instances of standalone", so I'm expecting a question like "what about the application being run concurrently multiple times on the same computer". The answer is easy: can't happen, because that's clearly stated in the instructions. But this complete topic seems to discuss the networked mode and RMI.

    And if you don't have the skills of a client-server application, nor RMI you can maybe start with reading about what's a client-server architecture and following some hands-on tutorial about RMI. You might spend now some extra hours learning these things (although you might think you don't have the time to be able to submit before October 1st), but gain in the end maybe a complete day because you understand everything and don't need to ask questions on this forum (and having to wait for an answer)


    SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
    http://www.javaroe.be/
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Multiple Instances of Standalone
     
    Similar Threads
    Locking Question
    How to process the networking with a local database?
    how to lock or unlock another Processes
    Waiting for my exam...
    Can anyone help me with this?