本文整理汇总了Java中org.I0Itec.zkclient.exception.ZkMarshallingError类的典型用法代码示例。如果您正苦于以下问题:Java ZkMarshallingError类的具体用法?Java ZkMarshallingError怎么用?Java ZkMarshallingError使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ZkMarshallingError类属于org.I0Itec.zkclient.exception包,在下文中一共展示了ZkMarshallingError类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.I0Itec.zkclient.exception.ZkMarshallingError; //导入依赖的package包/类
private void init() throws Exception {
zkClient = new ZkClient(HOST.concat(":" + CLIENT_PORT), TIME_OUT_MILLISECOND);
zkSerializer = new ZkSerializer() {
/**
* TODO{Benedict Jin}: kryo
*/
@Override
public byte[] serialize(Object data) throws ZkMarshallingError {
return new byte[0];
}
@Override
public Object deserialize(byte[] bytes) throws ZkMarshallingError {
return null;
}
};
// zkClient.setZkSerializer(zkSerializer);
}
示例2: deserialize
import org.I0Itec.zkclient.exception.ZkMarshallingError; //导入依赖的package包/类
public Object deserialize(final byte[] bytes) throws ZkMarshallingError {
try {
return new String(bytes, "utf-8");
} catch (final UnsupportedEncodingException e) {
throw new ZkMarshallingError(e);
}
}
示例3: serialize
import org.I0Itec.zkclient.exception.ZkMarshallingError; //导入依赖的package包/类
public byte[] serialize(final Object data) throws ZkMarshallingError {
try {
return ((String) data).getBytes("utf-8");
} catch (final UnsupportedEncodingException e) {
throw new ZkMarshallingError(e);
}
}
示例4: serialize
import org.I0Itec.zkclient.exception.ZkMarshallingError; //导入依赖的package包/类
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);
}
}
示例5: serialize
import org.I0Itec.zkclient.exception.ZkMarshallingError; //导入依赖的package包/类
@Override
public byte[] serialize(Object data) throws ZkMarshallingError {
if (!(data instanceof InputStream)) {
return new byte[0];
}
try {
return IOUtils.toByteArray((InputStream) data);
} catch (IOException e) {
if (logger.isErrorEnabled()) {
logger.error(e.getMessage(), e);
}
return new byte[0];
}
}
示例6: serialize
import org.I0Itec.zkclient.exception.ZkMarshallingError; //导入依赖的package包/类
@Override
public byte[] serialize(Object data) throws ZkMarshallingError {
try {
return data.toString().getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
throw new ZkMarshallingError(e);
}
}
示例7: deserialize
import org.I0Itec.zkclient.exception.ZkMarshallingError; //导入依赖的package包/类
@Override
public Object deserialize(byte[] bytes) throws ZkMarshallingError {
if (bytes == null)
return null;
else
try {
return new String(bytes, "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new ZkMarshallingError(e);
}
}
示例8: deserialize
import org.I0Itec.zkclient.exception.ZkMarshallingError; //导入依赖的package包/类
@Override
public Object deserialize(byte[] bytes) throws ZkMarshallingError {
if (isZKDirectBytes.get()) {
return bytes;
} else {
return ZKStringSerializer.deserialize(bytes);
}
}
示例9: serialize
import org.I0Itec.zkclient.exception.ZkMarshallingError; //导入依赖的package包/类
@Override
public byte[] serialize(Object data) throws ZkMarshallingError {
byte[] bytes = null;
try {
bytes = data.toString().getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
throw new ZkMarshallingError(e);
}
return bytes;
}
示例10: deserialize
import org.I0Itec.zkclient.exception.ZkMarshallingError; //导入依赖的package包/类
@Override
public Object deserialize(byte[] bytes) throws ZkMarshallingError {
if (bytes == null)
return null;
else
try {
return new String(bytes, "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new ZkMarshallingError(e);
}
}
示例11: deserialize
import org.I0Itec.zkclient.exception.ZkMarshallingError; //导入依赖的package包/类
@Override
public Object deserialize(byte[] abyte0) throws ZkMarshallingError {
try {
return new String(abyte0, "utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
}
示例12: serialize
import org.I0Itec.zkclient.exception.ZkMarshallingError; //导入依赖的package包/类
@Override
public byte[] serialize(Object obj) throws ZkMarshallingError {
try {
return ((String) obj).getBytes("utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
}
示例13: deserialize
import org.I0Itec.zkclient.exception.ZkMarshallingError; //导入依赖的package包/类
@Override
public Object deserialize(byte[] abyte0) throws ZkMarshallingError {
try {
return new String(abyte0, "utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
}
示例14: serialize
import org.I0Itec.zkclient.exception.ZkMarshallingError; //导入依赖的package包/类
@Override
public byte[] serialize(Object obj) throws ZkMarshallingError {
try {
return ((String) obj).getBytes("utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
}
示例15: deserialize
import org.I0Itec.zkclient.exception.ZkMarshallingError; //导入依赖的package包/类
public Object deserialize(byte[] abyte0) throws ZkMarshallingError {
try {
return new String(abyte0, this.encoding);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}