martin naughton

Ranch Hand
+ Follow
since Sep 09, 2009
Merit badge: grant badges
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by martin naughton

Hey sorry,
To reply to this was on my todo list.

All the details of what i did in the project can be found here. hopefully this helps some one else.

https://coderanch.com/t/519208/java-developer-SCJD/certification/project-detailes-here-Waiting-exam

Some question i had. Was not sure about them but they got answered and helped me out. thanks


thanks a million for the helps guys. Will see if i can help other people on the forum with the project.

Would of taken longer to do it with out you guys
14 years ago
I just got this email today. I sent in my assignment on the 13/12/10. They were pretty fast

The only thing is I do not know where to check my score. Like what what score I got out of 400. They say you just get a passing score but everyone on the forum that did the exam seems to know what points they got.

When i submitted my exam i had to do it through email. The reason was that when i signed up for the exam oracle was changing stuff in sun.

So i think i definitely passed. just not being able to see my score is putting me in doubt

Hi Martin,
Congratulations! You have passed the Oracle Certified Master, Java SE6 Developer certification. You are among the elite 1% of certified Java professionals who have gone on to achieve the Oracle Certified Master, Java SE6 Developer certification.

Your certificate package is being processed for shipping. Look for a certificate in the mail in approximately 4 to 6 weeks. You can publish official certification records from our certification portal at http://www.certmanager.net/sun

You have received a passing score. Passing grades do not receive a score, just the pass. A failing grade will receive section level scoring so that a candidate may isolate the area of failure and resubmit their assignment. Numeric scores are only provided on failures.

Thank you for all your efforts with this certification, and good luck in your future endeavors with Java.

Please let us know if we may provide further assistance.

Regards,
OCP Team


14 years ago
that is what my exact confusion was. i thought the queue and pool were seperate.

thanks alot for clearing that up for me.

At least now the shutdown() method will exectue everyting in the queue. makes my implementation simpler. thanks alot and i hope this clears it up for anyone else.
Hey henry,
thanks for clearing that up.





Yes. Previous submitted tasks are tasks submitted into the pool prior to the shutdown call. And they will be executed before the pool threads terminates.


So that means then that any thing in the queue is discarded. Understand

This method simply waits for termination -- whether termination occurs after the queue is drained or not depends on whether you requested an orderly shutdown or not.


this confuses me from what you said above. shutdown() is an orderly shutdown. it sounds like if do an request for an orderly shutdown through shutdown() that awaitTermination will wait until the queue is drained then terminate the executor? so it sounds like from your quote above that shutdown() will finish all tasks in the pool but then awaitTermination will say "hey shutdown do not terminate until everything in the queue is finished". correct?

an example would help

There are 10 tasks in the queue and 5 tasks in the thread pool. then shutdown() is called. then awaitTermination method is called. the 5 tasks in pool will be let finished and the code will wait at the awaitTermination line until all 5 tasks are finished then the executor will be terminated. so the 10 tasks in the queue will be discarded and never run. correct?

if this is so then i would have to do some thing like this




thanks for your help

Also serached the internet this morning for understanding the api. This post came up first in google. that was fast
http://www.google.ie/#hl=en&biw=1600&bih=990&q=threadpoolexecutor+shutdown+when+queue+is+empty&aq=f&aqi=&aql=&oq=&gs_rfai=&fp=ff8be12b9b06f6de
Hello Guys,
I am changing over some code to use the concurrent api in java. at the moment it is using this Pooledexecutor. I want to use ThreadPoolExecutor

http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/PooledExecutor.html

One bit i like about it is the the method below. it will only shutdown when every thing is processed in the queue.

http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/PooledExecutor.html#shutdownAfterProcessingCurrentlyQueuedTasks%28%29

I was trying to look for the equvalent in the java concurrent API. I was looking at the shutdown method below.

java.util.concurrent.ThreadPoolExecutor

public void shutdown()

Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted. Invocation has no additional effect if already shut down.



I have searched all over the internet. I trying to understand by what they mean by "submitted task". Is it when all the task in pool will be finished and everything in the queue will be discarded or is it everything submitted in the queue will be finished including what is in the queue at the time the shutdown command is given?

Also await seems to only wait until all the tasks that were in the pool are finished. it does not care if any tasks are in the queue.

public boolean awaitTermination(long timeout,
TimeUnit unit)
throws InterruptedException

Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first.

