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

feat(store): integrate store-dist and store-cli submodule #2562

Merged
merged 8 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions hugegraph-pd/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
<include>*.tar.gz</include>
<include>.flattened-pom.xml</include>
<!-- WARN: delete dist dir may influence dev? -->
<!-- TODO: replace with ${final.name} in pd-dist -->
<include>dist/**</include>
</includes>
<followSymlinks>false</followSymlinks>
Expand Down
82 changes: 82 additions & 0 deletions hugegraph-store/hg-store-cli/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->

<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.apache.hugegraph</groupId>
<artifactId>hugegraph-store</artifactId>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>hg-store-cli</artifactId>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>2.5.14</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.hugegraph</groupId>
<artifactId>hg-store-client</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>org.apache.hugegraph</groupId>
<artifactId>hg-store-grpc</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>org.apache.hugegraph</groupId>
<artifactId>hg-pd-client</artifactId>
<version>${revision}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.5.14</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<mainClass>
org.apache.hugegraph.store.cli.StoreConsoleApplication
</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* 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.hugegraph.store.cli;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import lombok.Data;

@Data
@Component
public class AppConfig {

@Value("${pd.address}")
private String pdAddress;

@Value("${net.kv.scanner.page.size}")
private int scannerPageSize;

@Value("${scanner.graph}")
private String scannerGraph;

@Value("${scanner.table}")
private String scannerTable;

@Value("${scanner.max}")
private int scannerMax;

@Value("${scanner.mod}")
private int scannerModNumber;

@Value("${committer.graph}")
private String committerGraph;

@Value("${committer.table}")
private String committerTable;

@Value("${committer.amount}")
private int committerAmount;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
* 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.hugegraph.store.cli;

import java.io.IOException;

import org.apache.hugegraph.pd.client.PDConfig;
import org.apache.hugegraph.pd.common.PDException;
import org.apache.hugegraph.store.HgStoreClient;
import org.apache.hugegraph.store.cli.loader.HgThread2DB;
import org.apache.hugegraph.store.cli.scan.GrpcShardScanner;
import org.apache.hugegraph.store.cli.scan.HgStoreScanner;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import lombok.extern.slf4j.Slf4j;

/**
* 2022/2/14
*/
@SpringBootApplication
@Slf4j
public class StoreConsoleApplication implements CommandLineRunner {

// TODO: this package seems to have many useless class and code, need to be updated.
@Autowired
private AppConfig appConfig;

public static void main(String[] args) {
log.info("Starting StoreConsoleApplication");
SpringApplication.run(StoreConsoleApplication.class, args);
log.info("StoreConsoleApplication finished.");
}

@Override
public void run(String... args) throws IOException, InterruptedException, PDException {
if (args.length <= 0) {
log.warn("参数类型 cmd[-load, -query, -scan]");
} else {
switch (args[0]) {
case "-load":
HgThread2DB hgThread2DB = new HgThread2DB(args[1]);
if (!args[3].isEmpty()) {
hgThread2DB.setGraphName(args[3]);
}
try {
if ("order".equals(args[2])) {
hgThread2DB.testOrder(args[4]);
} else {
hgThread2DB.startMultiprocessInsert(args[2]);
}
} catch (IOException e) {
e.printStackTrace();
}
break;
case "-query":
HgThread2DB hgDB = new HgThread2DB(args[1]);
try {
hgDB.startMultiprocessQuery("12", args[2]);
} catch (IOException e) {
e.printStackTrace();
}
break;
case "-scan":
if (args.length < 4) {
log.warn("参数类型 -scan pd graphName tableName");
} else {
doScan(args[1], args[2], args[3]);
}
break;
case "-shard":
GrpcShardScanner scanner = new GrpcShardScanner();
scanner.getData();
break;
case "-shard-single":
scanner = new GrpcShardScanner();
scanner.getDataSingle();
break;
default:
log.warn("参数类型错误,未执行任何程序");
}
}
}

private void doScan(String pd, String graphName, String tableName) throws PDException {
HgStoreClient storeClient = HgStoreClient.create(PDConfig.of(pd)
.setEnableCache(true));

HgStoreScanner storeScanner = HgStoreScanner.of(storeClient, graphName);
storeScanner.scanTable2(tableName);
}
}
Loading
Loading