@Override public void onBusinessMethodFinish() { EventManager.post(new InvocationBusinessMethodFinishEvent(this)); }
public MemberDiscovery(List<String> configCenterUri) { if (configCenterUri != null && !configCenterUri.isEmpty()) { configServerAddresses.addAll(configCenterUri); } Collections.shuffle(configServerAddresses); EventManager.register(this); }
@Subscribe public void afterRegistryInstance(MicroserviceInstanceRegisterTask microserviceInstanceRegisterTask) { LOGGER.info("receive MicroserviceInstanceRegisterTask event, check instance Id..."); if (!StringUtils.isEmpty(RegistryUtils.getMicroserviceInstance().getInstanceId())) { LOGGER.info("instance registry succeeds for the first time, will send AFTER_REGISTRY event."); status = SCBStatus.UP; triggerEvent(EventType.AFTER_REGISTRY); EventManager.unregister(this); LOGGER.info("ServiceComb is ready."); } } });
@Override public void onBootEvent(BootEvent event) { switch (event.getEventType()) { case BEFORE_PRODUCER_PROVIDER: registerSchemas(); break; case AFTER_REGISTRY: metricsBootstrap.start(new GlobalRegistry(), EventManager.getEventBus()); break; case BEFORE_CLOSE: metricsBootstrap.shutdown(); break; default: break; } }
@Override public void onBootEvent(BootEvent event) { switch (event.getEventType()) { case BEFORE_PRODUCER_PROVIDER: registerSchemas(); break; case AFTER_REGISTRY: metricsBootstrap.start(new GlobalRegistry(), EventManager.getEventBus()); break; case BEFORE_CLOSE: metricsBootstrap.shutdown(); break; default: break; } }
/** * <p>As the process of instance registry is asynchronous, the {@code AFTER_REGISTRY} * event should not be sent immediately after {@link RegistryUtils#run()} is invoked. * When the instance registry succeeds, {@link MicroserviceInstanceRegisterTask} will be posted in {@link EventManager}, * register a subscriber to watch this event and send {@code AFTER_REGISTRY}.</p> * * <p>This method should be called before {@link RegistryUtils#run()} to avoid that the registry process is too quick * that the event is not watched by this subscriber.</p> * * <p>Check if {@code InstanceId} is null to judge whether the instance registry has succeeded.</p> */ private void triggerAfterRegistryEvent() { EventManager.register(new Object() { @Subscribe public void afterRegistryInstance(MicroserviceInstanceRegisterTask microserviceInstanceRegisterTask) { LOGGER.info("receive MicroserviceInstanceRegisterTask event, check instance Id..."); if (!StringUtils.isEmpty(RegistryUtils.getMicroserviceInstance().getInstanceId())) { LOGGER.info("instance registry succeeds for the first time, will send AFTER_REGISTRY event."); status = SCBStatus.UP; triggerEvent(EventType.AFTER_REGISTRY); EventManager.unregister(this); LOGGER.info("ServiceComb is ready."); } } }); }
@Subscribe public void afterRegistryInstance(MicroserviceInstanceRegisterTask microserviceInstanceRegisterTask) { LOGGER.info("receive MicroserviceInstanceRegisterTask event, check instance Id..."); if (!StringUtils.isEmpty(RegistryUtils.getMicroserviceInstance().getInstanceId())) { LOGGER.info("instance registry succeeds for the first time, will send AFTER_REGISTRY event."); status = SCBStatus.UP; triggerEvent(EventType.AFTER_REGISTRY); EventManager.unregister(this); LOGGER.info("ServiceComb is ready."); } } });
@Override public void onBusinessMethodStart() { invocationStageTrace.startBusinessMethod(); EventManager.post(new InvocationBusinessMethodStartEvent(this)); }
public MemberDiscovery(List<String> configCenterUri) { if (configCenterUri != null && !configCenterUri.isEmpty()) { configServerAddresses.addAll(configCenterUri); } Collections.shuffle(configServerAddresses); EventManager.register(this); }
public void onFinish(Response response) { if (finished) { // avoid to post repeated event return; } invocationStageTrace.finish(); EventManager.post(new InvocationFinishEvent(this, response)); finished = true; }
/** * <p>As the process of instance registry is asynchronous, the {@code AFTER_REGISTRY} * event should not be sent immediately after {@link RegistryUtils#run()} is invoked. * When the instance registry succeeds, {@link MicroserviceInstanceRegisterTask} will be posted in {@link EventManager}, * register a subscriber to watch this event and send {@code AFTER_REGISTRY}.</p> * * <p>This method should be called before {@link RegistryUtils#run()} to avoid that the registry process is too quick * that the event is not watched by this subscriber.</p> * * <p>Check if {@code InstanceId} is null to judge whether the instance registry has succeeded.</p> */ private void triggerAfterRegistryEvent() { EventManager.register(new Object() { @Subscribe public void afterRegistryInstance(MicroserviceInstanceRegisterTask microserviceInstanceRegisterTask) { LOGGER.info("receive MicroserviceInstanceRegisterTask event, check instance Id..."); if (!StringUtils.isEmpty(RegistryUtils.getMicroserviceInstance().getInstanceId())) { LOGGER.info("instance registry succeeds for the first time, will send AFTER_REGISTRY event."); status = SCBStatus.UP; triggerEvent(EventType.AFTER_REGISTRY); EventManager.unregister(this); LOGGER.info("ServiceComb is ready."); } } }); }
public void onStart(long start) { invocationStageTrace.start(start); initTraceId(); EventManager.post(new InvocationStartEvent(this)); }
private HeartbeatResult heartbeat() { HeartbeatResponse response = srClient.heartbeat(microserviceInstance.getServiceId(), microserviceInstance.getInstanceId()); if (response == null) { LOGGER.error("Disconnected from service center and heartbeat failed for microservice instance={}/{}", microserviceInstance.getServiceId(), microserviceInstance.getInstanceId()); EventManager.post(new HeartbeatFailEvent()); return HeartbeatResult.DISCONNECTED; } if (!response.isOk()) { LOGGER.error("Update heartbeat to service center failed, microservice instance={}/{} does not exist", microserviceInstance.getServiceId(), microserviceInstance.getInstanceId()); EventManager.post(new HeartbeatFailEvent()); return HeartbeatResult.INSTANCE_NOT_REGISTERED; } EventManager.post(new HeartbeatSuccEvent()); return HeartbeatResult.SUCCESS; } }
new TypeReference<LinkedHashMap<String, Map<String, String>>>() { })); EventManager.post(new ConnSuccEvent()); } catch (IOException e) { EventManager.post(new ConnFailEvent( "config update result parse fail " + e.getMessage())); LOGGER.error("Config update from {} failed. Error message is [{}].", } else if (rsp.statusCode() == HttpResponseStatus.NOT_MODIFIED.code()) { EventManager.post(new ConnSuccEvent()); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Updating remote config is done. the revision {} has no change", latch.countDown(); }); EventManager.post(new ConnFailEvent("fetch config fail")); LOGGER.error("Config update from {} failed.", configcenter); null)))); request.exceptionHandler(e -> { EventManager.post(new ConnFailEvent("fetch config fail")); LOGGER.error("Config update from {} failed. Error message is [{}].", configcenter,
@Override public void onBusinessMethodFinish() { EventManager.post(new InvocationBusinessMethodFinishEvent(this)); }
@Override public void onBusinessMethodStart() { invocationStageTrace.startBusinessMethod(); EventManager.post(new InvocationBusinessMethodStartEvent(this)); }
public void onFinish(Response response) { if (finished) { // avoid to post repeated event return; } invocationStageTrace.finish(); EventManager.post(new InvocationFinishEvent(this, response)); finished = true; }
public void onStart(long start) { invocationStageTrace.start(start); initTraceId(); EventManager.post(new InvocationStartEvent(this)); }