dosubot[bot] commented on issue #2668:
URL: 
https://github.com/apache/incubator-hugegraph/issues/2668#issuecomment-2367415436

   <!-- Answer -->
   To address the issue of creating hundreds of graph instances on a single 
node and the resulting MySQL connection limitations, it's important to 
understand the user's usage scenarios and methods. Here are some key points:
   
   ### Usage Scenarios and Methods for Creating Graph Instances
   
   1. **Dynamic Graph Creation**:
      - The `createGraph` method allows for the dynamic creation of graph 
instances. This method checks if dynamic creation is enabled 
(`ENABLE_DYNAMIC_CREATE_DROP`), validates the graph name, and then creates a 
new graph instance using the provided configuration.
      - Example:
        ```java
        public HugeGraph createGraph(String name, String configText) {
            
E.checkArgument(this.conf.get(ServerOptions.ENABLE_DYNAMIC_CREATE_DROP),
                            "Not allowed to create graph '%s' dynamically, " +
                            "please set `enable_dynamic_create_drop` to true.",
                            name);
            E.checkArgument(StringUtils.isNotEmpty(name),
                            "The graph name can't be null or empty");
            E.checkArgument(!this.graphs().contains(name),
                            "The graph name '%s' has existed", name);
   
            PropertiesConfiguration propConfig = 
ConfigUtil.buildConfig(configText);
            HugeConfig config = new HugeConfig(propConfig);
            this.checkOptions(config);
   
            return this.createGraph(config, name);
        }
        ```
   
   2. **Cloning Graphs**:
      - The `cloneGraph` method allows for cloning an existing graph with a new 
name and optional configuration changes.
      - Example:
        ```java
        public HugeGraph cloneGraph(String name, String newName, String 
configText) {
            HugeGraph cloneGraph = this.graph(name);
            E.checkArgumentNotNull(cloneGraph,
                                   "The clone graph '%s' doesn't exist", name);
            E.checkArgument(StringUtils.isNotEmpty(newName),
                            "The graph name can't be null or empty");
            E.checkArgument(!this.graphs().contains(newName),
                            "The graph '%s' has existed", newName);
   
            HugeConfig cloneConfig = cloneGraph.cloneConfig(newName);
            if (StringUtils.isNotEmpty(configText)) {
                PropertiesConfiguration propConfig = 
ConfigUtil.buildConfig(configText);
                propConfig.getKeys().forEachRemaining(key -> {
                    cloneConfig.setProperty(key, propConfig.getProperty(key));
                });
                this.checkOptions(cloneConfig);
            }
   
            return this.createGraph(cloneConfig, newName);
        }
        ```
   
   3. **Loading Graphs**:
      - The `loadGraphs` method loads graph configurations from a specified 
directory and initializes them.
      - Example:
        ```java
        public void loadGraphs(Map<String, String> graphConfs) {
            for (Map.Entry<String, String> conf : graphConfs.entrySet()) {
                String name = conf.getKey();
                String graphConfPath = conf.getValue();
                HugeFactory.checkGraphName(name, "rest-server.properties");
                try {
                    this.loadGraph(name, graphConfPath);
                } catch (Throwable e) {
                    LOG.error("Graph '{}' can't be loaded: '{}'", name, 
graphConfPath, e);
                }
            }
        }
        ```
   
   ### Reasons for Not Using Subgraph Partitioning, Permission Management, or 
Tenants
   
   1. **Complexity and Overhead**:
      - Implementing subgraph partitioning, permission management, or 
multi-tenancy can add significant complexity and overhead to the system. The 
current approach of managing multiple graph instances might be simpler and more 
straightforward for the use cases intended by the developers.
   
   2. **Dynamic Graph Management**:
      - The ability to dynamically create, clone, and drop graph instances 
suggests a flexible and dynamic environment where individual graph instances 
are managed independently. This might be more aligned with the system's design 
goals compared to managing subgraphs or tenants.
   
   3. **Resource Isolation**:
      - By creating separate graph instances, each graph can have its own 
configuration and resources, providing a form of isolation without the need for 
more complex partitioning or multi-tenancy mechanisms.
   
   These points should help clarify the user's usage scenarios and methods, and 
why they might not be using subgraph partitioning, permission management, or 
tenants for resource isolation 
<sup>[[1]](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java)</sup>.
   
   
   <!-- Dosu Comment Footer -->
   *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
   


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to