@Override public void visit(InvokeEvent event) { int process = event.process(); pendingForProcess.put(process, event); this.lockName = event.value(); }
private Map<String, List<Event>> partitionEventsByInvokeValue(List<Event> events) { Map<String, List<Event>> partitionedEvents = new HashMap<>(); Map<Integer, String> lastInvokeValueForProcess = new HashMap<>(); for (Event event : events) { int process = event.process(); if (event instanceof InvokeEvent) { InvokeEvent invokeEvent = (InvokeEvent) event; lastInvokeValueForProcess.put(process, invokeEvent.value()); } String key = lastInvokeValueForProcess.getOrDefault(process, null); /* * Note that all InfoEvents get mapped to null */ if (event instanceof InfoEvent) { key = null; } List<Event> history = partitionedEvents.getOrDefault(key, new ArrayList<>()); history.add(event); partitionedEvents.put(key, history); } return partitionedEvents; }
+ "time {}, but another process was granted the lock between {} and {} " + "(last known time the lock was held by {})", invokeEvent.function(), invokeEvent.value(), invokeEvent.process(), invokeEvent.time(), event.time(), lastLockTime, invokeEvent.time(), invokeEvent.process());
private CheckerResult checkLockName(String lockName, List<Event> events) { boolean noOtherLock = true; boolean atLeastOneInvoke = false; for (Event event : events) { if (event instanceof InvokeEvent) { atLeastOneInvoke = true; InvokeEvent invokeEvent = (InvokeEvent) event; if (!invokeEvent.value().equals(lockName)) { noOtherLock = false; } } } if (noOtherLock && atLeastOneInvoke) { return ImmutableCheckerResult.builder() .valid(false) .errors(events) .build(); } else { return ImmutableCheckerResult.builder() .valid(true) .errors(new ArrayList<>()) .build(); } }