Thomas Vachuska
Committed by Gerrit Code Review

Enhancing intent-perf logging

Fixing defect in distributed app mgmt
Reducing DB manager heartbeat aggressiveness

Change-Id: I9ba948a2b2166625c56566502143c0d27f9a2c44
...@@ -55,9 +55,12 @@ import java.util.concurrent.Executors; ...@@ -55,9 +55,12 @@ import java.util.concurrent.Executors;
55 import java.util.concurrent.TimeUnit; 55 import java.util.concurrent.TimeUnit;
56 56
57 import static com.google.common.base.Preconditions.checkState; 57 import static com.google.common.base.Preconditions.checkState;
58 +import static java.lang.String.format;
58 import static org.apache.felix.scr.annotations.ReferenceCardinality.MANDATORY_UNARY; 59 import static org.apache.felix.scr.annotations.ReferenceCardinality.MANDATORY_UNARY;
59 import static org.onlab.util.Tools.delay; 60 import static org.onlab.util.Tools.delay;
60 import static org.onlab.util.Tools.groupedThreads; 61 import static org.onlab.util.Tools.groupedThreads;
62 +import static org.onosproject.net.intent.IntentEvent.Type.INSTALLED;
63 +import static org.onosproject.net.intent.IntentEvent.Type.WITHDRAWN;
61 import static org.slf4j.LoggerFactory.getLogger; 64 import static org.slf4j.LoggerFactory.getLogger;
62 65
63 /** 66 /**
...@@ -119,23 +122,24 @@ public class IntentPerfInstaller { ...@@ -119,23 +122,24 @@ public class IntentPerfInstaller {
119 // we will need to discard the first few results for priming and warmup 122 // we will need to discard the first few results for priming and warmup
120 listener = new Listener(); 123 listener = new Listener();
121 intentService.addListener(listener); 124 intentService.addListener(listener);
125 +
126 + long delay = System.currentTimeMillis() % REPORT_PERIOD;
122 reportTimer = new Timer("onos-intent-perf-reporter"); 127 reportTimer = new Timer("onos-intent-perf-reporter");
123 reportTimer.scheduleAtFixedRate(new TimerTask() { 128 reportTimer.scheduleAtFixedRate(new TimerTask() {
124 @Override 129 @Override
125 public void run() { 130 public void run() {
126 listener.report(); 131 listener.report();
127 } 132 }
128 - }, REPORT_PERIOD, REPORT_PERIOD); 133 + }, delay, REPORT_PERIOD);
129 134
130 stopped = false; 135 stopped = false;
131 worker.submit(() -> { 136 worker.submit(() -> {
132 - delay(2000); 137 + delay(2000); // take a breath to start
133 createIntents(NUM_KEYS, 2); //FIXME 138 createIntents(NUM_KEYS, 2); //FIXME
134 prime(); 139 prime();
135 while (!stopped) { 140 while (!stopped) {
136 cycle(); 141 cycle();
137 - // TODO delay if required 142 + delay(800); // take a breath
138 - delay(600);
139 } 143 }
140 }); 144 });
141 145
...@@ -186,7 +190,6 @@ public class IntentPerfInstaller { ...@@ -186,7 +190,6 @@ public class IntentPerfInstaller {
186 } 190 }
187 191
188 private void createIntents(int numberOfKeys, int pathLength) { 192 private void createIntents(int numberOfKeys, int pathLength) {
189 -
190 Iterator<Device> deviceItr = deviceService.getAvailableDevices().iterator(); 193 Iterator<Device> deviceItr = deviceService.getAvailableDevices().iterator();
191 194
192 Device ingressDevice = null; 195 Device ingressDevice = null;
...@@ -238,12 +241,11 @@ public class IntentPerfInstaller { ...@@ -238,12 +241,11 @@ public class IntentPerfInstaller {
238 241
239 class Listener implements IntentListener { 242 class Listener implements IntentListener {
240 243
241 - 244 + private final Map<IntentEvent.Type, Counter> counters;
242 - private Map<IntentEvent.Type, Counter> counters; 245 + private final Counter runningTotal = new Counter();
243 246
244 public Listener() { 247 public Listener() {
245 counters = initCounters(); 248 counters = initCounters();
246 -
247 } 249 }
248 250
249 private Map<IntentEvent.Type, Counter> initCounters() { 251 private Map<IntentEvent.Type, Counter> initCounters() {
...@@ -263,18 +265,21 @@ public class IntentPerfInstaller { ...@@ -263,18 +265,21 @@ public class IntentPerfInstaller {
263 265
264 public void report() { 266 public void report() {
265 StringBuilder stringBuilder = new StringBuilder(); 267 StringBuilder stringBuilder = new StringBuilder();
266 - double total = counters.get(IntentEvent.Type.INSTALLED).throughput() + 268 + Counter installed = counters.get(INSTALLED);
267 - counters.get(IntentEvent.Type.WITHDRAWN).throughput(); 269 + Counter withdrawn = counters.get(WITHDRAWN);
270 + double current = installed.throughput() + withdrawn.throughput();
271 + runningTotal.add(installed.total() + withdrawn.total());
268 for (IntentEvent.Type type : IntentEvent.Type.values()) { 272 for (IntentEvent.Type type : IntentEvent.Type.values()) {
269 stringBuilder.append(printCounter(type)).append("; "); 273 stringBuilder.append(printCounter(type)).append("; ");
270 } 274 }
271 - stringBuilder.append(String.format("TOTAL=%.2f", total)); 275 + log.info("Throughput: OVERALL={}; CURRENT={}; {}",
272 - log.info("Intent Throughput:\n{}", stringBuilder); 276 + format("%.2f", runningTotal.throughput()),
277 + format("%.2f", current), stringBuilder);
273 } 278 }
274 279
275 private String printCounter(IntentEvent.Type event) { 280 private String printCounter(IntentEvent.Type event) {
276 Counter counter = counters.get(event); 281 Counter counter = counters.get(event);
277 - String result = String.format("%s=%.2f", event, counter.throughput()); 282 + String result = format("%s=%.2f", event, counter.throughput());
278 counter.reset(); 283 counter.reset();
279 return result; 284 return result;
280 } 285 }
......
...@@ -148,7 +148,7 @@ public class ApplicationArchive ...@@ -148,7 +148,7 @@ public class ApplicationArchive
148 * archive stream or store 148 * archive stream or store
149 * the application archive 149 * the application archive
150 */ 150 */
151 - public ApplicationDescription saveApplication(InputStream stream) { 151 + public synchronized ApplicationDescription saveApplication(InputStream stream) {
152 try (InputStream ais = stream) { 152 try (InputStream ais = stream) {
153 byte[] cache = toByteArray(ais); 153 byte[] cache = toByteArray(ais);
154 InputStream bis = new ByteArrayInputStream(cache); 154 InputStream bis = new ByteArrayInputStream(cache);
...@@ -190,7 +190,7 @@ public class ApplicationArchive ...@@ -190,7 +190,7 @@ public class ApplicationArchive
190 * 190 *
191 * @param appName application name 191 * @param appName application name
192 */ 192 */
193 - public void purgeApplication(String appName) { 193 + public synchronized void purgeApplication(String appName) {
194 File appDir = new File(appsDir, appName); 194 File appDir = new File(appsDir, appName);
195 try { 195 try {
196 Tools.removeDirectory(appDir); 196 Tools.removeDirectory(appDir);
...@@ -209,7 +209,7 @@ public class ApplicationArchive ...@@ -209,7 +209,7 @@ public class ApplicationArchive
209 * @param appName application name 209 * @param appName application name
210 * @return application archive stream 210 * @return application archive stream
211 */ 211 */
212 - public InputStream getApplicationInputStream(String appName) { 212 + public synchronized InputStream getApplicationInputStream(String appName) {
213 try { 213 try {
214 File appFile = appFile(appName, appName + ".zip"); 214 File appFile = appFile(appName, appName + ".zip");
215 return new FileInputStream(appFile.exists() ? appFile : appFile(appName, APP_XML)); 215 return new FileInputStream(appFile.exists() ? appFile : appFile(appName, APP_XML));
......
...@@ -104,8 +104,8 @@ public class DatabaseManager implements StorageService { ...@@ -104,8 +104,8 @@ public class DatabaseManager implements StorageService {
104 .withReceiveBufferSize(32768) 104 .withReceiveBufferSize(32768)
105 .withSendBufferSize(8192) 105 .withSendBufferSize(8192)
106 .withThreads(1)) 106 .withThreads(1))
107 - .withElectionTimeout(300) 107 + .withElectionTimeout(3000)
108 - .withHeartbeatInterval(150) 108 + .withHeartbeatInterval(1500)
109 .withMembers(activeNodeUris) 109 .withMembers(activeNodeUris)
110 .withLocalMember(localNodeUri); 110 .withLocalMember(localNodeUri);
111 111
...@@ -114,8 +114,8 @@ public class DatabaseManager implements StorageService { ...@@ -114,8 +114,8 @@ public class DatabaseManager implements StorageService {
114 partitionMap.forEach((name, nodes) -> { 114 partitionMap.forEach((name, nodes) -> {
115 Set<String> replicas = nodes.stream().map(this::nodeToUri).collect(Collectors.toSet()); 115 Set<String> replicas = nodes.stream().map(this::nodeToUri).collect(Collectors.toSet());
116 DatabaseConfig partitionConfig = new DatabaseConfig() 116 DatabaseConfig partitionConfig = new DatabaseConfig()
117 - .withElectionTimeout(300) 117 + .withElectionTimeout(3000)
118 - .withHeartbeatInterval(150) 118 + .withHeartbeatInterval(1500)
119 .withConsistency(Consistency.STRONG) 119 .withConsistency(Consistency.STRONG)
120 .withLog(new FileLog() 120 .withLog(new FileLog()
121 .withDirectory(logDir) 121 .withDirectory(logDir)
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
4 # ----------------------------------------------------------------------------- 4 # -----------------------------------------------------------------------------
5 5
6 #export JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-7-openjdk-amd64/} 6 #export JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-7-openjdk-amd64/}
7 -export JAVA_OPTS="${JAVA_OPTS:--Xms256m -Xmx2048m}" 7 +export JAVA_OPTS="${JAVA_OPTS:--Xms256m -Xmx2g}"
8 8
9 ONOS_HOME=/opt/onos 9 ONOS_HOME=/opt/onos
10 10
......
1 +#!/bin/bash
2 +# -----------------------------------------------------------------------------
3 +# Scrapes intent performance numbers from the remote ONOS log file.
4 +# -----------------------------------------------------------------------------
5 +
6 +[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
7 +. $ONOS_ROOT/tools/build/envDefaults
8 +
9 +nodes=$(env | sort | egrep "OC[0-9]+" | cut -d= -f2)
10 +
11 +for node in $nodes; do
12 + echo "fetching from ${node}..."
13 + ssh $ONOS_USER@${node} "
14 + grep 'Throughput: OVERALL=' $ONOS_INSTALL_DIR/log/karaf.log \
15 + | sed 's/ | INFO .*\: OVERALL=/|/;s/\; INSTALL_REQ=.*//;s/\; CURRENT=/|/' | cut -c12-
16 + " > ${node}.perf.log
17 +done