or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

index.md

index.mddocs/

0

# CDAP Features

1

2

CDAP Features is a Java library that provides feature flag management functionality for the CDAP (Cask Data Application Platform) ecosystem. It enables runtime control of platform features based on version compatibility and administrative configuration.

3

4

## Package Information

5

6

- **Package Name**: cdap-features

7

- **Package Type**: Maven

8

- **Group ID**: io.cdap.cdap

9

- **Artifact ID**: cdap-features

10

- **Language**: Java

11

- **Installation**: Add Maven dependency:

12

```xml

13

<dependency>

14

<groupId>io.cdap.cdap</groupId>

15

<artifactId>cdap-features</artifactId>

16

<version>6.11.0</version>

17

</dependency>

18

```

19

20

## Core Imports

21

22

```java

23

import io.cdap.cdap.features.Feature;

24

import io.cdap.cdap.api.feature.FeatureFlagsProvider;

25

import io.cdap.cdap.api.PlatformInfo;

26

import javax.annotation.Nullable;

27

```

28

29

## Basic Usage

30

31

```java

32

import io.cdap.cdap.features.Feature;

33

import io.cdap.cdap.api.feature.FeatureFlagsProvider;

34

35

// Assuming you have a FeatureFlagsProvider implementation

36

FeatureFlagsProvider provider = // ... obtained from configuration

37

38

// Check if a specific feature is enabled

39

boolean isEnabled = Feature.EVENT_PUBLISH.isEnabled(provider);

40

41

if (isEnabled) {

42

// Use the feature

43

enableEventPublishing();

44

}

45

46

// Get the feature flag string identifier

47

String flagName = Feature.EVENT_PUBLISH.getFeatureFlagString();

48

// Returns: "event.publish.enabled"

49

```

50

51

## Architecture

52

53

The CDAP Features library is built around a simple but powerful design:

54

55

- **Feature Enum**: Defines all available feature flags as enumerated constants with version information

56

- **Version-based Logic**: Features are automatically enabled/disabled based on platform version compatibility

57

- **Configuration Override**: Features can be explicitly enabled/disabled through FeatureFlagsProvider configuration

58

- **Default Behavior Control**: Each feature defines its default behavior after introduction (enabled/disabled)

59

60

## Capabilities

61

62

### Feature Flag Management

63

64

The core functionality revolves around the `Feature` enum which provides version-aware feature flag management.

65

66

```java { .api }

67

public enum Feature {

68

REPLICATION_TRANSFORMATIONS("6.6.0"),

69

EVENT_PUBLISH("6.7.0", false),

70

EVENT_READER("6.10.0", false),

71

PIPELINE_COMPOSITE_TRIGGERS("6.8.0"),

72

PUSHDOWN_TRANSFORMATION_GROUPBY("6.7.0"),

73

PUSHDOWN_TRANSFORMATION_DEDUPLICATE("6.7.0"),

74

STREAMING_PIPELINE_CHECKPOINT_DELETION("6.7.1"),

75

LIFECYCLE_MANAGEMENT_EDIT("6.8.0"),

76

WRANGLER_FAIL_PIPELINE_FOR_ERROR("6.8.0"),

77

STREAMING_PIPELINE_NATIVE_STATE_TRACKING("6.8.0", false),

78

PUSHDOWN_TRANSFORMATION_WINDOWAGGREGATION("6.9.1"),

79

SOURCE_CONTROL_MANAGEMENT_GIT("6.9.0"),

80

SOURCE_CONTROL_MANAGEMENT_MULTI_APP("6.10.0"),

81

WRANGLER_PRECONDITION_SQL("6.9.1"),

82

WRANGLER_EXECUTION_SQL("6.10.0"),

83

WRANGLER_SCHEMA_MANAGEMENT("6.10.0"),

84

NAMESPACED_SERVICE_ACCOUNTS("6.10.0"),

85

WRANGLER_KRYO_SERIALIZATION("6.10.1"),

86

SOURCE_CONTROL_MANAGEMENT_GITLAB_BITBUCKET("6.10.1"),

87

DATAPLANE_AUDIT_LOGGING("6.10.1");

88

89

// Constructors

90

Feature(String versionIntroduced);

91

Feature(String versionIntroduced, boolean defaultAfterIntroduction);

92

93

// Methods

94

public boolean isEnabled(FeatureFlagsProvider featureFlagsProvider);

95

public String getFeatureFlagString();

96

}

97

```

