use of com.twitter.distributedlog.thrift.BKDLConfigFormat in project distributedlog by twitter.
the class BKDLConfig method deserialize.
@Override
public void deserialize(byte[] data) throws IOException {
BKDLConfigFormat configFormat = new BKDLConfigFormat();
TMemoryInputTransport transport = new TMemoryInputTransport(data);
TJSONProtocol protocol = new TJSONProtocol(transport);
try {
configFormat.read(protocol);
} catch (TException e) {
throw new IOException("Failed to deserialize data '" + new String(data, UTF_8) + "' : ", e);
}
// bookkeeper cluster settings
if (configFormat.isSetBkZkServers()) {
bkZkServersForWriter = configFormat.getBkZkServers();
}
if (configFormat.isSetBkZkServersForReader()) {
bkZkServersForReader = configFormat.getBkZkServersForReader();
} else {
bkZkServersForReader = bkZkServersForWriter;
}
if (configFormat.isSetBkLedgersPath()) {
bkLedgersPath = configFormat.getBkLedgersPath();
}
// dl zookeeper cluster settings
if (configFormat.isSetDlZkServersForWriter()) {
dlZkServersForWriter = configFormat.getDlZkServersForWriter();
}
if (configFormat.isSetDlZkServersForReader()) {
dlZkServersForReader = configFormat.getDlZkServersForReader();
} else {
dlZkServersForReader = dlZkServersForWriter;
}
// dl settings
sanityCheckTxnID = !configFormat.isSetSanityCheckTxnID() || configFormat.isSanityCheckTxnID();
encodeRegionID = configFormat.isSetEncodeRegionID() && configFormat.isEncodeRegionID();
if (configFormat.isSetAclRootPath()) {
aclRootPath = configFormat.getAclRootPath();
}
if (configFormat.isSetFirstLogSegmentSeqNo()) {
firstLogSegmentSeqNo = configFormat.getFirstLogSegmentSeqNo();
}
isFederatedNamespace = configFormat.isSetFederatedNamespace() && configFormat.isFederatedNamespace();
// Validate the settings
if (null == bkZkServersForWriter || null == bkZkServersForReader || null == bkLedgersPath || null == dlZkServersForWriter || null == dlZkServersForReader) {
throw new IOException("Missing zk/bk settings in BKDL Config : " + new String(data, UTF_8));
}
}
use of com.twitter.distributedlog.thrift.BKDLConfigFormat in project distributedlog by twitter.
the class BKDLConfig method serialize.
@Override
public String serialize() {
BKDLConfigFormat configFormat = new BKDLConfigFormat();
if (null != bkZkServersForWriter) {
configFormat.setBkZkServers(bkZkServersForWriter);
}
if (null != bkZkServersForReader) {
configFormat.setBkZkServersForReader(bkZkServersForReader);
}
if (null != dlZkServersForWriter) {
configFormat.setDlZkServersForWriter(dlZkServersForWriter);
}
if (null != dlZkServersForReader) {
configFormat.setDlZkServersForReader(dlZkServersForReader);
}
if (null != bkLedgersPath) {
configFormat.setBkLedgersPath(bkLedgersPath);
}
configFormat.setSanityCheckTxnID(sanityCheckTxnID);
configFormat.setEncodeRegionID(encodeRegionID);
if (null != aclRootPath) {
configFormat.setAclRootPath(aclRootPath);
}
if (null != firstLogSegmentSeqNo) {
configFormat.setFirstLogSegmentSeqNo(firstLogSegmentSeqNo);
}
if (isFederatedNamespace) {
configFormat.setFederatedNamespace(true);
}
return serialize(configFormat);
}
Aggregations