dosubot[bot] commented on issue #2667:
URL:
https://github.com/apache/incubator-hugegraph/issues/2667#issuecomment-2380581088
<!-- Answer -->
To resolve the `java.lang.IllegalArgumentException: The server with name
'server-1' already in cluster` error when restarting a HugeGraph container, you
need to ensure that the server information is properly removed before
restarting. The `ServerInfoManager` class has a method `removeSelfServerInfo`
that can be used to remove the server information.
Here is a code snippet that demonstrates how to remove the server
information before restarting the container:
```java
public synchronized boolean close() {
this.closed = true;
if (!this.dbExecutor.isShutdown()) {
this.removeSelfServerInfo();
this.call(() -> {
try {
this.tx().close();
} catch (ConnectionException ignored) {
// ConnectionException means no connection established
}
this.graph.closeTx();
return null;
});
}
return true;
}
```
Additionally, ensure that the `server.id` in your `rest-server.properties`
configuration file is unique for each server in the cluster. The default value
is `server-1`, and if multiple servers use the same ID, it will cause
conflicts. You can change the `server.id` to a unique value for each server:
```properties
server.id=unique-server-id
```
Ensure that this method is called before the container is restarted to
remove the server information and avoid the `IllegalArgumentException`. Also,
verify that the `server.id` is unique across your cluster configuration.
Refer to the HugeGraph configuration documentation for more details on the
`rest-server.properties` file and other configuration options:
```properties
# rest-server.properties
server.id=server-1
server.role=master
restserver.url=http://127.0.0.1:8080
# Other configurations...
```
By following these steps, you can avoid conflicts and ensure a smooth
restart of your HugeGraph container
<sup>[[1]](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/ServerInfoManager.java)</sup><sup>[[2]](https://github.com/apache/incubator-hugegraph-doc/blob/master/content/en/docs/config/config-option.md)</sup><sup>[[3]](https://github.com/apache/incubator-hugegraph-doc/blob/master/content/cn/docs/config/config-option.md)</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]