You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2022/12/03 17:42:07 UTC
[GitHub] [bookkeeper] chenzhenyang opened a new issue, #3690: How can I have a transaction contains distributedlog operations and table service operations?
chenzhenyang opened a new issue, #3690:
URL: https://github.com/apache/bookkeeper/issues/3690
DistributedLogManager distributedLogManager = namespace.openLog("stream2");
AsyncLogWriter writer = FutureUtils.result(distributedLogManager.openAsyncLogWriter());
byte[] data = "abdsfdsfdsfdsfasfdsfdsafaser324234243211v23rrcrevrevvtojr3n4ucrn4ru4rqnc".getBytes();
Transaction.begin();
LogRecord record = new LogRecord(System.currentTimeMillis(), data);
Future<DLSN> writeFuture = writer.write(record);
DLSN dlsn= writeFuture.get();
String namespace = "tableservice_namespace";
String tableName = "test";
String key = "progress";
DLSN dlsn = DLSN.InitialDLSN;
StorageClientSettings settings = StorageClientSettingsInstance.SETTINGS;
try (StorageClient client = StorageClientBuilder.newBuilder()
.withSettings(settings)
.withNamespace(namespace)
.build()) {
try (Table<ByteBuf, ByteBuf> table = result(client.openTable(tableName))) {
result(table.put(
Unpooled.wrappedBuffer(key.getBytes(UTF_8)),
Unpooled.wrappedBuffer(dlsn.toString().getBytes(UTF_8))));
System.out.println("Successfully update kv: ('" + key + "', '" + dlsn + "').");
}
} catch (Exception e) {
// log.error("Failed to process commands under namespace '{}'",
// globalFlags.namespace, e);
// spec.console().println("Failed to process stream admin command");
// e.printStackTrace(spec.console());
e.printStackTrace();
}
Transaction.commit();
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@bookkeeper.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org