letaoj commented on code in PR #85: URL: https://github.com/apache/flink-agents/pull/85#discussion_r2255483649
########## api/src/main/java/org/apache/flink/agents/api/AgentsExecutionEnvironment.java: ########## @@ -0,0 +1,161 @@ +/* + * 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.flink.agents.api; + +import org.apache.flink.api.java.functions.KeySelector; +import org.apache.flink.streaming.api.datastream.DataStream; +import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; +import org.apache.flink.table.api.Table; +import org.apache.flink.table.api.bridge.java.StreamTableEnvironment; + +import java.util.List; + +/** + * Base class for agent execution environment. + * + * <p>This class provides the main entry point for integrating Flink Agents with different types of + * Flink data sources (DataStream, Table, or simple lists). + */ +public abstract class AgentsExecutionEnvironment { + + /** + * Get agents execution environment. + * + * <p>Factory method that creates an appropriate execution environment based on the provided + * StreamExecutionEnvironment. If no environment is provided, a local execution environment is + * returned for testing and development. + * + * <p>When integrating with Flink DataStream/Table APIs, users should pass the Flink + * StreamExecutionEnvironment to enable remote execution capabilities. + * + * @param env Optional StreamExecutionEnvironment for remote execution. If null, a local + * execution environment will be created. + * @return AgentsExecutionEnvironment appropriate for the execution context. + */ + public static AgentsExecutionEnvironment getExecutionEnvironment( + StreamExecutionEnvironment env) { + if (env == null) { + // Return local execution environment for testing/development + try { + Class<?> localEnvClass = + Class.forName( + "org.apache.flink.agents.runtime.env.LocalExecutionEnvironment"); Review Comment: use class reference to break the cyclic dependency problem. -- 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]
