All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nepxion.discovery.common.zookeeper.proccessor.ZookeeperProcessor Maven / Gradle / Ivy

Go to download

Nepxion Discovery is a solution for Spring Cloud with blue green, gray, weight, limitation, circuit breaker, degrade, isolation, monitor, tracing, dye, failover, async agent

The newest version!
package com.nepxion.discovery.common.zookeeper.proccessor;

/**
 * 

Title: Nepxion Discovery

*

Description: Nepxion Discovery

*

Copyright: Copyright (c) 2017-2050

*

Company: Nepxion

* @author Haojun Ren * @version 1.0 */ import javax.annotation.PostConstruct; import org.springframework.beans.factory.annotation.Autowired; import com.nepxion.discovery.common.entity.ConfigType; import com.nepxion.discovery.common.processor.DiscoveryConfigProcessor; import com.nepxion.discovery.common.zookeeper.operation.ZookeeperListener; import com.nepxion.discovery.common.zookeeper.operation.ZookeeperOperation; import com.nepxion.discovery.common.zookeeper.operation.ZookeeperSubscribeCallback; public abstract class ZookeeperProcessor extends DiscoveryConfigProcessor { @Autowired private ZookeeperOperation zookeeperOperation; private ZookeeperListener zookeeperListener; @PostConstruct public void initialize() { beforeInitialization(); String group = getGroup(); String dataId = getDataId(); logSubscribeStarted(); try { zookeeperListener = zookeeperOperation.subscribeConfig(group, dataId, new ZookeeperSubscribeCallback() { @Override public void callback(String config) { try { callbackConfig(config); } catch (Exception e) { logCallbackFailed(e); } } }); } catch (Exception e) { logSubscribeFailed(e); } logGetStarted(); try { String config = zookeeperOperation.getConfig(group, dataId); if (config != null) { callbackConfig(config); } else { logNotFound(); } } catch (Exception e) { logGetFailed(e); } afterInitialization(); } @Override public void destroy() { if (zookeeperListener == null) { return; } String group = getGroup(); String dataId = getDataId(); logUnsubscribeStarted(); try { zookeeperOperation.unsubscribeConfig(group, dataId, zookeeperListener); } catch (Exception e) { logUnsubscribeFailed(e); } } @Override public ConfigType getConfigType() { return ConfigType.ZOOKEEPER; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy