Joshua Garcia Daniel Popescu Gholamreza Safi William G.J. Halfond Nenad Medvidovic University of Southern California, Los Angeles, CA, USA 1
Distributed Event-Based (DEB) Systems • Financial systems, sensor networks, enterprise software, etc. DEB Application • Implemented using Message- Message-Oriented Oriented Middleware (MOM) Middleware + Highly decoupled Operating System + Non-functional properties Scalability, Adaptability, Heterogeneity - Obfuscate control and data flow - Hamper system maintenance 2
Three Sources of Maintenance Difficulties 1. Reliance on ambiguous interfaces 2. Use of attribute-based message types 3. Unclear message flow 3
Maintenance 1. Ambiguity of Interfaces Challenges: 1. Ambiguous interfaces 2. Attribute-based public class Adder extends Component{ message types … 3. Message flow public void consume(Message m) { String nameAttr = (String)m.getAttr("name"); if ("add".equals(nameAttr)) { consume Message sumMsg = this.add(m); this.publish(sumMsg);} Adder else if ("result".equals(nameAttr)){ …}} private Message add(Message m3){ Integer n1 = m3.getAttr("num1"); Integer n2 = m3.getAttr("num2"); sum = n1 + n2; Message m4 = new Message(); m4.setAttribute("name", "sum"); m4.setAttribute("val", sum); return m4;} 4
Maintenance 1. Ambiguity of Interfaces Challenges: 1. Ambiguous interfaces 2. Attribute-based public class Adder extends Component{ message types … 3. Message flow public void consume(Message m) { String nameAttr = (String)m.getAttr("name"); if ("add".equals(nameAttr)) { add result Message sumMsg = this.add(m); Message this.publish(sumMsg);} Adder Dispatching else if ("result".equals(nameAttr)){ …}} private Message add(Message m3){ Integer n1 = m3.getAttr("num1"); Integer n2 = m3.getAttr("num2"); sum = n1 + n2; Message m4 = new Message(); m4.setAttribute("name", "sum"); m4.setAttribute("val", sum); return m4;} 5
Maintenance 2. Attribute-Based Message Types Challenges: 1. Ambiguous interfaces 2. Attribute-based public class Adder extends Component{ message types … Consumed 3. Message flow public void consume(Message m) { Message String nameAttr = (String)m.getAttr("name"); “name” : “add” if ("add".equals(nameAttr)) { add result “num1” Message sumMsg = this.add(m); this.publish(sumMsg);} “num2” Adder else if ("result".equals(nameAttr)){ …}} private Message add(Message m3){ Message type is Integer n1 = m3.getAttr("num1"); scattered Integer n2 = m3.getAttr("num2"); sum = n1 + n2; Message m4 = new Message(); m4.setAttribute("name", "sum"); m4.setAttribute("val", sum); return m4;} 6
Maintenance 3. Message Flow Challenges: 1. Ambiguous interfaces 2. Attribute-based public class Adder extends Component{ message types … Consumed 3. Message flow public void consume(Message m) { Message String nameAttr = (String)m.getAttr("name"); add result “name” : “add” if ("add".equals(nameAttr)) { “num1” Message sumMsg = this.add(m); this.publish(sumMsg);} “num2” else if ("result".equals(nameAttr)){ sum …}} private Message add(Message m3){ Integer n1 = m3.getAttr("num1"); Published Integer n2 = m3.getAttr("num2"); sum = n1 + n2; Message Message m4 = new Message(); “name” : “sum” m4.setAttribute("name", "sum"); m4.setAttribute("val", sum); “ val ” return m4;} 7
Eos Goal - Determine message flow for attribute-based systems Consumed Attribute-Based MOM Message Types Specification Insight – Message Revealing statements Published Attribute-Based Eos Message Types DEB System Implementation Message Flow 8
Identifying Consumed Message Types (CMTs) • For each method m – Identify the message object that is consumed – Determine attributes extracted from the message object along program paths – Define message types based on sets of attributes 9
CMT Example public class Adder extends Component{ … Consumed public void consume(Message m) { Message String nameAttr = (String)m.getAttr("name"); add result “name” : “add” “name” if ("add".equals(nameAttr)) { “num1” Message sumMsg = this.add(m); Adder this.publish(sumMsg);} “num2” else if ("result".equals(nameAttr)){ sum …}} private Message add(Message m3){ Integer n1 = m3.getAttr("num1"); Integer n2 = m3.getAttr("num2"); sum = n1 + n2; Message m4 = new Message(); m4.setAttribute("name", "sum"); m4.setAttribute("val", sum); return m4;} 10
Identifying Published Message Types (PMTs) • For each method m – Identify creation of message objects – Determine attributes added to message objects – Track if message objects reach publish statement 11
PMT Example public class Adder extends Component{ Message … “name” : “sum” public void consume(Message m) { “ val ” String nameAttr = (String)m.getAttr("name"); add result if ("add".equals(nameAttr)) { Message sumMsg = this.add(m); Adder this.publish(sumMsg);} else if ("result".equals(nameAttr)){ sum …}} private Message add(Message m3){ Must reach Integer n1 = m3.getAttr("num1"); publish Integer n2 = m3.getAttr("num2"); statement sum = n1 + n2; Message m4 = new Message(); m4.setAttribute("name", "sum"); m4.setAttribute("val", sum); return m4;} 12
Identifying Message Flow • Message flow represented by message dependencies – Intra-flow dependencies – Inter-flow dependencies Adder add result sum sum sum Printer 13
Identifying Intra-Flow Dependencies • Goal: Within a component, identify types published as a result of types consumed • For each published message type – Identify the statement at which the type is published – Determine the consumed types that flow into the statement – Create dependencies between the consumed types and the published types 14
Intra-Flow Dependency Example public class Adder extends Component{ … Consumed public void consume(Message m) { Message String nameAttr = (String)m.getAttr("name"); add result “name” : “add” if ("add".equals(nameAttr)) { “num1” t add Message sumMsg = this.add(m); t add this.publish(sumMsg);} “num2” else if ("result".equals(nameAttr)){ sum …}} intra private Message add(Message m3){ Integer n1 = m3.getAttr("num1"); Published Integer n2 = m3.getAttr("num2"); sum = n1 + n2; Message t add t add Message m4 = new Message(); “name” : “sum” t add m4.setAttribute("name", "sum"); t add m4.setAttribute("val", sum); “ val ” t add return m4;} 15
Identifying Inter-Flow Dependencies • Goal: Identify pairs of components that communicate with each other • How: Match published and consumed types of the components • Definition of “match”: Published type provides superset of a consumed type’s attributes 16
Simple Inter-Flow Dependency Example Adder’s Published Message “name” : “sum” “ val ” Adder sum inter sum Printer Printer’s Consumed Message “name” : “sum” “ val ” 17
Subtle Inter-Flow Dependency Example Adder’s Published Message “name” : “sum” “ val ” Adder sum inter sum Printer Printer’s Consumed Message “name” : “sum” 18
All Information Identified for Example Adder Consumed Message Consumed Message “name” : “add” “name” : “result” “num1” “num2” Printer intra intra Published Published Published Message Message Message inter “name” : “sum” “name” : “sum” “name” : “ lastResult ” “ val ” “ val ” “ val ” 19
Empirical Evaluation • Accuracy in identifying message information • Execution time for Eos • Effectiveness for maintenance 20
Eos Implementation • Written in Java • Leverages Soot • Implementation is available online: http://softarch.usc.edu/wiki/doku.php?id=mfa:start 21
Subject Systems App Name App Type SLOC Comps Msg Type MOM KLAX Arcade Game 4.5K 14 attr-based c2.fw DRADEL Architectural 10.8K 8 attr-based c2.fw Analysis ERS Emergency 7.1K 11 attr-based Prism-MW Response Stoxx Stock Ticker 6.2K 4 nominal REBECA Notification jms2009-PS JMS 18.6K 4 attr-based JMS Benchmark Spark Chat Client 85K 59 nominal Smack 22
Accuracy - Setup • Check for false positives and false negatives • “Ground truth” prepared by three graduate students – Ground truth is available online: http://softarch.usc.edu/wiki/doku.php?id=mfa:start 23
Accuracy - Results 100.00% 100.00% 80.00% 80.00% 60.00% 60.00% Over 95% average precision and recall Over 95% average precision and recall 40.00% 40.00% 20.00% 20.00% 0.00% 0.00% CMT Precision CMT Recall PMT Precision PMT Recall 100.00% 80.00% 60.00% Intra-Flow 40.00% Over 93% average precision and recall Dependencies Precision 20.00% 0.00% Intra-Flow Dependencies Recall 24
Recommend
More recommend