/** * Check event counters in the ControllerBB shared map. For example, if baseKey is * ControllerBB.NumForcedDiscEventsKey and vmList is a list containing vmId 2, and expectedCount * is 1, then the event count of key with base NumForcedDiscEvents plus vmId 2 is expected to be * 1, and any other key found in the map that is prefixed by baseKey should have value be 0. * Throws an exception if the conditions are not satisfied. * * @param baseKey The base string of the key to check (the prefix to the vm id) * @param vmList The vms (ClientVmInfo) for the baseKey should have a value of expectedCount. * @param expectedCount The expected value of any baseKeys that refer to the given vmIds, * otherwise the expectedCount is 0. */ public static void checkEventCounters(String baseKey, List vmList, int expectedCount) { Map aMap = ControllerBB.getBB().getSharedMap().getMap(); Iterator it = aMap.keySet().iterator(); while (it.hasNext()) { String key = (String) (it.next()); if (key.startsWith(baseKey)) { // found a key prefixed by baseKey int value = ((Integer) (aMap.get(key))).intValue(); // value for the key boolean foundInVmIdList = false; for (int i = 0; i < vmList.size(); i++) { int vmId = ((Integer) ((ClientVmInfo) (vmList.get(i))).getVmid()).intValue(); if (key.endsWith("_" + vmId)) { // found a baseKey with a vmid in the vmList foundInVmIdList = true; if (value != expectedCount) { throw new TestException( "Expected value for BB key " + key + " to be " + expectedCount + " but it is " + value); } } } if (!foundInVmIdList) { // this key's value should be 0 if (value != 0) { throw new TestException( "Expected value for BB key " + key + " to be 0 but it is " + value); } } } } }
/** With data from pRowToClone */ public List makeRow(List pRowToClone) { // note: -1 indicates that the number of fields is not fixed if (mNumFields != -1 && pRowToClone.size() != mNumFields) { throw new RuntimeException( "Cannot make row: numFiedlds = " + mNumFields + " != numTokens = " + pRowToClone.size()); } return new ArrayList(pRowToClone); }
/** Start all cqs running for this VM, and create a CQHistory instance for each CQ. */ private void startCQsWithHistory() { initializeQueryService(); CqAttributesFactory cqFac = new CqAttributesFactory(); cqFac.addCqListener(new CQHistoryListener()); cqFac.addCqListener(new CQGatherListener()); CqAttributes cqAttr = cqFac.create(); Iterator it = queryMap.keySet().iterator(); while (it.hasNext()) { String queryName = (String) (it.next()); String query = (String) (queryMap.get(queryName)); try { CqQuery cq = qService.newCq(queryName, query, cqAttr); CQHistory history = new CQHistory(cq.getName()); CQHistoryListener.recordHistory(history); Log.getLogWriter() .info( "Creating CQ with name " + queryName + ": " + query + ", cq attributes: " + cqAttr); Log.getLogWriter().info("Calling executeWithInitialResults on " + cq); CqResults rs = cq.executeWithInitialResults(); SelectResults sr = CQUtil.getSelectResults(rs); if (sr == null) { throw new TestException( "For cq " + cq + " with name " + cq.getName() + " executeWithInitialResults returned " + sr); } Log.getLogWriter() .info( "Done calling executeWithInitializResults on " + cq + " with name " + queryName + ", select results size is " + sr.size()); history.setSelectResults(sr); logNumOps(); // log the select results List srList = sr.asList(); StringBuffer aStr = new StringBuffer(); aStr.append("SelectResults returned from " + queryName + " is\n"); for (int i = 0; i < srList.size(); i++) { aStr.append(srList.get(i) + "\n"); } Log.getLogWriter().info(aStr.toString()); } catch (CqExistsException e) { throw new TestException(TestHelper.getStackTrace(e)); } catch (RegionNotFoundException e) { throw new TestException(TestHelper.getStackTrace(e)); } catch (CqException e) { throw new TestException(TestHelper.getStackTrace(e)); } } }
public List<Temp> use() { List<Temp> answer = empty; for (IRExp k : kids()) { List<Temp> kuse = k.use(); for (Temp t : kuse) { if (!answer.contains(t)) answer = List.cons(t, answer); } } return answer; }
List<Instr> codegen(List<Stm> body) { List<Instr> l = null, t = null; for (; body != null; body = body.tail) { munchStm(body.head); if (l == null) l = ilist; else t.tail = ilist; t = last; ilist = last = null; } return l; }
public abstract class IRStm extends DefaultIndentable implements IRNode { // The book implements these methods on most statements public abstract List<IRExp> kids(); public abstract IRStm build(List<IRExp> kids); static final List<Temp> empty = List.empty(); /** * Simulate the execution of an atomic IRStm. The statement may return a Label if its execution * causes an explicit transfer of control, or it may return null for an implicit transfer of * control to the next statement. */ public abstract Label interp(X86_64SimFrame frame); /** * Is this particular statement a kind of jump (to be more precise, is it a statement that * transfers control explicitly rather than "fall" into the next statement implicitly. */ public boolean isJump() { return false; // Most statements aren't jumps. We must not forget to override // this method for those that are! } public boolean isMove() { return false; } /** * If this statement is a kind of JUMP, then this method should be implemented and it should * return a List of possible jump targets. * * <p>This method is used by the TraceScheduling algorithm. The order in which the jumptargets are * returned ... */ public List<Label> getJumpTargets() { return List.empty(); } public boolean mentions(Temp t) { for (IRExp k : kids()) { if (k.mentions(t)) return true; } return false; } public List<Temp> use() { List<Temp> answer = empty; for (IRExp k : kids()) { List<Temp> kuse = k.use(); for (Temp t : kuse) { if (!answer.contains(t)) answer = List.cons(t, answer); } } return answer; } public List<Temp> def() { return empty; } public List<Label> jumps() { return getJumpTargets(); } public boolean mentionsMemOrCall() { for (IRExp k : kids()) { if (k.mentionsMemOrCall()) return true; } return false; } }
/** * If this statement is a kind of JUMP, then this method should be implemented and it should * return a List of possible jump targets. * * <p>This method is used by the TraceScheduling algorithm. The order in which the jumptargets are * returned ... */ public List<Label> getJumpTargets() { return List.empty(); }
/** * Verify the result of the CQs registered for this VM. Query results from * executeWithInitialResults are combined with subsequent cq events to form the final result. */ protected void verifyQueryResultsCombine() { Log.getLogWriter().info("In verifyQueryResultsCombine"); Iterator it = queryMap.keySet().iterator(); int count = 0; while (it.hasNext()) { count++; String cqName = (String) (it.next()); Log.getLogWriter() .info("Verifying query " + count + " out of " + queryMap.size() + " with name " + cqName); CqQuery cq = qService.getCq(cqName); String queryStr = cq.getQueryString(); String readableQueryStr = CQTest.getReadableQueryString(queryStr); // combine the initial selectResults with history of events CQHistory history = CQHistoryListener.getCQHistory(cqName); Map combinedMap = history.getCombinedResults(); List combinedList = new ArrayList(combinedMap.values()); List expectedResults = CQTestInstance.getExpectedResults(queryStr); List missingInCombined = new ArrayList(expectedResults); List unexpectedInCombined = new ArrayList(combinedList); unexpectedInCombined.removeAll(expectedResults); missingInCombined.removeAll(combinedList); // prepare error Strings StringBuffer aStr = new StringBuffer(); if (unexpectedInCombined.size() > 0) { String tmpStr = getLocationString(unexpectedInCombined, expectedResults, history) + "\n" + "Found the following " + unexpectedInCombined.size() + " unexpected elements in combined results for cq " + cqName + ", " + readableQueryStr + ": " + QueryObject.toStringFull(unexpectedInCombined); Log.getLogWriter().info(tmpStr); aStr.append(tmpStr); } if (missingInCombined.size() > 0) { String tmpStr = getLocationString(missingInCombined, expectedResults, history) + "\n" + "The following " + missingInCombined.size() + " elements were missing from combined results for cq " + cqName + ", " + readableQueryStr + ": " + QueryObject.toStringFull(missingInCombined); Log.getLogWriter().info(tmpStr); aStr.append(tmpStr); } if (aStr.length() > 0) { throw new TestException( "Probably bug 38065: For cq " + cqName + ", " + readableQueryStr + "\n" + aStr.toString()); } } Log.getLogWriter().info("Done verifying " + count + " queries"); }
/** * Given a List of QueryObjects known to be inconsistent as determined by validation, log where * the suspect objects are found by checking for it in 1) the expected List 2) the CQ history of * events 3) the select results 4) the localRegion * * @param inconsistencies A List of suspect QueryObjects to check in each location. * @param expected The expected List of objects for a query. * @param history The CQHistory for the query * @returns */ private String getLocationString(List inconsistencies, List expected, CQHistory history) { StringBuffer aStr = new StringBuffer(); for (int i = 0; i < inconsistencies.size(); i++) { QueryObject suspect = (QueryObject) (inconsistencies.get(i)); // check the local region boolean found = false; Iterator it = aRegion.keySet().iterator(); while (it.hasNext()) { Object key = it.next(); Region.Entry entry = aRegion.getEntry(key); QueryObject qo = (QueryObject) (entry.getValue()); if ((qo != null) && (qo.equals(suspect))) { found = true; aStr.append( qo.toStringAbbreviated() + " was found in " + aRegion.getFullPath() + " at key " + key + "\n"); } } if (!found) { aStr.append( suspect.toStringAbbreviated() + " was NOT found in " + aRegion.getFullPath() + "\n"); } // seach for all occurrences in expected list found = false; it = expected.iterator(); while (it.hasNext()) { QueryObject qo = (QueryObject) (it.next()); if (qo.equals(suspect)) { found = true; aStr.append(qo.toStringAbbreviated() + " was found in expected results\n"); } } if (!found) { aStr.append(suspect.toStringAbbreviated() + " was NOT found in expected results\n"); } // seach for all occurrences in selectResults SelectResults selResults = history.getSelectResults(); found = false; it = selResults.iterator(); while (it.hasNext()) { QueryObject qo = (QueryObject) (it.next()); if (qo.equals(suspect)) { found = true; aStr.append(qo.toStringAbbreviated() + " was found in SelectResults\n"); } } if (!found) { aStr.append(suspect.toStringAbbreviated() + " was NOT found in SelectResults\n"); } // seach for all occurrences in history found = false; List eventList = history.getEvents(); for (int j = 0; j < eventList.size(); j++) { CqEvent event = (CqEvent) (eventList.get(j)); QueryObject qo = (QueryObject) (event.getNewValue()); if ((qo != null) && (qo.equals(suspect))) { found = true; aStr.append( qo.toStringAbbreviated() + " was found in event history as new value " + event + "\n"); } } if (!found) { aStr.append(suspect.toStringAbbreviated() + " was NOT found in CqEvent history\n"); } } return aStr.toString(); }
private void emit(Instr inst) { if (last != null) last = last.tail = new List<Instr>(inst, null); else last = ilist = new List<Instr>(inst, null); }