• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

NX: Contractors Multi Data Instances Per File

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All
I have just finished my assignment, and about to upload.
However, I have been reading a few threads regarding the number of instances of Data created by the database server for a particular file. It seems that the consensus is to create one instance of Data per data file. I seem to remember Andrew saying that he created multiple instances of Data, but now regrets this. So, it seems that this approach will not lose points (or at least not very many!), but is not the best one to adopt. So, on to my solution........
I create an instance of Data per connection, regardless of the file (hence my concern and this post!). The main reason was that reads and searches would not block as they have their own file channel. I do have a very simple mechanism to synchronize updates/deletes/inserts to ensure no primary key violations (in addition to normal record locking). Everything seems to work fine......
Should I stick with the above? Its not a question of losing/gaining a couple of points here and there (though it would be nice to pass!), but going forward I want to make sure I adopt best possible practises. Plus, I dont think it would take very long to change my solution to one instance per file.
Many Thanks
Jamie
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jamie
Don't read too much into my regrets about having multiple instances of the data class - I was doing a different assignment. Many of my regrets were because I had to change some code supplied by Sun, and I dont believe that was the right thing to do.
I think my questions for the new assignment would be:
  • is there only one class that can write to the the physical file?
  • is the Data class the class that is doing that writing?
    I think it would be better to have only one class that can actually do writing to the file. And I think that there should only be one instance of the class that does the writing per file (By the way, the class that does the writing does not have to be the Data class).
    Just my 2 cents worth.
    Regards, Andrew
  •  
    Jamie Orme
    Greenhorn
    Posts: 22
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by Andrew Monkhouse:
    Hi Jamie
    Don't read too much into my regrets about having multiple instances of the data class - I was doing a different assignment. Many of my regrets were because I had to change some code supplied by Sun, and I dont believe that was the right thing to do.
    I think my questions for the new assignment would be:

  • is there only one class that can write to the the physical file?
  • is the Data class the class that is doing that writing?
    I think it would be better to have only one class that can actually do writing to the file. And I think that there should only be one instance of the class that does the writing per file (By the way, the class that does the writing does not have to be the Data class).
    Just my 2 cents worth.
    Regards, Andrew



  • Hi Andrew
    Thanks for your reply.
    My Data class does write to the data file, using NIO. Although each client will get its own copy of Data for a particular file (so it can read/search records without blocking), only one instance of Data for that file can write to it any any one time.
    Regards
    Jamie
     
    Consider Paul's rocket mass heater.
    reply
      Bookmark Topic Watch Topic
    • New Topic