98

99

#### Feature Constants

100

101

Each feature constant represents a specific CDAP platform capability:

102

103

- **REPLICATION_TRANSFORMATIONS**: Enables data replication transformations (introduced in 6.6.0)

104

- **EVENT_PUBLISH**: Enables event publishing functionality (introduced in 6.7.0, defaults to disabled)

105

- **EVENT_READER**: Enables event reader functionality (introduced in 6.10.0, defaults to disabled)

106

- **PIPELINE_COMPOSITE_TRIGGERS**: Enables composite triggers in pipelines (introduced in 6.8.0)

107

- **PUSHDOWN_TRANSFORMATION_GROUPBY**: Enables pushdown GroupBy transformations (introduced in 6.7.0)

108

- **PUSHDOWN_TRANSFORMATION_DEDUPLICATE**: Enables pushdown deduplication transformations (introduced in 6.7.0)

109

- **STREAMING_PIPELINE_CHECKPOINT_DELETION**: Enables checkpoint deletion in streaming pipelines (introduced in 6.7.1)

110

- **LIFECYCLE_MANAGEMENT_EDIT**: Enables lifecycle management editing (introduced in 6.8.0)

111

- **WRANGLER_FAIL_PIPELINE_FOR_ERROR**: Enables pipeline failure on Wrangler errors (introduced in 6.8.0)

112

- **STREAMING_PIPELINE_NATIVE_STATE_TRACKING**: Enables native state tracking in streaming pipelines (introduced in 6.8.0, defaults to disabled)

113

- **PUSHDOWN_TRANSFORMATION_WINDOWAGGREGATION**: Enables pushdown window aggregation transformations (introduced in 6.9.1)

114

- **SOURCE_CONTROL_MANAGEMENT_GIT**: Enables Git-based source control management (introduced in 6.9.0)

115

- **SOURCE_CONTROL_MANAGEMENT_MULTI_APP**: Enables multi-application source control management (introduced in 6.10.0)

116

- **WRANGLER_PRECONDITION_SQL**: Enables SQL preconditions in Wrangler (introduced in 6.9.1)

117

- **WRANGLER_EXECUTION_SQL**: Enables SQL execution in Wrangler (introduced in 6.10.0)

118

- **WRANGLER_SCHEMA_MANAGEMENT**: Enables schema management in Wrangler (introduced in 6.10.0)

119

- **NAMESPACED_SERVICE_ACCOUNTS**: Enables namespaced service accounts (introduced in 6.10.0)

120

- **WRANGLER_KRYO_SERIALIZATION**: Enables Kryo serialization in Wrangler (introduced in 6.10.1)

121

- **SOURCE_CONTROL_MANAGEMENT_GITLAB_BITBUCKET**: Enables GitLab and Bitbucket source control management (introduced in 6.10.1)

122

- **DATAPLANE_AUDIT_LOGGING**: Enables dataplane audit logging (introduced in 6.10.1)

123

124

#### Feature Enablement Logic

125

126

```java { .api }

127

public boolean isEnabled(FeatureFlagsProvider featureFlagsProvider)

128

```

129

130

Determines if a feature flag is enabled using the following logic:

131

1. First checks the `featureFlagsProvider` for explicit configuration

132

2. If not configured, falls back to version-based default behavior:

133

- If current platform version ≤ feature introduction version: returns `false`

134

- If current platform version > feature introduction version: returns the feature's default behavior (true for most features, false for some)

135

136

**Parameters:**

137

- `featureFlagsProvider` (FeatureFlagsProvider): Provider that contains feature flag configuration

138

139

**Returns:** `boolean` - `true` if the feature is enabled, `false` otherwise

140

141

**Exception Handling:** Handles NullPointerException internally and falls back to default version-based logic

142

143

#### Feature Flag String Identifier

144

145

```java { .api }

146

public String getFeatureFlagString()

147

```

148

149

Returns the string identifier used to configure this feature flag in the provider.

150

151

**Returns:** `String` - The feature flag identifier (feature name in lowercase with underscores replaced by dots, plus ".enabled" suffix)

152

153

**Example:** `Feature.EVENT_PUBLISH.getFeatureFlagString()` returns `"event.publish.enabled"`

154

155

## Types

156

157

### FeatureFlagsProvider Interface

158

159

