本文整理汇总了Java中org.I0Itec.zkclient.serialize.ZkSerializer类的典型用法代码示例。如果您正苦于以下问题:Java ZkSerializer类的具体用法?Java ZkSerializer怎么用?Java ZkSerializer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ZkSerializer类属于org.I0Itec.zkclient.serialize包,在下文中一共展示了ZkSerializer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.I0Itec.zkclient.serialize.ZkSerializer; //导入依赖的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: ChainedPathZkSerializer
import org.I0Itec.zkclient.serialize.ZkSerializer; //导入依赖的package包/类
private ChainedPathZkSerializer(ZkSerializer defaultSerializer, List<ChainItem> items) {
_items = items;
// sort by longest paths first
// if two items would match one would be prefix of the other
// and the longest must be more specific
Collections.sort(_items);
_defaultSerializer = defaultSerializer;
}
示例3: ZkCacheBaseDataAccessor
import org.I0Itec.zkclient.serialize.ZkSerializer; //导入依赖的package包/类
public ZkCacheBaseDataAccessor(String zkAddress, ZkSerializer serializer, String chrootPath,
List<String> wtCachePaths, List<String> zkCachePaths, String monitorType, String monitorkey) {
ZkClient.Builder zkClientBuilder = new ZkClient.Builder();
zkClientBuilder.setZkServer(zkAddress).setSessionTimeout(ZkClient.DEFAULT_SESSION_TIMEOUT)
.setConnectionTimeout(ZkClient.DEFAULT_CONNECTION_TIMEOUT).setZkSerializer(serializer)
.setMonitorType(monitorType).setMonitorKey(monitorkey);
_zkclient = zkClientBuilder.build();
_zkclient.waitUntilConnected(ZkClient.DEFAULT_CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS);
_baseAccessor = new ZkBaseDataAccessor<>(_zkclient);
if (chrootPath == null || chrootPath.equals("/")) {
_chrootPath = null;
} else {
PathUtils.validatePath(chrootPath);
_chrootPath = chrootPath;
}
_wtCachePaths = wtCachePaths;
_zkCachePaths = zkCachePaths;
// TODO: need to make sure no overlap between wtCachePaths and zkCachePaths
// TreeMap key is ordered by key string length, so more general (i.e. short) prefix
// comes first
_cacheMap = new TreeMap<>(new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
int len1 = o1.split("/").length;
int len2 = o2.split("/").length;
return len1 - len2;
}
});
start();
}
示例4: ZKDumper
import org.I0Itec.zkclient.serialize.ZkSerializer; //导入依赖的package包/类
public ZKDumper(String zkAddress) {
client = new ZkClient(zkAddress, ZkClient.DEFAULT_CONNECTION_TIMEOUT);
ZkSerializer zkSerializer = new ByteArraySerializer();
client.setZkSerializer(zkSerializer);
filter = new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return !name.startsWith(".");
}
};
}
示例5: before
import org.I0Itec.zkclient.serialize.ZkSerializer; //导入依赖的package包/类
@Override
protected void before() throws Throwable {
tempDir.create();
zkServer = new TestingServer();
zkClient = new ZkClient("localhost:" + zkServer.getPort(), 20000, 20000, new ZkSerializer() {
@Override
public byte[] serialize(Object data) throws ZkMarshallingError {
try {
return ((String)data).getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
@Override
public Object deserialize(byte[] bytes) throws ZkMarshallingError {
if (bytes == null)
return null;
try {
return new String(bytes, "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
});
}
示例6: ZkClientx
import org.I0Itec.zkclient.serialize.ZkSerializer; //导入依赖的package包/类
public ZkClientx(String zkServers, int sessionTimeout, int connectionTimeout, ZkSerializer zkSerializer){
this(new ZooKeeperx(zkServers, sessionTimeout), connectionTimeout, zkSerializer);
}
示例7: setZkSerializer
import org.I0Itec.zkclient.serialize.ZkSerializer; //导入依赖的package包/类
public void setZkSerializer(ZkSerializer zkSerializer) {
_zkSerializer = zkSerializer;
}
示例8: BasicZkSerializer
import org.I0Itec.zkclient.serialize.ZkSerializer; //导入依赖的package包/类
public BasicZkSerializer(ZkSerializer delegate) {
_delegate = delegate;
}
示例9: Builder
import org.I0Itec.zkclient.serialize.ZkSerializer; //导入依赖的package包/类
private Builder(ZkSerializer defaultSerializer) {
_defaultSerializer = defaultSerializer;
}
示例10: ChainItem
import org.I0Itec.zkclient.serialize.ZkSerializer; //导入依赖的package包/类
ChainItem(String path, ZkSerializer serializer) {
_path = path;
_serializer = serializer;
}
示例11: setZkSerializer
import org.I0Itec.zkclient.serialize.ZkSerializer; //导入依赖的package包/类
public void setZkSerializer(ZkSerializer zkSerializer) {
_pathBasedZkSerializer = new BasicZkSerializer(zkSerializer);
}
示例12: ZkClient
import org.I0Itec.zkclient.serialize.ZkSerializer; //导入依赖的package包/类
public ZkClient(IZkConnection connection, int connectionTimeout, ZkSerializer zkSerializer) {
this(connection, connectionTimeout, new BasicZkSerializer(zkSerializer));
}
示例13: setZkSerializer
import org.I0Itec.zkclient.serialize.ZkSerializer; //导入依赖的package包/类
public Builder setZkSerializer(ZkSerializer zkSerializer) {
this._zkSerializer = new BasicZkSerializer(zkSerializer);
return this;
}
示例14: serialize
import org.I0Itec.zkclient.serialize.ZkSerializer; //导入依赖的package包/类
public byte[] serialize(ZkSerializer serializer) {
return serializer.serialize(_record);
}
示例15: ZkHelixPropertyStore
import org.I0Itec.zkclient.serialize.ZkSerializer; //导入依赖的package包/类
public ZkHelixPropertyStore(String zkAddress, ZkSerializer serializer, String chrootPath,
List<String> zkCachePaths) {
super(zkAddress, serializer, chrootPath, null, zkCachePaths, MONITOR_TYPE, chrootPath);
}