I think it depends on whether this is CPU or IO bound, where the files
will be stored and how expensive it is to generate blocks, check for
existence, copy etc. Over a distributed filesystem running across
data-centers the decision will probably be different than on a
multi-core cpu on a sing
On Sat, Feb 14, 2009 at 5:44 PM, James Reeves wrote:
>
> On Feb 14, 5:30 pm, Dan wrote:
> > What about making the file an agent and sending write actions to it?
>
> I don't see how that would solve the problem, unless you're suggesting
> that I have a single agent to handle all reads and writes?
Yes, and combined with the technique in the link Kevin provided, it's clean
if something goes wrong, java/the os will take care of deleting the temp
file for you :
// Create temp file.
File temp = File.createTempFile(*"pattern"*, *".suffix"*);
// Delete temp file when program exits.
temp.deleteOn
On Feb 15, 12:42 pm, Laurent PETIT wrote:
> Well, so indeed, the temporary file solution seems a good one, then.
The consensus seems to be to use a temporary file, then. I had thought
there might be a flashy cutting-edge way of handling this sort of IO,
but I guess sometimes the best solutions a
Well, so indeed, the temporary file solution seems a good one, then.
--
laurent
2009/2/15 James Reeves
>
> On Feb 14, 10:58 pm, Laurent PETIT wrote:
> > You could maybe solve the read problem by also embedding, in the name of
> the
> > file, its intended content size ?
>
> That solves the rea
On Feb 14, 10:58 pm, Laurent PETIT wrote:
> You could maybe solve the read problem by also embedding, in the name of the
> file, its intended content size ?
That solves the read problem, but not the conflicting write problem.
It also seems harder than using a temporary file.
> If the file is im
http://www.exampledepot.com/egs/java.io/CreateTempFile.html
On Sat, Feb 14, 2009 at 4:38 PM, Mark H. wrote:
>
> On Feb 14, 6:48 am, James Reeves wrote:
>> I've been having some difficulty coming up with a scheme for writing
>> to files in a thread-safe manner. The files are named with the hash
On Feb 14, 6:48 am, James Reeves wrote:
> I've been having some difficulty coming up with a scheme for writing
> to files in a thread-safe manner. The files are named with the hash of
> their content, so they are effectively immutable.
>
> The problem comes with writing them for the first time. I
Hello,
You could maybe solve the read problem by also embedding, in the name of the
file, its intended content size ?
So it could be reasonably cheap to check if a file is present but not yet
totally flushed to the disk by comparing its intended size (from its name)
and its current real size ?
F
On Feb 14, 5:30 pm, Dan wrote:
> What about making the file an agent and sending write actions to it?
I don't see how that would solve the problem, unless you're suggesting
that I have a single agent to handle all reads and writes?
- James
--~--~-~--~~~---~--~~
Y
On Sat, Feb 14, 2009 at 9:48 AM, James Reeves wrote:
>
> Hi folks,
>
> I've been having some difficulty coming up with a scheme for writing
> to files in a thread-safe manner. The files are named with the hash of
> their content, so they are effectively immutable.
>
What about making the file an
11 matches
Mail list logo