Skip to content

Commit

Permalink
Merge branch 'master' into fix_start_shell
Browse files Browse the repository at this point in the history
  • Loading branch information
imbajin authored Nov 20, 2022
2 parents b3bff4c + aa0d8da commit 05d49f1
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 61 deletions.
62 changes: 39 additions & 23 deletions hugegraph-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<top.level.dir>${basedir}/..</top.level.dir>
<jraft.version>1.3.11</jraft.version>
<ohc.version>0.7.4</ohc.version>
<jna.version>5.12.1</jna.version>
<lz4.version>1.8.0</lz4.version>
<mmseg4j-core.version>1.10.0</mmseg4j-core.version>
<jcseg.version>2.6.2</jcseg.version>
Expand Down Expand Up @@ -112,6 +113,7 @@
</exclusions>
</dependency>

<!-- ohc -->
<dependency>
<groupId>org.caffinitas.ohc</groupId>
<artifactId>ohc-core</artifactId>
Expand All @@ -121,9 +123,43 @@
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
<exclusion>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>${jna.version}</version>
</dependency>

<!-- collections -->
<dependency>
<groupId>org.eclipse.collections</groupId>
<artifactId>eclipse-collections-api</artifactId>
<version>${eclipse-collections.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.collections</groupId>
<artifactId>eclipse-collections</artifactId>
<version>${eclipse-collections.version}</version>
</dependency>

<!-- compress -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>${commons-compress.version}</version>
</dependency>
<dependency>
<groupId>org.lz4</groupId>
<artifactId>lz4-java</artifactId>
<version>${lz4.version}</version>
</dependency>

<!-- analyzers -->
<dependency>
<groupId>org.ansj</groupId>
<artifactId>ansj_seg</artifactId>
Expand Down Expand Up @@ -165,34 +201,14 @@
<version>${ikanalyzer.version}</version>
</dependency>

<dependency>
<groupId>org.lz4</groupId>
<artifactId>lz4-java</artifactId>
<version>${lz4.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>${commons-compress.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.collections</groupId>
<artifactId>eclipse-collections-api</artifactId>
<version>${eclipse-collections.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.collections</groupId>
<artifactId>eclipse-collections</artifactId>
<version>${eclipse-collections.version}</version>
</dependency>

<!-- https://mvnrepository.com/artifact/it.unimi.dsi/fastutil -->
<!-- fastutil: https://mvnrepository.com/artifact/it.unimi.dsi/fastutil -->
<dependency>
<groupId>it.unimi.dsi</groupId>
<artifactId>fastutil</artifactId>
<version>${fastutil.version}</version>
</dependency>
<!-- jwt auth token TODO: move to auth pom -->

<!-- jwt auth token, TODO: move to auth pom -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,13 @@ public List<Shard> getSplits(Session session, long splitSize) {
count = 1;
}
long maxKey = this.maxKey();
double each = maxKey / count;
Double each = maxKey / count;

List<Shard> splits = new ArrayList<>((int) count);
String last = START;
long offset = 0L;
while (offset < maxKey) {
offset += each;
offset += each.longValue();
if (offset > maxKey) {
splits.add(new Shard(last, END, 0L));
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.nio.file.Paths;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -110,11 +109,13 @@ public static Map<String, String> scanGraphsDir(String graphsDirPath) {

public static String writeToFile(String dir, String graphName,
HugeConfig config) {
E.checkArgument(FileUtils.getFile(dir).exists(),
"The directory '%s' must exist", dir);
String fileName = Paths.get(dir, graphName + CONF_SUFFIX).toString();
File path = FileUtils.getFile(dir);
E.checkArgument(path.exists(),
"The directory '%s' must exist", dir);
String fileName = path.getPath() + File.separator + graphName + CONF_SUFFIX;
try {
config.save(new File(fileName));
File newFile = FileUtils.getFile(fileName);
config.save(newFile);
LOG.info("Write HugeConfig to file: '{}'", fileName);
} catch (ConfigurationException e) {
throw new HugeException("Failed to write HugeConfig to file '%s'",
Expand Down
3 changes: 1 addition & 2 deletions hugegraph-dist/scripts/dependency/known-dependencies.txt
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ jjwt-api-0.11.5.jar
jjwt-impl-0.11.5.jar
jjwt-jackson-0.11.5.jar
jline-2.14.6.jar
jna-4.2.2.jar
jna-5.5.0.jar
jna-5.12.1.jar
jnr-ffi-2.1.7.jar
jnr-x86asm-1.0.2.jar
joda-time-2.10.8.jar
Expand Down
28 changes: 13 additions & 15 deletions hugegraph-dist/src/assembly/static/bin/hugegraph-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ if [[ $# -lt 3 ]]; then
fi

BIN=$(abs_path)
TOP="$(cd $BIN/../ && pwd)"
TOP="$(cd "$BIN"/../ && pwd)"
CONF="$TOP/conf"
LIB="$TOP/lib"
EXT="$TOP/ext"
Expand All @@ -41,7 +41,7 @@ LOGS="$TOP/logs"
OUTPUT=${LOGS}/hugegraph-server.log

export HUGEGRAPH_HOME="$TOP"
. ${BIN}/util.sh
. "${BIN}"/util.sh

GREMLIN_SERVER_CONF="$1"
REST_SERVER_CONF="$2"
Expand All @@ -58,13 +58,13 @@ elif [[ $# -eq 5 ]]; then
GC_OPTION="$5"
fi

ensure_path_writable $LOGS
ensure_path_writable $PLUGINS
ensure_path_writable "$LOGS"
ensure_path_writable "$PLUGINS"

# The maximum and minium heap memory that service can use
# The maximum and minimum heap memory that service can use
MAX_MEM=$((32 * 1024))
MIN_MEM=$((1 * 512))
EXPECT_JDK_VERSION=1.8
MIN_JAVA_VERSION=8

# Add the slf4j-log4j12 binding
CP=$(find -L $LIB -name 'log4j-slf4j-impl*.jar' | sort | tr '\n' ':')
Expand All @@ -85,19 +85,18 @@ CP="$CP":$(find -L $PLUGINS -name '*.jar' | sort | tr '\n' ':')
export CLASSPATH="${CLASSPATH:-}:$CP"

# Change to $BIN's parent
cd ${TOP}
cd "${TOP}" || exit 1;

# Find Java
# Find java & enable server option
if [ "$JAVA_HOME" = "" ]; then
JAVA="java -server"
else
JAVA="$JAVA_HOME/bin/java -server"
fi

JAVA_VERSION=$($JAVA -version 2>&1 | awk 'NR==1{gsub(/"/,""); print $3}' \
| awk -F'_' '{print $1}')
if [[ $? -ne 0 || $JAVA_VERSION < $EXPECT_JDK_VERSION ]]; then
echo "Please make sure that the JDK is installed and the version >= $EXPECT_JDK_VERSION" \
JAVA_VERSION=$($JAVA -version 2>&1 | head -1 | cut -d'"' -f2 | sed 's/^1\.//' | cut -d'.' -f1)
if [[ $? -ne 0 || $JAVA_VERSION -lt $MIN_JAVA_VERSION ]]; then
echo "Make sure the JDK is installed and the version >= $MIN_JAVA_VERSION, current is $JAVA_VERSION" \
>> ${OUTPUT}
exit 1
fi
Expand All @@ -106,8 +105,7 @@ fi
if [ "$JAVA_OPTIONS" = "" ]; then
XMX=$(calc_xmx $MIN_MEM $MAX_MEM)
if [ $? -ne 0 ]; then
echo "Failed to start HugeGraphServer, requires at least ${MIN_MEM}m free memory" \
>> ${OUTPUT}
echo "Failed to start HugeGraphServer, requires at least ${MIN_MEM}MB free memory" >> ${OUTPUT}
exit 1
fi
JAVA_OPTIONS="-Xms${MIN_MEM}m -Xmx${XMX}m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${LOGS} ${USER_OPTION}"
Expand All @@ -117,7 +115,7 @@ if [ "$JAVA_OPTIONS" = "" ]; then
# -Xloggc:./logs/gc.log -XX:+PrintHeapAtGC -XX:+PrintGCDetails -XX:+PrintGCDateStamps"
fi

if [[ $JAVA_VERSION > "1.9" ]]; then
if [[ $JAVA_VERSION -gt 9 ]]; then
JAVA_OPTIONS="${JAVA_OPTIONS} --add-exports=java.base/jdk.internal.reflect=ALL-UNNAMED \
--add-modules=jdk.unsupported \
--add-exports=java.base/sun.nio.ch=ALL-UNNAMED "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ private static Map<String, Object> formatMetrics(
.values();
long fileSizeBytes = 0L;
for (RegionMetrics region : regions) {
fileSizeBytes += region.getStoreFileSize().get(Size.Unit.BYTE);
Double tempValue = region.getStoreFileSize().get(Size.Unit.BYTE);
fileSizeBytes += tempValue.longValue();
}
metrics.put(DISK_USAGE, UnitUtil.bytesToGB(fileSizeBytes));
metrics.put(DISK_USAGE + READABLE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,11 @@ public long storeSize(String table) throws IOException {
//total += load.getMemStoreSizeMB() * Bytes.MB;
TableName tableName = TableName.valueOf(this.namespace, table);
for (RegionMetrics m : admin.getRegionMetrics(rs, tableName)) {
total += m.getStoreFileSize().get(Size.Unit.BYTE);
total += m.getMemStoreSize().get(Size.Unit.BYTE);
Double storeFileSize = m.getStoreFileSize().get(Size.Unit.BYTE);
total += storeFileSize.longValue();

Double memStoreFileSize = m.getMemStoreSize().get(Size.Unit.BYTE);
total += memStoreFileSize.longValue();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5218,15 +5218,15 @@ public void testQueryBothEdgesOfVertexInPaging() {
while (page != null) {
GraphTraversal<?, ?> iterator = graph.traversal().V(james).bothE()
.has("~page", page).limit(1);
long size = IteratorUtils.count(iterator);
Long size = IteratorUtils.count(iterator);
if (size == 0L) {
// The last page is empty
Assert.assertEquals(6, count);
} else {
Assert.assertEquals(1, size);
Assert.assertEquals(1, size.intValue());
}
page = TraversalUtil.page(iterator);
count += size;
count += size.intValue();
}
Assert.assertEquals(6, count);
}
Expand All @@ -5244,15 +5244,15 @@ public void testQueryOutEdgesOfVertexInPaging() {
while (page != null) {
GraphTraversal<?, ?> iterator = graph.traversal().V(james).outE()
.has("~page", page).limit(1);
long size = IteratorUtils.count(iterator);
Long size = IteratorUtils.count(iterator);
if (size == 0L) {
// The last page is empty
Assert.assertEquals(4, count);
} else {
Assert.assertEquals(1, size);
Assert.assertEquals(1, size.intValue());
}
page = TraversalUtil.page(iterator);
count += size;
count += size.intValue();
}
Assert.assertEquals(4, count);
}
Expand All @@ -5270,15 +5270,15 @@ public void testQueryInEdgesOfVertexInPaging() {
while (page != null) {
GraphTraversal<?, ?> iterator = graph.traversal().V(james).inE()
.has("~page", page).limit(1);
long size = IteratorUtils.count(iterator);
Long size = IteratorUtils.count(iterator);
if (size == 0L) {
// The last page is empty
Assert.assertEquals(2, count);
} else {
Assert.assertEquals(1, size);
Assert.assertEquals(1, size.intValue());
}
page = TraversalUtil.page(iterator);
count += size;
count += size.intValue();
}
Assert.assertEquals(2, count);
}
Expand Down Expand Up @@ -7516,10 +7516,10 @@ private int traverseInPage(Function<String, GraphTraversal<?, ?>> fetcher) {
int count = 0;
while (page != null) {
GraphTraversal<?, ?> iterator = fetcher.apply(page);
long size = IteratorUtils.count(iterator);
Long size = IteratorUtils.count(iterator);
Assert.assertLte(1L, size);
page = TraversalUtil.page(iterator);
count += size;
count += size.intValue();
}
return count;
}
Expand Down

0 comments on commit 05d49f1

Please sign in to comment.