Does the threadpoolexecutor api support waiting for queue to be empty before shutting down? or do you have to implement a wait for the queue to be empty before calling shutdown yourself.

I do not mind implementing my own wait just that i want to understand the api completely. i would probably do a while statement waiting for the queue to be empty.

thanks for you help.
Hey Steeve,
Thanks for getting back to me. The database does not provide a way to set a time out. It is a proprietary database that is not that good. I had look at the API and does not give a time out for queries which is kind of stupid.

I will probably have to throw an exception from the timer thread and do a interrupt.

thanks for your help.
Hello Guys,
I am using the threadPoolExecutor class from the java api to handle all my threads. At the moment i have 5 threads that can exist in the thread pool. My threads are all doing the same task. They are doing a requests to the database and they wait for a reply. Some times the database does not reply for some time. This means these threads get stuck in the thread pool waiting.

I was wondering was there any way to set a time out on threads in the thread pool. so if a thread is running for more than half an hour then the thread pool will kill it and process the next thread in the queue. I do not

At the moment the threads inside the thread pool have their own timer task that writes to a log saying the thread is taking more than 30 minutes. I am trying to think of a way of killing off threads that take this long.

java.util.concurrent.ThreadPoolExecutor
http://download.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/ThreadPoolExecutor.html

You are probably thinking why do you not look at the database side. I want to implement this timeout as a precaution if the database does not reply.

thanks for you time.
thanks Roel. I was trying to find a way of doing bullet points because i thought it would be nicer.

Many thanks to you. it would of taking me a long time to figure out if features were needed or not with out your help.

I will be checking over the project until then. never can be too perfect.
Here is a few things i did in my project. URLybird hotels. This might gives some people some ideas on what they might do for their project.

