Status
Current state: [One of "Under Discussion", "Accepted", "Rejected"]
Discussion thread: link
JIRA:
Released: 0.4.0
Motivation
Finalize the stream operation primitives in distributedlog.
Public Interfaces
All supported stream primitives are listed as below.
Primitive | Status | Jira | Notes |
---|---|---|---|
#openLog | Done | Open a distributedlog stream | |
#deleteLog | Done | Delete a distributedlog stream | |
#getLogs | Done | List all the log streams under a given namespace | |
#markEndOfStream | Done | Seal a log stream | |
#truncate | Done | Truncate a log stream | |
#getLogStatus | Get the status/attributes of a log stream | ||
#renameLog | Rename a distributedlog stream | ||
#listLogs | List all the log streams under a given path | ||
#symlink | Create a symlink stream for a log stream | ||
#fork | Fork a log stream |
Proposed Changes
GetLogStatus
Proposed API:
Future<LogStatus> getLogStatus(String streamName);
Proposed Changes:
Struct LogStatus { required long creation_time; required long modification_time; required int ensemble_size; required int write_quorum_size; required int ack_quorum_size; optional String symlinkLog; optional Map<byte[], byte[]> attributes; }
The LogStatus is serialized and stored under the root znode of the log stream.
Rename
Proposed API:
Future<LogStatus> renameLog(String oldStreamName, String newStreamName);
Proposed Changes:
It will be a zookeeper transaction to copy all the znodes to the new location.
List
Proposed API:
Future<List<LogStatus>> listLogs(String logPath);
Proposed Changes:
It will get all the children under a given path and retrieve the `LogStatus` for each child stream.
Symlink
Proposed API:
Future<Void> symlink(String realLogPath, String symlinkLogPath);
Proposed Changes:
It will create a log stream with LogStatus (symlink = 'real log path').
Fork
Proposed API: (Added to AsyncLogWriter)
Future<AsyncLogWriter> fork(String newLogStreamName);
AsyncLogWriter writer = ...; AsyncLogWriter forkedWriter = FutureUtils.result(writer.fork('newStream'));
Proposed Changes:
At the forking time, the writer will do following:
- Create a new log stream 'newStream'. The new log stream will copy the list of log segments, whose log segments will be symlinked to the original log segments.
- Once the metadata is ready, the current writer will close the current in progress log segment.
- All the writes happened after 'fork' will go to a new log segment.
Compatibility, Deprecation, and Migration Plan
N/A - Doesn't change existing primitives
Test Plan
N/A
Rejected Alternatives
N/A