DataTrace.java

Go to the documentation of this file.
00001 package edu.rice.cs.hpc.traceviewer.data.db;
00002 
00003 import java.io.IOException;
00004 import java.io.PrintStream;
00005 import java.nio.ByteBuffer;
00006 import java.nio.channels.FileChannel;
00007 
00008 import edu.rice.cs.hpc.data.db.DataCommon;
00009 
00010 /*******************************************************************************
00011  * 
00012  * Class to read data trace from file (via DataCommon) and store the info
00013  * 
00014  * User needs to use open() method to start opening the file
00015  *
00016  *******************************************************************************/
00017 public class DataTrace extends DataCommon 
00018 {
00019     private final static String TRACE_NAME = "hpctoolkit trace metrics";
00020 
00021     long index_start, index_length;
00022     long trace_start, trace_length;
00023     long min_time,    max_time;
00024 
00025     int  size_offset, size_length;
00026     int  size_gtid,   size_time;
00027     int  size_cctid;
00028     
00029     public DataTrace() {
00030     }
00031 
00032     @Override
00033     protected boolean isTypeFormatCorrect(long type) {
00034         return type == 2;
00035     }
00036 
00037     @Override
00038     protected boolean isFileHeaderCorrect(String header) {
00039         return header.compareTo(TRACE_NAME) >= 0;
00040     }
00041 
00042     @Override
00043     protected boolean readNext(FileChannel input)
00044             throws IOException
00045     {
00046         ByteBuffer buffer = ByteBuffer.allocate(256);
00047         int numBytes      = input.read(buffer);
00048         if (numBytes > 0) 
00049         {
00050             buffer.flip();
00051             
00052             index_start  = buffer.getLong();
00053             index_length = buffer.getLong();
00054             
00055             trace_start  = buffer.getLong();
00056             trace_length = buffer.getLong();
00057             
00058             min_time = buffer.getLong();
00059             max_time = buffer.getLong();
00060             
00061             size_offset = buffer.getInt();
00062             size_length = buffer.getInt();
00063             size_gtid   = buffer.getInt();
00064             size_time   = buffer.getInt();
00065             size_cctid  = buffer.getInt();
00066         }
00067         
00068         return true;
00069     }
00070 
00071     public void read(int rank, long index)
00072     {
00073         
00074     }
00075     
00076     @Override
00077     public void printInfo( PrintStream out)
00078     {
00079         super.printInfo(out);
00080         out.println("Min time: " + min_time);
00081         out.println("Max time: " + max_time);
00082         
00083         out.println("index start: " + index_start);
00084         out.println("index length: " + index_length);
00085         
00086         out.println(" trace start: " + trace_start + "\n trace length: " + trace_length);
00087         
00088         out.println("size offset: " + size_offset);
00089         out.println("size length: " + size_length);
00090         out.println("size time: " + size_time);
00091         out.println("size cctid: " + size_cctid + "\n size gtid: " + size_gtid);
00092     }
00093 
00094     /***************************
00095      * unit test 
00096      * 
00097      * @param argv
00098      ***************************/
00099     public static void main(String []argv)
00100     {
00101         DataTrace trace_data = new DataTrace();
00102         try {
00103             trace_data.open("/Users/laksonoadhianto/work/data/new-prof/hpctoolkit-trace-database-32465/trace.db");          
00104             trace_data.printInfo(System.out);
00105             
00106         } catch (IOException e) {
00107             // TODO Auto-generated catch block
00108             e.printStackTrace();
00109         }
00110     }
00111 }

Generated on 5 May 2015 for HPCVIEWER by  doxygen 1.6.1