gpt4 book ai didi

org.apache.hadoop.hbase.zookeeper.ZKUtil.convert()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-16 01:42:40 29 4
gpt4 key购买 nike

本文整理了Java中org.apache.hadoop.hbase.zookeeper.ZKUtil.convert()方法的一些代码示例,展示了ZKUtil.convert()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKUtil.convert()方法的具体详情如下:
包路径:org.apache.hadoop.hbase.zookeeper.ZKUtil
类名称:ZKUtil
方法名:convert

ZKUtil.convert介绍

[英]Convert a DeserializationException to a more palatable KeeperException. Used when can't let a DeserializationException out w/o changing public API.
[中]将反序列化异常转换为更容易接受的KeeperException。当无法在不更改公共API的情况下释放反序列化异常时使用。

代码示例

代码示例来源:origin: apache/hbase

public static String readClusterIdZNode(ZKWatcher watcher)
 throws KeeperException {
 if (ZKUtil.checkExists(watcher, watcher.getZNodePaths().clusterIdZNode) != -1) {
  byte [] data;
  try {
   data = ZKUtil.getData(watcher, watcher.getZNodePaths().clusterIdZNode);
  } catch (InterruptedException e) {
   Thread.currentThread().interrupt();
   return null;
  }
  if (data != null) {
   try {
    return ClusterId.parseFrom(data).toString();
   } catch (DeserializationException e) {
    throw ZKUtil.convert(e);
   }
  }
 }
 return null;
}

代码示例来源:origin: apache/hbase

throw ke;
} catch (DeserializationException e) {
 throw ZKUtil.convert(e);

代码示例来源:origin: apache/hbase

throw ZKUtil.convert(e);
} catch (InterruptedException e) {
 Thread.currentThread().interrupt();

代码示例来源:origin: apache/hbase

private TableState.State getTableStateInZK(ZKWatcher watcher, final TableName tableName)
   throws KeeperException, IOException, InterruptedException {
  String znode = ZNodePaths.joinZNode(watcher.getZNodePaths().tableZNode,
      tableName.getNameAsString());
  byte [] data = ZKUtil.getData(watcher, znode);
  if (data == null || data.length <= 0) {
   return null;
  }
  try {
   ProtobufUtil.expectPBMagicPrefix(data);
   ZooKeeperProtos.DeprecatedTableState.Builder builder =
     ZooKeeperProtos.DeprecatedTableState.newBuilder();
   int magicLen = ProtobufUtil.lengthOfPBMagic();
   ProtobufUtil.mergeFrom(builder, data, magicLen, data.length - magicLen);
   return TableState.State.valueOf(builder.getState().toString());
  } catch (IOException e) {
   KeeperException ke = new KeeperException.DataInconsistencyException();
   ke.initCause(e);
   throw ke;
  } catch (DeserializationException e) {
   throw ZKUtil.convert(e);
  }
 }
}

代码示例来源:origin: harbby/presto-connectors

private static RegionTransition getRegionTransition(final byte [] bytes) throws KeeperException {
 try {
  return RegionTransition.parseFrom(bytes);
 } catch (DeserializationException e) {
  // Convert to a zk exception for now.  Otherwise have to change API
  throw ZKUtil.convert(e);
 }
}

代码示例来源:origin: harbby/presto-connectors

public static String readClusterIdZNode(ZooKeeperWatcher watcher)
throws KeeperException {
 if (ZKUtil.checkExists(watcher, watcher.clusterIdZNode) != -1) {
  byte [] data;
  try {
   data = ZKUtil.getData(watcher, watcher.clusterIdZNode);
  } catch (InterruptedException e) {
   Thread.currentThread().interrupt();
   return null;
  }
  if (data != null) {
   try {
    return ClusterId.parseFrom(data).toString();
   } catch (DeserializationException e) {
    throw ZKUtil.convert(e);
   }
  }
 }
 return null;
}

代码示例来源:origin: org.apache.hbase/hbase-zookeeper

public static String readClusterIdZNode(ZKWatcher watcher)
 throws KeeperException {
 if (ZKUtil.checkExists(watcher, watcher.getZNodePaths().clusterIdZNode) != -1) {
  byte [] data;
  try {
   data = ZKUtil.getData(watcher, watcher.getZNodePaths().clusterIdZNode);
  } catch (InterruptedException e) {
   Thread.currentThread().interrupt();
   return null;
  }
  if (data != null) {
   try {
    return ClusterId.parseFrom(data).toString();
   } catch (DeserializationException e) {
    throw ZKUtil.convert(e);
   }
  }
 }
 return null;
}

代码示例来源:origin: harbby/presto-connectors

