or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

core-types.mdindex.mdprofile.mdprovisioner.mdruntime-job.mdssh.md

profile.mddocs/

0

# Profile Management

1

2

Simple profile status management for runtime configuration profiles, controlling whether profiles can be assigned to programs or deleted from the system. This minimal API provides essential lifecycle controls for CDAP runtime profiles used in cluster provisioning and job execution.

3

4

## Capabilities

5

6

### Profile Status

7

8

Enumeration controlling the lifecycle and assignment capabilities of runtime profiles.

9

10

```java { .api }

11

/**

12

* The status of a runtime profile

13

* Controls assignment and deletion permissions

14

*/

15

enum ProfileStatus {

16

/**

17

* Profile is enabled and active

18

* - Can be assigned to new programs

19

* - Cannot be deleted while enabled

20

* - Existing assignments remain active

21

*/

22

ENABLED,

23

24

/**

25

* Profile is disabled and inactive

26

* - Cannot be assigned to new programs

27

* - Can be deleted when no active program runs exist

28

* - Existing program runs using this profile continue normally

29

*/

30

DISABLED

31

}

32

```

33

34

**Usage Example:**

35

36

```java

37

public class ProfileManager {

38

39

public void manageProfileLifecycle(String profileName) {

40

ProfileStatus currentStatus = getProfileStatus(profileName);

41

42

switch (currentStatus) {

43

case ENABLED:

44

System.out.println("Profile '" + profileName + "' is active");

45

System.out.println("- Available for new program assignments");

46

System.out.println("- Cannot be deleted while enabled");

47

48

// To delete, must first disable

49

if (shouldDeleteProfile(profileName)) {

50

disableProfile(profileName);

51

}

52

break;

53

54

case DISABLED:

55

System.out.println("Profile '" + profileName + "' is disabled");

56

System.out.println("- Cannot be assigned to new programs");

57

58

// Check if safe to delete

59

if (hasActiveProgramRuns(profileName)) {

60

System.out.println("- Has active program runs - wait for completion");

61

} else {

62

System.out.println("- Can be safely deleted");

63

if (shouldDeleteProfile(profileName)) {

64

deleteProfile(profileName);

65

}

66

}

67

break;

68

}

69

}

70

71

public void disableProfileForDeletion(String profileName) {

72

ProfileStatus status = getProfileStatus(profileName);

73

74

if (status == ProfileStatus.ENABLED) {

75

// Change status to disabled

76

setProfileStatus(profileName, ProfileStatus.DISABLED);

77

System.out.println("Profile disabled - waiting for active runs to complete");

78

79

// Monitor active runs

80

waitForActiveRunsToComplete(profileName);

81

82

// Now safe to delete

83

deleteProfile(profileName);

84

}

85

}

86

87

public void enableProfile(String profileName) {

88

setProfileStatus(profileName, ProfileStatus.ENABLED);

89

System.out.println("Profile '" + profileName + "' is now available for assignment");

90

}

91

92

// Helper methods (implementation would interact with profile storage)

93

private ProfileStatus getProfileStatus(String profileName) {

94

// Implementation would query profile storage

95

return ProfileStatus.ENABLED; // Example

96

}

97

98

private void setProfileStatus(String profileName, ProfileStatus status) {

99

// Implementation would update profile storage

100

}

101

102

private boolean hasActiveProgramRuns(String profileName) {

103

// Implementation would check for running programs using this profile

104

return false;

105

}

106

107

private boolean shouldDeleteProfile(String profileName) {

108

// Implementation would check deletion conditions

109

return false;

110

}

111

112

private void deleteProfile(String profileName) {

113

// Implementation would remove profile from storage

114

}

115

116

private void waitForActiveRunsToComplete(String profileName) {

117

// Implementation would monitor program run completion

118

}

119

}

120

```

121

122

## Profile Status State Transitions

123

124

The profile status follows a simple state machine:

125

126

```

127

[CREATE]

128

129

ProfileStatus.ENABLED

130

↓ (disable)

131

ProfileStatus.DISABLED

132

↓ (delete when safe)

133

[DELETED]

134

```

135

136

### State Transition Rules

137

138

1. **ENABLED → DISABLED**: Always allowed

139

- Profile can no longer be assigned to new programs

140

- Existing program runs continue unaffected

141

- Profile becomes eligible for deletion

142

143

2. **DISABLED → ENABLED**: Always allowed

144

- Profile becomes available for new program assignments

145

- Profile can no longer be deleted

146

147

3. **DISABLED → DELETED**: Only when safe

148

- No active program runs using the profile

149

- Profile is permanently removed from system

150

151

4. **ENABLED → DELETED**: Not allowed directly

152

- Must first transition to DISABLED

153

- Ensures graceful handling of active assignments

154

155

### Integration with Other SPI Components

156

157

Profile status is used throughout the CDAP runtime system:

158

159

```java

160

// In ProvisionerContext

161

String profileName = context.getProfileName();

162

ProfileStatus status = getProfileStatus(profileName);

163

164

if (status == ProfileStatus.DISABLED) {

165

throw new IllegalStateException("Cannot use disabled profile: " + profileName);

166

}

167

168

// Profile validation in provisioner

169

public class MyProvisioner implements Provisioner {

170

@Override

171

public void validateProperties(Map<String, String> properties) {

172

String profileName = properties.get("profile.name");

173

174

if (profileName != null) {

175

ProfileStatus status = getProfileStatus(profileName);

176

if (status == ProfileStatus.DISABLED) {

177

throw new IllegalArgumentException("Profile is disabled: " + profileName);

178

}

179

}

180

}

181

}

182

```

183

184

This simple but essential API ensures that runtime profiles are managed safely throughout their lifecycle, preventing orphaned resources and ensuring clean system state transitions.