Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified icp_server/database/icpdb.mv.db
Binary file not shown.
216 changes: 100 additions & 116 deletions icp_server/graphql_api.bal

Large diffs are not rendered by default.

255 changes: 239 additions & 16 deletions icp_server/modules/storage/artifact_repository.bal

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions icp_server/modules/storage/heartbeat_repository.bal
Original file line number Diff line number Diff line change
Expand Up @@ -628,9 +628,9 @@ isolated function insertAdditionalMIArtifacts(types:Heartbeat heartbeat) returns
foreach types:Template template in <types:Template[]>heartbeat.artifacts.templates {
_ = check dbClient->execute(`
Comment on lines 628 to 629

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Log Improvement Suggestion No: 5

Suggested change
foreach types:Template template in <types:Template[]>heartbeat.artifacts.templates {
_ = check dbClient->execute(`
log:printInfo("Inserting additional MI artifacts for runtime: " + heartbeat.runtime);
foreach types:Template template in <types:Template[]>heartbeat.artifacts.templates {

INSERT INTO runtime_templates (
runtime_id, template_name, template_type, state
runtime_id, template_name, template_type
) VALUES (
${heartbeat.runtime}, ${template.name}, ${template.'type}, ${template.state}
${heartbeat.runtime}, ${template.name}, ${template.'type}
)
`);
}
Comment on lines 629 to 636

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Log Improvement Suggestion No: 6

Suggested change
_ = check dbClient->execute(`
INSERT INTO runtime_templates (
runtime_id, template_name, template_type, state
runtime_id, template_name, template_type
) VALUES (
${heartbeat.runtime}, ${template.name}, ${template.'type}, ${template.state}
${heartbeat.runtime}, ${template.name}, ${template.'type}
)
`);
}
_ = check dbClient->execute(`
INSERT INTO runtime_templates (
runtime_id, template_name, template_type
) VALUES (
${heartbeat.runtime}, ${template.name}, ${template.'type}
)
`);
log:printDebug("Inserted template: " + template.name + " of type: " + template.'type + " for runtime: " + heartbeat.runtime);

Expand Down
5 changes: 3 additions & 2 deletions icp_server/modules/storage/runtime_repository.bal
Original file line number Diff line number Diff line change
Expand Up @@ -368,13 +368,14 @@ public isolated function getTasksForRuntime(string runtimeId) returns types:Task
public isolated function getTemplatesForRuntime(string runtimeId) returns types:Template[]|error {
types:Template[] templateList = [];
stream<types:Template, sql:Error?> templateStream = dbClient->query(`
SELECT template_name, template_type, state
SELECT template_name, template_type
FROM runtime_templates
WHERE runtime_id = ${runtimeId}
`);
Comment on lines 370 to 374

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Log Improvement Suggestion No: 7

Suggested change
stream<types:Template, sql:Error?> templateStream = dbClient->query(`
SELECT template_name, template_type, state
SELECT template_name, template_type
FROM runtime_templates
WHERE runtime_id = ${runtimeId}
`);
stream<types:Template, sql:Error?> templateStream = dbClient->query(`
SELECT template_name, template_type
FROM runtime_templates
WHERE runtime_id = ${runtimeId}
`);
log:printInfo("Fetching templates for runtime: " + runtimeId);


check from types:Template templateRecord in templateStream
do {
// state is no longer persisted; default value in type will be used
templateList.push(templateRecord);
};

Expand Down Expand Up @@ -540,7 +541,7 @@ public isolated function getDataSourcesForRuntime(string runtimeId) returns type
public isolated function getConnectorsForRuntime(string runtimeId) returns types:Connector[]|error {
types:Connector[] connectorList = [];
stream<types:Connector, sql:Error?> connectorStream = dbClient->query(`
SELECT connector_name, package as connector_package, version, state
SELECT connector_name, package, version, state
FROM runtime_connectors
WHERE runtime_id = ${runtimeId}
`);
Comment on lines 543 to 547

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Log Improvement Suggestion No: 8

Suggested change
stream<types:Connector, sql:Error?> connectorStream = dbClient->query(`
SELECT connector_name, package as connector_package, version, state
SELECT connector_name, package, version, state
FROM runtime_connectors
WHERE runtime_id = ${runtimeId}
`);
stream<types:Connector, sql:Error?> connectorStream = dbClient->query(`
SELECT connector_name, package, version, state
FROM runtime_connectors
WHERE runtime_id = ${runtimeId}
`);
log:printInfo("Fetching connectors for runtime: " + runtimeId);

Expand Down
27 changes: 24 additions & 3 deletions icp_server/modules/types/types.bal
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ public type Service record {
Resource[] resources;
Listener[] listeners;
string[] runtimeIds?;
ArtifactRuntimeInfo[]? runtimes?;
};

public type Listener record {
Expand Down Expand Up @@ -480,6 +481,7 @@ public type Listener record {
}
string state = "ENABLED"; // "ENABLED", "DISABLED"
string[] runtimeIds?;
ArtifactRuntimeInfo[]? runtimes?;
};

// MI Runtime specific artifact types
Expand All @@ -497,6 +499,7 @@ public type RestApi record {
string state = "ENABLED"; // "ENABLED", "DISABLED"
ApiResource[] resources = []; // API resources (path + methods)
string[] runtimeIds?;
ArtifactRuntimeInfo[]? runtimes?;
};

// API Resource type for MI API resources
Expand All @@ -519,6 +522,7 @@ public type ProxyService record {
}
string state = "ENABLED"; // "ENABLED", "DISABLED"
string[] runtimeIds?;
ArtifactRuntimeInfo[]? runtimes?;
};

public type Endpoint record {
Expand All @@ -533,6 +537,7 @@ public type Endpoint record {
}
string state = "ENABLED"; // "ENABLED", "DISABLED"
string[] runtimeIds?;
ArtifactRuntimeInfo[]? runtimes?;
};

public type InboundEndpoint record {
Expand All @@ -547,6 +552,7 @@ public type InboundEndpoint record {
}
string state = "ENABLED"; // "ENABLED", "DISABLED"
string[] runtimeIds?;
ArtifactRuntimeInfo[]? runtimes?;
};

public type Sequence record {
Expand All @@ -561,6 +567,7 @@ public type Sequence record {
}
string state = "ENABLED"; // "ENABLED", "DISABLED"
string[] runtimeIds?;
ArtifactRuntimeInfo[]? runtimes?;
};

public type Task record {
Expand All @@ -575,19 +582,20 @@ public type Task record {
}
string state = "ENABLED"; // "ENABLED", "DISABLED"
string[] runtimeIds?;
ArtifactRuntimeInfo[]? runtimes?;
};

public type Template record {
@sql:Column {
name: "template_name"
}
string name;
string 'type;
@sql:Column {
name: "template_state"
name: "template_type"
}
string state = "ENABLED"; // "ENABLED", "DISABLED"
string 'type;
string[] runtimeIds?;
ArtifactRuntimeInfo[]? runtimes?;
};

public type MessageStore record {
Expand All @@ -602,6 +610,7 @@ public type MessageStore record {
}
string state = "ENABLED"; // "ENABLED", "DISABLED"
string[] runtimeIds?;
ArtifactRuntimeInfo[]? runtimes?;
};

public type MessageProcessor record {
Expand All @@ -616,6 +625,7 @@ public type MessageProcessor record {
}
string state = "ENABLED"; // "ENABLED", "DISABLED"
string[] runtimeIds?;
ArtifactRuntimeInfo[]? runtimes?;
};

public type LocalEntry record {
Expand All @@ -630,6 +640,7 @@ public type LocalEntry record {
}
string state = "ENABLED"; // "ENABLED", "DISABLED"
string[] runtimeIds?;
ArtifactRuntimeInfo[]? runtimes?;
};

public type DataService record {
Expand All @@ -644,6 +655,7 @@ public type DataService record {
}
string state = "ENABLED"; // "ENABLED", "DISABLED"
string[] runtimeIds?;
ArtifactRuntimeInfo[]? runtimes?;
};

public type CarbonApp record {
Expand All @@ -660,6 +672,7 @@ public type CarbonApp record {
// Artifacts packaged within the Carbon App (from heartbeat payload)
CarbonAppArtifact[] artifacts?;
string[] runtimeIds?;
ArtifactRuntimeInfo[]? runtimes?;
};

// Artifact shape used inside CarbonApp
Expand All @@ -685,6 +698,7 @@ public type DataSource record {
}
string state = "ENABLED"; // "ENABLED", "DISABLED"
string[] runtimeIds?;
ArtifactRuntimeInfo[]? runtimes?;
};

public type Connector record {
Expand All @@ -711,6 +725,7 @@ public type RegistryResource record {
string 'type = "";
// Populated at query time to indicate runtimes containing this resource
string[] runtimeIds = [];
ArtifactRuntimeInfo[]? runtimes?;
};

// === Project & Component Types ===
Expand Down Expand Up @@ -1362,6 +1377,12 @@ public enum LogEntryRequestSort {
desc
}

// Lightweight runtime reference for artifact availability
public type ArtifactRuntimeInfo record {
string runtimeId;
string status;
};

public type ICPLogEntryRequest record {
string componentId?;
string[] componentIdList?;
Expand Down
3 changes: 1 addition & 2 deletions icp_server/resources/db/init-scripts/h2_init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,6 @@ CREATE TABLE runtime_templates (
runtime_id VARCHAR(100) NOT NULL,
template_name VARCHAR(200) NOT NULL,
template_type VARCHAR(100) NOT NULL,
state VARCHAR(20) NOT NULL DEFAULT 'ENABLED',
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT fk_runtime_templates_runtime FOREIGN KEY (runtime_id) REFERENCES runtimes (runtime_id) ON DELETE CASCADE,
Expand All @@ -951,7 +950,7 @@ CREATE INDEX idx_runtime_templates_template_name ON runtime_templates (template_

CREATE INDEX idx_runtime_templates_template_type ON runtime_templates (template_type);

CREATE INDEX idx_runtime_templates_state ON runtime_templates (state);
-- state column removed for templates; no index needed

-- Message Stores (MI)
CREATE TABLE runtime_message_stores (
Expand Down
10 changes: 1 addition & 9 deletions icp_server/resources/db/init-scripts/mysql_init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -805,21 +805,13 @@ CREATE TABLE runtime_templates (
runtime_id VARCHAR(100) NOT NULL,
template_name VARCHAR(200) NOT NULL,
template_type VARCHAR(100) NOT NULL,
state ENUM(
'ENABLED',
'DISABLED',
'STARTING',
'STOPPING',
'FAILED'
) NOT NULL DEFAULT 'ENABLED',
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
CONSTRAINT fk_runtime_templates_runtime FOREIGN KEY (runtime_id) REFERENCES runtimes (runtime_id) ON DELETE CASCADE,
UNIQUE KEY uk_runtime_template (runtime_id, template_name),
INDEX idx_runtime_id (runtime_id),
INDEX idx_template_name (template_name),
INDEX idx_template_type (template_type),
INDEX idx_state (state)
INDEX idx_template_type (template_type)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;

-- Message Stores (MI)
Expand Down
Loading