- Improve code structuration,

- Fix Message Count = 0 handling,
- Fix printout.
This commit is contained in:
agibert 2008-12-04 15:02:16 +00:00
parent bc2254cab8
commit 542f5b9bd6

View File

@ -1,7 +1,7 @@
// $RCSfile: MQSLoad.java,v $
// $Revision: 1.14 $
// $Revision: 1.15 $
// $Name: $
// $Date: 2008/12/04 10:45:06 $
// $Date: 2008/12/04 15:02:16 $
// $Author: agibert $
/*
@ -35,9 +35,9 @@ import com.ibm.mq.*;
public class MQSLoad
{
private String MQSLoad_Revision = "$Revision: 1.14 $";
private String MQSLoad_Revision = "$Revision: 1.15 $";
private String MQSLoad_Tag = "$Name: $";
private String MQSLoad_Date = "$Date: 2008/12/04 10:45:06 $";
private String MQSLoad_Date = "$Date: 2008/12/04 15:02:16 $";
private String MQSLoad_Author = "$Author: agibert $";
private MQQueueManager QMng = null;
private String QMng_Name = "";
@ -53,6 +53,7 @@ public class MQSLoad
private int Repeat_Count = 1;
private boolean Keep_Message_Break = false;
private String File_Name;
private int Msg_Counter = 0;
@ -431,19 +432,21 @@ public class MQSLoad
//
//-------------------------------------------------------------------------------------------------------------------------
private void Counter_Print( int Msg_Nb)
private void Counter_Print( String Mark)
{
if( ( Msg_Nb % 50) == 0)
if( ( Msg_Counter % 50) == 0)
{
System.out.print( "\n(" + Msg_Nb + ")\t");
System.out.print( "\n(" + Msg_Counter + ")\t");
}
if( ( Msg_Nb % 10) == 0)
if( ( Msg_Counter % 10) == 0)
{
System.out.print( " ");
}
System.out.print( ".");
System.out.print( Mark);
Msg_Counter++;
}
@ -480,11 +483,17 @@ public class MQSLoad
//
//-------------------------------------------------------------------------------------------------------------------------
private int Put_Msg( MQMessage Output_Msg, int Count_Nb, int Msg_Nb) throws Exception
private int Put_Msg( MQMessage Output_Msg, int Msg_Id, int Msg_Nb, int Msg_Skip, int Msg_Count) throws Exception
{
if( Msg_Nb > Count_Nb)
if( Msg_Id < Msg_Skip)
{
// System.out.print( "#");
Counter_Print( "*");
}
else
{
if( ( Msg_Count != 0) && ( Msg_Id >= ( Msg_Skip + Msg_Count)))
{
Counter_Print( "#");
}
else
{
@ -492,10 +501,13 @@ public class MQSLoad
MQSPut_Msg( Output_Msg);
Output_Msg.clearMessage();
Counter_Print( Msg_Nb++);
Counter_Print( ".");
Msg_Nb++;
Stand_By( Sleep_Time);
}
}
return(Msg_Nb);
}
@ -508,14 +520,13 @@ public class MQSLoad
//
//-------------------------------------------------------------------------------------------------------------------------
private int Load_File( RandomAccessFile Input_File, int Msg_Skip, int Msg_Count, int Msg_Nb) throws Exception
private int Load_File( RandomAccessFile Input_File, int Msg_Nb, int Msg_Skip, int Msg_Count) throws Exception
{
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;
int msg_id = 0;
byte[] buffer_byte;
String buffer_string, out_string = null;
@ -609,17 +620,10 @@ public class MQSLoad
output_msg.writeString( Message_Break);
}
// System.out.println( "(" + Msg_Nb + ")");
Msg_Nb = Put_Msg( output_msg, msg_id, Msg_Nb, Msg_Skip, Msg_Count);
if( skip_nb < Msg_Skip)
{
skip_nb++;
// System.out.print( "*");
}
else
{
Msg_Nb = Put_Msg( output_msg, count_nb, Msg_Nb);
}
msg_id++;
out_string = null;
cur_pos += Message_Break.length();
}
@ -639,7 +643,7 @@ public class MQSLoad
if( out_string != null)
{
// System.out.println( "* Flushing Msg");
Msg_Nb = Put_Msg( output_msg, count_nb, Msg_Nb);
Msg_Nb = Put_Msg( output_msg, msg_id, Msg_Nb, Msg_Skip, Msg_Count);
}
return( Msg_Nb);
@ -741,7 +745,7 @@ public class MQSLoad
}
}
msg_nb = Load_File( input_file, Message_Skip, Message_Count, msg_nb);
msg_nb = Load_File( input_file, msg_nb, Message_Skip, Message_Count);
}
time_end = System.currentTimeMillis();