-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Improve comments in ConfigNode and DataNode #18603
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
base: master
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -165,6 +165,11 @@ public ConfigPhysicalPlanType getType() { | |
| return this.type; | ||
| } | ||
|
|
||
| /** | ||
| * Serializes this plan, including its type discriminator and implementation-specific payload. | ||
| * | ||
| * @return a buffer positioned at the beginning of the serialized plan | ||
| */ | ||
| @Override | ||
| public ByteBuffer serializeToByteBuffer() { | ||
| try (final PublicBAOS byteArrayOutputStream = new PublicBAOS(); | ||
|
|
@@ -189,6 +194,13 @@ public int getSerializedSize() throws IOException { | |
|
|
||
| public static class Factory { | ||
|
|
||
| /** | ||
| * Deserializes a plan from the buffer using the encoded type discriminator. | ||
| * | ||
| * @param buffer the buffer containing one serialized plan | ||
| * @return the deserialized plan | ||
| * @throws IOException if the encoded plan type or payload cannot be read | ||
|
Contributor
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. A truncated buffer is not covered by this documented exception: buffer.getShort() throws the unchecked BufferUnderflowException when fewer than two bytes remain. Please either validate/wrap buffer underflow as IOException or document the unchecked failure instead of promising IOException whenever the encoded type or payload cannot be read. |
||
| */ | ||
| public static ConfigPhysicalPlan create(final ByteBuffer buffer) throws IOException { | ||
| final short planType = buffer.getShort(); | ||
| final ConfigPhysicalPlanType configPhysicalPlanType = | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -84,6 +84,13 @@ public String getClusterId() { | |
| return clusterInfo.getClusterId(); | ||
| } | ||
|
|
||
| /** | ||
| * Waits up to the specified time for the cluster ID to become available. | ||
| * | ||
| * @param maxWaitTime maximum wait time in milliseconds | ||
| * @return the cluster ID, or null if it is unavailable after the timeout or the wait is | ||
| * interrupted | ||
| */ | ||
| public String getClusterIdWithRetry(long maxWaitTime) { | ||
| long startTime = System.currentTimeMillis(); | ||
| while (clusterInfo.getClusterId() == null | ||
|
|
@@ -109,7 +116,12 @@ private void generateClusterId() { | |
| } | ||
| } | ||
|
|
||
| // TODO: Parallel test ConfigNode and DataNode | ||
| /** | ||
| * Tests connectivity from this ConfigNode to all registered ConfigNodes and DataNodes and | ||
|
Contributor
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 probes do not all originate from this ConfigNode. This method sends the complete node list to every registered ConfigNode and DataNode, each recipient performs doConnectionTest(nodeLocations), and the leader aggregates those per-node results. Please describe this as a cluster-wide or all-to-all connectivity test coordinated by this ConfigNode. |
||
| * aggregates the results. | ||
| * | ||
| * @return aggregated connection-test results | ||
| */ | ||
| public TTestConnectionResp submitTestConnectionTaskToEveryNode() { | ||
| TTestConnectionResp resp = new TTestConnectionResp(); | ||
| resp.resultList = new ArrayList<>(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -156,10 +156,17 @@ protected void remove(Set<Integer> nodeIds) throws IoTDBException { | |
| ConfigNodeMessages.THE_REMOVE_CONFIGNODE_SCRIPT_HAS_BEEN_DEPRECATED_PLEASE_CONNECT_TO, -1); | ||
| } | ||
|
|
||
| /** | ||
| * Starts the ConfigNode services in dependency order. | ||
| * | ||
| * <p>The method must preserve the distinction between seed and non-seed ConfigNodes and must | ||
| * start the RPC service only after the local services required to handle requests are ready. | ||
|
Contributor
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. This is not true for the initial non-seed path. That path intentionally calls setUpRPCService() before sendRegisterConfigNodeRequest() and before the node has joined a consensus group so that the leader can schedule expansion. Please document this exception instead of stating that RPC always starts only after the required local services are ready. |
||
| */ | ||
| public void active() { | ||
| LOGGER.info(ConfigNodeMessages.ACTIVATING, ConfigNodeConstant.GLOBAL_NAME); | ||
|
|
||
| try { | ||
| // Process pid file, register deleteOnExit | ||
| processPid(); | ||
| // Add shutdown hook | ||
| addShutDownHook(); | ||
|
|
@@ -503,6 +510,12 @@ public void deactivate() throws IOException { | |
| LOGGER.info(ConfigNodeMessages.IS_DEACTIVATED, ConfigNodeConstant.GLOBAL_NAME); | ||
| } | ||
|
|
||
| /** | ||
| * Stops ConfigNode services and releases their resources in reverse dependency order. | ||
| * | ||
| * <p>The operation should be safe to invoke during partial startup and should not leave | ||
| * background scheduling, RPC, or consensus resources running. | ||
|
Comment on lines
+514
to
+517
Contributor
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. This cleanup contract is stronger than the implementation. deactivate() deregisters services and ConfigManager.close() shuts down the region maintainer, procedure executor, and consensus, but consensus shutdown does not guarantee that ConfigRegionStateMachine.stopLeaderServices() runs; ConfigRegionStateMachine.stop() itself only notifies the pipe runtime. The shutdown is also not implemented as reverse dependency order. Please narrow this Javadoc to the actual best-effort deactivation followed by process exit, or implement the promised cleanup. |
||
| */ | ||
| public void stop() { | ||
| try { | ||
| deactivate(); | ||
|
|
||
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 contract is not true for every implementation. ConfigPhysicalReadPlan.serializeImpl() is deliberately a no-op, so serializeToByteBuffer() returns an empty buffer with neither a type discriminator nor a payload for read plans. Please qualify the Javadoc to say that it serializes whatever the concrete implementation emits, or explicitly document the read-plan exception.