本文整理了Java中com.github.ltsopensource.zookeeper.serializer.ZkSerializer
类的一些代码示例,展示了ZkSerializer
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZkSerializer
类的具体详情如下:
包路径:com.github.ltsopensource.zookeeper.serializer.ZkSerializer
类名称:ZkSerializer
暂无
代码示例来源:origin: ltsopensource/light-task-scheduler
@SuppressWarnings("unchecked")
@Override
public <T> T getData(String path) {
try {
return (T) zkSerializer.deserialize(client.getData().forPath(path));
} catch (Exception e) {
throw new IllegalStateException(e.getMessage(), e);
}
}
代码示例来源:origin: ltsopensource/light-task-scheduler
private byte[] serialize(Object data) {
return serializer.serialize(data);
}
代码示例来源:origin: ltsopensource/light-task-scheduler
private byte[] serialize(Object data) {
return serializer.serialize(data);
}
代码示例来源:origin: ltsopensource/light-task-scheduler
@SuppressWarnings("unchecked")
@Override
public <T> T getData(String path) {
try {
return (T) zkSerializer.deserialize(client.getData().forPath(path));
} catch (Exception e) {
throw new IllegalStateException(e.getMessage(), e);
}
}
代码示例来源:origin: ltsopensource/light-task-scheduler
@Override
public void setData(String path, Object data) {
byte[] zkDataBytes;
if (data instanceof Serializable) {
zkDataBytes = zkSerializer.serialize(data);
} else {
zkDataBytes = (byte[]) data;
}
try {
client.setData().forPath(path, zkDataBytes);
} catch (Exception e) {
throw new IllegalStateException(e.getMessage(), e);
}
}
代码示例来源:origin: ltsopensource/light-task-scheduler
@Override
public <T> T getData(String path) {
// 暂时不watch data change 所以第二个参数为false
try {
byte[] data = zk.getData(path, false, null);
return (T) serializer.deserialize(data);
} catch (KeeperException e) {
throw new ZkException(e);
} catch (InterruptedException e) {
throw new ZkInterruptedException(e);
}
}
代码示例来源:origin: ltsopensource/light-task-scheduler
@Override
public void setData(String path, Object data) {
byte[] zkDataBytes;
if (data instanceof Serializable) {
zkDataBytes = zkSerializer.serialize(data);
} else {
zkDataBytes = (byte[]) data;
}
try {
client.setData().forPath(path, zkDataBytes);
} catch (Exception e) {
throw new IllegalStateException(e.getMessage(), e);
}
}
代码示例来源:origin: ltsopensource/light-task-scheduler
@Override
public <T> T getData(String path) {
// 暂时不watch data change 所以第二个参数为false
try {
byte[] data = zk.getData(path, false, null);
return (T) serializer.deserialize(data);
} catch (KeeperException e) {
throw new ZkException(e);
} catch (InterruptedException e) {
throw new ZkInterruptedException(e);
}
}
代码示例来源:origin: ltsopensource/light-task-scheduler
@Override
protected String createPersistent(String path, Object data, boolean sequential) {
try {
if (sequential) {
byte[] zkDataBytes;
if (data instanceof Serializable) {
zkDataBytes = zkSerializer.serialize(data);
} else {
zkDataBytes = (byte[]) data;
}
return client.create().withMode(CreateMode.PERSISTENT_SEQUENTIAL).forPath(path, zkDataBytes);
} else {
return client.create().withMode(CreateMode.PERSISTENT).forPath(path);
}
} catch (KeeperException.NodeExistsException e) {
return path;
} catch (Exception e) {
throw new IllegalStateException(e.getMessage(), e);
}
}
代码示例来源:origin: com.github.ltsopensource/lts-core
@SuppressWarnings("unchecked")
@Override
public <T> T getData(String path) {
try {
return (T) zkSerializer.deserialize(client.getData().forPath(path));
} catch (Exception e) {
throw new IllegalStateException(e.getMessage(), e);
}
}
代码示例来源:origin: ltsopensource/light-task-scheduler
@Override
protected String createEphemeral(String path, Object data, boolean sequential) {
try {
if (sequential) {
byte[] zkDataBytes;
if (data instanceof Serializable) {
zkDataBytes = zkSerializer.serialize(data);
} else {
zkDataBytes = (byte[]) data;
}
return client.create().withMode(CreateMode.EPHEMERAL_SEQUENTIAL).forPath(path, zkDataBytes);
} else {
return client.create().withMode(CreateMode.EPHEMERAL).forPath(path);
}
} catch (KeeperException.NodeExistsException e) {
return path;
} catch (Exception e) {
throw new IllegalStateException(e.getMessage(), e);
}
}
代码示例来源:origin: com.github.ltsopensource/lts-core
@Override
public <T> T getData(String path) {
// 暂时不watch data change 所以第二个参数为false
try {
byte[] data = zk.getData(path, false, null);
return (T) serializer.deserialize(data);
} catch (KeeperException e) {
throw new ZkException(e);
} catch (InterruptedException e) {
throw new ZkInterruptedException(e);
}
}
代码示例来源:origin: ltsopensource/light-task-scheduler
@Override
protected String createPersistent(String path, Object data, boolean sequential) {
try {
if (sequential) {
byte[] zkDataBytes;
if (data instanceof Serializable) {
zkDataBytes = zkSerializer.serialize(data);
} else {
zkDataBytes = (byte[]) data;
}
return client.create().withMode(CreateMode.PERSISTENT_SEQUENTIAL).forPath(path, zkDataBytes);
} else {
return client.create().withMode(CreateMode.PERSISTENT).forPath(path);
}
} catch (KeeperException.NodeExistsException e) {
return path;
} catch (Exception e) {
throw new IllegalStateException(e.getMessage(), e);
}
}
代码示例来源:origin: ltsopensource/light-task-scheduler
@Override
protected String createEphemeral(String path, Object data, boolean sequential) {
try {
if (sequential) {
byte[] zkDataBytes;
if (data instanceof Serializable) {
zkDataBytes = zkSerializer.serialize(data);
} else {
zkDataBytes = (byte[]) data;
}
return client.create().withMode(CreateMode.EPHEMERAL_SEQUENTIAL).forPath(path, zkDataBytes);
} else {
return client.create().withMode(CreateMode.EPHEMERAL).forPath(path);
}
} catch (KeeperException.NodeExistsException e) {
return path;
} catch (Exception e) {
throw new IllegalStateException(e.getMessage(), e);
}
}
代码示例来源:origin: ltsopensource/light-task-scheduler
@Override
public void setData(String path, Object data) {
byte[] bytes = serializer.serialize(data);
try {
zk.setData(path, bytes, -1);
} catch (KeeperException e) {
throw new ZkException(e);
} catch (InterruptedException e) {
throw new ZkInterruptedException(e);
}
}
代码示例来源:origin: ltsopensource/light-task-scheduler
@Override
public void setData(String path, Object data) {
byte[] bytes = serializer.serialize(data);
try {
zk.setData(path, bytes, -1);
} catch (KeeperException e) {
throw new ZkException(e);
} catch (InterruptedException e) {
throw new ZkInterruptedException(e);
}
}
代码示例来源:origin: com.github.ltsopensource/lts-core
private byte[] serialize(Object data) {
return serializer.serialize(data);
}
代码示例来源:origin: com.github.ltsopensource/lts-core
@Override
public void setData(String path, Object data) {
byte[] zkDataBytes;
if (data instanceof Serializable) {
zkDataBytes = zkSerializer.serialize(data);
} else {
zkDataBytes = (byte[]) data;
}
try {
client.setData().forPath(path, zkDataBytes);
} catch (Exception e) {
throw new IllegalStateException(e.getMessage(), e);
}
}
代码示例来源:origin: com.github.ltsopensource/lts-core
@Override
protected String createPersistent(String path, Object data, boolean sequential) {
try {
if (sequential) {
byte[] zkDataBytes;
if (data instanceof Serializable) {
zkDataBytes = zkSerializer.serialize(data);
} else {
zkDataBytes = (byte[]) data;
}
return client.create().withMode(CreateMode.PERSISTENT_SEQUENTIAL).forPath(path, zkDataBytes);
} else {
return client.create().withMode(CreateMode.PERSISTENT).forPath(path);
}
} catch (KeeperException.NodeExistsException e) {
return path;
} catch (Exception e) {
throw new IllegalStateException(e.getMessage(), e);
}
}
代码示例来源:origin: com.github.ltsopensource/lts-core
@Override
protected String createEphemeral(String path, Object data, boolean sequential) {
try {
if (sequential) {
byte[] zkDataBytes;
if (data instanceof Serializable) {
zkDataBytes = zkSerializer.serialize(data);
} else {
zkDataBytes = (byte[]) data;
}
return client.create().withMode(CreateMode.EPHEMERAL_SEQUENTIAL).forPath(path, zkDataBytes);
} else {
return client.create().withMode(CreateMode.EPHEMERAL).forPath(path);
}
} catch (KeeperException.NodeExistsException e) {
return path;
} catch (Exception e) {
throw new IllegalStateException(e.getMessage(), e);
}
}
内容来源于网络,如有侵权,请联系作者删除!