@PostConstruct @Override public void init() { super.init(); }
@PreDestroy public void shutdown() { logger.info("Shutting down the self registration service"); if (subscription != null) { subscription.unsubscribe(); } cleanUpResources(); }
@Override public void call() { logger.info("Eureka server shutdown requested."); logger.info("Unregistering itself from the registry..."); selfRegistrationService.shutdown(); logger.info("Shutting down service container..."); lifecycleManager.close(); } });
@SuppressWarnings("unchecked") @PostConstruct public void connect() { selfRegistrationService.resolve().subscribe(new Subscriber<InstanceInfo>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { logger.error("failed to connect bridge channel, cannot resolve self instanceInfo", e); } @Override public void onNext(InstanceInfo self) { logger.info("Starting bridge service"); BridgeChannel channel = new BridgeChannel( registry, discoveryClient, config.getRefreshRateSec(), self, metricFactory.getBridgeChannelMetrics()); if (channelRef.compareAndSet(null, channel)) { channel.connect(); } else { logger.debug("No op, already connected"); } } }); }
resolverSubscription = selfRegistrationService.resolve() .flatMap(new Func1<InstanceInfo, Observable<ChangeNotification<InetSocketAddress>>>() { @Override
@PostConstruct public void startRegistryAuditing() { InstanceInfo auditServer = serverIdentity.resolve().toBlocking().firstOrDefault(null); final String auditServerId = auditServer == null ? null : auditServer.getId(); // TODO: this should be only Origin.Local, but since bridge works on replication channel we would not audit eureka 1.0 entries. registry.forInterest(Interests.forFullRegistry()).subscribe(new Subscriber<ChangeNotification<InstanceInfo>>() { @Override public void onCompleted() { logger.warn("Registry auditing finished"); } @Override public void onError(Throwable e) { logger.warn("Registry auditing finished due to an error in interest channel subscription", e); } @Override public void onNext(ChangeNotification<InstanceInfo> notification) { AuditRecord record = AuditRecords.forChangeNotification(auditServerId, System.currentTimeMillis(), false, notification); auditService.write(record); } }); } }
@PostConstruct @Override public void init() { super.init(); }
@PostConstruct public void start() { shutdownListener = new ShutdownListener(port, new Action0() { @Override public void call() { logger.info("Eureka server shutdown requested."); logger.info("Unregistering itself from the registry..."); selfRegistrationService.shutdown(); logger.info("Shutting down service container..."); lifecycleManager.close(); } }); shutdownListener.start(); selfRegistrationService.resolve() .take(1) .doOnNext(new Action1<InstanceInfo>() { @Override public void call(InstanceInfo instanceInfo) { logger.info("Instance {} listening for shutdown on port {}", instanceInfo.getId(), getShutdownPort()); } }).subscribe(new NoOpSubscriber<>()); // logging only, so ignore errors by using a no-op subscriber }