/** * Stops a supervisor with a given id and then removes it from the list. * <p/> * Caller should have acquired [lock] before invoking this method to avoid contention with other threads that may be * starting, stopping, suspending and resuming supervisors. * * @return true if a supervisor was stopped, false if there was no supervisor with this id */ private boolean possiblyStopAndRemoveSupervisorInternal(String id, boolean writeTombstone) { Pair<Supervisor, SupervisorSpec> pair = supervisors.get(id); if (pair == null) { return false; } if (writeTombstone) { metadataSupervisorManager.insert( id, new NoopSupervisorSpec(null, pair.rhs.getDataSources()) ); // where NoopSupervisorSpec is a tombstone } pair.lhs.stop(true); supervisors.remove(id); return true; }
metadataSupervisorManager.insert("id1", spec); supervisor3.start(); supervisor1.start(); metadataSupervisorManager.insert("id1", spec2); supervisor2.start(); supervisor1.stop(true); metadataSupervisorManager.insert(eq("id1"), anyObject(NoopSupervisorSpec.class)); supervisor2.stop(true); replayAll();
metadataSupervisorManager.insert("id1", spec); supervisor3.start(); supervisor1.start(); metadataSupervisorManager.insert(eq("id1"), capture(capturedInsert)); supervisor2.start(); supervisor1.stop(true); metadataSupervisorManager.insert(eq("id1"), capture(capturedInsert)); supervisor2.stop(true); supervisor1.start(); metadataSupervisorManager.insert(eq("id1"), anyObject(NoopSupervisorSpec.class)); supervisor1.stop(true); replayAll();
/** * Stops a supervisor with a given id and then removes it from the list. * <p/> * Caller should have acquired [lock] before invoking this method to avoid contention with other threads that may be * starting, stopping, suspending and resuming supervisors. * * @return true if a supervisor was stopped, false if there was no supervisor with this id */ private boolean possiblyStopAndRemoveSupervisorInternal(String id, boolean writeTombstone) { Pair<Supervisor, SupervisorSpec> pair = supervisors.get(id); if (pair == null) { return false; } if (writeTombstone) { metadataSupervisorManager.insert(id, new NoopSupervisorSpec(null, pair.rhs.getDataSources())); // where NoopSupervisorSpec is a tombstone } pair.lhs.stop(true); supervisors.remove(id); return true; }