Source:
<code>public void onStatusUpdate(PTOperator oper) { for (StatsListener l : oper.statsListeners) { final StatsListener.Response rsp; <START> if (l instanceof StatsListener.StatsListenerWithContext) { <END> rsp = ((StatsListener.StatsListenerWithContext)l).processStats(oper.stats, statsListenerContext); } else { rsp = l.processStats(oper.stats); } if (rsp != null) { oper.loadIndicator = rsp.loadIndicator; if (rsp.repartitionRequired) { final OperatorMeta om = oper.getOperatorMeta(); if (this.pendingRepartition.putIfAbsent(om, om) != null) { LOG.debug("Skipping repartitioning for load {}", oper, oper.loadIndicator); } else { LOG.debug("Scheduling repartitioning for load {}", oper, oper.loadIndicator); Runnable r = new Runnable() { @Override public void run() { redoPartitions(logicalToPTOperator.get(om), rsp.repartitionNote); pendingRepartition.remove(om); } }; ctx.dispatch(r); } } if (rsp.operatorRequests != null) { for (OperatorRequest cmd : rsp.operatorRequests) { StramToNodeRequest request = new StramToNodeRequest(); request.operatorId = oper.getId(); request.requestType = StramToNodeRequest.RequestType.CUSTOM; request.cmd = cmd; ctx.addOperatorRequest(oper, request); } } if (rsp.operatorCommands != null) { for (@SuppressWarnings("deprecation") com.datatorrent.api.StatsListener.OperatorCommand cmd : rsp.operatorCommands) { StramToNodeRequest request = new StramToNodeRequest(); request.operatorId = oper.getId(); request.requestType = StramToNodeRequest.RequestType.CUSTOM; OperatorCommandConverter converter = new OperatorCommandConverter(); converter.cmd = cmd; request.cmd = converter; ctx.addOperatorRequest(oper, request); } } } } }</code><technical_language>internally handle listeners new interface adapt interface adapter? deprecate interface</technical_language>

Target:
public void onStatusUpdate(PTOperator oper) { for (StatsListenerWithContext l : oper.statsListeners) { final StatsListener.Response rsp = l.processStats(oper.stats, statsListenerContext); if (rsp != null) { oper.loadIndicator = rsp.loadIndicator; if (rsp.repartitionRequired) { final OperatorMeta om = oper.getOperatorMeta(); if (this.pendingRepartition.putIfAbsent(om, om) != null) { LOG.debug("Skipping repartitioning for load {}", oper, oper.loadIndicator); } else { LOG.debug("Scheduling repartitioning for load {}", oper, oper.loadIndicator); Runnable r = new Runnable() { @Override public void run() { redoPartitions(logicalToPTOperator.get(om), rsp.repartitionNote); pendingRepartition.remove(om); } }; ctx.dispatch(r); } } if (rsp.operatorRequests != null) { for (OperatorRequest cmd : rsp.operatorRequests) { StramToNodeRequest request = new StramToNodeRequest(); request.operatorId = oper.getId(); request.requestType = StramToNodeRequest.RequestType.CUSTOM; request.cmd = cmd; ctx.addOperatorRequest(oper, request); } } if (rsp.operatorCommands != null) { for (@SuppressWarnings("deprecation") com.datatorrent.api.StatsListener.OperatorCommand cmd : rsp.operatorCommands) { StramToNodeRequest request = new StramToNodeRequest(); request.operatorId = oper.getId(); request.requestType = StramToNodeRequest.RequestType.CUSTOM; OperatorCommandConverter converter = new OperatorCommandConverter(); converter.cmd = cmd; request.cmd = converter; ctx.addOperatorRequest(oper, request); } } } } }