Skip to content
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

[HUDI-3654] Add new module hudi-metaserver #5064

Merged
merged 21 commits into from
Jan 16, 2023
Merged

Conversation

minihippo
Copy link
Contributor

@minihippo minihippo commented Mar 18, 2022

Change Logs

Add a new module hudi-metastore

Impact

HoodieMetastoreBasedTimeline
HoodieMetastoreFileSystemView
MetaStore has three parts:

  • client, connects with server by Thrift
  • service, is divided into tableService, partitionService, timelineService and snapshotService
  • store, has a relation db based implementation with the power of MyBatis

Writing a commit/deltacommit is available, but read is not ready.

Risk level

medium

For test, metastore will start up with an embedded one.

This change added tests and can be verified as follows:

  • Add metastore client ut
  • Add metastore store ut
  • Add a case of cow writing based on metastore

Documentation Update

  • add a new section on website for introduction

Contributor's checklist

  • Read through contributor's guide
  • Change Logs and Impact were stated clearly
  • Adequate tests were added if applicable
  • CI passed

@melin
Copy link

melin commented Mar 18, 2022

Add catalogName parameter to MetadataStore interface method

@minihippo minihippo changed the title [HUDI-3654] Initialize hudi metastore module. [WIP][HUDI-3654] Initialize hudi metastore module. Mar 18, 2022
@xiarixiaoyao
Copy link
Contributor

great feature !!!

@minihippo minihippo changed the title [WIP][HUDI-3654] Initialize hudi metastore module. [HUDI-3654] Initialize hudi metastore module. Apr 1, 2022
@nsivabalan
Copy link
Contributor

@xiarixiaoyao : can you review this when you get a chance. I have assigned it to myself as well. So, will try to review in a weeks time.

@xiarixiaoyao
Copy link
Contributor

@minihippo could you pls rebase the code and run azure again, thanks

@minihippo
Copy link
Contributor Author

The CI environment lacks thrift under /usr/local/bin/thrift, so that hudi-metastore can't be compiled. I push the compiled thrift classes as a temporary way to pass CI.

@minihippo
Copy link
Contributor Author

@xiarixiaoyao It seems that the code review doesn't finish, right?

.newProxyInstance(HoodieMetaStoreProxyHandler.class.getClassLoader(),
new Class[]{ThriftHoodieMetastore.Iface.class}, proxyHandler);
ThriftHoodieMetastore.Processor processor = new ThriftHoodieMetastore.Processor(proxy);
TServerTransport serverTransport = new TServerSocketWrapper(9090);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make the port configurable

.newProxyInstance(HoodieMetaStoreProxyHandler.class.getClassLoader(),
new Class[]{ThriftHoodieMetastore.Iface.class}, proxyHandler);
ThriftHoodieMetastore.Processor processor = new ThriftHoodieMetastore.Processor(proxy);
TServerTransport serverTransport = new TServerSocketWrapper(9090);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make the port configurable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a. jcommander to do it, will fix later

Throwable err = null;
do {
try {
Object res = method.invoke(client, args);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will be better to log time cost

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should us involve metrics to do this or just log?

Throwable err = null;
do {
try {
Object res = method.invoke(client, args);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will be better to log time cost

import java.nio.ByteBuffer;
import java.util.List;

public class HoodieMetastoreService implements ThriftHoodieMetastore.Iface, Serializable {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls add doc for all new class

location_uri VARCHAR(512) COMMENT 'database storage path',
name VARCHAR(512) UNIQUE COMMENT 'database name',
owner_name VARCHAR(512) COMMENT 'database owner' ,
owner_type VARCHAR(512) COMMENT 'database owner'
Copy link
Contributor

@XuQianJin-Stars XuQianJin-Stars Jun 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All tables here are added with create_time and update_time for easy problem analysis

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will fix


@Override
protected void initMetaClient(HoodieTableType tableType, Properties properties) throws IOException {
properties.put(HoodieTableConfig.NAME.key(), "test");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant, repeat with initMetastoreConfig below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will fix

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@minihippo
Copy link
Contributor Author

@hudi-bot run azure

@apache apache deleted a comment from hudi-bot Jan 16, 2023
Copy link
Member

@xushiyan xushiyan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm overall. suggest some minor changes. pls follow up the comments in separate PRs

}
LOG.info(String.format("Table %s.%s doesn't exist, will create it.", db, tb));
table = new Table();
table.setDbName(db);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setDatabaseName()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

/**
* A proxy for meta server, accepts all thrift calls and routes them to the corresponding service.
*/
public class HoodieMetaserverService implements ThriftHoodieMetaserver.Iface, Serializable {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MetaserverGateway sounds better

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

Comment on lines +108 to +109
// todo: support SSS
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should actually reuse the format from the existing constant. And make millisecond first supported.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

}

@Override
public byte[] getInstantMetadata(long tableId, THoodieInstant instant) throws MetaserverStorageException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the other interface is using Option<byte[]>. we should align them for consistency

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

* Table entity for store.
*/
public class TableBean {
private String dbName;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use databaseName; pls review all occurrences

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix all

}

public BatchDaoOperation(String sqlID, Object parameter, String operationType) {
this(null, sqlID, parameter, operationType);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

namespace is nullable? let's avoid passing null around by making Option namespace

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete the useless code

// table related
struct Table {
1: string tableName,
2: string dbName,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

databaseName

@xushiyan xushiyan dismissed prasannarajaperumal’s stale review January 16, 2023 05:43

comments addressed and planned for follow up changes

@xushiyan
Copy link
Member

Screen Shot 2023-01-15 at 11 42 32 PM

CI passed

@xushiyan xushiyan merged commit 16d33ba into apache:master Jan 16, 2023
fengjian428 pushed a commit to fengjian428/hudi that referenced this pull request Jan 31, 2023

Co-authored-by: gengxiaoyu <gengxiaoyu@bytedance.com>
Co-authored-by: Raymond Xu <2701446+xushiyan@users.noreply.github.com>
fengjian428 pushed a commit to fengjian428/hudi that referenced this pull request Apr 5, 2023

Co-authored-by: gengxiaoyu <gengxiaoyu@bytedance.com>
Co-authored-by: Raymond Xu <2701446+xushiyan@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.