apache / apache/geaflow

refactor: piplineutil async mode

Open
#607 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
808
Forks
188
Avg merge
3d 22h
Merged PRs (30d)
2

Description

## Analysis of current implementation issues

The `isAsync` method in `PipelineUtil.java` currently relies solely on the `SERVICE_SHARE_ENABLE` configuration key to determine the asynchronous mode. This implementation is overly simple and lacks flexibility.

## Refactoring Plan

### 1. Create an Async Mode Strategy Interface

It is recommended to create an `AsyncModeStrategy` interface to abstract the asynchronous mode decision logic:

```java
public interface AsyncModeStrategy {
boolean shouldUseAsyncMode(Configuration config);
String getStrategyName();
}
```

### 2. Implement Multiple Decision Strategies

- **ConfigBasedStrategy**: Configuration-based strategy (maintains compatibility with existing logic)
- **ResourceBasedStrategy**: Resource-based strategy
- **WorkloadBasedStrategy**: Workload-based strategy
- **HybridStrategy**: A strategy that combines multiple factors

### 3. Refactor the PipelineUtil Class

Refactor the `isAsync` method in `PipelineUtil` to:

```java
public class PipelineUtil {
private static final Map strategies = new HashMap<>();
private static final String DEFAULT_STRATEGY = "config-based";

public static boolean isAsync(Configuration config) {
String strategyName = config.getString(FrameworkConfigKeys.ASYNC_MODE_STRATEGY, DEFAULT_STRATEGY);
AsyncModeStrategy strategy = strategies.getOrDefault(strategyName, new ConfigBasedStrategy());
return strategy.shouldUseAsyncMode(config);
}
}
```

### 4. Add new configuration key

Add related configuration keys in `FrameworkConfigKeys.java`:

```java
public static final ConfigKey ASYNC_MODE_STRATEGY = ConfigKeys
.key("geaflow.pipeline.async.strategy")
.defaultValue("config-based") .description("Strategy for determining async mode");
```

### 5. Update PipelineClientFactory

Ensure `PipelineClientFactory` can correctly use the refactored asynchronous mode checking logic .

### 6. Enhance Validation Logic

Add configuration validation and exception handling:
- Verify configuration validity
- Provide clear error messages
- Support hot configuration updates

#

Contributor guide

Open the contributing guide

Research direction

Start by reading PipelineUtil.java and its current isAsync method, then inspect FrameworkConfigKeys.java and PipelineClientFactory to trace configuration and async-mode usage. Review the proposed strategy and validation requirements against the existing implementation; done means the selected strategy, configuration handling, validation, error reporting, and client-factory behavior are defined and covered appropriately.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
distributed-systems
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.