From bc2254cab8fb40f85ebea4d60d296a4afae8a87b Mon Sep 17 00:00:00 2001 From: agibert Date: Thu, 4 Dec 2008 10:45:06 +0000 Subject: [PATCH] First step to 2.0.*: - Code cleanup, - Add message skip option "-ms", - Add message count option "-mc", - Add repeat count option "-rc", - Fix Java 1.4 compatibility. --- MQSLoad.java | 983 ++++++++++++++++++++++++++--------------------- ReleaseNotes.txt | 16 +- 2 files changed, 564 insertions(+), 435 deletions(-) diff --git a/MQSLoad.java b/MQSLoad.java index 96d6741..5b59400 100644 --- a/MQSLoad.java +++ b/MQSLoad.java @@ -1,7 +1,7 @@ // $RCSfile: MQSLoad.java,v $ -// $Revision: 1.13 $ +// $Revision: 1.14 $ // $Name: $ -// $Date: 2008/11/14 00:00:51 $ +// $Date: 2008/12/04 10:45:06 $ // $Author: agibert $ /* @@ -25,9 +25,9 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -import com.ibm.mq.*; import java.io.*; import java.text.*; +import com.ibm.mq.*; @@ -35,21 +35,24 @@ import java.text.*; public class MQSLoad { - private MQQueueManager QMng = null; - private String QMng_Name = ""; - private MQQueue MsgQ; - private String MsgQ_Name; - private int MsgQ_Open_Options = MQC.MQOO_OUTPUT | MQC.MQOO_FAIL_IF_QUIESCING; - private String File_Name; - private String Field_Break = ""; - private String Message_Break = "\r\n"; - private String Message_Tail = ""; - private boolean Keep_Message_Break = false; - private String MQSLoad_Revision = "$Revision: 1.13 $"; + private String MQSLoad_Revision = "$Revision: 1.14 $"; private String MQSLoad_Tag = "$Name: $"; - private String MQSLoad_Date = "$Date: 2008/11/14 00:00:51 $"; + private String MQSLoad_Date = "$Date: 2008/12/04 10:45:06 $"; private String MQSLoad_Author = "$Author: agibert $"; - private Integer Sleep_Time = 0; + private MQQueueManager QMng = null; + private String QMng_Name = ""; + private MQQueue MsgQ; + private String MsgQ_Name; + private int MsgQ_Open_Options = MQC.MQOO_OUTPUT | MQC.MQOO_FAIL_IF_QUIESCING; + private int Sleep_Time = 0; + private String Field_Break = ""; + private String Message_Break = "\r\n"; + private String Message_Tail = ""; + private int Message_Skip = 0; + private int Message_Count = 0; + private int Repeat_Count = 1; + private boolean Keep_Message_Break = false; + private String File_Name; @@ -59,9 +62,9 @@ public class MQSLoad // //------------------------------------------------------------------------------------------------------------------------- - public static void main( String args[]) + public static void main( String args[]) { - new MQSLoad( args); + new MQSLoad( args); } @@ -72,66 +75,66 @@ public class MQSLoad // //------------------------------------------------------------------------------------------------------------------------- - public static String Str_Format( String UnFmt) + public static String Str_Format( String UnFmt) { - int idx; - boolean esc = false; - String fmt = ""; + int idx; + boolean esc = false; + String fmt = ""; - for( idx = 0; idx < UnFmt.length(); idx++) - { - if( esc) - { - switch( UnFmt.charAt( idx)) - { - case '\\': - { - fmt += "\\"; - break; - } + for( idx = 0; idx < UnFmt.length(); idx++) + { + if( esc) + { + switch( UnFmt.charAt( idx)) + { + case '\\': + { + fmt += "\\"; + break; + } - case 'n': - { - fmt += "\n"; - break; - } + case 'n': + { + fmt += "\n"; + break; + } - case 'r': - { - fmt += "\r"; - break; - } + case 'r': + { + fmt += "\r"; + break; + } - case 't': - { - fmt += "\t"; - break; - } + case 't': + { + fmt += "\t"; + break; + } - default: - { - fmt += "?"; - break; - } - } + default: + { + fmt += "?"; + break; + } + } - esc = false; - } - else - { - if( UnFmt.charAt( idx) == '\\') - { - esc = true; - } - else - { - fmt += UnFmt.charAt( idx); - } - } - } + esc = false; + } + else + { + if( UnFmt.charAt( idx) == '\\') + { + esc = true; + } + else + { + fmt += UnFmt.charAt( idx); + } + } + } - return( fmt); + return( fmt); } @@ -142,49 +145,49 @@ public class MQSLoad // //------------------------------------------------------------------------------------------------------------------------- - public static String Str_UnFormat( String Fmt) + public static String Str_UnFormat( String Fmt) { - int idx; - String unfmt = ""; + int idx; + String unfmt = ""; - for( idx = 0; idx < Fmt.length(); idx++) - { - switch( Fmt.charAt( idx)) - { - case '\\': - { - unfmt += "\\\\"; - break; - } + for( idx = 0; idx < Fmt.length(); idx++) + { + switch( Fmt.charAt( idx)) + { + case '\\': + { + unfmt += "\\\\"; + break; + } - case '\n': - { - unfmt += "\\n"; - break; - } + case '\n': + { + unfmt += "\\n"; + break; + } - case '\r': - { - unfmt += "\\r"; - break; - } + case '\r': + { + unfmt += "\\r"; + break; + } - case '\t': - { - unfmt += "\\t"; - break; - } + case '\t': + { + unfmt += "\\t"; + break; + } - default: - { - unfmt += Fmt.charAt( idx); - break; - } - } - } + default: + { + unfmt += Fmt.charAt( idx); + break; + } + } + } - return( unfmt); + return( unfmt); } @@ -195,99 +198,135 @@ public class MQSLoad // //------------------------------------------------------------------------------------------------------------------------- - private void Arg_Parse( String args[]) throws Exception + private void Arg_Parse( String args[]) throws Exception { - int argc = 0; + int argc = 0; - try - { - while( argc < args.length) - { - 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)) - { - Field_Break = Str_Format( args[++argc]); - } - else - { - System.out.println( "Invalid number of command line options..."); - throw new Exception(); - } - } - else if ( args[argc].equals( "-mb")) - { - if( argc < ( args.length + 1)) - { - Message_Break = Str_Format( args[++argc]); - } - else - { - System.out.println( "Invalid number of command line options..."); - throw new Exception(); - } - } - else if ( args[argc].equals( "-mt")) - { - if( argc < ( args.length + 1)) - { - Message_Tail = Str_Format( args[++argc]); - } - else - { - System.out.println( "Invalid number of command line options..."); - throw new Exception(); - } - } - 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; - } - else - { - MsgQ_Name = args[argc++]; - File_Name = args[argc++]; + try + { + while( argc < args.length) + { + 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)) + { + Field_Break = Str_Format( args[++argc]); + } + else + { + System.out.println( "Invalid number of command line options..."); + throw new Exception(); + } + } + else if ( args[argc].equals( "-mb")) + { + if( argc < ( args.length + 1)) + { + Message_Break = Str_Format( args[++argc]); + } + else + { + System.out.println( "Invalid number of command line options..."); + throw new Exception(); + } + } + else if ( args[argc].equals( "-mt")) + { + if( argc < ( args.length + 1)) + { + Message_Tail = Str_Format( args[++argc]); + } + else + { + System.out.println( "Invalid number of command line options..."); + throw new Exception(); + } + } + 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( "-ms")) + { + if( argc < ( args.length + 1)) + { + Message_Skip = Integer.parseInt( args[++argc]); + } + else + { + System.out.println( "Invalid number of command line options..."); + throw new Exception(); + } + } + else if ( args[argc].equals( "-mc")) + { + if( argc < ( args.length + 1)) + { + Message_Count = Integer.parseInt( args[++argc]); + } + else + { + System.out.println( "Invalid number of command line options..."); + throw new Exception(); + } + } + else if ( args[argc].equals( "-rc")) + { + if( argc < ( args.length + 1)) + { + Repeat_Count = 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; + } + else + { + MsgQ_Name = args[argc++]; + File_Name = args[argc++]; - if( argc < args.length) - { - System.out.println( "Invalid number of command line options..."); - throw new Exception(); - } - } + if( argc < args.length) + { + System.out.println( "Invalid number of command line options..."); + throw new Exception(); + } + } - ++argc; - } - } + ++argc; + } + } - catch( Exception Expt) - { - throw Expt; - } + catch( Exception Expt) + { + throw Expt; + } } @@ -298,44 +337,44 @@ public class MQSLoad // //------------------------------------------------------------------------------------------------------------------------- - private void MQSInit() throws Exception + private void MQSInit() throws Exception { - short retry = 0; - final short RETRY_MAX = 10; + short retry = 0; + final short RETRY_MAX = 10; - while( QMng == null) + while( QMng == null) + { + try { - try - { - QMng = new MQQueueManager( QMng_Name); + QMng = new MQQueueManager( QMng_Name); // System.out.println( "QManager Open: (" + QMng + ") !"); - } + } - catch( Exception Expt) - { - System.out.print("!"); + catch( Exception Expt) + { + System.out.print("!"); - if( retry++ > RETRY_MAX) - { - throw Expt; - } - } - } + if( retry++ > RETRY_MAX) + { + throw Expt; + } + } + } - try - { - MsgQ = QMng.accessQueue( MsgQ_Name, MsgQ_Open_Options, null, null, null); + try + { + MsgQ = QMng.accessQueue( MsgQ_Name, MsgQ_Open_Options, null, null, null); // System.out.println( "MsgQ Open: (" + MsgQ + ") !"); - } + } - catch( Exception Expt) - { - QMng.disconnect(); + catch( Exception Expt) + { + QMng.disconnect(); // System.out.println( "QManager Close: (" + QMng + ") !"); - throw Expt; - } + throw Expt; + } } @@ -346,20 +385,20 @@ public class MQSLoad // //------------------------------------------------------------------------------------------------------------------------- - private void MQSDeInit() throws Exception + private void MQSDeInit() throws Exception { - try - { - MsgQ.close(); + try + { + MsgQ.close(); // System.out.println( "MsgQ Close: (" + MsgQ + ") !"); - QMng.disconnect(); + QMng.disconnect(); // System.out.println( "QManager Close: (" + QMng + ") !"); - } + } - catch( Exception Expt) - { - throw Expt; - } + catch( Exception Expt) + { + throw Expt; + } } @@ -370,18 +409,18 @@ public class MQSLoad // //------------------------------------------------------------------------------------------------------------------------- - private void MQSPut_Msg( MQMessage Msg) throws Exception + private void MQSPut_Msg( MQMessage Msg) throws Exception { - try - { - MQPutMessageOptions pmo = new MQPutMessageOptions(); - MsgQ.put( Msg, pmo); - } + try + { + MQPutMessageOptions pmo = new MQPutMessageOptions(); + MsgQ.put( Msg, pmo); + } - catch( Exception Expt) - { - throw Expt; - } + catch( Exception Expt) + { + throw Expt; + } } @@ -392,19 +431,19 @@ public class MQSLoad // //------------------------------------------------------------------------------------------------------------------------- - private void Counter_Print( int Msg_Nb) + private void Counter_Print( int Msg_Nb) { - if( ( Msg_Nb % 50) == 0) - { - System.out.print( "\n(" + Msg_Nb + ")\t"); - } + if( ( Msg_Nb % 50) == 0) + { + System.out.print( "\n(" + Msg_Nb + ")\t"); + } - if( ( Msg_Nb % 10) == 0) - { - System.out.print( " "); - } + if( ( Msg_Nb % 10) == 0) + { + System.out.print( " "); + } - System.out.print( "."); + System.out.print( "."); } @@ -415,22 +454,22 @@ public class MQSLoad // //------------------------------------------------------------------------------------------------------------------------- - private void Stand_By(int timer) + private void Stand_By(int timer) throws Exception { - if( timer > 0) + if( timer > 0) + { + try { - try - { - synchronized( this) - { - wait( timer); - } - } - catch(InterruptedException ie) - { - ie.printStackTrace(); - } + synchronized( this) + { + wait( timer); + } } + catch(InterruptedException ie) + { + ie.printStackTrace(); + } + } } @@ -441,148 +480,175 @@ public class MQSLoad // //------------------------------------------------------------------------------------------------------------------------- - private int Load_File( BufferedInputStream Input_File) throws Exception + private int Put_Msg( MQMessage Output_Msg, int Count_Nb, int Msg_Nb) throws Exception + { + if( Msg_Nb > Count_Nb) + { +// System.out.print( "#"); + } + else + { + Output_Msg.messageId = MQC.MQMI_NONE; + MQSPut_Msg( Output_Msg); + Output_Msg.clearMessage(); + + Counter_Print( Msg_Nb++); + + Stand_By( Sleep_Time); + } + + return( Msg_Nb); + } + + + + + + //------------------------------------------------------------------------------------------------------------------------- + // + //------------------------------------------------------------------------------------------------------------------------- + + private int Load_File( RandomAccessFile Input_File, int Msg_Skip, int Msg_Count, int Msg_Nb) throws Exception { - byte input_char; - int msg_nb = 0; - MQMessage output_msg = new MQMessage(); - int buffer_size, cur_buffer_size, window_size, cur_window_size, prefetch_size, buffer_offset, read_size; - int cur_pos, end_pos, next_message, next_field; - byte[] buffer_byte; - String buffer_string, out_string = null; + byte input_char; + MQMessage output_msg = new MQMessage(); + int buffer_size, cur_buffer_size, window_size, cur_window_size, prefetch_size, buffer_offset, read_size; + int cur_pos, end_pos, next_message, next_field; + int skip_nb = 0; + int count_nb = Msg_Nb + Msg_Count; + byte[] buffer_byte; + String buffer_string, out_string = null; - try - { - output_msg.format = MQC.MQFMT_STRING; + try + { + output_msg.format = MQC.MQFMT_STRING; - /* Default window size */ - window_size = 1024 * 64; - prefetch_size = Field_Break.length() + Message_Break.length(); - buffer_size = window_size + prefetch_size; + /* Default window size */ + window_size = 1024 * 64; + prefetch_size = Field_Break.length() + Message_Break.length(); + buffer_size = window_size + prefetch_size; - buffer_offset = 0; + buffer_offset = 0; - buffer_byte = new byte[buffer_size]; + buffer_byte = new byte[buffer_size]; - do - { - read_size = Input_File.read( buffer_byte, buffer_offset, buffer_size - buffer_offset); + do + { + 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) + ")"); - if( read_size == -1) - { - read_size = 0; - } + if( read_size == -1) + { + read_size = 0; + } - /* Compute current buffer and window size */ - cur_window_size = Math.min( ( read_size + buffer_offset), window_size); - cur_buffer_size = ( read_size + buffer_offset); + /* Compute current buffer and window size */ + 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; + buffer_string = new String( buffer_byte, 0, cur_buffer_size); + cur_pos = 0; // System.out.println( " CurWS: (" + cur_window_size + ") CurBS: (" + cur_buffer_size + ") Buffer: [" + buffer_string + "]"); - while( cur_pos < cur_window_size) - { + while( cur_pos < cur_window_size) + { // System.out.println( "- CurPos: (" + cur_pos + ")"); - next_message = buffer_string.indexOf( Message_Break, cur_pos); + next_message = buffer_string.indexOf( Message_Break, cur_pos); - if( ( next_message == -1) || ( next_message > cur_window_size)) - { - next_message = cur_window_size + 1; - end_pos = cur_window_size; - } - else - { + 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; - } + end_pos = next_message; + } - while( cur_pos < end_pos) - { + 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( 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)) - { - out_string = buffer_string.substring( cur_pos, end_pos); - cur_pos = end_pos; - } - else - { + if( ( next_field == -1) || ( next_field > end_pos)) + { + out_string = buffer_string.substring( cur_pos, end_pos); + cur_pos = end_pos; + } + else + { // System.out.println( "+ Get field next_field: (" + next_field + ")"); - out_string = buffer_string.substring( cur_pos, next_field); - cur_pos = next_field + Field_Break.length(); - } + out_string = buffer_string.substring( cur_pos, next_field); + 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) - { - /* A message break has been found: send the data... */ + if( next_message <= cur_window_size) + { + /* A message break has been found: send the data... */ // System.out.println( "* Write Msg CurPos: (" + cur_pos + ")"); - output_msg.writeString( Message_Tail); + 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( Keep_Message_Break) + { + output_msg.writeString( Message_Break); + } - Stand_By( Sleep_Time); - } - } + + if( skip_nb < Msg_Skip) + { + skip_nb++; +// System.out.print( "*"); + } + else + { + Msg_Nb = Put_Msg( output_msg, count_nb, Msg_Nb); + } + + out_string = null; + cur_pos += Message_Break.length(); + } + } - buffer_offset = cur_buffer_size - cur_pos; + 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( cur_buffer_size > 0); + if( buffer_offset > 0) + { + /* Copy back prefetch area */ + System.arraycopy( buffer_byte, cur_pos, buffer_byte, 0, buffer_offset); + } + } + while( cur_buffer_size > 0); - if( out_string != null) - { + if( out_string != null) + { // System.out.println( "* Flushing Msg"); - output_msg.messageId = MQC.MQMI_NONE; - MQSPut_Msg( output_msg); - - Counter_Print( msg_nb++); + Msg_Nb = Put_Msg( output_msg, count_nb, Msg_Nb); + } - Stand_By( Sleep_Time); - } - - System.out.println( "\n"); - return( msg_nb); - } + return( Msg_Nb); + } - catch( Exception Expt) - { - throw Expt; - } + catch( Exception Expt) + { + throw Expt; + } } @@ -593,89 +659,140 @@ public class MQSLoad // //------------------------------------------------------------------------------------------------------------------------- - public MQSLoad( String args[]) + private void Print_Usage( ) throws Exception { - int msg_nb; - long time_begin, time_end; - double time_elapsed, speed; - NumberFormat nf = NumberFormat.getInstance(); - - - try - { - System.out.println("MQSLoad: " + MQSLoad_Tag + " / " + MQSLoad_Date + " / " + MQSLoad_Author); - - if( ( args.length < 2) || ( args.length > 8)) - { - System.out.println( "Usage: MQSLoad [-qm \"Output_QueueMng_Name\"] [-st \"sleep_time\"] [-fb \"field_break\"] [-mb \"message_break\"] [-mt \"message_tail\"] [-kmb] "); - 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.out.println( "Usage: MQSLoad [-qm \"Output_QueueMng_Name\"] [-st \"sleep_time\"] [-fb \"field_break\"] [-mb \"message_break\"] [-mt \"message_tail\"] [-kmb] [-ms \"message_skip\"] [-mc \"message_count\"] [-rc \"repeat_count\"] "); + 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 + ") Message Skip: (" + Message_Skip + ") Message Count: (" + Message_Count + ") Repeat Count: (" + Repeat_Count + ")"); + } + + + + + + //------------------------------------------------------------------------------------------------------------------------- + // + //------------------------------------------------------------------------------------------------------------------------- + + private void Print_Args( ) throws Exception + { + System.out.println( "Output QueueMng Name: (" + QMng_Name + ") Output MsgQueue Name: (" + MsgQ_Name + ") Input File Name: (" + File_Name + ")"); + 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 + ") Message Skip: (" + Message_Skip + ") Message Count: (" + Message_Count + ") Repeat Count: (" + Repeat_Count + ")"); + } - System.exit( 1); - } - else - { - System.out.println( "MQS Load Starting..."); - - Arg_Parse( args); - - System.out.println( "Output QueueMng Name: (" + QMng_Name + ") Output MsgQueue Name: (" + MsgQ_Name + ") Input File Name: (" + File_Name + ")"); - 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(); - try - { - BufferedInputStream input_file = new BufferedInputStream( new FileInputStream( File_Name)); + + + //------------------------------------------------------------------------------------------------------------------------- + // + //------------------------------------------------------------------------------------------------------------------------- + + public MQSLoad( String args[]) + { + int msg_nb = 0; + int loop; + long time_begin, time_end; + double time_elapsed, speed; + NumberFormat nf = NumberFormat.getInstance(); + + + try + { + System.out.println("MQSLoad: " + MQSLoad_Tag + " / " + MQSLoad_Date + " / " + MQSLoad_Author); + + if( ( args.length < 2) || ( args.length > 19)) + { + Print_Usage(); + System.exit( 1); + } + else + { + System.out.println( "MQS Load Starting..."); + + Arg_Parse( args); + + Print_Args(); + + MQSInit(); + + try + { + RandomAccessFile input_file = new RandomAccessFile( File_Name, "r"); - try - { + try + { // System.out.println("Input File Open: (" + input_file + ") !"); - time_begin = System.currentTimeMillis(); - msg_nb = Load_File( input_file); - time_end = System.currentTimeMillis(); + time_begin = System.currentTimeMillis(); + + for( loop = 0; loop < Repeat_Count; loop++ ) + { + try + { + input_file.seek(0); + } + + catch( Exception Expt) + { + if( Repeat_Count > 1) + { + System.out.println( "Repeat Count should be 1 for non seekable file !"); + throw Expt; + } + } + + msg_nb = Load_File( input_file, Message_Skip, Message_Count, msg_nb); + } + + time_end = System.currentTimeMillis(); - time_elapsed = ( time_end - time_begin) / 1000.0; - speed = msg_nb / time_elapsed; + time_elapsed = ( time_end - time_begin) / 1000.0; + speed = msg_nb / time_elapsed; - nf.setMinimumFractionDigits(2); - nf.setMaximumFractionDigits(2); + nf.setMinimumFractionDigits(2); + nf.setMaximumFractionDigits(2); - System.out.println( "Loaded Message Nb: (" + msg_nb - + ") Elapsed Time: (" + nf.format(time_elapsed) - + ") s Speed: (" + nf.format(speed) - + ") msg/s"); - } + System.out.println( "\n"); + System.out.println( "Loaded Message Nb: (" + msg_nb + + ") Elapsed Time: (" + nf.format(time_elapsed) + + ") s Speed: (" + nf.format(speed) + + ") msg/s"); + } - catch( Exception Expt) - { - input_file.close(); - throw Expt; - } + catch( Exception Expt) + { + input_file.close(); + throw Expt; + } - input_file.close(); - } + input_file.close(); + } - catch( Exception Expt) - { - MQSDeInit(); - throw Expt; - } + catch( Exception Expt) + { + MQSDeInit(); + throw Expt; + } - MQSDeInit(); - System.out.println( "MQS Load Completed !"); + MQSDeInit(); + System.out.println( "MQS Load Completed !"); - System.exit( 0); - } - } + System.exit( 0); + } + } - catch( Exception Expt) - { - System.out.println("Exception: (" + Expt + ") !"); - Expt.printStackTrace(); + catch( Exception Expt) + { + System.out.println("Exception: (" + Expt + ") !"); + Expt.printStackTrace(); - System.exit( 1); - } - } + System.exit( 1); + } + } + + + + //------------------------------------------------------------------------------------------------------------------------- + } diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt index 8552a93..403ca3c 100644 --- a/ReleaseNotes.txt +++ b/ReleaseNotes.txt @@ -1,13 +1,25 @@ # $RCSfile: ReleaseNotes.txt,v $ -# $Revision: 1.11 $ +# $Revision: 1.12 $ # $Name: $ -# $Date: 2008/11/14 00:00:51 $ +# $Date: 2008/12/04 10:45:06 $ # $Author: agibert $ +-------------------------------------------------------------------------------- +MQSLoad V 2.0.0 - A. Gibert - 2008/12/03 +-------------------------------------------------------------------------------- + +- Major code cleanup, +- Add message skip option "-ms", +- Add message count option "-mc", +- Add repeat count option "-rc", +- Fix Java 1.4 compatibility. + + + -------------------------------------------------------------------------------- MQSLoad V 1.3.2 - A. Gibert - 2008/11/14 --------------------------------------------------------------------------------