当前位置: 首页>>代码示例>>Java>>正文


Java CuratorFramework.getState方法代码示例

本文整理汇总了Java中org.apache.curator.framework.CuratorFramework.getState方法的典型用法代码示例。如果您正苦于以下问题:Java CuratorFramework.getState方法的具体用法?Java CuratorFramework.getState怎么用?Java CuratorFramework.getState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.curator.framework.CuratorFramework的用法示例。


在下文中一共展示了CuratorFramework.getState方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: TopicPartition

import org.apache.curator.framework.CuratorFramework; //导入方法依赖的package包/类
/**
 * 在拉完全量后将此schema的kafka consumer的offset设置为最新
 * @param dbSchema
 */
/*public void setKafkaOffsetToLargest(String targetTopic){
	if(targetTopic==null)
		return;
	TopicPartition partition0 = new TopicPartition(targetTopic, 0);
	KafkaConsumerContainer.getInstances().getConsumer(targetTopic).seekToEnd(Arrays.asList(partition0));
}*/

protected <T> T deserialize(String path, Class<T> clazz) throws Exception {
    T packet = null;
    CuratorFramework curator = CuratorContainer.getInstance().getCurator();
    if (curator.getState() == CuratorFrameworkState.STOPPED) {
        LOG.info("[EventContainer] CuratorFrameworkState:{}", CuratorFrameworkState.STOPPED.name());
    } else {
        byte[] bytes = curator.getData().forPath(path);
        if (bytes != null && bytes.length != 0) {
            packet = JsonUtil.fromJson(new String(bytes, Charset.forName("UTF-8")),  clazz);
        }
    }
    return packet;
}
 
开发者ID:BriData,项目名称:DBus,代码行数:25,代码来源:EventContainer.java

示例2: logout

import org.apache.curator.framework.CuratorFramework; //导入方法依赖的package包/类
/**
 * 关闭注册
 */
@Override
public synchronized void logout() {
	CuratorFramework client = (CuratorFramework) regCenter.getRawClient();
	if (client.getState() == CuratorFrameworkState.STARTED) {
		// 移除注册节点
		regCenter.remove(nodePath.getWorkerIdPath());
		// 关闭连接
		regCenter.close();
	}
}
 
开发者ID:imadcn,项目名称:idworker,代码行数:14,代码来源:ZookeeperWorkerRegister.java

示例3: deserialize

import org.apache.curator.framework.CuratorFramework; //导入方法依赖的package包/类
protected <T> T deserialize(String path, Class<T> clazz) throws Exception {
    T packet = null;
    CuratorFramework curator = CuratorContainer.getInstance().getCurator();
    if (curator.getState() == CuratorFrameworkState.STOPPED) {
        LOG.info("[control-event] CuratorFrameworkState:{}", CuratorFrameworkState.STOPPED.name());
    } else {
        byte[] bytes = curator.getData().forPath(path);
        if (bytes != null && bytes.length != 0) {
            packet = JsonUtil.fromJson(new String(bytes, Charset.forName("UTF-8")),  clazz);
        }
    }
    return packet;
}
 
开发者ID:BriData,项目名称:DBus,代码行数:14,代码来源:AbstractEvent.java

示例4: saveZk

import org.apache.curator.framework.CuratorFramework; //导入方法依赖的package包/类
protected void saveZk(String node, String packet) {
    try {
        CuratorFramework curator = CuratorContainer.getInstance().getCurator();
        if (curator.getState() == CuratorFrameworkState.STOPPED) {
            LOG.info("[control-event] CuratorFrameworkState:{}", CuratorFrameworkState.STOPPED.name());
        } else {
            curator.setData().forPath(node, packet.getBytes());
        }
    } catch (Exception e) {
        LOG.error("[control-event] 报错znode: " + node + ",数据包:" + packet + "失败!", e);
    }
}
 
开发者ID:BriData,项目名称:DBus,代码行数:13,代码来源:AbstractEvent.java

示例5: saveZk

import org.apache.curator.framework.CuratorFramework; //导入方法依赖的package包/类
protected void saveZk(String node, String packet) {
    try {
        CuratorFramework curator = CuratorContainer.getInstance().getCurator();
        if (curator.getState() == CuratorFrameworkState.STOPPED) {
            LOG.info("[EventContainer] CuratorFrameworkState:{}", CuratorFrameworkState.STOPPED.name());
        } else {
            curator.setData().forPath(node, packet.getBytes());
        }
    } catch (Exception e) {
        LOG.error("[control-event] 报错znode: " + node + ",数据包:" + packet + "失败!", e);
    }
}
 
开发者ID:BriData,项目名称:DBus,代码行数:13,代码来源:EventContainer.java


注:本文中的org.apache.curator.framework.CuratorFramework.getState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。