-
Notifications
You must be signed in to change notification settings - Fork 448
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
fix(interactive): Implement HttpIrMetaReader
to Get Meta Data From Remote Http Service
#3908
Changes from 12 commits
6336844
5582553
d35c5bb
f785414
3513782
6c3a32a
e9e7b5a
49d7d5f
83e3a31
e1292e2
675db21
0e72f83
dc6ba31
906766f
53eab57
6996274
063fa0e
dcf0f8d
229d92e
fb6c702
77f2bb0
c719c21
867cdde
c53a009
3072239
7e9d687
8ec0447
076ffec
3e22d82
ba4d2d7
1912d5f
23a0509
64dd138
aa256f8
767303b
4a6c36d
5cb7940
e5b41a7
9d14d68
eea8a78
0b94c17
bca39bb
ef92dc9
4736052
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#!/bin/bash | ||
# Copyright 2020 Alibaba Group Holding Limited. | ||
# | ||
# Licensed 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. | ||
set -e | ||
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) | ||
FLEX_HOME=${SCRIPT_DIR}/../../ | ||
SERVER_BIN=${FLEX_HOME}/build/bin/interactive_server | ||
GIE_HOME=${FLEX_HOME}/../interactive_engine/ | ||
ADMIN_PORT=7777 | ||
QUERY_PORT=10000 | ||
|
||
# | ||
if [ ! $# -eq 2 ]; then | ||
echo "only receives: $# args, need 2" | ||
echo "Usage: $0 <INTERACTIVE_WORKSPACE> <ENGINE_CONFIG>" | ||
exit 1 | ||
fi | ||
|
||
INTERACTIVE_WORKSPACE=$1 | ||
ENGINE_CONFIG_PATH=$2 | ||
if [ ! -d ${INTERACTIVE_WORKSPACE} ]; then | ||
echo "INTERACTIVE_WORKSPACE: ${INTERACTIVE_WORKSPACE} not exists" | ||
exit 1 | ||
fi | ||
if [ ! -f ${ENGINE_CONFIG_PATH} ]; then | ||
echo "ENGINE_CONFIG: ${ENGINE_CONFIG_PATH} not exists" | ||
exit 1 | ||
fi | ||
|
||
|
||
RED='\033[0;31m' | ||
GREEN='\033[0;32m' | ||
NC='\033[0m' # No Color | ||
err() { | ||
echo -e "${RED}[$(date +'%Y-%m-%d %H:%M:%S')] -ERROR- $* ${NC}" >&2 | ||
} | ||
|
||
info() { | ||
echo -e "${GREEN}[$(date +'%Y-%m-%d %H:%M:%S')] -INFO- $* ${NC}" | ||
} | ||
|
||
|
||
kill_service(){ | ||
info "Kill Service first" | ||
ps -ef | grep "interactive_server" | awk '{print $2}' | xargs kill -9 || true | ||
ps -ef | grep "compiler" | awk '{print $2}' | xargs kill -9 || true | ||
sleep 3 | ||
# check if service is killed | ||
info "Kill Service success" | ||
} | ||
|
||
# kill service when exit | ||
trap kill_service EXIT | ||
|
||
# start engine service and load ldbc graph | ||
start_engine_service(){ | ||
#check SERVER_BIN exists | ||
if [ ! -f ${SERVER_BIN} ]; then | ||
err "SERVER_BIN not found" | ||
exit 1 | ||
fi | ||
|
||
cmd="${SERVER_BIN} -c ${ENGINE_CONFIG_PATH} --enable-admin-service true " | ||
cmd="${cmd} -w ${INTERACTIVE_WORKSPACE} --start-compiler true" | ||
|
||
echo "Start engine service with command: ${cmd}" | ||
eval ${cmd} | ||
sleep 10 | ||
#check interactive_server is running, if not, exit | ||
ps -ef | grep "interactive_server" | grep -v grep | ||
|
||
info "Start engine service success" | ||
} | ||
|
||
run_cypher_test() { | ||
# run a simple cypher query: MATCH (n) RETURN count(n) | ||
python3 ./test_count_vertices.py --endpoint localhost:7687 | ||
} | ||
|
||
kill_service | ||
start_engine_service | ||
# comiper service will fail to start, if the graph meta can not be retrieved | ||
run_cypher_test | ||
kill_service | ||
|
||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright 2020 Alibaba Group Holding Limited. All Rights Reserved. | ||
# | ||
# Licensed 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. | ||
# | ||
|
||
from neo4j import GraphDatabase | ||
from neo4j import Session as Neo4jSession | ||
|
||
import argparse | ||
|
||
def count_vertices(sess: Neo4jSession): | ||
query = "MATCH (n) RETURN COUNT(n);" | ||
result = sess.run(query) | ||
for record in result: | ||
print(record[0]) | ||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser(description="Count the number of vertices in a graph.") | ||
parser.add_argument("--endpoint", type=str, required=True, help="The endpoint to connect.") | ||
args = parser.parse_args() | ||
|
||
driver = GraphDatabase.driver(args.endpoint, auth=None) | ||
with driver.session() as session: | ||
count_vertices(session) | ||
driver.close() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,3 +61,15 @@ calcite.default.charset: UTF-8 | |
|
||
# set the max capacity of the result streaming buffer for each query | ||
# per.query.stream.buffer.max.capacity: 256 | ||
|
||
# set the mode to read ir meta, either from a 'local' file or via remote 'http'. | ||
# ir.meta.reader.mode: local | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The configuration of ir.meta.xx, should be uniformly defined with graph.schema and graph.statistics. In addition, we can really configure those service scheme, to automatically differentiate from local and http. For example, graph.meta.statistics.uri: http://localhost:8080 -> this is a http file, or Also give a uri for schema There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
# if ir.meta.reader.mode is 'http', set the remote ir meta service host | ||
# ir.meta.service.host: localhost:8080 | ||
|
||
# if ir.meta.reader.mode is 'http', set the interval in milliseconds to fetch ir meta | ||
# ir.meta.fetch.interval.ms: 1000 | ||
|
||
# if ir.meta.reader.mode is 'http', set the timeout in milliseconds to fetch ir graph statistics | ||
# ir.statistics.fetch.interval.ms: 86400000l |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* | ||
* * Copyright 2020 Alibaba Group Holding Limited. | ||
* * | ||
* * Licensed 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 com.alibaba.graphscope.common.client.channel; | ||
|
||
import com.alibaba.graphscope.common.config.Configs; | ||
import com.alibaba.graphscope.common.config.FrontendConfig; | ||
import com.google.common.collect.ImmutableList; | ||
|
||
import java.net.URI; | ||
import java.util.List; | ||
|
||
// read meta service host from config and return it as URI format | ||
public class MetaServiceChannelFetcher implements ChannelFetcher<URI> { | ||
private static final String schema = "http"; | ||
private final Configs graphConfig; | ||
|
||
public MetaServiceChannelFetcher(Configs graphConfig) { | ||
this.graphConfig = graphConfig; | ||
} | ||
|
||
@Override | ||
public List<URI> fetch() { | ||
String host = FrontendConfig.IR_META_SERVICE_HOST.get(graphConfig); | ||
return ImmutableList.of(URI.create(schema + "://" + host)); | ||
} | ||
|
||
@Override | ||
public Type getType() { | ||
return Type.HTTP; | ||
} | ||
} |
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 still runs in local mode?