當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。