minihippo commented on code in PR #5064: URL: https://github.com/apache/hudi/pull/5064#discussion_r890880153
########## hudi-metastore/src/main/java/org/apache/hudi/metastore/HoodieMetastoreServer.java: ########## @@ -0,0 +1,123 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hudi.metastore; + +import org.apache.hudi.exception.HoodieIOException; +import org.apache.hudi.metastore.service.HoodieMetastoreService; +import org.apache.hudi.metastore.service.HoodieMetaStoreProxyHandler; +import org.apache.hudi.metastore.service.PartitionService; +import org.apache.hudi.metastore.service.SnapshotService; +import org.apache.hudi.metastore.service.TableService; +import org.apache.hudi.metastore.service.TimelineService; +import org.apache.hudi.metastore.store.RelationDBBasedStore; +import org.apache.hudi.metastore.store.MetadataStore; +import org.apache.hudi.metastore.thrift.MetaStoreException; +import org.apache.hudi.metastore.thrift.ThriftHoodieMetastore; +import org.apache.hudi.metastore.util.TServerSocketWrapper; +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; +import org.apache.thrift.server.TServer; +import org.apache.thrift.server.TThreadPoolServer; +import org.apache.thrift.transport.TServerTransport; + +import java.lang.reflect.Proxy; + +public class HoodieMetastoreServer { + + private static final Logger LOG = LogManager.getLogger(HoodieMetastoreServer.class); + + private static volatile TServer server; + private static volatile Thread serverThread; + private static volatile MetadataStore metadataStore; + private static volatile HoodieMetastoreService metastoreService; + + public static void main(String[] args) { + startServer(); + } + + public static void startServer() { + try { + if (server != null) { + return; + } + metadataStore = new RelationDBBasedStore(); + // service + TableService tableService = new TableService(metadataStore); + PartitionService partitionService = new PartitionService(metadataStore); + TimelineService timelineService = new TimelineService(metadataStore); + SnapshotService snapshotService = new SnapshotService(metadataStore); + HoodieMetastoreService hoodieMetastoreService = new HoodieMetastoreService(tableService, + partitionService, timelineService, snapshotService); + HoodieMetaStoreProxyHandler proxyHandler = new HoodieMetaStoreProxyHandler(hoodieMetastoreService); + + // start a thrift server + ThriftHoodieMetastore.Iface proxy = (ThriftHoodieMetastore.Iface) Proxy + .newProxyInstance(HoodieMetaStoreProxyHandler.class.getClassLoader(), + new Class[]{ThriftHoodieMetastore.Iface.class}, proxyHandler); + ThriftHoodieMetastore.Processor processor = new ThriftHoodieMetastore.Processor(proxy); + TServerTransport serverTransport = new TServerSocketWrapper(9090); Review Comment: We need a. jcommander to do it, will fix later -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