I am waiting to do the exam and submit my project yet.

  • I used static maps to keep a track of the locked records
  • I disabled multiple row highlighting in the Jtable to stop confusion
  • When the server shuts down i did not implement the unbind of the rmi name from the registry. When the process is killed it should be removed by default
  • I made my own object to represent a record. this was easier than using string arrays and easier to maintain.
  • Instead of having if statements all around the GUi to try and figure out if was a remote connection or location i had one interface that handle that for me. then 2 class implmented this interface for remote and local operations. easier to maintain.
  • I did not add any method to the provided interface. If you are adding to that interface then you are adding features to the applications that they did not ask for.
  • I broke the data class into a facade of DataAccess and DataLock to make it easier to keep the classes small.
  • I did not publish private methods or private variables in the javadoc. but in the code they are commented.
  • I made the Data class a singleton. that made sure that only one connection to the database.
  • I implemented my own TabelModel because i want the Jtable to deal with my record class.
  • If 2 network guis were started and one gui updated the database then the other gui would not see that. To stop unknown over writing i i would read from the database first before updating.
  • I implemented the serializble variable in all my classes even though i was not using them in that way.
  • No warning or errors in my project.
  • Turned off all logging
  • Only have joptionpane appear with the error to the user
  • Have a trouble message section in my user guide
  • I have a tracker class that keeps track of all the valid and invalid records. also give me a new record number.
  • If i send all null values to my find it sends all the valid records back to me.
  • i have exact matching in my gui. case sensitive.
  • I reuse delete records and locations
  • When the server shuts down it waits until all the locks map is empty before shutting down. the stand alone client does this aswell.
  • I validate the ip address port numbers. I also make sure the file exists before continuing with the standalone client or server
  • If the server shuts down and the client is still running. the next action the user does an error pane will appear saying it lost connection to server.
  • I have a trouble message section in my userguide.
  • All 5 operations on the database side are sychronized
  • I did not implement unbinding of the rmi service name
  • I did not implement the 48 hour rule
  • I implemented thin client
  • I added in the unbook feature
  • I extended the interface they gave me to add extra operations.
  • 8.5K userguide.txt
  • 19K choices.txt


  • Will post up anything else i can thing of i did. Hope this is enough to pass and also the application works.

    Martin
    I just found out that i could not submit the assignment until i did the exam. thought it would be the other way around. submit the assignment then do the exam. my mistake. Well it gives me another week to work on this thing Nothing can ever be perfect.

    Roel: Did you ever find out the answer to your question here: https://coderanch.com/t/428093/java-developer-SCJD/certification/DBMain-extend-or-change#1899916

    I had to use an extra interface because i wanted to close the connection to the database file. I made interface DBOpertations that extends DBMain so it is a DBMain.

    public interface DBOpertations extends DBMain

    public class Data implements DBMain, DBOpertations {

    so now i use DBOpertations as my interface because it has the funtionaility of DB Main and a method to shutdown the database file.

    I am sure this is ok.
    One more thing came to mind. I am not serializing anything in my implementation but the only warnings i have in my workspace are these. Do i need to make these classes serializable even thought i do intend in using them that way. maybe just use the default value eclipse gives me?

    Description Resource Path Location Type
    The serializable class ClientDatabaseOperationsImpl does not declare a static final serialVersionUID field of type long ClientDatabaseOperationsImpl.java /DatabaseTest/src/suncertify/client line 20 Java Problem
    The serializable class DataBaseConnectionFactoryImpl does not declare a static final serialVersionUID field of type long DataBaseConnectionFactoryImpl.java /DatabaseTest/src/suncertify/remote line 19 Java Problem
    The serializable class DuplicateKeyException does not declare a static final serialVersionUID field of type long DuplicateKeyException.java /DatabaseTest/src/suncertify/db line 9 Java Problem
    The serializable class JTextFieldLimitDigits does not declare a static final serialVersionUID field of type long JTextFieldLimitDigits.java /DatabaseTest/src/suncertify/common line 13 Java Problem
    The serializable class MagicCookieException does not declare a static final serialVersionUID field of type long MagicCookieException.java /DatabaseTest/src/suncertify/db line 10 Java Problem
    The serializable class RecordNotFoundException does not declare a static final serialVersionUID field of type long RecordNotFoundException.java /DatabaseTest/src/suncertify/db line 10 Java Problem
    The serializable class TableModel does not declare a static final serialVersionUID field of type long TableModel.java /DatabaseTest/src/suncertify/client line 13 Java Problem


    I changed you build script a bit to work but now it is working. thanks a million. would you accept any enhancements on the script?
    hey Matt Lobo,
    In my implementation i have a map that keeps track of what is locked. before i lock a record i check that it exists. if it doesnt then throw a exception.

    For unlock then i check that the record exists in the lock map. it it does not exist then i throw a record not found. This is incase some how some other another thread removed it from the map. This is a great way to know if your locking works. you should never get unlock exception. if you do then the implementation does not work. happened to me.


    Regards
    martin

    Roel De Nijs wrote:1/ That's confusing me. You have to restart an application to see a booked entry What about refreshing the data doing a search? My gui is also not updated when another gui has made a change to the database file (e.g. a booking), but if this gui executes a new search, the booking will be visible



    Yes when a user does a search it will come up in the results. just the GUI is not updating every second i mean. So that is ok.

    Roel De Nijs wrote:2/ It's not implicitly required to first end all operations before closing down the server, but you have to make sure your server is not shut down in the middle of a write operation (might result in a corrupted database file)


    I implemented this very easy. i used the static map i had for the locks and checked if that was empty before shutting down.

    Roel De Nijs wrote:3/ I kept the logging I used during development in my code, but disabled all logging. I justified this decision in my choices.txt: these logging statements can be simply turned on and can be used by debugging the application when a bug is found or a new requirement is implemented


    i implemented the log now.should of done it from the start instead of doing system.out. thanks

    Thanks a million Roel. Probably submit it tomorrow or tuesday. just have tidy up the choices and user guide. also have to fully build everything into one jar and do rmic for the rmi. that should all be doable in one day. thanks

    Hopefully nothing else will come up.
    Also i was going to leave out logging in my application. instead of i have error message popping up if there is problems. this message a user can understand because they are simple. I have documented in my design choices why i left out the logging but their argument might be the junior programmer might find it hard to debug?

    Is this right or wrong?
    thanks again. Nearly finished just little things keep popping up.

    Question 1 scenario
    2 network GUIs are started in network mode then one changes a booking. It will not appear in the other GUI unless they restart the network GUI and then the entry will show. I know it is not a requirement but is it an implicit requirement that the GUI should be updated if changes are done to the file by another gui?

    Question 2 scenario
    I seen in the SCJD book that the server will only close down only if all the operations are completed or there is no more operations. Is this implicitly required?


    thanks. thought i would had it up today but probably be monday. thanks