Package hitune.analysis.mapreduce

Examples of hitune.analysis.mapreduce.HiTuneKey


            //doing the filter

            //<key,value>
            //<[AttemptID/PhaseAlias/ThreadName/ThreadId/Func], [Callee,isLast]>
            HiTuneRecord valproxy = new HiTuneRecord(value);
            HiTuneKey keyproxy = new HiTuneKey(key);

            String hostname = valproxy.getHost();
            String status  = valproxy.getValue("ThreadState");
            String stack = valproxy.getValue("CallStack");
            if(stack !=null && stack.length()!=0)stack = stack.replace(" ", "");
            else stack = "";
            String attemptID = valproxy.getValue("TaskID");
            log.debug("hostname:" + hostname + " ThreadState:" + status + " stack:" + stack + " attemptID:" + attemptID);
            if(isMatched(this.nodelist,hostname)){
                if(isMatched(this.statuslist, status)){
                    for(String s : phasealias.keySet()){
                        log.debug("phasealias:" +s);

                        String phase_name = phasealias.get(s);
                        if(s==null || s.length()==0)s="";
                        Pattern p = Pattern.compile(s);
                        if(stack!=null && stack.length()!=0)stack=stack.replace(" ", "");
                        else stack="";
                        Matcher matcher = p.matcher(stack);
                        if(matcher.find()){


                            String thread_id = valproxy.getValue("ThreadID");
                            String thread_name = valproxy.getValue("ThreadName");


                            try {
                                K newkey = (K) key.getClass().getConstructor().newInstance();
                                V newvalue = (V) value.getClass().getConstructor().newInstance();

                                HiTuneRecord newvalproxy = new HiTuneRecord(newvalue);
                                HiTuneKey newkeyproxy = new HiTuneKey(newkey);

                                String[] fcs = stack.split("#");   

                                String[] funcs = new String [fcs.length+2];
                                funcs[0]="_PHASE_";                         
                                funcs[1]=getFuncPattern(stack, this.phases.get(s));

                                System.arraycopy(fcs,0,funcs,2,fcs.length);
                                for (int i =0; i< funcs.length; i++){

                                    newkeyproxy.setKey(attemptID + "/" + phase_name + "/" + thread_name + "/" + thread_id + "/" + funcs[i]);
                                    newkeyproxy.setDataType(keyproxy.getDataType());
                                    newvalproxy.copyCommonFields(value);
                                    newvalproxy.add("func", funcs[i]);
                                    newvalproxy.add("thread_id", thread_id);
                                    newvalproxy.add("thread_name", thread_name);
                                    newvalproxy.add("phase_name",phase_name );
                                    newvalproxy.add("phase_stack", s);
                                    newvalproxy.add("attempt_id", attemptID);
                                    newvalproxy.add("Callee", "1");
                                    if(i==2){
                                        newvalproxy.add("isLast", "1");
                                    }else{
                                        newvalproxy.add("isLast", "0");
                                    }
                                    output.collect((K)newkeyproxy.getObject(), (V)newvalproxy.getObject());
                                }
                            } catch (IllegalArgumentException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                                log.warn(e);
View Full Code Here


            try{
                V val = null;
                HiTuneRecord valproxy = null;
                K newkey = (K) key.getClass().getConstructor().newInstance();
                HiTuneKey newkeyproxy = new HiTuneKey(newkey);
                while(values.hasNext()){
                    val = (V)values.next();
                    valproxy = new HiTuneRecord(val);
                    callee_num += Integer.parseInt(valproxy.getValue("Callee"));
                    lastlevel_callee_num += Integer.parseInt(valproxy.getValue("isLast"));
                }

                V newvalue = (V) val.getClass().getConstructor().newInstance();
                HiTuneRecord newvalproxy = new HiTuneRecord(newvalue);
                newvalproxy.copyCommonFields(val);

                newvalproxy.add("callee_num", ""+callee_num);
                newvalproxy.add("last_level_callee_num", ""+lastlevel_callee_num );
                newvalproxy.add("attempt_id",valproxy.getValue("attempt_id") );
                newvalproxy.add("phase_name",valproxy.getValue("phase_name") );
                newvalproxy.add("phase_stack", valproxy.getValue("phase_stack") );
                newvalproxy.add("thread_name",valproxy.getValue("thread_name") );
                newvalproxy.add("thread_id",valproxy.getValue("thread_id") );
                newvalproxy.add("host", valproxy.getHost());
                newvalproxy.add("func", valproxy.getValue("func") );


                newkeyproxy.setKey(valproxy.getValue("attempt_id")
                        + "/" + valproxy.getValue("phase_name")
                        + "/" + valproxy.getValue("thread_name")
                        + "/" + valproxy.getValue("thread_id"));
                newkeyproxy.setDataType(new HiTuneKey(key).getDataType());

                output.collect((K)newkeyproxy.getObject(), (V)newvalproxy.getObject());
            } catch (IllegalArgumentException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (SecurityException e) {
                // TODO Auto-generated catch block
View Full Code Here

                OutputCollector<K, V> output,
                Reporter reporter) throws IOException {
            // TODO Auto-generated method stub
            //doing the filter

            HiTuneKey keyproxy = new HiTuneKey(key);
            HiTuneRecord valproxy = new HiTuneRecord(value);
           
           
            String device = null;       
            long timestamp = valproxy.getTime();
            String hostname = valproxy.getHost();
            String datatype = keyproxy.getDataType();
           
            log.debug("timestamp:" + timestamp + " hostname:" + hostname + " datatype:" + datatype);
            if(timestamp >= this.starttime && timestamp <= this.endtime){
//              if(datatype.equals("HiTune.Cpustat")){
//              device = value.getValue("CPU");
View Full Code Here

                Reporter reporter) throws IOException {
            // TODO Auto-generated method stub
            //doing the filter
            // Get the records of same job id
            HiTuneRecord valproxy = new HiTuneRecord(value);
            HiTuneKey keyproxy = new HiTuneKey(key);

            log.debug(key.toString());
            log.debug(value.toString());
            try {
                K newkey = (K) key.getClass().getConstructor().newInstance();
                HiTuneKey newkeyproxy = new HiTuneKey(newkey);
                String []parts = keyproxy.getDataType().split("/");
                String recordType = parts[parts.length-1];
                log.debug("record_type: " + recordType);
                if(recordType.equals("Job")){
                    newkeyproxy.setKey(valproxy.getValue("JOBID"));
                }
                else if(recordType.equals("MapAttempt")){
                    newkeyproxy.setKey(valproxy.getValue("TASK_ATTEMPT_ID"));
                }
                else if(recordType.equals("MapTask")){
                    newkeyproxy.setKey(valproxy.getValue("TASKID"));
                }
                else if(recordType.equals("ReduceAttempt")){
                    newkeyproxy.setKey(valproxy.getValue("TASK_ATTEMPT_ID"));
                }
                else if(recordType.equals("ReduceTask")){
                    newkeyproxy.setKey(valproxy.getValue("TASKID"));
                }
                if (newkeyproxy.getKey()!=null && newkeyproxy.getKey().length()!=0){
                    newkeyproxy.setDataType(keyproxy.getDataType());
                    output.collect((K) newkeyproxy.getObject(),(V) value);
                }
            } catch (IllegalArgumentException e) {
                // TODO Auto-generated catch block
                log.warn(e);
                e.printStackTrace();
View Full Code Here

                    if(val == null){
                        val = "";
                    }
                    filter.put(metric,val);
                }
                filter.put("id", new HiTuneKey(key).getKey());


                String [] fields = filter.keySet().toArray(new String[0]);
                if(!initialized){
                    newValue = new TextArrayWritable(fields);
View Full Code Here

                        try{
                            log.debug("find pattern");
                            K newkey = (K) key.getClass().getConstructor().newInstance();
                            V newval = (V) value.getClass().getConstructor().newInstance();

                            HiTuneKey newkeyproxy = new HiTuneKey(newkey);
                            HiTuneRecord newvalproxy = new HiTuneRecord(newval);

                            newkeyproxy.setKey(attemptID + "/" + s + "/" + phasealias.get(s));
                            newkeyproxy.setDataType(new HiTuneKey(key).getDataType());
                            newvalproxy.copyCommonFields(value);


                            newvalproxy.add("thread_id", valproxy.getValue("ThreadID"));
                            newvalproxy.add("thread_name", valproxy.getValue("ThreadName"));
                            newvalproxy.add("attempt_id", attemptID);
                            newvalproxy.add("phase_stack", s);
                            newvalproxy.add("phase_name", phasealias.get(s));
                            newvalproxy.add("start", "" + newvalproxy.getTime());
                            newvalproxy.add("count" , "1");
                            log.debug("status:" + conf.get("status"));
                            newvalproxy.add("statusList", conf.get("status"));
                            newvalproxy.add("statusCount", count(status, this.statuslist));

                            log.debug("funList:" + this.phases.get(s));
                            newvalproxy.add("funList", List2String(this.phases.get(s),SEPERATOR_COMMA));
                            newvalproxy.add("funCount", count(stack, this.phases.get(s)));
                            newvalproxy.add(AnalysisProcessorConfiguration.jobid, conf.get(AnalysisProcessorConfiguration.jobid));

                            log.debug("Key:" + newkeyproxy.toString() + " Record" + newkeyproxy.toString());
                            output.collect((K)newkeyproxy.getObject(), (V)newvalproxy.getObject());
                        } catch (IllegalArgumentException e) {
                            // TODO Auto-generated catch block
                            log.warn(e);
                            e.printStackTrace();
                        } catch (SecurityException e) {
View Full Code Here

TOP

Related Classes of hitune.analysis.mapreduce.HiTuneKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.