CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-io-cdap-cdap--cdap-runtime-spi

Service Provider Interfaces (SPIs) that define extensible contracts for CDAP runtime functionality, enabling pluggable implementations of cluster provisioning, job lifecycle management, and infrastructure integration

Pending
Overview
Eval results
Files

profile.mddocs/

Profile Management

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.

Capabilities

Profile Status

Enumeration controlling the lifecycle and assignment capabilities of runtime profiles.

/**
 * The status of a runtime profile
 * Controls assignment and deletion permissions
 */
enum ProfileStatus {
    /** 
     * Profile is enabled and active
     * - Can be assigned to new programs
     * - Cannot be deleted while enabled
     * - Existing assignments remain active
     */
    ENABLED,
    
    /**
     * Profile is disabled and inactive
     * - Cannot be assigned to new programs  
     * - Can be deleted when no active program runs exist
     * - Existing program runs using this profile continue normally
     */
    DISABLED
}

Usage Example:

public class ProfileManager {
    
    public void manageProfileLifecycle(String profileName) {
        ProfileStatus currentStatus = getProfileStatus(profileName);
        
        switch (currentStatus) {
            case ENABLED:
                System.out.println("Profile '" + profileName + "' is active");
                System.out.println("- Available for new program assignments");
                System.out.println("- Cannot be deleted while enabled");
                
                // To delete, must first disable
                if (shouldDeleteProfile(profileName)) {
                    disableProfile(profileName);
                }
                break;
                
            case DISABLED:
                System.out.println("Profile '" + profileName + "' is disabled");
                System.out.println("- Cannot be assigned to new programs");
                
                // Check if safe to delete
                if (hasActiveProgramRuns(profileName)) {
                    System.out.println("- Has active program runs - wait for completion");
                } else {
                    System.out.println("- Can be safely deleted");
                    if (shouldDeleteProfile(profileName)) {
                        deleteProfile(profileName);
                    }
                }
                break;
        }
    }
    
    public void disableProfileForDeletion(String profileName) {
        ProfileStatus status = getProfileStatus(profileName);
        
        if (status == ProfileStatus.ENABLED) {
            // Change status to disabled
            setProfileStatus(profileName, ProfileStatus.DISABLED);
            System.out.println("Profile disabled - waiting for active runs to complete");
            
            // Monitor active runs
            waitForActiveRunsToComplete(profileName);
            
            // Now safe to delete
            deleteProfile(profileName);
        }
    }
    
    public void enableProfile(String profileName) {
        setProfileStatus(profileName, ProfileStatus.ENABLED);
        System.out.println("Profile '" + profileName + "' is now available for assignment");
    }
    
    // Helper methods (implementation would interact with profile storage)
    private ProfileStatus getProfileStatus(String profileName) {
        // Implementation would query profile storage
        return ProfileStatus.ENABLED; // Example
    }
    
    private void setProfileStatus(String profileName, ProfileStatus status) {
        // Implementation would update profile storage
    }
    
    private boolean hasActiveProgramRuns(String profileName) {
        // Implementation would check for running programs using this profile  
        return false;
    }
    
    private boolean shouldDeleteProfile(String profileName) {
        // Implementation would check deletion conditions
        return false;
    }
    
    private void deleteProfile(String profileName) {
        // Implementation would remove profile from storage
    }
    
    private void waitForActiveRunsToComplete(String profileName) {
        // Implementation would monitor program run completion
    }
}

Profile Status State Transitions

The profile status follows a simple state machine:

[CREATE] 
        ↓
   ProfileStatus.ENABLED
        ↓ (disable)
   ProfileStatus.DISABLED
        ↓ (delete when safe)
     [DELETED]

State Transition Rules

  1. ENABLED → DISABLED: Always allowed

    • Profile can no longer be assigned to new programs
    • Existing program runs continue unaffected
    • Profile becomes eligible for deletion
  2. DISABLED → ENABLED: Always allowed

    • Profile becomes available for new program assignments
    • Profile can no longer be deleted
  3. DISABLED → DELETED: Only when safe

    • No active program runs using the profile
    • Profile is permanently removed from system
  4. ENABLED → DELETED: Not allowed directly

    • Must first transition to DISABLED
    • Ensures graceful handling of active assignments

Integration with Other SPI Components

Profile status is used throughout the CDAP runtime system:

// In ProvisionerContext
String profileName = context.getProfileName();
ProfileStatus status = getProfileStatus(profileName);

if (status == ProfileStatus.DISABLED) {
    throw new IllegalStateException("Cannot use disabled profile: " + profileName);
}

// Profile validation in provisioner
public class MyProvisioner implements Provisioner {
    @Override
    public void validateProperties(Map<String, String> properties) {
        String profileName = properties.get("profile.name");
        
        if (profileName != null) {
            ProfileStatus status = getProfileStatus(profileName);
            if (status == ProfileStatus.DISABLED) {
                throw new IllegalArgumentException("Profile is disabled: " + profileName);
            }
        }
    }
}

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

Install with Tessl CLI

npx tessl i tessl/maven-io-cdap-cdap--cdap-runtime-spi

docs

core-types.md

index.md

profile.md

provisioner.md

runtime-job.md

ssh.md

tile.json