You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Jean-Baptiste Onofré (Created JIRA)" <ji...@apache.org> on 2012/04/02 15:27:24 UTC
[jira] [Created] (CAMEL-5136) File producer should support a flush
attribute
File producer should support a flush attribute
----------------------------------------------
Key: CAMEL-5136
URL: https://issues.apache.org/jira/browse/CAMEL-5136
Project: Camel
Issue Type: Improvement
Components: camel-core
Affects Versions: 2.9.1, 2.8.4
Reporter: Jean-Baptiste Onofré
Assignee: Jean-Baptiste Onofré
Fix For: 2.8.5, 2.10.0, 2.9.2
Currently, the file operation doesn't flush the file change while writing to the filesystem:
private void writeFileByFile(File source, File target) throws IOException {
FileChannel in = new FileInputStream(source).getChannel();
FileChannel out = null;
try {
out = prepareOutputFileChannel(target, out);
LOG.trace("Using FileChannel to transfer from: {} to: {}", in, out);
long size = in.size();
long position = 0;
while (position < size) {
position += in.transferTo(position, endpoint.getBufferSize(), out);
}
} finally {
IOHelper.close(in, source.getName(), LOG);
IOHelper.close(out, target.getName(), LOG);
}
}
private void writeFileByStream(InputStream in, File target) throws IOException {
FileChannel out = null;
try {
out = prepareOutputFileChannel(target, out);
LOG.trace("Using InputStream to transfer from: {} to: {}", in, out);
int size = endpoint.getBufferSize();
byte[] buffer = new byte[size];
ByteBuffer byteBuffer = ByteBuffer.wrap(buffer);
int bytesRead;
while ((bytesRead = in.read(buffer)) != -1) {
if (bytesRead < size) {
byteBuffer.limit(bytesRead);
}
out.write(byteBuffer);
byteBuffer.clear();
}
} finally {
IOHelper.close(in, target.getName(), LOG);
IOHelper.close(out, target.getName(), LOG);
}
}
It means that the file can be visible on the filesystem quite a long time after starting to send the exchanges to the file endpoint.
It could be interesting to add a flush attribute doing:
FileOutputStream os = ...
FileDescriptor fd = os.getFD();
...
os.write(data);
os.flush();
fd.sync();
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Assigned] (CAMEL-5136) File producer should support a flush
attribute
Posted by "Claus Ibsen (Assigned) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CAMEL-5136?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Claus Ibsen reassigned CAMEL-5136:
----------------------------------
Assignee: Claus Ibsen (was: Jean-Baptiste Onofré)
> File producer should support a flush attribute
> ----------------------------------------------
>
> Key: CAMEL-5136
> URL: https://issues.apache.org/jira/browse/CAMEL-5136
> Project: Camel
> Issue Type: Improvement
> Components: camel-core
> Affects Versions: 2.8.4, 2.9.1
> Reporter: Jean-Baptiste Onofré
> Assignee: Claus Ibsen
> Fix For: 2.8.5, 2.9.2, 2.10.0
>
>
> Currently, the file operation doesn't flush the file change while writing to the filesystem:
> private void writeFileByFile(File source, File target) throws IOException {
> FileChannel in = new FileInputStream(source).getChannel();
> FileChannel out = null;
> try {
> out = prepareOutputFileChannel(target, out);
> LOG.trace("Using FileChannel to transfer from: {} to: {}", in, out);
> long size = in.size();
> long position = 0;
> while (position < size) {
> position += in.transferTo(position, endpoint.getBufferSize(), out);
> }
> } finally {
> IOHelper.close(in, source.getName(), LOG);
> IOHelper.close(out, target.getName(), LOG);
> }
> }
> private void writeFileByStream(InputStream in, File target) throws IOException {
> FileChannel out = null;
> try {
> out = prepareOutputFileChannel(target, out);
> LOG.trace("Using InputStream to transfer from: {} to: {}", in, out);
> int size = endpoint.getBufferSize();
> byte[] buffer = new byte[size];
> ByteBuffer byteBuffer = ByteBuffer.wrap(buffer);
> int bytesRead;
> while ((bytesRead = in.read(buffer)) != -1) {
> if (bytesRead < size) {
> byteBuffer.limit(bytesRead);
> }
> out.write(byteBuffer);
> byteBuffer.clear();
> }
> } finally {
> IOHelper.close(in, target.getName(), LOG);
> IOHelper.close(out, target.getName(), LOG);
> }
> }
> It means that the file can be visible on the filesystem quite a long time after starting to send the exchanges to the file endpoint.
> It could be interesting to add a flush attribute doing:
> FileOutputStream os = ...
> FileDescriptor fd = os.getFD();
> ...
> os.write(data);
> os.flush();
> fd.sync();
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Resolved] (CAMEL-5136) File producer should support a flush
attribute
Posted by "Claus Ibsen (Resolved) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CAMEL-5136?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Claus Ibsen resolved CAMEL-5136.
--------------------------------
Resolution: Fixed
Fix Version/s: (was: 2.8.5)
> File producer should support a flush attribute
> ----------------------------------------------
>
> Key: CAMEL-5136
> URL: https://issues.apache.org/jira/browse/CAMEL-5136
> Project: Camel
> Issue Type: Improvement
> Components: camel-core
> Affects Versions: 2.8.4, 2.9.1
> Reporter: Jean-Baptiste Onofré
> Assignee: Claus Ibsen
> Fix For: 2.9.2, 2.10.0
>
>
> Currently, the file operation doesn't flush the file change while writing to the filesystem:
> private void writeFileByFile(File source, File target) throws IOException {
> FileChannel in = new FileInputStream(source).getChannel();
> FileChannel out = null;
> try {
> out = prepareOutputFileChannel(target, out);
> LOG.trace("Using FileChannel to transfer from: {} to: {}", in, out);
> long size = in.size();
> long position = 0;
> while (position < size) {
> position += in.transferTo(position, endpoint.getBufferSize(), out);
> }
> } finally {
> IOHelper.close(in, source.getName(), LOG);
> IOHelper.close(out, target.getName(), LOG);
> }
> }
> private void writeFileByStream(InputStream in, File target) throws IOException {
> FileChannel out = null;
> try {
> out = prepareOutputFileChannel(target, out);
> LOG.trace("Using InputStream to transfer from: {} to: {}", in, out);
> int size = endpoint.getBufferSize();
> byte[] buffer = new byte[size];
> ByteBuffer byteBuffer = ByteBuffer.wrap(buffer);
> int bytesRead;
> while ((bytesRead = in.read(buffer)) != -1) {
> if (bytesRead < size) {
> byteBuffer.limit(bytesRead);
> }
> out.write(byteBuffer);
> byteBuffer.clear();
> }
> } finally {
> IOHelper.close(in, target.getName(), LOG);
> IOHelper.close(out, target.getName(), LOG);
> }
> }
> It means that the file can be visible on the filesystem quite a long time after starting to send the exchanges to the file endpoint.
> It could be interesting to add a flush attribute doing:
> FileOutputStream os = ...
> FileDescriptor fd = os.getFD();
> ...
> os.write(data);
> os.flush();
> fd.sync();
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (CAMEL-5136) File producer should support a
flush attribute
Posted by "Claus Ibsen (Commented) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CAMEL-5136?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13251323#comment-13251323 ]
Claus Ibsen commented on CAMEL-5136:
------------------------------------
We should use force on the file channel to flush the updates
http://docs.oracle.com/javase/6/docs/api/java/nio/channels/FileChannel.html#force(boolean)
> File producer should support a flush attribute
> ----------------------------------------------
>
> Key: CAMEL-5136
> URL: https://issues.apache.org/jira/browse/CAMEL-5136
> Project: Camel
> Issue Type: Improvement
> Components: camel-core
> Affects Versions: 2.8.4, 2.9.1
> Reporter: Jean-Baptiste Onofré
> Assignee: Claus Ibsen
> Fix For: 2.8.5, 2.9.2, 2.10.0
>
>
> Currently, the file operation doesn't flush the file change while writing to the filesystem:
> private void writeFileByFile(File source, File target) throws IOException {
> FileChannel in = new FileInputStream(source).getChannel();
> FileChannel out = null;
> try {
> out = prepareOutputFileChannel(target, out);
> LOG.trace("Using FileChannel to transfer from: {} to: {}", in, out);
> long size = in.size();
> long position = 0;
> while (position < size) {
> position += in.transferTo(position, endpoint.getBufferSize(), out);
> }
> } finally {
> IOHelper.close(in, source.getName(), LOG);
> IOHelper.close(out, target.getName(), LOG);
> }
> }
> private void writeFileByStream(InputStream in, File target) throws IOException {
> FileChannel out = null;
> try {
> out = prepareOutputFileChannel(target, out);
> LOG.trace("Using InputStream to transfer from: {} to: {}", in, out);
> int size = endpoint.getBufferSize();
> byte[] buffer = new byte[size];
> ByteBuffer byteBuffer = ByteBuffer.wrap(buffer);
> int bytesRead;
> while ((bytesRead = in.read(buffer)) != -1) {
> if (bytesRead < size) {
> byteBuffer.limit(bytesRead);
> }
> out.write(byteBuffer);
> byteBuffer.clear();
> }
> } finally {
> IOHelper.close(in, target.getName(), LOG);
> IOHelper.close(out, target.getName(), LOG);
> }
> }
> It means that the file can be visible on the filesystem quite a long time after starting to send the exchanges to the file endpoint.
> It could be interesting to add a flush attribute doing:
> FileOutputStream os = ...
> FileDescriptor fd = os.getFD();
> ...
> os.write(data);
> os.flush();
> fd.sync();
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira