gnodet commented on code in PR #25498: URL: https://github.com/apache/camel/pull/25498#discussion_r3857117931
########## components/camel-alibaba/camel-alibaba-sls/src/main/java/org/apache/camel/component/alibaba/sls/constants/AlibabaSlsHeaders.java: ########## @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.alibaba.sls.constants; + +import org.apache.camel.spi.Metadata; + +public final class AlibabaSlsHeaders { + + @Metadata(label = "producer", description = "SLS project name override", javaType = "String") Review Comment: The sibling OTS component includes an `OPERATION` header constant in `AlibabaOtsHeaders`, and `AlibabaSlsUtils.createClientConfigurations()` reads the operation from exchange headers via `AlibabaSlsProperties.OPERATION`. However, `AlibabaSlsHeaders` omits this entry, so the SLS operation header won't appear in the generated catalog. Consider adding: ```java @Metadata(label = "producer", description = "Operation override", javaType = "String") public static final String OPERATION = AlibabaSlsProperties.OPERATION; ``` ########## components/camel-alibaba/camel-alibaba-sls/src/main/java/org/apache/camel/component/alibaba/sls/AlibabaSlsEndpoint.java: ########## @@ -0,0 +1,264 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.alibaba.sls; + +import com.aliyun.sls20201230.Client; +import org.apache.camel.Category; +import org.apache.camel.Consumer; +import org.apache.camel.Processor; +import org.apache.camel.Producer; +import org.apache.camel.component.alibaba.common.models.ServiceKeys; +import org.apache.camel.component.alibaba.sls.constants.AlibabaSlsHeaders; +import org.apache.camel.spi.Metadata; +import org.apache.camel.spi.UriEndpoint; +import org.apache.camel.spi.UriParam; +import org.apache.camel.spi.UriPath; +import org.apache.camel.support.DefaultEndpoint; + +/** + * Manage logs on Alibaba Cloud Simple Log Service (SLS). + */ +@UriEndpoint(firstVersion = "4.23.0", scheme = "alibaba-sls", title = "Alibaba Simple Log Service (SLS)", + syntax = "alibaba-sls:operation", category = { Category.CLOUD, Category.MONITORING }, + headersClass = AlibabaSlsHeaders.class, producerOnly = true) +public class AlibabaSlsEndpoint extends DefaultEndpoint { + + @UriPath(description = "Operation to perform", displayName = "Operation", label = "producer", + enums = "putLogs,getLogs,listLogStores") + @Metadata(required = true) + private String operation; + + @UriParam(description = "Alibaba Cloud region", displayName = "Region") + private String region; + + @UriParam(description = "SLS endpoint URL (e.g. cn-hangzhou.log.aliyuncs.com). " + + "Carries higher precedence than region based client initialization", + displayName = "Endpoint") + private String endpoint; + + @UriParam(description = "Access key for the cloud user", displayName = "Access Key", + secret = true, security = "secret", label = "security") + private String accessKey; + + @UriParam(description = "Secret key for the cloud user", displayName = "Secret Key", + secret = true, security = "secret", label = "security") + private String secretKey; + + @UriParam(description = "Configuration object for cloud service authentication", displayName = "Service Keys", + secret = true, security = "secret", label = "security") + private ServiceKeys serviceKeys; + + @UriParam(description = "SLS project name", displayName = "Project") + private String project; + + @UriParam(description = "SLS log store name", displayName = "Log Store Name") + private String logStoreName; + + @UriParam(description = "Log query string for getLogs", displayName = "Query", label = "getLogs") + private String query; + + @UriParam(description = "Query start time for getLogs (Unix timestamp in seconds)", displayName = "From", + label = "getLogs") + private Integer from; + + @UriParam(description = "Query end time for getLogs (Unix timestamp in seconds)", displayName = "To", + label = "getLogs") + private Integer to; + + @UriParam(description = "Maximum number of log lines to return for getLogs", displayName = "Line", + label = "getLogs") + private Long line; + + @UriParam(description = "Log query offset for getLogs", displayName = "Offset", label = "getLogs") + private Long offset; + + @UriParam(description = "Log topic filter for getLogs", displayName = "Topic", label = "getLogs") + private String topic; + + @UriParam(description = "Whether to return logs in reverse order for getLogs", displayName = "Reverse", + label = "getLogs") + private Boolean reverse; + + @UriParam(description = "Autowire an existing SLS client instance", displayName = "SLS Client", label = "advanced") + @Metadata(autowired = true) + private Client slsClient; + + private boolean autowiredSlsClient; + + public AlibabaSlsEndpoint() { + } + + public AlibabaSlsEndpoint(String uri, String operation, AlibabaSlsComponent component) { + super(uri, component); + this.operation = operation; + } + + @Override + public Producer createProducer() throws Exception { + return new AlibabaSlsProducer(this); + } + + @Override + public Consumer createConsumer(Processor processor) throws Exception { + throw new UnsupportedOperationException("You cannot consume from this endpoint"); + } + + public Client initClient() throws Exception { + if (slsClient != null) { + return slsClient; + } + slsClient = AlibabaSlsUtils.createClient(this); + return slsClient; + } + + @Override + protected void doStop() throws Exception { + if (slsClient != null && !autowiredSlsClient) { + slsClient = null; + } + super.doStop(); + } + + public String getOperation() { Review Comment: Minor inconsistency: `doStop()` sets `slsClient = null` without calling any close/shutdown method. The sibling OTS endpoint calls `otsClient.shutdown()` and the existing OSS endpoint calls `ossClient.close()` before nulling. If the Alibaba SLS `Client` (extending `com.aliyun.teaopenapi.Client`) holds HTTP connection pools, they won't be released. Could you check whether the SLS client has a `close()` or `shutdown()` method and call it here? -- 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]
