locked
Concurrent Network Resource Access RRS feed

  • Question

  • Hi all,

    I was hoping someone could help me figure this problem out. Here's the issue:

    I recently wrote an app for searching a database, printing off results, changing results in that database, etc. The app is located on a shared network folder, and everyone who uses the app runs it from that shared folder. I've now been asked to keep a central log file in that shared folder that keeps track of statistics like number and frequency of database queries, number of results found, time the search took, etc. If I was dealing iwth a multi-threaded program I'd know how to solve this, but since we're dealing with a resource shared between different processes on different systems across a network, I'm un sure on the proper way to safely maintain that central log file.

    At first I thought maybe checking to see if the log file was open already by trying to access it and seeing if an exception was thrown, and keep looping until an exception isn't thrown would be the way to do this, but I really don't like that solution. Add to that the fact that there will be many reads and writes to the log file, it becomes unappealing as a solution due to hang/waiting times.

     Then maybe I thought an easy way to reduce the number of times a given session accesses a log would be to keep a record of the session of the local computer, but when the user closes the program, have the program run an "exit procesure" where it accesses the central log file and dumps in the information on the local file. This would be the same as the first approach but becuase theres less attemtps to access the central log, should reduce the hangs caused by waiting for the file to be available. However, if the user exits irregularly or something similar, all the log information will be lost.

     I've thought up other ways of doing it, like keeping a seperate log each time someone starts the program (named based on the time/date and who's accessing it) and then compiling these session log sinto a central log.

    I was just wondering if anyone had suggestions on the proper way to deal with a problem like this is. If I'm on the right track, or totally off base.

    Thanks in advance

    Wednesday, October 7, 2009 4:58 PM

Answers

  • Don't take this wrong, but why play database? Keep such a log in a database table and let the db worry about concurrent access.

    William Wegerson (www.OmegaCoder.Com)
    • Marked as answer by Harry Zhu Tuesday, October 20, 2009 9:55 AM
    Thursday, October 15, 2009 12:32 PM