Compare commits
6 Commits
mqsload-1_
...
mqsload-1_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f12bcae985 | ||
|
|
67b4a7aa8b | ||
|
|
99d17a844e | ||
|
|
ded4a3926f | ||
|
|
d882d2a6a1 | ||
|
|
2c55f4ac61 |
229
MQSLoad.java
229
MQSLoad.java
@@ -1,14 +1,14 @@
|
|||||||
// $RCSfile: MQSLoad.java,v $
|
// $RCSfile: MQSLoad.java,v $
|
||||||
// $Revision: 1.8 $
|
// $Revision: 1.13 $
|
||||||
// $Name: $
|
// $Name: $
|
||||||
// $Date: 2002/05/21 15:48:09 $
|
// $Date: 2008/11/14 00:00:51 $
|
||||||
// $Author: giberta1 $
|
// $Author: agibert $
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MQSLoad.java - Data file to MQ/Series queue loader
|
* MQSLoad.java - Data file to MQ/Series queue loader
|
||||||
* Copyright (C) 2001-2002 Arnaud G. Gibert
|
* Copyright (C) 2001-2006 Arnaud G. Gibert
|
||||||
* arnaud.gibert@misys.com
|
* mailto:arnaud@rx3.net
|
||||||
* www.miys-ibs.fr
|
* http://www.rx3.org/dvp/MQSLoad
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
@@ -45,11 +45,12 @@ 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.8 $";
|
private String MQSLoad_Revision = "$Revision: 1.13 $";
|
||||||
private String MQSLoad_Tag = "$Name: $";
|
private String MQSLoad_Tag = "$Name: $";
|
||||||
private String MQSLoad_Date = "$Date: 2002/05/21 15:48:09 $";
|
private String MQSLoad_Date = "$Date: 2008/11/14 00:00:51 $";
|
||||||
private String MQSLoad_Author = "$Author: giberta1 $";
|
private String MQSLoad_Author = "$Author: agibert $";
|
||||||
|
private Integer Sleep_Time = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -203,7 +204,19 @@ public class MQSLoad
|
|||||||
{
|
{
|
||||||
while( argc < args.length)
|
while( argc < args.length)
|
||||||
{
|
{
|
||||||
if( args[argc].equals( "-fb"))
|
if( args[argc].equals( "-qm"))
|
||||||
|
{
|
||||||
|
if( argc < ( args.length + 1))
|
||||||
|
{
|
||||||
|
QMng_Name = Str_Format( args[++argc]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
System.out.println( "Invalid number of command line options...");
|
||||||
|
throw new Exception();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( args[argc].equals( "-fb"))
|
||||||
{
|
{
|
||||||
if( argc < ( args.length + 1))
|
if( argc < ( args.length + 1))
|
||||||
{
|
{
|
||||||
@@ -239,7 +252,19 @@ public class MQSLoad
|
|||||||
throw new Exception();
|
throw new Exception();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( args[argc].equals( "-kmb"))
|
else if ( args[argc].equals( "-st"))
|
||||||
|
{
|
||||||
|
if( argc < ( args.length + 1))
|
||||||
|
{
|
||||||
|
Sleep_Time = Integer.parseInt( args[++argc]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
System.out.println( "Invalid number of command line options...");
|
||||||
|
throw new Exception();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( args[argc].equals( "-kmb"))
|
||||||
{
|
{
|
||||||
Keep_Message_Break = true;
|
Keep_Message_Break = true;
|
||||||
}
|
}
|
||||||
@@ -386,6 +411,32 @@ public class MQSLoad
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
private void Stand_By(int timer)
|
||||||
|
{
|
||||||
|
if( timer > 0)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
synchronized( this)
|
||||||
|
{
|
||||||
|
wait( timer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(InterruptedException ie)
|
||||||
|
{
|
||||||
|
ie.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
//-------------------------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -406,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;
|
||||||
@@ -417,87 +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++);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
@@ -506,6 +571,8 @@ public class MQSLoad
|
|||||||
MQSPut_Msg( output_msg);
|
MQSPut_Msg( output_msg);
|
||||||
|
|
||||||
Counter_Print( msg_nb++);
|
Counter_Print( msg_nb++);
|
||||||
|
|
||||||
|
Stand_By( Sleep_Time);
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println( "\n");
|
System.out.println( "\n");
|
||||||
@@ -538,10 +605,10 @@ public class MQSLoad
|
|||||||
{
|
{
|
||||||
System.out.println("MQSLoad: " + MQSLoad_Tag + " / " + MQSLoad_Date + " / " + MQSLoad_Author);
|
System.out.println("MQSLoad: " + MQSLoad_Tag + " / " + MQSLoad_Date + " / " + MQSLoad_Author);
|
||||||
|
|
||||||
if( ( args.length < 2) || ( args.length > 6))
|
if( ( args.length < 2) || ( args.length > 8))
|
||||||
{
|
{
|
||||||
System.out.println( "Usage: MQSLoad [-fb \"field_break\"] [-mb \"message_break\"] [-mt \"message_tail\"] [-kmb] <Output_MsgQueue_Name> <Input_File_Name>");
|
System.out.println( "Usage: MQSLoad [-qm \"Output_QueueMng_Name\"] [-st \"sleep_time\"] [-fb \"field_break\"] [-mb \"message_break\"] [-mt \"message_tail\"] [-kmb] <Output_MsgQueue_Name> <Input_File_Name>");
|
||||||
System.out.println( " Default: Field Break: (" + Str_UnFormat( Field_Break) + ") Message Break: (" + Str_UnFormat( Message_Break) + ") Message Tail: (" + Str_UnFormat( Message_Tail) + ") Keep Message Break: (" + Keep_Message_Break + ")");
|
System.out.println( " Default: Output QueueMng Name: (" + QMng_Name + ") Sleep Time: (" + Sleep_Time + ") Field Break: (" + Str_UnFormat( Field_Break) + ") Message Break: (" + Str_UnFormat( Message_Break) + ") Message Tail: (" + Str_UnFormat( Message_Tail) + ") Keep Message Break: (" + Keep_Message_Break + ")");
|
||||||
|
|
||||||
System.exit( 1);
|
System.exit( 1);
|
||||||
}
|
}
|
||||||
@@ -551,8 +618,8 @@ public class MQSLoad
|
|||||||
|
|
||||||
Arg_Parse( args);
|
Arg_Parse( args);
|
||||||
|
|
||||||
System.out.println( "Output MsgQueue Name: (" + MsgQ_Name + ") Input File Name: (" + File_Name + ")");
|
System.out.println( "Output QueueMng Name: (" + QMng_Name + ") Output MsgQueue Name: (" + MsgQ_Name + ") Input File Name: (" + File_Name + ")");
|
||||||
System.out.println( "Field Break: (" + Str_UnFormat( Field_Break) + ") Message Break: (" + Str_UnFormat( Message_Break) + ") Message Tail: (" + Str_UnFormat( Message_Tail) + ") Keep Message Break: (" + Keep_Message_Break + ")");
|
System.out.println( "Sleep Time: (" + Sleep_Time + ") Field Break: (" + Str_UnFormat( Field_Break) + ") Message Break: (" + Str_UnFormat( Message_Break) + ") Message Tail: (" + Str_UnFormat( Message_Tail) + ") Keep Message Break: (" + Keep_Message_Break + ")");
|
||||||
|
|
||||||
MQSInit();
|
MQSInit();
|
||||||
|
|
||||||
@@ -568,7 +635,7 @@ public class MQSLoad
|
|||||||
msg_nb = Load_File( input_file);
|
msg_nb = Load_File( input_file);
|
||||||
time_end = System.currentTimeMillis();
|
time_end = System.currentTimeMillis();
|
||||||
|
|
||||||
time_elapsed = ( time_end - time_begin) / 100.0;
|
time_elapsed = ( time_end - time_begin) / 1000.0;
|
||||||
speed = msg_nb / time_elapsed;
|
speed = msg_nb / time_elapsed;
|
||||||
|
|
||||||
nf.setMinimumFractionDigits(2);
|
nf.setMinimumFractionDigits(2);
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
# $RCSfile: ReadMe.txt,v $
|
# $RCSfile: ReadMe.txt,v $
|
||||||
# $Revision: 1.7 $
|
# $Revision: 1.8 $
|
||||||
# $Name: $
|
# $Name: $
|
||||||
# $Date: 2002/05/21 15:22:00 $
|
# $Date: 2007/12/11 16:46:37 $
|
||||||
# $Author: giberta1 $
|
# $Author: agibert $
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ Installation:
|
|||||||
Notes:
|
Notes:
|
||||||
------
|
------
|
||||||
|
|
||||||
- MQSLoad has been tested with MQ/Series 5.2,
|
- MQSLoad has been tested with MQ/Series 5.2, 5.3 and WMQ 6.0
|
||||||
|
|
||||||
- "-fb" and "-mb" arguments accept a string with formated escape character:
|
- "-fb" and "-mb" arguments accept a string with formated escape character:
|
||||||
+ "\n" for newline,
|
+ "\n" for newline,
|
||||||
|
|||||||
@@ -1,15 +1,49 @@
|
|||||||
# $RCSfile: ReleaseNotes.txt,v $
|
# $RCSfile: ReleaseNotes.txt,v $
|
||||||
# $Revision: 1.6 $
|
# $Revision: 1.11 $
|
||||||
# $Name: $
|
# $Name: $
|
||||||
# $Date: 2002/05/21 15:55:17 $
|
# $Date: 2008/11/14 00:00:51 $
|
||||||
# $Author: giberta1 $
|
# $Author: agibert $
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
MQSLoad V 1.1.3 - A. Gibert - 21/05/02
|
MQSLoad V 1.3.2 - A. Gibert - 2008/11/14
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
- WARNING: Fix a big bug in Load_File() method: all previous MQSLoad versions
|
||||||
|
can corrupt messages during loading !!!
|
||||||
|
- Fix elapsed time computation !
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
MQSLoad V 1.3.1 - A. Gibert - 2008/01/03
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Fix usage print out.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
MQSLoad V 1.3.0 - C. Colin / A. Gibert - 2007/12/10
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Add sleep time option "-st".
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
MQSLoad V 1.2.0 - A. Gibert - 2007/06/05
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Add queue manager name option "-qm".
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
MQSLoad V 1.1.4 - A. Gibert - 2002/05/21
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
Add message tail option "-mt",
|
Add message tail option "-mt",
|
||||||
@@ -19,7 +53,7 @@ Add version, date and author print out.
|
|||||||
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
MQSLoad V 1.1.2 - A. Gibert - 06/05/02
|
MQSLoad V 1.1.2 - A. Gibert - 2002/05/06
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
Add return code handling.
|
Add return code handling.
|
||||||
@@ -27,7 +61,7 @@ Add return code handling.
|
|||||||
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
MQSLoad V 1.1.1 - A. Gibert - 02/05/02
|
MQSLoad V 1.1.1 - A. Gibert - 2002/05/02
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
Add Keep Message Break support,
|
Add Keep Message Break support,
|
||||||
@@ -36,7 +70,7 @@ Add -kmb option.
|
|||||||
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
MQSLoad V 1.1.0 - A. Gibert - 23/04/02
|
MQSLoad V 1.1.0 - A. Gibert - 2002/04/23
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
Add string field break and string message break support,
|
Add string field break and string message break support,
|
||||||
@@ -51,7 +85,7 @@ Add GPL and FDL licenses files.
|
|||||||
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
MQSLoad V 1.0.0 - A. Gibert - 12/07/01
|
MQSLoad V 1.0.0 - A. Gibert - 2001/07/12
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
First release,
|
First release,
|
||||||
|
|||||||
Reference in New Issue
Block a user