Search in sources :

Example 6 with PinpointZookeeperException

use of com.navercorp.pinpoint.common.server.cluster.zookeeper.exception.PinpointZookeeperException in project pinpoint by naver.

the class CuratorZookeeperClient method delete.

@Override
public void delete(String path) throws PinpointZookeeperException {
    checkState();
    assertPathHasLength(path);
    logger.debug("delete() started. path:{}", path);
    try {
        CuratorFramework curator = connectionManager.getCuratorFramework();
        curator.delete().forPath(path);
    } catch (KeeperException.NoNodeException noNode) {
    // skip
    } catch (Exception e) {
        ZookeeperExceptionResolver.resolveAndThrow(e);
    }
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework) KeeperException(org.apache.zookeeper.KeeperException) PinpointZookeeperException(com.navercorp.pinpoint.common.server.cluster.zookeeper.exception.PinpointZookeeperException) KeeperException(org.apache.zookeeper.KeeperException) ConnectionException(com.navercorp.pinpoint.common.server.cluster.zookeeper.exception.ConnectionException)

Example 7 with PinpointZookeeperException

use of com.navercorp.pinpoint.common.server.cluster.zookeeper.exception.PinpointZookeeperException in project pinpoint by naver.

the class CuratorZookeeperClient method getData.

@Override
public byte[] getData(String path, boolean watch) throws PinpointZookeeperException {
    checkState();
    assertPathHasLength(path);
    logger.debug("getData() started. path:{}, watch:{}", path, watch);
    try {
        CuratorFramework curator = connectionManager.getCuratorFramework();
        final GetDataBuilder data = curator.getData();
        if (watch) {
            return data.usingWatcher(zookeeperEventWatcher).forPath(path);
        } else {
            return data.forPath(path);
        }
    } catch (Exception e) {
        throw ZookeeperExceptionResolver.resolve(e);
    }
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework) GetDataBuilder(org.apache.curator.framework.api.GetDataBuilder) PinpointZookeeperException(com.navercorp.pinpoint.common.server.cluster.zookeeper.exception.PinpointZookeeperException) KeeperException(org.apache.zookeeper.KeeperException) ConnectionException(com.navercorp.pinpoint.common.server.cluster.zookeeper.exception.ConnectionException)

Example 8 with PinpointZookeeperException

use of com.navercorp.pinpoint.common.server.cluster.zookeeper.exception.PinpointZookeeperException in project pinpoint by naver.

the class FlinkClusterService method setUp.

@PostConstruct
public void setUp() {
    if (!config.isFlinkClusterEnable()) {
        logger.info("flink cluster disable.");
        return;
    }
    switch(this.serviceState.getCurrentState()) {
        case NEW:
            if (this.serviceState.changeStateInitializing()) {
                logger.info("{} initialization started.", this.getClass().getSimpleName());
                ClusterManagerWatcher watcher = new ClusterManagerWatcher(pinpointFlinkClusterPath);
                this.client = new CuratorZookeeperClient(config.getFlinkClusterZookeeperAddress(), config.getFlinkClusterSessionTimeout(), watcher);
                try {
                    this.client.connect();
                } catch (PinpointZookeeperException e) {
                    throw new RuntimeException("ZookeeperClient connect failed", e);
                }
                this.zookeeperClusterManager = new ZookeeperClusterManager(client, pinpointFlinkClusterPath, clusterConnectionManager);
                this.zookeeperClusterManager.start();
                this.serviceState.changeStateStarted();
                logger.info("{} initialization completed.", this.getClass().getSimpleName());
                if (client.isConnected()) {
                    watcher.handleConnected();
                }
            }
            break;
        case INITIALIZING:
            logger.info("{} already initializing.", this.getClass().getSimpleName());
            break;
        case STARTED:
            logger.info("{} already started.", this.getClass().getSimpleName());
            break;
        case DESTROYING:
            throw new IllegalStateException("Already destroying.");
        case STOPPED:
            throw new IllegalStateException("Already stopped.");
        case ILLEGAL_STATE:
            throw new IllegalStateException("Invalid State.");
    }
}
Also used : PinpointZookeeperException(com.navercorp.pinpoint.common.server.cluster.zookeeper.exception.PinpointZookeeperException) ZookeeperClusterManager(com.navercorp.pinpoint.collector.cluster.zookeeper.ZookeeperClusterManager) CuratorZookeeperClient(com.navercorp.pinpoint.common.server.cluster.zookeeper.CuratorZookeeperClient) PostConstruct(javax.annotation.PostConstruct)

Example 9 with PinpointZookeeperException

use of com.navercorp.pinpoint.common.server.cluster.zookeeper.exception.PinpointZookeeperException in project pinpoint by naver.

the class ZookeeperClusterDataManager method start.

@Override
public void start() {
    this.timer = createTimer();
    this.client = new CuratorZookeeperClient(connectAddress, sessionTimeout, this);
    try {
        this.client.connect();
    } catch (PinpointZookeeperException e) {
        throw new RuntimeException("ZookeeperClient connect failed", e);
    }
    if (periodicSyncTask != null) {
        this.timer.newTimeout(periodicSyncTask, periodicSyncTask.getIntervalMillis(), TimeUnit.MILLISECONDS);
    }
}
Also used : PinpointZookeeperException(com.navercorp.pinpoint.common.server.cluster.zookeeper.exception.PinpointZookeeperException) CuratorZookeeperClient(com.navercorp.pinpoint.common.server.cluster.zookeeper.CuratorZookeeperClient)

Aggregations

PinpointZookeeperException (com.navercorp.pinpoint.common.server.cluster.zookeeper.exception.PinpointZookeeperException)9 ConnectionException (com.navercorp.pinpoint.common.server.cluster.zookeeper.exception.ConnectionException)6 KeeperException (org.apache.zookeeper.KeeperException)6 CuratorFramework (org.apache.curator.framework.CuratorFramework)5 CuratorZookeeperClient (com.navercorp.pinpoint.common.server.cluster.zookeeper.CuratorZookeeperClient)3 ZookeeperClusterManager (com.navercorp.pinpoint.collector.cluster.zookeeper.ZookeeperClusterManager)1 PostConstruct (javax.annotation.PostConstruct)1 CreateBuilder (org.apache.curator.framework.api.CreateBuilder)1 GetChildrenBuilder (org.apache.curator.framework.api.GetChildrenBuilder)1 GetDataBuilder (org.apache.curator.framework.api.GetDataBuilder)1 ConnectionState (org.apache.curator.framework.state.ConnectionState)1 Stat (org.apache.zookeeper.data.Stat)1