use of com.twitter.distributedlog.metadata.BKDLConfig in project distributedlog by twitter.
the class TestDistributedLogServer method testRequestDenied.
@Test(timeout = 60000)
public void testRequestDenied() throws Exception {
String name = "request-denied";
dlClient.routingService.addHost(name, dlServer.getAddress());
AccessControlEntry ace = new AccessControlEntry();
ace.setDenyWrite(true);
ZooKeeperClient zkc = TestZooKeeperClientBuilder.newBuilder().uri(getUri()).connectionTimeoutMs(60000).sessionTimeoutMs(60000).build();
DistributedLogNamespace dlNamespace = dlServer.dlServer.getLeft().getDistributedLogNamespace();
BKDLConfig bkdlConfig = BKDLConfig.resolveDLConfig(zkc, getUri());
String zkPath = getUri().getPath() + "/" + bkdlConfig.getACLRootPath() + "/" + name;
ZKAccessControl accessControl = new ZKAccessControl(ace, zkPath);
accessControl.create(zkc);
AccessControlManager acm = dlNamespace.createAccessControlManager();
while (acm.allowWrite(name)) {
Thread.sleep(100);
}
try {
Await.result(dlClient.dlClient.write(name, ByteBuffer.wrap("1".getBytes(UTF_8))));
fail("Should fail with request denied exception");
} catch (DLException dle) {
assertEquals(StatusCode.REQUEST_DENIED, dle.getCode());
}
}
use of com.twitter.distributedlog.metadata.BKDLConfig in project distributedlog by twitter.
the class DistributedLogCluster method start.
public void start() throws Exception {
this.dlmEmulator.start();
BKDLConfig bkdlConfig = new BKDLConfig(this.dlmEmulator.getZkServers(), "/ledgers").setACLRootPath(".acl");
DLMetadata.create(bkdlConfig).update(this.dlmEmulator.getUri());
if (shouldStartProxy) {
this.dlServer = new DLServer(dlConf, this.dlmEmulator.getUri(), proxyPort);
} else {
this.dlServer = null;
}
}
use of com.twitter.distributedlog.metadata.BKDLConfig in project distributedlog by twitter.
the class TestZKLogMetadataForWriter method testCreateLogMetadataWithCustomMetadata.
@Test(timeout = 60000)
public void testCreateLogMetadataWithCustomMetadata() throws Exception {
URI uri = DLMTestUtil.createDLMURI(zkPort, "");
String logName = testName.getMethodName();
String logIdentifier = "<default>";
List<String> pathsToDelete = Lists.newArrayList();
DLMetadata.create(new BKDLConfig(zkServers, "/ledgers")).update(uri);
DistributedLogNamespace namespace = DistributedLogNamespaceBuilder.newBuilder().conf(new DistributedLogConfiguration()).uri(uri).build();
DistributedLogManager dlm = namespace.openLog(logName);
dlm.createOrUpdateMetadata(logName.getBytes("UTF-8"));
dlm.close();
testCreateLogMetadataWithMissingPaths(uri, logName, logIdentifier, pathsToDelete, true, false);
}
use of com.twitter.distributedlog.metadata.BKDLConfig in project distributedlog by twitter.
the class DLAuditor method calculateLedgerSpaceUsage.
public long calculateLedgerSpaceUsage(URI uri) throws IOException {
List<URI> uris = Lists.newArrayList(uri);
String zkServers = validateAndGetZKServers(uris);
RetryPolicy retryPolicy = new BoundExponentialBackoffRetryPolicy(conf.getZKRetryBackoffStartMillis(), conf.getZKRetryBackoffMaxMillis(), Integer.MAX_VALUE);
ZooKeeperClient zkc = ZooKeeperClientBuilder.newBuilder().name("DLAuditor-ZK").zkServers(zkServers).sessionTimeoutMs(conf.getZKSessionTimeoutMilliseconds()).retryPolicy(retryPolicy).zkAclId(conf.getZkAclId()).build();
ExecutorService executorService = Executors.newCachedThreadPool();
try {
BKDLConfig bkdlConfig = resolveBKDLConfig(zkc, uris);
logger.info("Resolved bookkeeper config : {}", bkdlConfig);
BookKeeperClient bkc = BookKeeperClientBuilder.newBuilder().name("DLAuditor-BK").dlConfig(conf).zkServers(bkdlConfig.getBkZkServersForWriter()).ledgersPath(bkdlConfig.getBkLedgersPath()).build();
try {
return calculateLedgerSpaceUsage(bkc, executorService);
} finally {
bkc.close();
}
} finally {
zkc.close();
executorService.shutdown();
}
}
use of com.twitter.distributedlog.metadata.BKDLConfig in project distributedlog by twitter.
the class DLAuditor method collectLedgers.
public Pair<Set<Long>, Set<Long>> collectLedgers(List<URI> uris, List<List<String>> allocationPaths) throws IOException {
Preconditions.checkArgument(uris.size() > 0, "No uri provided to audit");
String zkServers = validateAndGetZKServers(uris);
RetryPolicy retryPolicy = new BoundExponentialBackoffRetryPolicy(conf.getZKRetryBackoffStartMillis(), conf.getZKRetryBackoffMaxMillis(), Integer.MAX_VALUE);
ZooKeeperClient zkc = ZooKeeperClientBuilder.newBuilder().name("DLAuditor-ZK").zkServers(zkServers).sessionTimeoutMs(conf.getZKSessionTimeoutMilliseconds()).retryPolicy(retryPolicy).zkAclId(conf.getZkAclId()).build();
ExecutorService executorService = Executors.newCachedThreadPool();
try {
BKDLConfig bkdlConfig = resolveBKDLConfig(zkc, uris);
logger.info("Resolved bookkeeper config : {}", bkdlConfig);
BookKeeperClient bkc = BookKeeperClientBuilder.newBuilder().name("DLAuditor-BK").dlConfig(conf).zkServers(bkdlConfig.getBkZkServersForWriter()).ledgersPath(bkdlConfig.getBkLedgersPath()).build();
try {
Set<Long> bkLedgers = collectLedgersFromBK(bkc, executorService);
Set<Long> dlLedgers = collectLedgersFromDL(uris, allocationPaths);
return Pair.of(bkLedgers, dlLedgers);
} finally {
bkc.close();
}
} finally {
zkc.close();
executorService.shutdown();
}
}
Aggregations