0

I am able to parse the mlab ndt trace log files using the PcapFileInputFormat using the GitHub code located at url https://github.com/raghuveerm/MRPcapParser. I'm able to parse the fields(like TIMESTAMP) which are predefined in the "Packet.java" class.But I'm unable to add the new fields like(total_traffic,Total_Size) and parse them .Eventhough I had included the new fields in Packet.java and tried to debug the code.The debugger is not entering into the code where I had newly edited with the new fields.

    My Edited Code:
    ===============

    In PacketReader.java:(In hadoop-pcap-lib)
    ====================
(src-->main-->java-->net-->ripe-->hadoop-->pcap-->PcapReader.java)

    At Line 62: public static final int TOTAL_SIZE_OFFSET = 12;
    At Line 162: 

        long totalSize = PcapReaderUtil.convertInt(pcapPacketHeader, TOTAL_SIZE_OFFSET, reverseHeaderByteOrder);
                packet.put(Packet.TOTAL_SIZE, totalSize);

    In Packet.java:(In hadoop-pcap-lib)
    ==============
    (src-->main-->java-->net-->ripe-->hadoop-->pcap-->packet-->Packet.java)

    At Line 36: public static final String TOTAL_SIZE = "tot_size";

    My Mapper:
    =========
    package com.calsoftlabs.parse;

    import net.ripe.hadoop.pcap.packet.Packet;

    public class PcapMapper extends Mapper<LongWritable, ObjectWritable, Text, Text> {


        public void map(LongWritable arg0, ObjectWritable arg1, Context context) throws IOException,
                InterruptedException {

            Packet packet = (Packet) arg1.get();

            String clientIp = null;
            String serverIp = null;
            String timeStamp = null;
            String totalTraffic = null;
            String srcPort = null;
            String destPort = null;
            String fields = null;

            if (packet != null) {

                clientIp = packet.get(Packet.SRC).toString();
                srcPort = packet.get(Packet.SRC_PORT).toString();
                serverIp = packet.get(Packet.DST).toString();
                destPort = packet.get(Packet.DST_PORT).toString();
                timeStamp = packet.get(Packet.TIMESTAMP).toString();
                totalTraffic = packet.get(Packet.TOTAL_SIZE).toString();

                if (serverIp != null && srcPort != null && destPort != null ) {
                    fields = serverIp
                            .concat(", ").concat(srcPort)
                            .concat(", ").concat(destPort);
                            .concat(", ").concat(totalTraffic);

                }

            }

            context.write(new Text(clientIp.concat("_").concat(timeStamp).concat("::")), new Text(fields));
        }
    }

Finally,If I run a MRJob I'm getting a null pointer exception near total_traffic.Because the debugger is not at all entering into the newly edited code.How can I overcome this issue.Can anyone please suggest on this issue ...

Thanks,in advance

Inevitable
  • 43
  • 1
  • 8
  • The trick is to **read** the exception stack trace. It tells where the exception is thrown, and thus allows you to find what is null and shouldn't be at this line. – JB Nizet Feb 23 '15 at 08:01
  • In the Mapper near total_traffic I'm getting an exception.This is because in PacketReader.java at line 162 it is showing that unable to access the field "Packet.TOTAL_SIZE".But I had included "TOTAL_SIZE" field in Packet.java class. – Inevitable Feb 23 '15 at 08:04
  • Here,I'm not talking about the null pointer exception.But how can I add new fields into the already existed GitHub Code . – Inevitable Feb 23 '15 at 08:52
  • It seems you simply didn't compile the code you modified. – JB Nizet Feb 23 '15 at 08:56
  • I have compiled the code.but ,still it is unable to enter into the newly added code. – Inevitable Feb 23 '15 at 09:00
  • My issue got resolved.The issue is with compilation of code itself.Thanks for ur suggestion – Inevitable Feb 23 '15 at 11:01

0 Answers0