本文整理了Java中org.I0Itec.zkclient.exception.ZkMarshallingError
类的一些代码示例,展示了ZkMarshallingError
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZkMarshallingError
类的具体详情如下:
包路径:org.I0Itec.zkclient.exception.ZkMarshallingError
类名称:ZkMarshallingError
暂无
代码示例来源:origin: alibaba/canal
public Object deserialize(final byte[] bytes) throws ZkMarshallingError {
try {
return new String(bytes, "utf-8");
} catch (final UnsupportedEncodingException e) {
throw new ZkMarshallingError(e);
}
}
代码示例来源:origin: alibaba/canal
public byte[] serialize(final Object data) throws ZkMarshallingError {
try {
if (data instanceof byte[]) {
return (byte[]) data;
} else {
return ((String) data).getBytes("utf-8");
}
} catch (final UnsupportedEncodingException e) {
throw new ZkMarshallingError(e);
}
}
代码示例来源:origin: alibaba/canal
public byte[] serialize(final Object data) throws ZkMarshallingError {
try {
return ((String) data).getBytes("utf-8");
} catch (final UnsupportedEncodingException e) {
throw new ZkMarshallingError(e);
}
}
代码示例来源:origin: weibocom/motan
@Override
public byte[] serialize(Object obj) throws ZkMarshallingError {
try {
return obj.toString().getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
throw new ZkMarshallingError(e);
}
}
}
代码示例来源:origin: killme2008/Metamorphosis
@Override
public Object deserialize(final byte[] bytes) throws ZkMarshallingError {
try {
return new String(bytes, "utf-8");
}
catch (final UnsupportedEncodingException e) {
throw new ZkMarshallingError(e);
}
}
代码示例来源:origin: killme2008/Metamorphosis
@Override
public byte[] serialize(final Object data) throws ZkMarshallingError {
try {
return ((String) data).getBytes("utf-8");
}
catch (final UnsupportedEncodingException e) {
throw new ZkMarshallingError(e);
}
}
代码示例来源:origin: weibocom/motan
@Override
public Object deserialize(byte[] bytes) throws ZkMarshallingError {
if (bytes == null){
return null;
}
try {
if (bytes.length > 1 && ByteUtil.bytes2short(bytes, 0) == ObjectStreamConstants.STREAM_MAGIC) {
return super.deserialize(bytes);
}
return new String(bytes, "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new ZkMarshallingError(e);
}
}
代码示例来源:origin: amient/kafka-metrics
@Override
public byte[] serialize(Object o) throws ZkMarshallingError {
throw new ZkMarshallingError("This is a read-only zkClient");
}
代码示例来源:origin: com.alibaba.otter/shared.common
public byte[] serialize(final Object data) throws ZkMarshallingError {
try {
return ((String) data).getBytes("utf-8");
} catch (final UnsupportedEncodingException e) {
throw new ZkMarshallingError(e);
}
}
代码示例来源:origin: com.alibaba.otter/shared.common
public byte[] serialize(final Object data) throws ZkMarshallingError {
try {
if (data instanceof byte[]) {
return (byte[]) data;
} else {
return ((String) data).getBytes("utf-8");
}
} catch (final UnsupportedEncodingException e) {
throw new ZkMarshallingError(e);
}
}
代码示例来源:origin: com.alibaba.otter/shared.common
public Object deserialize(final byte[] bytes) throws ZkMarshallingError {
try {
return new String(bytes, "utf-8");
} catch (final UnsupportedEncodingException e) {
throw new ZkMarshallingError(e);
}
}
代码示例来源:origin: amient/kafka-metrics
@Override
public Object deserialize(byte[] bytes) throws ZkMarshallingError {
try {
return mapper.readTree(bytes);
} catch (IOException e) {
throw new ZkMarshallingError(e);
}
}
});
代码示例来源:origin: variflight/feeyo-redisproxy
public byte[] serialize(final Object data) throws ZkMarshallingError {
try {
if (data instanceof byte[]) {
return (byte[]) data;
} else {
return ((String) data).getBytes("utf-8");
}
} catch (final UnsupportedEncodingException e) {
throw new ZkMarshallingError(e);
}
}
代码示例来源:origin: com.github.sgroschupf/zkclient
@Override
public Object deserialize(byte[] bytes) throws ZkMarshallingError {
try {
ObjectInputStream inputStream = new ObjectInputStream(new ByteArrayInputStream(bytes));
Object object = inputStream.readObject();
return object;
} catch (ClassNotFoundException e) {
throw new ZkMarshallingError("Unable to find object class.", e);
} catch (IOException e) {
throw new ZkMarshallingError(e);
}
}
代码示例来源:origin: com.weibo/motan-registry-zookeeper
@Override
public byte[] serialize(Object obj) throws ZkMarshallingError {
try {
return obj.toString().getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
throw new ZkMarshallingError(e);
}
}
}
代码示例来源:origin: com.101tec/zkclient
@Override
public byte[] serialize(Object serializable) throws ZkMarshallingError {
try {
ByteArrayOutputStream byteArrayOS = new ByteArrayOutputStream();
ObjectOutputStream stream = new ObjectOutputStream(byteArrayOS);
stream.writeObject(serializable);
stream.close();
return byteArrayOS.toByteArray();
} catch (IOException e) {
throw new ZkMarshallingError(e);
}
}
代码示例来源:origin: com.github.sgroschupf/zkclient
@Override
public byte[] serialize(Object serializable) throws ZkMarshallingError {
try {
ByteArrayOutputStream byteArrayOS = new ByteArrayOutputStream();
ObjectOutputStream stream = new ObjectOutputStream(byteArrayOS);
stream.writeObject(serializable);
stream.close();
return byteArrayOS.toByteArray();
} catch (IOException e) {
throw new ZkMarshallingError(e);
}
}
代码示例来源:origin: com.101tec/zkclient
@Override
public Object deserialize(byte[] bytes) throws ZkMarshallingError {
try {
ObjectInputStream inputStream = new TcclAwareObjectIputStream(new ByteArrayInputStream(bytes));
Object object = inputStream.readObject();
return object;
} catch (ClassNotFoundException e) {
throw new ZkMarshallingError("Unable to find object class.", e);
} catch (IOException e) {
throw new ZkMarshallingError(e);
}
}
代码示例来源:origin: javachen/learning-hadoop
public byte[] serialize(Object obj) throws ZkMarshallingError {
if (obj == null) {
return null;
}
if (!(obj instanceof String)) {
throw new ZkMarshallingError(
"The input obj must be an instance of String.");
}
try {
return ((String) obj).getBytes(this.encoding);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
}
代码示例来源:origin: com.weibo/motan-registry-zookeeper
@Override
public Object deserialize(byte[] bytes) throws ZkMarshallingError {
if (bytes == null){
return null;
}
try {
if (bytes.length > 1 && ByteUtil.bytes2short(bytes, 0) == ObjectStreamConstants.STREAM_MAGIC) {
return super.deserialize(bytes);
}
return new String(bytes, "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new ZkMarshallingError(e);
}
}
内容来源于网络,如有侵权,请联系作者删除!