本文整理匯總了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;
}
示例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();
}
}
示例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;
}
示例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);
}
}
示例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);
}
}