-
Notifications
You must be signed in to change notification settings - Fork 223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[admin] Add create_time to database and table metadata. #289
Conversation
4950011
to
caf5158
Compare
fluss-client/src/test/java/com/alibaba/fluss/client/admin/FlussAdminITCase.java
Show resolved
Hide resolved
fluss-common/src/main/java/com/alibaba/fluss/metadata/DatabaseInfo.java
Outdated
Show resolved
Hide resolved
fluss-common/src/main/java/com/alibaba/fluss/metadata/DatabaseInfo.java
Outdated
Show resolved
Hide resolved
fluss-common/src/main/java/com/alibaba/fluss/metadata/TableInfo.java
Outdated
Show resolved
Hide resolved
fluss-common/src/main/java/com/alibaba/fluss/metadata/TableInfo.java
Outdated
Show resolved
Hide resolved
...onnector-flink/src/test/java/com/alibaba/fluss/connector/flink/catalog/FlinkCatalogTest.java
Outdated
Show resolved
Hide resolved
fluss-server/src/main/java/com/alibaba/fluss/server/zk/data/TableRegistration.java
Outdated
Show resolved
Hide resolved
fluss-server/src/main/java/com/alibaba/fluss/server/coordinator/MetaDataManager.java
Outdated
Show resolved
Hide resolved
/** Get the database in ZK. */ | ||
public Optional<DatabaseRegistration> getDatabase(String database) throws Exception { | ||
Optional<byte[]> bytes = getOrEmpty(DatabaseZNode.path(database)); | ||
return bytes.map(DatabaseZNode::decode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- we should add a unit test in
ZooKeeperClientTest
thatgetDatabase
from a legacy node. this may throw a json parse exception. - we can try catch the parse exception and return a default
DatabaseRegistration
with thecreated_time
andmodified_time
extracted from `zkClient.checkExists().forPath(path).getCtime()/.getMtime()``. - add the same unit test for
getTable
as well. - decode legacy table node will not throw parse exception but with
-1
time, we can check if it is-1
time, and get thecreated_time
andmodified_time
extracted fromzkClient.checkExists().forPath(path).getCtime()/.getMtime()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can try catch the parse exception and return a default DatabaseRegistration with the created_time and modified_time extracted from `zkClient.checkExists().forPath(path).getCtime()/.getMtime()``.
I have considered it because it will be more easier, but the meta data will be bounded to zookeeper. It maybe easy now, but will be tricky if we remove the zookeeper later. @wuchong , WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a backward-compatibility, in the past, we only support zookeeper metastore. The standard support of created_time/modified_time is your current implementation (adding additional properties in serialized data).
fluss-server/src/main/java/com/alibaba/fluss/server/zk/data/DatabaseRegistrationJsonSerde.java
Outdated
Show resolved
Hide resolved
fluss-common/src/main/java/com/alibaba/fluss/metadata/DatabaseDescriptor.java
Outdated
Show resolved
Hide resolved
fluss-common/src/main/java/com/alibaba/fluss/metadata/DatabaseDescriptor.java
Outdated
Show resolved
Hide resolved
* | ||
* <p>Table properties are controlled by Fluss and will change the behavior of the table. | ||
*/ | ||
public <T> Builder property(ConfigOption<T> configOption, T value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this method can be removed since we don't have any pre-defined ConfigOption for database...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I will modify property as customProperty which Jark Wu has addvised.
fluss-common/src/main/java/com/alibaba/fluss/metadata/DatabaseDescriptor.java
Outdated
Show resolved
Hide resolved
fluss-common/src/main/java/com/alibaba/fluss/metadata/DatabaseDescriptor.java
Outdated
Show resolved
Hide resolved
fluss-common/src/main/java/com/alibaba/fluss/metadata/DatabaseDescriptor.java
Outdated
Show resolved
Hide resolved
fluss-server/src/main/java/com/alibaba/fluss/server/zk/data/DatabaseRegistration.java
Outdated
Show resolved
Hide resolved
033073b
to
2c01767
Compare
#312 is introducing a compatibility breaking change which requires all the tables to be re-created. So v0.6 is not a compatible version. How about making modified_time and created_time required in this PR to simplify the compatible logic? Currently, many code still create |
d3287af
to
c465753
Compare
Please do not squash commits even if it is a big change. |
@@ -79,20 +96,18 @@ public boolean equals(Object o) { | |||
|
|||
@Override | |||
public int hashCode() { | |||
return Objects.hash(tablePath, tableDescriptor, tableId, schemaId); | |||
return Objects.hash(tablePath, tableDescriptor, tableId, schemaId, createdTime, modifiedTime); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove createdTime, modifiedTime
from hashCode()
if they are not compared in equals()
.
r.getSchemaId())); | ||
r.getSchemaId(), | ||
r.hasCreatedTime() ? r.getCreatedTime() : -1, | ||
r.hasModifiedTime() ? r.getModifiedTime() : -1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they are required fields now, no need to check hasXxx()
tableDescriptor.getCustomProperties()); | ||
tableDescriptor.getCustomProperties(), | ||
System.currentTimeMillis(), | ||
System.currentTimeMillis()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use a same time for them when creation.
I pushed a commit to fix the problems. |
Purpose
Linked issue: close #281