WARNING: Fix a big bug in Load_File() method: all previous MQSLoad versions can corrupt messages during loading !!!
This commit is contained in:
parent
67b4a7aa8b
commit
f12bcae985
150
MQSLoad.java
150
MQSLoad.java
@ -1,7 +1,7 @@
|
|||||||
// $RCSfile: MQSLoad.java,v $
|
// $RCSfile: MQSLoad.java,v $
|
||||||
// $Revision: 1.12 $
|
// $Revision: 1.13 $
|
||||||
// $Name: $
|
// $Name: $
|
||||||
// $Date: 2008/11/10 01:50:19 $
|
// $Date: 2008/11/14 00:00:51 $
|
||||||
// $Author: agibert $
|
// $Author: agibert $
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -45,9 +45,9 @@ public class MQSLoad
|
|||||||
private String Message_Break = "\r\n";
|
private String Message_Break = "\r\n";
|
||||||
private String Message_Tail = "";
|
private String Message_Tail = "";
|
||||||
private boolean Keep_Message_Break = false;
|
private boolean Keep_Message_Break = false;
|
||||||
private String MQSLoad_Revision = "$Revision: 1.12 $";
|
private String MQSLoad_Revision = "$Revision: 1.13 $";
|
||||||
private String MQSLoad_Tag = "$Name: $";
|
private String MQSLoad_Tag = "$Name: $";
|
||||||
private String MQSLoad_Date = "$Date: 2008/11/10 01:50:19 $";
|
private String MQSLoad_Date = "$Date: 2008/11/14 00:00:51 $";
|
||||||
private String MQSLoad_Author = "$Author: agibert $";
|
private String MQSLoad_Author = "$Author: agibert $";
|
||||||
private Integer Sleep_Time = 0;
|
private Integer Sleep_Time = 0;
|
||||||
|
|
||||||
@ -457,6 +457,7 @@ public class MQSLoad
|
|||||||
output_msg.format = MQC.MQFMT_STRING;
|
output_msg.format = MQC.MQFMT_STRING;
|
||||||
|
|
||||||
|
|
||||||
|
/* Default window size */
|
||||||
window_size = 1024 * 64;
|
window_size = 1024 * 64;
|
||||||
prefetch_size = Field_Break.length() + Message_Break.length();
|
prefetch_size = Field_Break.length() + Message_Break.length();
|
||||||
buffer_size = window_size + prefetch_size;
|
buffer_size = window_size + prefetch_size;
|
||||||
@ -468,89 +469,100 @@ public class MQSLoad
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
read_size = Input_File.read( buffer_byte, buffer_offset, buffer_size - buffer_offset);
|
read_size = Input_File.read( buffer_byte, buffer_offset, buffer_size - buffer_offset);
|
||||||
// System.out.println( "Load buffer read_size: (" + read_size + ") asked: (" + (buffer_size - buffer_offset) + ")");
|
// System.out.println( "Load buffer read_size: (" + read_size + ") asked: (" + (buffer_size - buffer_offset) + ")");
|
||||||
|
|
||||||
if( read_size > 0)
|
if( read_size == -1)
|
||||||
{
|
{
|
||||||
cur_window_size = Math.min( ( read_size + buffer_offset), window_size);
|
read_size = 0;
|
||||||
cur_buffer_size = ( read_size + buffer_offset);
|
}
|
||||||
|
|
||||||
buffer_string = new String( buffer_byte, 0, cur_buffer_size);
|
/* Compute current buffer and window size */
|
||||||
cur_pos = 0;
|
cur_window_size = Math.min( ( read_size + buffer_offset), window_size);
|
||||||
|
cur_buffer_size = ( read_size + buffer_offset);
|
||||||
|
|
||||||
|
buffer_string = new String( buffer_byte, 0, cur_buffer_size);
|
||||||
|
cur_pos = 0;
|
||||||
|
|
||||||
while( cur_pos < cur_window_size)
|
// System.out.println( " CurWS: (" + cur_window_size + ") CurBS: (" + cur_buffer_size + ") Buffer: [" + buffer_string + "]");
|
||||||
{
|
|
||||||
// System.out.println( "- CurPos: (" + cur_pos + ")");
|
while( cur_pos < cur_window_size)
|
||||||
next_message = buffer_string.indexOf( Message_Break, cur_pos);
|
{
|
||||||
|
// System.out.println( "- CurPos: (" + cur_pos + ")");
|
||||||
|
next_message = buffer_string.indexOf( Message_Break, cur_pos);
|
||||||
|
|
||||||
if( ( next_message == -1) || ( next_message > cur_window_size))
|
if( ( next_message == -1) || ( next_message > cur_window_size))
|
||||||
|
{
|
||||||
|
next_message = cur_window_size + 1;
|
||||||
|
end_pos = cur_window_size;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// System.out.println( "+ Get message next_message: (" + next_message + ")");
|
||||||
|
end_pos = next_message;
|
||||||
|
}
|
||||||
|
|
||||||
|
while( cur_pos < end_pos)
|
||||||
|
{
|
||||||
|
// System.out.println( "+ CurPos: (" + cur_pos + ") end_pos: (" + end_pos + ")");
|
||||||
|
if( Field_Break.length() > 0)
|
||||||
{
|
{
|
||||||
next_message = cur_window_size + 1;
|
next_field = buffer_string.indexOf( Field_Break, cur_pos);
|
||||||
end_pos = cur_window_size;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// System.out.println( "+ Get message next_message: (" + next_message + ")");
|
next_field = -1;
|
||||||
end_pos = next_message;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while( cur_pos < end_pos)
|
|
||||||
{
|
|
||||||
// System.out.println( "+ CurPos: (" + cur_pos + ") end_pos: (" + end_pos + ")");
|
|
||||||
if( Field_Break.length() > 0)
|
|
||||||
{
|
|
||||||
next_field = buffer_string.indexOf( Field_Break, cur_pos);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
next_field = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( ( next_field == -1) || ( next_field > end_pos))
|
if( ( next_field == -1) || ( next_field > end_pos))
|
||||||
{
|
{
|
||||||
out_string = buffer_string.substring( cur_pos, end_pos);
|
out_string = buffer_string.substring( cur_pos, end_pos);
|
||||||
cur_pos = end_pos;
|
cur_pos = end_pos;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// System.out.println( "+ Get field next_field: (" + next_field + ")");
|
// System.out.println( "+ Get field next_field: (" + next_field + ")");
|
||||||
out_string = buffer_string.substring( cur_pos, next_field);
|
out_string = buffer_string.substring( cur_pos, next_field);
|
||||||
cur_pos = next_field + Field_Break.length();
|
cur_pos = next_field + Field_Break.length();
|
||||||
}
|
}
|
||||||
|
|
||||||
output_msg.writeString( out_string);
|
output_msg.writeString( out_string);
|
||||||
}
|
// System.out.println( "* Msg: [" + out_string + "]");
|
||||||
|
|
||||||
if( next_message <= cur_window_size)
|
|
||||||
{
|
|
||||||
// System.out.println( "* Write Msg CurPos: (" + cur_pos + ")");
|
|
||||||
output_msg.writeString( Message_Tail);
|
|
||||||
|
|
||||||
if( Keep_Message_Break)
|
|
||||||
{
|
|
||||||
output_msg.writeString( Message_Break);
|
|
||||||
}
|
|
||||||
|
|
||||||
output_msg.messageId = MQC.MQMI_NONE;
|
|
||||||
MQSPut_Msg( output_msg);
|
|
||||||
output_msg.clearMessage();
|
|
||||||
out_string = null;
|
|
||||||
cur_pos += Message_Break.length();
|
|
||||||
|
|
||||||
Counter_Print( msg_nb++);
|
|
||||||
|
|
||||||
Stand_By( Sleep_Time);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( cur_buffer_size > cur_window_size)
|
if( next_message <= cur_window_size)
|
||||||
{
|
{
|
||||||
buffer_offset = cur_buffer_size - cur_window_size;
|
/* A message break has been found: send the data... */
|
||||||
System.arraycopy( buffer_byte, cur_window_size, buffer_byte, 0, buffer_offset);
|
// System.out.println( "* Write Msg CurPos: (" + cur_pos + ")");
|
||||||
|
output_msg.writeString( Message_Tail);
|
||||||
|
|
||||||
|
if( Keep_Message_Break)
|
||||||
|
{
|
||||||
|
output_msg.writeString( Message_Break);
|
||||||
|
}
|
||||||
|
|
||||||
|
output_msg.messageId = MQC.MQMI_NONE;
|
||||||
|
MQSPut_Msg( output_msg);
|
||||||
|
output_msg.clearMessage();
|
||||||
|
out_string = null;
|
||||||
|
cur_pos += Message_Break.length();
|
||||||
|
|
||||||
|
Counter_Print( msg_nb++);
|
||||||
|
|
||||||
|
Stand_By( Sleep_Time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buffer_offset = cur_buffer_size - cur_pos;
|
||||||
|
// System.out.println( "% CurPos: (" + cur_pos + ") BufOff: (" + buffer_offset + ")");
|
||||||
|
|
||||||
|
if( buffer_offset > 0)
|
||||||
|
{
|
||||||
|
/* Copy back prefetch area */
|
||||||
|
System.arraycopy( buffer_byte, cur_pos, buffer_byte, 0, buffer_offset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
while( read_size > 0);
|
while( cur_buffer_size > 0);
|
||||||
|
|
||||||
if( out_string != null)
|
if( out_string != null)
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# $RCSfile: ReleaseNotes.txt,v $
|
# $RCSfile: ReleaseNotes.txt,v $
|
||||||
# $Revision: 1.10 $
|
# $Revision: 1.11 $
|
||||||
# $Name: $
|
# $Name: $
|
||||||
# $Date: 2008/11/10 01:50:19 $
|
# $Date: 2008/11/14 00:00:51 $
|
||||||
# $Author: agibert $
|
# $Author: agibert $
|
||||||
|
|
||||||
|
|
||||||
@ -9,10 +9,12 @@
|
|||||||
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
MQSLoad V 1.3.2 - A. Gibert - 2008/11/10
|
MQSLoad V 1.3.2 - A. Gibert - 2008/11/14
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
Fix elapsed time computation !
|
- WARNING: Fix a big bug in Load_File() method: all previous MQSLoad versions
|
||||||
|
can corrupt messages during loading !!!
|
||||||
|
- Fix elapsed time computation !
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user