[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [jgit-dev] JGit thread safety
- From: Dimitar Georgiev <dimitar.georgiev.bg@xxxxxxxxx>
- Date: Fri, 19 Apr 2013 10:28:12 +0300
- Delivered-to: firstname.lastname@example.org
- User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130328 Thunderbird/17.0.5
Thanks! I will try out the DirCache API today.
In the meantime, I'd like to add that by design of my system each user's
contents resides in a separate FS folder and each add / commit operation
operates on only one user folder. If I ensure locking around the folder
if many request by one user occur, does this change anything and make my
If not, I will take up the index approach.
Ultimately I need a repo with a working folder, to make the submitted
content available to a static HTTP server.
In this case would I need two repos? One to write resources and commit
info, and one which only pulls and checks out from the other, and serves
the HTTP server?
Thanks in advance. Sorry about this starting to sound like a general
programming consultation. I just want to understand what is the sane way
to use JGit to manage revisions of a simple FS-based CMS in a
On 4/18/2013 6:54 PM, Shawn Pearce wrote:
On Thu, Apr 18, 2013 at 4:26 AM, Dimitar Georgiev
Are local JGit operations such as commit and add thread-safe?
No. There is only one working directory. JGit assumes the caller has
managed synchronization with the working directory, since there is
I am building
a homegrown content management solution and am using JGit Command API behind
the scenes. Requests to JGit can come from multiple (HTTP) threads and I was
wondering whether having no programmatic locking around this could result in
data corruption / race conditions.
Also what is the expected results when there is a simultaneous commit /
Don't use a working directory. The internals are thread-safe for
accessing the local repository's object database and references. If
all edits are done in-memory using the lower-level API you can do this
completely thread-safe and without the local working directory. It
requires using the DirCache to manipulate what is in the repository's
file listing, and CommitBuilder to fill out a commit. These are the
primitives used by the JGit command API.
Alternatively, make a working directory per web request. This is going
to be some really ugly code, so I wouldn't encourage it.