[AINode] AINode docker compose file (#15987)

This commit is contained in:
Yongzao 2025-07-21 23:31:10 +08:00 committed by GitHub
parent 5bb17061bb
commit 2288d7af39
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 118 additions and 123 deletions

View File

@ -17,16 +17,30 @@
# under the License.
#
volumes:
ainode-data:
driver: local
driver_opts:
type: none
device: /data/ainode
o: bind
services:
iotdb-ainode:
image: apache/iotdb:2.0.5-SNAPSHOT-ainode
hostname: iotdb-ainode
image: apache/iotdb:<version>-ainode
container_name: iotdb-ainode
ports:
- "10810:10810"
network_mode: host
environment:
- ain_seed_config_node=iotdb-confignode:10710
- ain_inference_rpc_address=iotdb-ainode
- ain_inference_rpc_port=10810
- cluster_name=defaultCluster
- ain_seed_config_node=<iotdb-confignode>:10710
- ain_rpc_address=<iotdb-ainode>
- ain_rpc_port=10810
- ain_cluster_ingress_address=<iotdb-datanode>
- ain_cluster_ingress_port=6667
- ain_cluster_ingress_username=root
- ain_cluster_ingress_password=root
- ain_cluster_ingress_time_zone=UTC+8
volumes:
- ./logs/ainode:/ainode/logs
- ainode-data:/ainode/data
- ./logs/ainode:/ainode/logs
# - ./lib/ainode:/ainode/lib # Uncomment for rolling upgrade

View File

@ -55,8 +55,8 @@ services:
container_name: iotdb-ainode
environment:
- ain_seed_config_node=iotdb-service:10710
- ain_inference_rpc_address=iotdb-ainode
- ain_inference_rpc_port=10810
- ain_rpc_address=iotdb-ainode
- ain_rpc_port=10810
volumes:
- ./logs/ainode:/ainode/logs
networks:

View File

@ -62,8 +62,5 @@ ENV PATH="${IOTDB_AINODE_HOME}/sbin/:${IOTDB_AINODE_HOME}/tools/:${PATH}"
RUN bash start-ainode.sh || true
RUN rm -r ${IOTDB_AINODE_HOME}/logs/*
EXPOSE 10810
VOLUME $IOTDB_AINODE_HOME/logs
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
CMD ["bash", "-c", "entrypoint.sh ainode"]

View File

@ -111,7 +111,7 @@ public class AINodeWrapper extends AbstractNodeWrapper {
// set attribute
replaceAttribute(
new String[] {"ain_seed_config_node", "ain_inference_rpc_port"},
new String[] {"ain_seed_config_node", "ain_rpc_port"},
new String[] {this.seedConfigNode, Integer.toString(getPort())},
propertiesFile);

View File

@ -43,8 +43,8 @@ def _generate_configuration() -> TAINodeConfiguration:
location = TAINodeLocation(
AINodeDescriptor().get_config().get_ainode_id(),
TEndPoint(
AINodeDescriptor().get_config().get_ain_inference_rpc_address(),
AINodeDescriptor().get_config().get_ain_inference_rpc_port(),
AINodeDescriptor().get_config().get_ain_rpc_address(),
AINodeDescriptor().get_config().get_ain_rpc_port(),
),
)
resource = TNodeResource(int(psutil.cpu_count()), int(psutil.virtual_memory()[0]))
@ -76,10 +76,8 @@ def _generate_system_properties(ainode_id: int):
"cluster_name": AINodeDescriptor().get_config().get_cluster_name(),
"iotdb_version": AINodeDescriptor().get_config().get_version_info(),
"commit_id": AINodeDescriptor().get_config().get_build_info(),
"ain_rpc_address": AINodeDescriptor()
.get_config()
.get_ain_inference_rpc_address(),
"ain_rpc_port": AINodeDescriptor().get_config().get_ain_inference_rpc_port(),
"ain_rpc_address": AINodeDescriptor().get_config().get_ain_rpc_address(),
"ain_rpc_port": AINodeDescriptor().get_config().get_ain_rpc_port(),
"config_node_list": AINodeDescriptor()
.get_config()
.get_ain_target_config_node_list(),

View File

@ -31,12 +31,12 @@ from ainode.core.constant import (
AINODE_CONF_GIT_FILE_NAME,
AINODE_CONF_POM_FILE_NAME,
AINODE_INFERENCE_BATCH_INTERVAL_IN_MS,
AINODE_INFERENCE_RPC_ADDRESS,
AINODE_INFERENCE_RPC_PORT,
AINODE_LOG_DIR,
AINODE_MODELS_DIR,
AINODE_ROOT_CONF_DIRECTORY_NAME,
AINODE_ROOT_DIR,
AINODE_RPC_ADDRESS,
AINODE_RPC_PORT,
AINODE_SYSTEM_DIR,
AINODE_SYSTEM_FILE_NAME,
AINODE_TARGET_CONFIG_NODE_LIST,
@ -53,9 +53,22 @@ logger = Logger()
class AINodeConfig(object):
def __init__(self):
# Used for connection of DataNode/ConfigNode clients
self._ain_inference_rpc_address: str = AINODE_INFERENCE_RPC_ADDRESS
self._ain_inference_rpc_port: int = AINODE_INFERENCE_RPC_PORT
self._version_info = AINODE_VERSION_INFO
self._build_info = AINODE_BUILD_INFO
# Cluster configuration
self._ainode_id = 0
self._cluster_name = AINODE_CLUSTER_NAME
self._ain_target_config_node_list: TEndPoint = AINODE_TARGET_CONFIG_NODE_LIST
self._ain_rpc_address: str = AINODE_RPC_ADDRESS
self._ain_rpc_port: int = AINODE_RPC_PORT
self._ain_cluster_ingress_address = AINODE_CLUSTER_INGRESS_ADDRESS
self._ain_cluster_ingress_port = AINODE_CLUSTER_INGRESS_PORT
self._ain_cluster_ingress_username = AINODE_CLUSTER_INGRESS_USERNAME
self._ain_cluster_ingress_password = AINODE_CLUSTER_INGRESS_PASSWORD
self._ain_cluster_ingress_time_zone = AINODE_CLUSTER_INGRESS_TIME_ZONE
# Inference configuration
self._ain_inference_batch_interval_in_ms: int = (
AINODE_INFERENCE_BATCH_INTERVAL_IN_MS
)
@ -77,23 +90,6 @@ class AINodeConfig(object):
# Cache number of model storage to avoid repeated loading
self._ain_model_storage_cache_size = 30
# Target ConfigNode to be connected by AINode
self._ain_target_config_node_list: TEndPoint = AINODE_TARGET_CONFIG_NODE_LIST
# use for node management
self._ainode_id = 0
self._cluster_name = AINODE_CLUSTER_NAME
# connect IoTDB cluster
self._ain_cluster_ingress_address = AINODE_CLUSTER_INGRESS_ADDRESS
self._ain_cluster_ingress_port = AINODE_CLUSTER_INGRESS_PORT
self._ain_cluster_ingress_username = AINODE_CLUSTER_INGRESS_USERNAME
self._ain_cluster_ingress_password = AINODE_CLUSTER_INGRESS_PASSWORD
self._ain_cluster_ingress_time_zone = AINODE_CLUSTER_INGRESS_TIME_ZONE
self._version_info = AINODE_VERSION_INFO
self._build_info = AINODE_BUILD_INFO
def get_cluster_name(self) -> str:
return self._cluster_name
@ -124,17 +120,17 @@ class AINodeConfig(object):
def set_version_info(self, version_info: str) -> None:
self._version_info = version_info
def get_ain_inference_rpc_address(self) -> str:
return self._ain_inference_rpc_address
def get_ain_rpc_address(self) -> str:
return self._ain_rpc_address
def set_ain_inference_rpc_address(self, ain_inference_rpc_address: str) -> None:
self._ain_inference_rpc_address = ain_inference_rpc_address
def set_ain_rpc_address(self, ain_rpc_address: str) -> None:
self._ain_rpc_address = ain_rpc_address
def get_ain_inference_rpc_port(self) -> int:
return self._ain_inference_rpc_port
def get_ain_rpc_port(self) -> int:
return self._ain_rpc_port
def set_ain_inference_rpc_port(self, ain_inference_rpc_port: int) -> None:
self._ain_inference_rpc_port = ain_inference_rpc_port
def set_ain_rpc_port(self, ain_rpc_port: int) -> None:
self._ain_rpc_port = ain_rpc_port
def get_ain_inference_batch_interval_in_ms(self) -> int:
return self._ain_inference_batch_interval_in_ms
@ -275,15 +271,11 @@ class AINodeDescriptor(object):
config_keys = file_configs.keys()
if "ain_inference_rpc_address" in config_keys:
self._config.set_ain_inference_rpc_address(
file_configs["ain_inference_rpc_address"]
)
if "ain_rpc_address" in config_keys:
self._config.set_ain_rpc_address(file_configs["ain_rpc_address"])
if "ain_inference_rpc_port" in config_keys:
self._config.set_ain_inference_rpc_port(
int(file_configs["ain_inference_rpc_port"])
)
if "ain_rpc_port" in config_keys:
self._config.set_ain_rpc_port(int(file_configs["ain_rpc_port"]))
if "ain_inference_batch_interval_in_ms" in config_keys:
self._config.set_ain_inference_batch_interval_in_ms(

View File

@ -23,6 +23,8 @@ from typing import List
from ainode.thrift.common.ttypes import TEndPoint
AINODE_VERSION_INFO = "UNKNOWN"
AINODE_BUILD_INFO = "UNKNOWN"
AINODE_CONF_DIRECTORY_NAME = "conf"
AINODE_ROOT_CONF_DIRECTORY_NAME = "conf"
AINODE_CONF_FILE_NAME = "iotdb-ainode.properties"
@ -30,33 +32,33 @@ AINODE_CONF_GIT_FILE_NAME = "git.properties"
AINODE_CONF_POM_FILE_NAME = "pom.properties"
AINODE_SYSTEM_FILE_NAME = "system.properties"
# inference_rpc_address
AINODE_INFERENCE_RPC_ADDRESS = "127.0.0.1"
AINODE_INFERENCE_RPC_PORT = 10810
AINODE_INFERENCE_BATCH_INTERVAL_IN_MS = 15
# AINode folder structure
AINODE_MODELS_DIR = "data/ainode/models"
AINODE_BUILTIN_MODELS_DIR = "data/ainode/models/weights" # For built-in models, we only need to store their weights and config.
AINODE_SYSTEM_DIR = "data/ainode/system"
AINODE_LOG_DIR = "logs"
AINODE_THRIFT_COMPRESSION_ENABLED = False
# use for node management
# AINode cluster configuration
AINODE_CLUSTER_NAME = "defaultCluster"
AINODE_VERSION_INFO = "UNKNOWN"
AINODE_BUILD_INFO = "UNKNOWN"
AINODE_ROOT_DIR = os.path.dirname(
os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
)
# connect IoTDB cluster
AINODE_TARGET_CONFIG_NODE_LIST = TEndPoint("127.0.0.1", 10710)
AINODE_RPC_ADDRESS = "127.0.0.1"
AINODE_RPC_PORT = 10810
AINODE_CLUSTER_INGRESS_ADDRESS = "127.0.0.1"
AINODE_CLUSTER_INGRESS_PORT = 6667
AINODE_CLUSTER_INGRESS_USERNAME = "root"
AINODE_CLUSTER_INGRESS_PASSWORD = "root"
AINODE_CLUSTER_INGRESS_TIME_ZONE = "UTC+8"
AINODE_TARGET_CONFIG_NODE_LIST = TEndPoint("127.0.0.1", 10710)
# RPC config
AINODE_THRIFT_COMPRESSION_ENABLED = False
DEFAULT_RECONNECT_TIMEOUT = 20
DEFAULT_RECONNECT_TIMES = 3
# AINode inference configuration
AINODE_INFERENCE_BATCH_INTERVAL_IN_MS = 15
# AINode folder structure
AINODE_ROOT_DIR = os.path.dirname(
os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
)
AINODE_MODELS_DIR = "data/ainode/models"
AINODE_BUILTIN_MODELS_DIR = "data/ainode/models/weights" # For built-in models, we only need to store their weights and config.
AINODE_SYSTEM_DIR = "data/ainode/system"
AINODE_LOG_DIR = "logs"
# AINode log
AINODE_LOG_FILE_NAMES = [
@ -66,21 +68,15 @@ AINODE_LOG_FILE_NAMES = [
"log_ainode_error.log",
]
AINODE_LOG_FILE_LEVELS = [logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR]
STD_LEVEL = logging.INFO
TRIAL_ID_PREFIX = "__trial_"
DEFAULT_TRIAL_ID = TRIAL_ID_PREFIX + "0"
# AINode model management
MODEL_WEIGHTS_FILE_IN_SAFETENSORS = "model.safetensors"
MODEL_CONFIG_FILE_IN_JSON = "config.json"
DEFAULT_MODEL_FILE_NAME = "model.pt"
DEFAULT_CONFIG_FILE_NAME = "config.yaml"
DEFAULT_CHUNK_SIZE = 8192
DEFAULT_RECONNECT_TIMEOUT = 20
DEFAULT_RECONNECT_TIMES = 3
STD_LEVEL = logging.INFO
class TSStatusCode(Enum):
SUCCESS_STATUS = 200

View File

@ -71,8 +71,8 @@ class AINodeRPCService(threading.Thread):
self._handler = handler
processor = IAINodeRPCService.Processor(handler=self._handler)
transport = TSocket.TServerSocket(
host=AINodeDescriptor().get_config().get_ain_inference_rpc_address(),
port=AINodeDescriptor().get_config().get_ain_inference_rpc_port(),
host=AINodeDescriptor().get_config().get_ain_rpc_address(),
port=AINodeDescriptor().get_config().get_ain_rpc_port(),
)
transport_factory = TTransport.TFramedTransportFactory()
if AINodeDescriptor().get_config().get_ain_thrift_compression_enabled():

View File

@ -39,10 +39,8 @@ def remove_ainode(arguments):
# Delete the current node
if len(arguments) == 2:
target_ainode_id = AINodeDescriptor().get_config().get_ainode_id()
target_rpc_address = (
AINodeDescriptor().get_config().get_ain_inference_rpc_address()
)
target_rpc_port = AINodeDescriptor().get_config().get_ain_inference_rpc_port()
target_rpc_address = AINodeDescriptor().get_config().get_ain_rpc_address()
target_rpc_port = AINodeDescriptor().get_config().get_ain_rpc_port()
# Delete the node with a given id
elif len(arguments) == 3:

View File

@ -26,6 +26,16 @@ cluster_name=defaultCluster
# Datatype: String
ain_seed_config_node=127.0.0.1:10710
# Used for connection of DataNode/ConfigNode clients
# Could set 127.0.0.1(for local test) or ipv4 address
# Datatype: String
ain_rpc_address=127.0.0.1
# Used for connection of DataNode/ConfigNode clients
# Bind with MN_RPC_ADDRESS
# Datatype: String
ain_rpc_port=10810
# The DataNode address for fetching IoTDB data
# Datatype: String
ain_cluster_ingress_address=127.0.0.1
@ -46,16 +56,6 @@ ain_cluster_ingress_password=root
# Datatype: String
ain_cluster_ingress_time_zone=UTC+8
# Used for connection of DataNode/ConfigNode clients
# Could set 127.0.0.1(for local test) or ipv4 address
# Datatype: String
ain_inference_rpc_address=127.0.0.1
# Used for connection of DataNode/ConfigNode clients
# Bind with MN_RPC_ADDRESS
# Datatype: String
ain_inference_rpc_port=10810
# The AINode metadata storage path.
# The starting directory of the relative path is related to the operating system.
# It is recommended to use an absolute path.

View File

@ -20,14 +20,14 @@
AINODE_CONF="`dirname "$0"`/../conf"
if [ -f "${AINODE_CONF}/iotdb-ainode.properties" ]; then
ain_inference_rpc_port=$(sed '/^ain_inference_rpc_port=/!d;s/.*=//' "${AINODE_CONF}"/iotdb-ainode.properties)
ain_rpc_port=$(sed '/^ain_rpc_port=/!d;s/.*=//' "${AINODE_CONF}"/iotdb-ainode.properties)
# trim the port
ain_inference_rpc_port=$(echo "$ain_inference_rpc_port" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
ain_rpc_port=$(echo "$ain_rpc_port" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
fi
if [ -z "$ain_inference_rpc_port" ]; then
echo "WARNING: ain_inference_rpc_port not found in the configuration file. Using default value ain_inference_rpc_port=10810"
ain_inference_rpc_port=10810
if [ -z "$ain_rpc_port" ]; then
echo "WARNING: ain_rpc_port not found in the configuration file. Using default value ain_rpc_port=10810"
ain_rpc_port=10810
fi
# fetch parameters with names
@ -45,18 +45,18 @@ while getopts "i:t:r" opt; do
esac
done
# If p_ain_remove_target exists, take the value after the colon of p_ain_remove_target as ain_inference_rpc_port
# If p_ain_remove_target exists, take the value after the colon of p_ain_remove_target as ain_rpc_port
if [ -n "$p_ain_remove_target" ]; then
ain_inference_rpc_port=${p_ain_remove_target#*:}
ain_rpc_port=${p_ain_remove_target#*:}
fi
echo "Check whether the rpc_port is used..., port is" $ain_inference_rpc_port
echo "Check whether the rpc_port is used..., port is" $ain_rpc_port
if type lsof > /dev/null 2>&1 ; then
echo $(lsof -t -i:"${ain_inference_rpc_port}" -sTCP:LISTEN)
PID=$(lsof -t -i:"${ain_inference_rpc_port}" -sTCP:LISTEN)
echo $(lsof -t -i:"${ain_rpc_port}" -sTCP:LISTEN)
PID=$(lsof -t -i:"${ain_rpc_port}" -sTCP:LISTEN)
elif type netstat > /dev/null 2>&1 ; then
PID=$(netstat -anp 2>/dev/null | grep ":${ain_inference_rpc_port} " | grep ' LISTEN ' | awk '{print $NF}' | sed "s|/.*||g" )
PID=$(netstat -anp 2>/dev/null | grep ":${ain_rpc_port} " | grep ' LISTEN ' | awk '{print $NF}' | sed "s|/.*||g" )
else
echo ""
echo " Error: No necessary tool."

View File

@ -35,27 +35,27 @@ shift
goto initial
:done
for /f "eol=# tokens=2 delims==" %%i in ('findstr /i "^ain_inference_rpc_port"
for /f "eol=# tokens=2 delims==" %%i in ('findstr /i "^ain_rpc_port"
%IOTDB_AINODE_HOME%\conf\iotdb-ainode.properties') do (
set ain_inference_rpc_port=%%i
set ain_rpc_port=%%i
)
echo Check whether the rpc_port is used..., port is %ain_inference_rpc_port%
echo Check whether the rpc_port is used..., port is %ain_rpc_port%
for /f "eol=# tokens=2 delims==" %%i in ('findstr /i "ain_inference_rpc_address"
for /f "eol=# tokens=2 delims==" %%i in ('findstr /i "ain_rpc_address"
%IOTDB_AINODE_HOME%\conf\iotdb-ainode.properties') do (
set ain_inference_rpc_address=%%i
set ain_rpc_address=%%i
)
if defined t (
for /f "tokens=2 delims=/" %%a in ("%t%") do set "ain_inference_rpc=%%a"
for /f "tokens=2 delims=/" %%a in ("%t%") do set "ain_rpc=%%a"
) else (
set ain_inference_rpc=%ain_inference_rpc_address%:%ain_inference_rpc_port%
set ain_rpc=%ain_rpc_address%:%ain_rpc_port%
)
echo Target AINode to be stopped: %ain_inference_rpc%
echo Target AINode to be stopped: %ain_rpc%
for /f "tokens=5" %%a in ('netstat /ano ^| findstr /r /c:"^ *TCP *%ain_inference_rpc%.*$"') do (
for /f "tokens=5" %%a in ('netstat /ano ^| findstr /r /c:"^ *TCP *%ain_rpc%.*$"') do (
taskkill /f /pid %%a
echo Close AINode, PID: %%a
)