```java { .api }

160

public interface FeatureFlagsProvider {

161

/**

162

* This method tells is feature flag is currently enabled. To ensure proper feature life cycle

163

* management and backwards compatibility please define features using Feature enum and use

164

* Feature#isEnabled method instead of directly calling this one.

165

*

166

* @param name the feature flag string identifier

167

* @return value of the feature flag if set

168

* @throws NullPointerException if feature flag name is not defined

169

* @throws IllegalArgumentException if the feature flag is not a valid boolean

170

*/

171

default boolean isFeatureEnabled(String name) throws NullPointerException, IllegalArgumentException;

172

}

173

```

174

175

Interface for providing feature flag configuration. The default implementation throws `UnsupportedOperationException`. Implementations should:

176

- Return `true` if the specified feature flag is enabled

177

- Return `false` if the specified feature flag is disabled

178

- Throw `NullPointerException` if the feature flag is not configured (allowing fallback to default logic)

179

- Throw `IllegalArgumentException` if the feature flag value is not a valid boolean

180

181

### VersionInfo Interface

182

183

```java { .api }

184

public interface VersionInfo extends Comparable<Object> {

185

// Marker interface for version information that is comparable

186

// All implementations must return proper version string from toString()

187

}

188

```

189

190

Marker interface for version information that is comparable to other instances or objects. Any implementation must return a properly formatted version string from its `toString()` method to enable comparison with string representations.

191

192

### PlatformInfo.Version

193

194

```java { .api }

195

public static final class PlatformInfo.Version implements VersionInfo {

196

// Constructors

197

public Version(int major, int minor, int fix, boolean snapshot, long buildTime);

198

public Version(@Nullable String version);

199

200

// Accessor methods

201

public int getMajor();

202

public int getMinor();

203

public int getFix();

204

public boolean isSnapshot();

205

public long getBuildTime();

206

207

// Object methods

208

public String toString();

209

public int compareTo(Object other);

210

public boolean equals(Object obj);

211

public int hashCode();

212

}

213

```

214

215

Version class used for comparing platform versions against feature introduction versions. This class is provided by the cdap-api dependency and implements comparison logic based on major.minor.fix version numbers.

216

217

## Usage Examples

218

219

### Checking Multiple Features

220

221

```java

222

import io.cdap.cdap.features.Feature;

223

import io.cdap.cdap.api.feature.FeatureFlagsProvider;

224

225

public class FeatureManager {

226

private final FeatureFlagsProvider provider;

227

228

public FeatureManager(FeatureFlagsProvider provider) {

229

this.provider = provider;

230

}

231

232

public boolean canUseAdvancedTransformations() {

233

return Feature.PUSHDOWN_TRANSFORMATION_GROUPBY.isEnabled(provider) &&

234

Feature.PUSHDOWN_TRANSFORMATION_DEDUPLICATE.isEnabled(provider) &&

235

Feature.PUSHDOWN_TRANSFORMATION_WINDOWAGGREGATION.isEnabled(provider);

236

}

237

238

public boolean isSourceControlEnabled() {

239

return Feature.SOURCE_CONTROL_MANAGEMENT_GIT.isEnabled(provider) ||

240

Feature.SOURCE_CONTROL_MANAGEMENT_GITLAB_BITBUCKET.isEnabled(provider);

241

}

242

}

243

```

244

245

### Feature Flag Configuration

246

247

```java

248

// Example of retrieving feature flag strings for configuration

249

import io.cdap.cdap.features.Feature;

250

251

public class ConfigurationHelper {

252

public static void printAllFeatureFlags() {

253

for (Feature feature : Feature.values()) {

254

System.out.println(feature.name() + " -> " + feature.getFeatureFlagString());

255

}

256

}

257

}

258

```

259

260

### Version-based Feature Logic

261

262

```java

263

import io.cdap.cdap.features.Feature;

264

265

public class PipelineProcessor {

266

private final FeatureFlagsProvider provider;

267

268

public void processData() {

269

// Use new checkpoint deletion if available

270

if (Feature.STREAMING_PIPELINE_CHECKPOINT_DELETION.isEnabled(provider)) {

271

useAdvancedCheckpointDeletion();

272

} else {

273

useLegacyCheckpointHandling();

274

}

275

276

// Enable native state tracking only if explicitly configured

277

// (defaults to disabled even after version 6.8.0)

278

if (Feature.STREAMING_PIPELINE_NATIVE_STATE_TRACKING.isEnabled(provider)) {

279

enableNativeStateTracking();

280

}

281

}

282

}