本文整理了Java中com.twitter.distributedlog.impl.metadata.ZKLogMetadata
类的一些代码示例,展示了ZKLogMetadata
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKLogMetadata
类的具体详情如下:
包路径:com.twitter.distributedlog.impl.metadata.ZKLogMetadata
类名称:ZKLogMetadata
[英]Class to represent the layout and metadata of the zookeeper-based log metadata
[中]类来表示基于zookeeper的日志元数据的布局和元数据
代码示例来源:origin: twitter/distributedlog
public String getFullyQualifiedName() {
return logMetadata.getFullyQualifiedName();
}
代码示例来源:origin: twitter/distributedlog
public void deleteLog() throws IOException {
lock.checkOwnershipAndReacquire();
FutureUtils.result(purgeLogSegmentsOlderThanTxnId(-1));
try {
Utils.closeQuietly(lock);
zooKeeperClient.get().exists(logMetadata.getLogSegmentsPath(), false);
zooKeeperClient.get().exists(logMetadata.getMaxTxIdPath(), false);
if (logMetadata.getLogRootPath().toLowerCase().contains("distributedlog")) {
ZKUtil.deleteRecursive(zooKeeperClient.get(), logMetadata.getLogRootPath());
} else {
LOG.warn("Skip deletion of unrecognized ZK Path {}", logMetadata.getLogRootPath());
}
} catch (InterruptedException ie) {
LOG.error("Interrupted while deleting log znodes", ie);
throw new DLInterruptedException("Interrupted while deleting " + logMetadata.getLogRootPath(), ie);
} catch (KeeperException ke) {
LOG.error("Error deleting" + logMetadata.getLogRootPath() + " in zookeeper", ke);
}
}
代码示例来源:origin: twitter/distributedlog
/**
* Get the log root path for a given log.
*
* @param uri
* namespace to store the log
* @param logName
* name of the log
* @param logIdentifier
* identifier of the log
* @return log root path
*/
public static String getLogRootPath(URI uri, String logName, String logIdentifier) {
return getLogComponentPath(uri, logName, logIdentifier, "");
}
代码示例来源:origin: twitter/distributedlog
@Test(timeout = 60000)
public void testGetPaths() throws Exception {
String rootPath = "/test-get-paths";
URI uri = DLMTestUtil.createDLMURI(2181, rootPath);
String logName = "test-log";
String logIdentifier = "<default>";
String logRootPath = uri.getPath() + "/" + logName + "/" + logIdentifier;
String logSegmentName = "test-segment";
ZKLogMetadata logMetadata = new ZKLogMetadata(uri, logName, logIdentifier);
assertEquals("wrong log name", logName, logMetadata.getLogName());
assertEquals("wrong root path", logRootPath, logMetadata.getLogRootPath());
assertEquals("wrong log segments path",
logRootPath + LOGSEGMENTS_PATH,
logMetadata.getLogSegmentsPath());
assertEquals("wrong log segment path",
logRootPath + LOGSEGMENTS_PATH + "/" + logSegmentName,
logMetadata.getLogSegmentPath(logSegmentName));
assertEquals("wrong lock path",
logRootPath + LOCK_PATH, logMetadata.getLockPath());
assertEquals("wrong max tx id path",
logRootPath + MAX_TXID_PATH, logMetadata.getMaxTxIdPath());
assertEquals("wrong allocation path",
logRootPath + ALLOCATION_PATH, logMetadata.getAllocationPath());
assertEquals("wrong qualified name",
logName + ":" + logIdentifier, logMetadata.getFullyQualifiedName());
}
代码示例来源:origin: twitter/distributedlog
String inprogressZNode(String inprogressZNodeName) {
return logMetadata.getLogSegmentsPath() + "/" + inprogressZNodeName;
}
}
代码示例来源:origin: twitter/distributedlog
/**
* metadata representation of a log
*
* @param uri
* namespace to store the log
* @param logName
* name of the log
* @param logIdentifier
* identifier of the log
*/
protected ZKLogMetadata(URI uri,
String logName,
String logIdentifier) {
this.uri = uri;
this.logName = logName;
this.logIdentifier = logIdentifier;
this.logRootPath = getLogRootPath(uri, logName, logIdentifier);
this.logSegmentsPath = logRootPath + LOGSEGMENTS_PATH;
this.lockPath = logRootPath + LOCK_PATH;
this.maxTxIdPath = logRootPath + MAX_TXID_PATH;
this.allocationPath = logRootPath + ALLOCATION_PATH;
}
代码示例来源:origin: twitter/distributedlog
this.notification = notification;
this.filter = filter;
this.logSegmentCache = new LogSegmentCache(metadata.getLogName());
LOG.debug("Using ZK Path {}", logMetadata.getLogRootPath());
this.bookKeeperClient = bkcBuilder.build();
this.metadataStore = metadataStore;
.registerChildWatcher(logMetadata.getLogSegmentsPath(), this);
代码示例来源:origin: twitter/distributedlog
LOG.trace("Got ledger list from {} : {}", logMetadata.getLogSegmentsPath(), children);
final AtomicInteger numFailures = new AtomicInteger(0);
for (final String segment: segmentsAdded) {
metadataStore.getLogSegment(logMetadata.getLogSegmentPath(segment))
.addEventListener(new FutureEventListener<LogSegmentMetadata>() {
代码示例来源:origin: twitter/distributedlog
/**
* Get the znode path for the inprogressZNode
*/
String inprogressZNode(long ledgerId, long firstTxId, long logSegmentSeqNo) {
return logMetadata.getLogSegmentsPath() + "/" + inprogressZNodeName(ledgerId, firstTxId, logSegmentSeqNo);
}
代码示例来源:origin: twitter/distributedlog
Optional<String> parentPathShouldNotCreate = Optional.of(logMetadata.getLogRootPath());
Utils.zkAsyncCreateFullPathOptimisticRecursive(zooKeeperClient, readLockPath, parentPathShouldNotCreate,
new byte[0], zooKeeperClient.getDefaultACL(), CreateMode.PERSISTENT,
代码示例来源:origin: twitter/distributedlog
/**
* Get the znode path for a finalize ledger
*/
String completedLedgerZNode(long firstTxId, long lastTxId, long logSegmentSeqNo) {
return String.format("%s/%s", logMetadata.getLogSegmentsPath(),
completedLedgerZNodeName(firstTxId, lastTxId, logSegmentSeqNo));
}
代码示例来源:origin: twitter/distributedlog
final boolean ownAllocator,
final boolean createIfNotExists) {
final String logRootPath = ZKLogMetadata.getLogRootPath(uri, logName, logIdentifier);
try {
PathUtils.validatePath(logRootPath);
代码示例来源:origin: twitter/distributedlog
/**
* Get the logsegments root path for a given log.
*
* @param uri
* namespace to store the log
* @param logName
* name of the log
* @param logIdentifier
* identifier of the log
* @return logsegments root path
*/
public static String getLogSegmentsPath(URI uri, String logName, String logIdentifier) {
return getLogComponentPath(uri, logName, logIdentifier, LOGSEGMENTS_PATH);
}
代码示例来源:origin: twitter/distributedlog
private void checkLogStreamExists() throws IOException {
try {
if (null == Utils.sync(zooKeeperClient, logMetadata.getLogSegmentsPath())
.exists(logMetadata.getLogSegmentsPath(), false)) {
throw new LogNotFoundException("Log " + getFullyQualifiedName() + " doesn't exist");
}
} catch (InterruptedException ie) {
LOG.error("Interrupted while reading {}", logMetadata.getLogSegmentsPath(), ie);
throw new DLInterruptedException("Interrupted while checking "
+ logMetadata.getLogSegmentsPath(), ie);
} catch (KeeperException ke) {
LOG.error("Error checking existence for {} : ", logMetadata.getLogSegmentsPath(), ke);
throw new ZKException("Error checking existence for " + getFullyQualifiedName() + " : ", ke);
}
}
代码示例来源:origin: twitter/distributedlog
@Test(timeout = 60000)
public void testCreateLogMetadataMissingLockPath() throws Exception {
URI uri = DLMTestUtil.createDLMURI(zkPort, "");
String logName = testName.getMethodName();
String logIdentifier = "<default>";
String logRootPath = getLogRootPath(uri, logName, logIdentifier);
List<String> pathsToDelete = Lists.newArrayList(
logRootPath + LOCK_PATH);
testCreateLogMetadataWithMissingPaths(uri, logName, logIdentifier, pathsToDelete, false, true);
}
代码示例来源:origin: twitter/distributedlog
@Override
public Future<Void> asyncClose() {
// No-op
this.zooKeeperClient.getWatcherManager().unregisterChildWatcher(logMetadata.getLogSegmentsPath(), this);
return Future.Void();
}
代码示例来源:origin: twitter/distributedlog
@Test(timeout = 60000)
public void testCreateLogMetadataMissingReadLockPath() throws Exception {
URI uri = DLMTestUtil.createDLMURI(zkPort, "");
String logName = testName.getMethodName();
String logIdentifier = "<default>";
String logRootPath = getLogRootPath(uri, logName, logIdentifier);
List<String> pathsToDelete = Lists.newArrayList(
logRootPath + READ_LOCK_PATH);
testCreateLogMetadataWithMissingPaths(uri, logName, logIdentifier, pathsToDelete, false, true);
}
代码示例来源:origin: twitter/distributedlog
try {
final ZooKeeper zk = zooKeeperClient.get();
zk.sync(logMetadata.getLogSegmentsPath(), new AsyncCallback.VoidCallback() {
@Override
public void processResult(int syncRc, String path, Object syncCtx) {
LOG.error("Interrupted while reading {}", logMetadata.getLogSegmentsPath(), ie);
promise.setException(new DLInterruptedException("Interrupted while checking "
+ logMetadata.getLogSegmentsPath(), ie));
} catch (ZooKeeperClient.ZooKeeperConnectionException e) {
promise.setException(e);
代码示例来源:origin: twitter/distributedlog
@Test(timeout = 60000)
public void testCreateLogMetadataMissingLogSegmentsPath() throws Exception {
URI uri = DLMTestUtil.createDLMURI(zkPort, "");
String logName = testName.getMethodName();
String logIdentifier = "<default>";
String logRootPath = getLogRootPath(uri, logName, logIdentifier);
List<String> pathsToDelete = Lists.newArrayList(
logRootPath + LOGSEGMENTS_PATH);
testCreateLogMetadataWithMissingPaths(uri, logName, logIdentifier, pathsToDelete, false, true);
}
代码示例来源:origin: twitter/distributedlog
zooKeeperClient.get().getChildren(logMetadata.getLogSegmentsPath(), watcher, new AsyncCallback.Children2Callback() {
@Override
public void processResult(final int rc, final String path, final Object ctx, final List<String> children, final Stat stat) {
内容来源于网络,如有侵权,请联系作者删除!