//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);