/**
 * start a state tracker to check whether this peer is enabled or not
 *
 * @param zookeeper zk watcher for the local cluster
 * @param peerStateNode path to zk node which stores peer state
 * @throws KeeperException
 */
public void startStateTracker(ZooKeeperWatcher zookeeper, String peerStateNode)
  throws KeeperException {
 ensurePeerEnabled(zookeeper, peerStateNode);
 this.peerStateTracker = new PeerStateTracker(peerStateNode, zookeeper, this);
 this.peerStateTracker.start();
 try {
  this.readPeerStateZnode();
 } catch (DeserializationException e) {
  throw ZKUtil.convert(e);
 }
}

代码示例来源:origin: harbby/presto-connectors

/**
 * Gets table state from ZK.
 * @param zkw ZooKeeperWatcher instance to use
 * @param tableName table we're checking
 * @return Null or {@link ZooKeeperProtos.Table.State} found in znode.
 * @throws KeeperException
 */
private ZooKeeperProtos.Table.State getTableState(final ZooKeeperWatcher zkw,
                         final TableName tableName)
 throws KeeperException, InterruptedException {
 String znode = ZKUtil.joinZNode(zkw.tableZNode, tableName.getNameAsString());
 byte [] data = ZKUtil.getData(zkw, znode);
 if (data == null || data.length <= 0) return null;
 try {
  ProtobufUtil.expectPBMagicPrefix(data);
  ZooKeeperProtos.Table.Builder builder = ZooKeeperProtos.Table.newBuilder();
  int magicLen = ProtobufUtil.lengthOfPBMagic();
  ProtobufUtil.mergeFrom(builder, data, magicLen, data.length - magicLen);
  return builder.getState();
 } catch (IOException e) {
  KeeperException ke = new KeeperException.DataInconsistencyException();
  ke.initCause(e);
  throw ke;
 } catch (DeserializationException e) {
  throw ZKUtil.convert(e);
 }
}

代码示例来源:origin: harbby/presto-connectors

/**
  * @param zkw ZooKeeperWatcher instance to use
  * @param tableName table we're checking
  * @return Null or {@link ZooKeeperProtos.Table.State} found in znode.
  * @throws KeeperException
  */
 static ZooKeeperProtos.Table.State getTableState(final ZooKeeperWatcher zkw,
   final TableName tableName)
   throws KeeperException, InterruptedException {
  String znode = ZKUtil.joinZNode(zkw.tableZNode, tableName.getNameAsString());
  byte [] data = ZKUtil.getData(zkw, znode);
  if (data == null || data.length <= 0) return null;
  try {
   ProtobufUtil.expectPBMagicPrefix(data);
   ZooKeeperProtos.Table.Builder builder = ZooKeeperProtos.Table.newBuilder();
   int magicLen = ProtobufUtil.lengthOfPBMagic();
   ProtobufUtil.mergeFrom(builder, data, magicLen, data.length - magicLen);
   return builder.getState();
  } catch (IOException e) {
   KeeperException ke = new KeeperException.DataInconsistencyException();
   ke.initCause(e);
   throw ke;
  } catch (DeserializationException e) {
   throw ZKUtil.convert(e);
  }
 }
}

代码示例来源:origin: harbby/presto-connectors

throw ZKUtil.convert(e);
} catch (InterruptedException e) {
 Thread.currentThread().interrupt();

代码示例来源:origin: org.apache.hbase/hbase-zookeeper

throw ZKUtil.convert(e);
} catch (InterruptedException e) {
 Thread.currentThread().interrupt();

代码示例来源:origin: org.apache.hbase/hbase-server

private TableState.State getTableStateInZK(ZKWatcher watcher, final TableName tableName)
   throws KeeperException, IOException, InterruptedException {
  String znode = ZNodePaths.joinZNode(watcher.getZNodePaths().tableZNode,
      tableName.getNameAsString());
  byte [] data = ZKUtil.getData(watcher, znode);
  if (data == null || data.length <= 0) {
   return null;
  }
  try {
   ProtobufUtil.expectPBMagicPrefix(data);
   ZooKeeperProtos.DeprecatedTableState.Builder builder =
     ZooKeeperProtos.DeprecatedTableState.newBuilder();
   int magicLen = ProtobufUtil.lengthOfPBMagic();
   ProtobufUtil.mergeFrom(builder, data, magicLen, data.length - magicLen);
   return TableState.State.valueOf(builder.getState().toString());
  } catch (IOException e) {
   KeeperException ke = new KeeperException.DataInconsistencyException();
   ke.initCause(e);
   throw ke;
  } catch (DeserializationException e) {
   throw ZKUtil.convert(e);
  }
 }
}

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com