/** * Constructor. */ public EventBusManagerImpl() { Home.getApp().registerPreActivateFunction(this::registerAllSubscribers); }
public static List<HealthCheck> getHealthChecks() { return Home.getApp().getDefinitionSpace().getAll(HealthCheckDefinition.class).stream() .map(HealthAnalyticsUtil::buildHealthCheck) .collect(Collectors.toList()); }
public static List<Metric> getMetrics() { return Home.getApp().getDefinitionSpace().getAll(MetricDefinition.class).stream() .flatMap(metricDefinition -> metricDefinition.getMetricSupplier().get().stream()) .collect(Collectors.toList()); }
private void registerCaches() { Home.getApp().getDefinitionSpace() .getAll(CacheDefinition.class).stream() .forEach(this::registerCache); }
/** * Démarre l'ensemble des démons préalablement enregistré dans le spaceDefinition. */ private void startAllDaemons() { Home.getApp().getDefinitionSpace().getAll(DaemonDefinition.class).stream() .forEach(this::startDaemon); }
private void registerCaches() { Home.getApp().getDefinitionSpace() .getAll(CacheDefinition.class).stream() .forEach(this::registerCache); }
/** * Construct an instance of DaemonManagerImpl. */ @Inject public DaemonManagerImpl(final AnalyticsManager analyticsManager) { Assertion.checkNotNull(analyticsManager); //--- this.analyticsManager = analyticsManager; Home.getApp().registerPreActivateFunction(this::startAllDaemons); }
private void readObject(final ObjectInputStream ois) throws ClassNotFoundException, IOException { //On récupère le nom de la définition definitionName = (String) ois.readObject(); definition = (D) Home.getApp().getDefinitionSpace().resolve(definitionName, Definition.class); } }
@Override public Optional<Node> find(final String nodeId) { if (Home.getApp().getConfig().getNodeConfig().getNodeId().equals(nodeId)) { return Optional.of(localNode); } return Optional.empty(); }
@Override public List<? extends Definition> provideDefinitions(final DefinitionSpace definitionSpace) { // we need to unwrap the component to scan the real class and not the enhanced version final AopPlugin aopPlugin = Home.getApp().getConfig().getBootConfig().getAopPlugin(); return Home.getApp().getComponentSpace().keySet() .stream() .flatMap(id -> createDaemonDefinitions(Home.getApp().getComponentSpace().resolve(id, Component.class), aopPlugin).stream()) .collect(Collectors.toList()); }
@Override public List<? extends Definition> provideDefinitions(final DefinitionSpace definitionSpace) { // we need to unwrap the component to scan the real class and not the enhanced version final AopPlugin aopPlugin = Home.getApp().getConfig().getBootConfig().getAopPlugin(); return Home.getApp().getComponentSpace().keySet() .stream() .flatMap(id -> createEventSubscriptions(id, Home.getApp().getComponentSpace().resolve(id, Component.class), aopPlugin).stream()) .collect(Collectors.toList()); }
private static CacheDefinition getCacheDefinition(final String cacheName) { return Home.getApp().getDefinitionSpace().resolve(cacheName, CacheDefinition.class); } }
@Override public void start() { nodeRegistryPlugin.register(toAppNode(Home.getApp())); }
@Override public void stop() { nodeRegistryPlugin.unregister(toAppNode(Home.getApp())); }
/** * Construct an instance of DaemonManagerImpl. */ @Inject public StartedManagerImpl() { Home.getApp().registerPreActivateFunction(() -> appPreActivated = true); }
@DaemonScheduled(name = "DMN_UPDATE_NODE_STATUS", periodInSeconds = HEART_BEAT_SECONDS, analytics = false) public void updateNodeStatus() { nodeRegistryPlugin.updateStatus(toAppNode(Home.getApp())); }
@Override public Node getCurrentNode() { final String currentNodeId = Home.getApp().getConfig().getNodeConfig().getNodeId(); return find(currentNodeId) .orElseThrow(() -> new VSystemException("Current node with '{0}' cannot be found in the registry", currentNodeId)); }
@Ignore // ignored for now we need heartbeat of node update to be parametized for shorter tests void testUpdate() throws InterruptedException { final NodeManager nodeManager = Home.getApp().getComponentSpace().resolve(NodeManager.class); // --- final Instant firstTouch = nodeManager.find("nodeTest1").get().getLastTouch(); Thread.sleep(7 * 1000L); final Instant secondTouch = nodeManager.find("nodeTest1").get().getLastTouch(); // --- Assertions.assertTrue(secondTouch.isAfter(firstTouch)); }
@Test public void testComponentSpace() { final ComponentSpace componentSpace = Home.getApp().getComponentSpace(); assertEquals(componentSpace.keySet().size(), 2 + 3); //ParamManager and ResourceManager are automaticaly declared final DiscoveryB discoveryB = componentSpace.resolve(DiscoveryB.class); //--- assertTrue(DiscoveryA.class.getName().equals(discoveryB.getClass().getName())); //--- final DiscoveryD discoveryD = componentSpace.resolve(DiscoveryD.class); assertTrue(discoveryD.isTrue()); }
@Test void testRegisterNode() { final NodeManager nodeManager = Home.getApp().getComponentSpace().resolve(NodeManager.class); final List<Node> nodesWithDbSkill = nodeManager.locateSkills("db"); final List<Node> nodesWithOtherSkill = nodeManager.locateSkills("other"); // --- Assertions.assertEquals(1, nodesWithDbSkill.size()); Assertions.assertEquals(0, nodesWithOtherSkill.size()); }