moremind commented on code in PR #5977:
URL: https://github.com/apache/shenyu/pull/5977#discussion_r2024748761


##########
shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/main/java/org/apache/shenyu/plugin/logging/elasticsearch/client/ElasticSearchLogCollectClient.java:
##########
@@ -145,6 +153,41 @@ public void createIndex(final String indexName) {
             LogUtils.error(LOG, "create index error:", e);
         }
     }
+    
+    /**
+     * Get the actual index name for the current date.
+     *
+     * @return the actual index name with date suffix
+     */
+    private String getActualIndexName() {
+        String date = LocalDate.now().format(DATE_FORMAT);
+        return String.format("%s-%s", indexName, date);
+    }
+    
+    /**
+     * Create an index alias that points to all date-based indices.
+     *
+     * @param aliasName the alias name
+     */
+    private void createOrUpdateIndexAlias(final String aliasName) {
+        try {
+            String actualIndex = getActualIndexName();
+            // Create the actual index if it doesn't exist
+            if (!existsIndex(actualIndex)) {
+                createIndex(actualIndex);
+                LogUtils.info(LOG, "Created new date-based index: {}", 
actualIndex);
+            }
+            
+            // Create or update the alias to point to the current index
+            client.indices().putAlias(r -> r
+                    .index(actualIndex)
+                    .name(aliasName)

Review Comment:
   format the code



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

Reply via email to