Liu,
From your logs I see that the client is able to reach ZooKeeper, so I think
that createLedger should complete.
Are you sure that your program is not stuck at “addEntry” ?
Is your client machine able to connect to the bookies ?
You can dump the stacktrace of the JVM with jstack
I suggest you to use the org.apache.bookkeeper.client.api package, the code is
like this (I don’t have an IDE now, I am not sure it compiles, but it gives an
idea):
org.apache.bookkeeper.client.api.Bookkeeper bookkeeper =
org.apache.bookkeeper.client.api.Bookkeeper.forConfig(config).build();
org.apache.bookkeeper.client.api.WriteHandle handle =
bookkeeper.newCreateLedgerOp()
.withEnsembleSize(1)
.withWriteQuorumSize(1)
.withAckQuorumSize(1)
.withDigestType(DigestType.CRC32C)
.execute()
.get();
long entryId = handle.append("Some entry data".getBytes());
long entryId1 = handle. append ("111Some entry data".getBytes());
long entryId2 = handle. append ("222Some entry data".getBytes());
// always close a WriteHandle !!!
handle.close();
Enrico
Il giorno 04/12/19, 03:43 "Wei Liu"
<[email protected]<mailto:[email protected]>> ha scritto:
Dear All:
I can't create ledger using bookkeeper 4.10.0 version.
Below is my test code:
static String connectionString = "xxx.xxx.xxx.xxx:2181";
bkClient = new BookKeeper(connectionString);
byte[] password = "some-password".getBytes();
handle = bkClient.createLedger(BookKeeper.DigestType.MAC, password);
long entryId = handle.addEntry("Some entry data".getBytes());
long entryId1 = handle.addEntry("111Some entry data".getBytes());
long entryId2 = handle.addEntry("222Some entry data".getBytes());
Stuck in 'createLedger' when the program is running.
Below is log:
2019-12-04 10:13:39,236 - INFO - [main:MetadataDrivers@107] - BookKeeper
metadata driver manager initialized
2019-12-04 10:13:39,239 - INFO - [main:MetadataDrivers@107] - BookKeeper
metadata driver manager initialized
2019-12-04 10:13:39,240 - INFO - [main:MetadataDrivers@107] - BookKeeper
metadata driver manager initialized
2019-12-04 10:13:39,247 - INFO - [main:ZKMetadataDriverBase@192] - Initialize
zookeeper metadata driver at metadata service uri
zk+null://xxx.xxxx.xxx.xxx:2181/ledgers : zkServers = xxx.xxxx.xxx.xxx,
ledgersRootPath = /ledgers.
2019-12-04 10:13:39,288 - INFO - [main-EventThread:ZooKeeperWatcherBase@130] -
ZooKeeper client is connected now.
2019-12-04 10:13:39,411 - ERROR -
[main:RackawareEnsemblePlacementPolicyImpl@267] - Failed to initialize DNS
Resolver org.apache.bookkeeper.net.ScriptBasedMapping, used default subnet
resolver : java.lang.RuntimeException: No network topology script is found when
using script based DNS resolver.
2019-12-04 10:13:39,430 - INFO -
[main:RackawareEnsemblePlacementPolicyImpl@214] - Initialize rackaware ensemble
placement policy @ <Bookie:127.0.1.1:0<http://127.0.1.1:0>> @ /default-rack :
org.apache.bookkeeper.client.TopologyAwareEnsemblePlacementPolicy$DefaultResolver.
2019-12-04 10:13:39,430 - INFO -
[main:RackawareEnsemblePlacementPolicyImpl@224] - Not weighted
2019-12-04 10:13:39,433 - INFO - [main:BookKeeper@509] - Weighted ledger
placement is not enabled
2019-12-04 10:13:39,458 - INFO -
[BookKeeperClientScheduler-OrderedScheduler-0-0:NetworkTopologyImpl@429] -
Adding a new node: /default-rack/xxx.xxxx.xxx.xxx:3181
2019-12-04 10:13:39,789 - INFO -
[BookKeeperClientScheduler-OrderedScheduler-0-0:NetworkTopologyImpl@429] -
Adding a new node: /default-rack/xxx.xxxx.xxx.xxx:3181
2019-12-04 10:13:39,791 - INFO -
[BookKeeperClientScheduler-OrderedScheduler-0-0:NetworkTopologyImpl@429] -
Adding a new node: /default-rack/xxx.xxxx.xxx.xxx:4181
2019-12-04 10:13:40,123 - INFO -
[BookKeeperClientScheduler-OrderedScheduler-0-0:NetworkTopologyImpl@429] -
Adding a new node: /default-rack/xxx.xxxx.xxx.xxx:3181
11111
2019-12-04 10:13:40,153 - WARN - [main:BookieWatcherImpl@240] - New ensemble:
[xxx.xxxx.xxx.xxx:4181, xxx.xxxx.xxx.xxx:3181, xxx.xxxx.xxx.xxx:3181] is not
adhering to Placement Policy. quarantinedBookies: []
--
一个人只拥有今生今世是不够的,
他还应该拥有诗意的世界。
[email protected]<mailto:[email protected]>
________________________________
CONFIDENTIALITY & PRIVACY NOTICE
This e-mail (including any attachments) is strictly confidential and may also
contain privileged information. If you are not the intended recipient you are
not authorised to read, print, save, process or disclose this message. If you
have received this message by mistake, please inform the sender immediately and
destroy this e-mail, its attachments and any copies. Any use, distribution,
reproduction or disclosure by any person other than the intended recipient is
strictly prohibited and the person responsible may incur in penalties.
The use of this e-mail is only for professional purposes; there is no guarantee
that the correspondence towards this e-mail will be read only by the recipient,
because, under certain circumstances, there may be a need to access this email
by third subjects belonging to the Company.