# 🧩 Internal Structure of a Method This page explores how a Method is represented internally in CCP, from its metadata to execution scripts and lifecycle. --- ## 🧭 What Is a Method? In CCP, a **Method** is a reusable computational unit: - It can be an algorithm, a script, a model, or a processing function - It can be written in any language (Python, R, Java, Shell, etc.) - It runs in an isolated container - It receives inputs and produces outputs --- ## 📘 Method Definition Format Methods are described in a `method.json` file that follows the [OGC API - Processes](https://ogcapi.ogc.org/processes/) specification. This file includes: - Metadata (title, author, context) - Input parameters - Declared outputs - Deploy/execute/undeploy scripts - Compatible infrastructures --- ## 🧱 Method JSON Example (Java + Maven) ```json { "title": "JDK-8 Example Maven", "id": "408d9dc5-ee37-4123-9f07-4294f13bce19", "version": "0.0.1", "description": "Runs a Maven-built Java app from GitHub", "inputs": { "ccpimage": { "schema": { "type": "string", "default": "nubisware/ccp-jdk8-jammy:latest" } }, "repository": { "schema": { "type": "string", "default": "https://github.com/dcore94/jdk-maven-example" } }, "mainclass": { "schema": { "type": "string", "default": "example.HelloWorld" } } }, "outputs": { "filejson": { "schema": { "type": "string", "contentMediaType": "application/json" } } }, "additionalParameters": { "parameters": [ { "name": "deploy-script", "value": [ "git clone {{ repository }} execution", "cd execution", "mvn clean package" ] }, { "name": "execute-script", "value": [ "cd execution", "java -cp target/*.jar {{ mainclass }}", "cp /tmp/output.json /ccp_data/" ] } ] }, "links": [ { "rel": "compatibleWith", "href": "infrastructures/nubisware-docker-swarm-nfs" } ] } ``` --- ## 🔄 Execution Lifecycle The figure below shows the phases of a method execution: ``` User → CCP → Launch → Deploy → Execute → Fetch → Destroy ``` Each phase corresponds to: - **Launch**: Prepares container using `ccpimage` - **Deploy**: Runs deploy-script (e.g. clone repo, install deps) - **Execute**: Runs the main algorithm - **Fetch**: Captures outputs - **Destroy**: Cleans up environment If an error occurs in any phase, execution transitions to `FAILED`. --- ## 🧬 Execution Context and Variables During execution, CCP provides several context values. ### 🧩 Inputs as Placeholders Inputs are referenced in scripts via: ```bash --input {{input_file}} --threshold {{threshold}} ``` These values are replaced at runtime with the actual user input. ### 🌐 Execution Variables | Variable | Meaning | |----------------|----------------------------------| | `ccpimage` | Docker image for runtime | | `ccptaskid` | Index of replica (1-based) | | `ccptaskname` | Unique execution identifier | | `ccpnote` | Optional user note for tracking | | `ccpmaxtime` | Max execution time (in seconds) | | `ccpreplicas` | Number of parallel instances | ### 🔐 Secure Variables | Env Variable | Usage | |--------------------|--------------------------------| | `ccprefreshtoken` | Token for API authentication | | `ccpclientid` | OAuth client | | `ccpcontext` | Execution context / VRE | --- ## 🔗 Related Pages - 📜 [Method JSON guide](/04_methods_development/07_method_json.md) - 🐳 [Runtime architecture](/05_advanced_topics/01_architecture/02_runtime_architecture.md) - 🔄 [Execution lifecycle](/05_advanced_topics/02_execution_engine/01_execution_lifecycle.md) - 🧬 [Provenance metadata (provo.xml)](/03_execution/05_metadata_provo.md)