mirror of
https://github.com/corda/corda.git
synced 2024-12-19 13:08:04 +00:00
working node startup with new tables and entities
This commit is contained in:
parent
7b3da95456
commit
2b079bd92e
@ -18,6 +18,7 @@ import javax.persistence.Column
|
||||
import javax.persistence.Entity
|
||||
import javax.persistence.Id
|
||||
import org.hibernate.annotations.Type
|
||||
import java.lang.Exception
|
||||
import java.math.BigInteger
|
||||
import java.sql.Connection
|
||||
import java.sql.SQLException
|
||||
@ -41,43 +42,47 @@ class DBCheckpointStorage : CheckpointStorage {
|
||||
PAUSED
|
||||
}
|
||||
|
||||
enum class StartReason {
|
||||
RPC, FLOW, SERVICE, SCHEDULED, INITIATED
|
||||
}
|
||||
|
||||
@Entity
|
||||
@javax.persistence.Table(name = "${NODE_DATABASE_PREFIX}checkpoints")
|
||||
@javax.persistence.Table(name = "${NODE_DATABASE_PREFIX}checkpoints_new")
|
||||
class DBFlowCheckpoint(
|
||||
@Id
|
||||
@Column(name = "flow_id", length = 64, nullable = false)
|
||||
private var id: String? = null,
|
||||
var id: String? = null,
|
||||
|
||||
@OneToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "id")
|
||||
private var blob: DBFlowCheckpointBlob? = null,
|
||||
@JoinColumn(name = "checkpoint_blob_id", referencedColumnName = "id")
|
||||
var blob: DBFlowCheckpointBlob? = null,
|
||||
|
||||
@OneToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "id")
|
||||
private var result: DBFlowResult? = null,
|
||||
@JoinColumn(name = "result_id", referencedColumnName = "id")
|
||||
var result: DBFlowResult? = null,
|
||||
|
||||
@OneToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "id")
|
||||
private var exceptionDetails: DBFlowException? = null,
|
||||
@JoinColumn(name = "error_id", referencedColumnName = "id")
|
||||
var exceptionDetails: DBFlowException? = null,
|
||||
|
||||
@OneToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "flow_id")
|
||||
private var flowMetadata: DBFlowMetadata? = null,
|
||||
var flowMetadata: DBFlowMetadata? = null,
|
||||
|
||||
@Column(name = "status")
|
||||
private var status: FlowStatus? = null,
|
||||
var status: FlowStatus? = null,
|
||||
|
||||
@Column(name = "compatible")
|
||||
private var compatible: Boolean? = null,
|
||||
var compatible: Boolean? = null,
|
||||
|
||||
@Column(name = "progress_step")
|
||||
private var progressStep: String? = null,
|
||||
var progressStep: String? = null,
|
||||
|
||||
@Column(name = "flow_io_request")
|
||||
private val ioRequestType: Class<FlowIORequest<*>>? = null,
|
||||
var ioRequestType: Class<FlowIORequest<*>>? = null,
|
||||
|
||||
@Column(name = "timestamp")
|
||||
private val checkpointInstant: Instant? = null
|
||||
var checkpointInstant: Instant? = null
|
||||
)
|
||||
|
||||
@Entity
|
||||
@ -85,7 +90,7 @@ class DBCheckpointStorage : CheckpointStorage {
|
||||
class DBFlowCheckpointBlob(
|
||||
@Id
|
||||
@Column(name = "id", nullable = false)
|
||||
private var id: BigInteger? = null,
|
||||
var id: BigInteger? = null,
|
||||
|
||||
@Type(type = "corda-blob")
|
||||
@Column(name = "checkpoint_value", nullable = false)
|
||||
@ -96,25 +101,89 @@ class DBCheckpointStorage : CheckpointStorage {
|
||||
var flowStack: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
|
||||
@Column(name = "timestamp")
|
||||
private val instant: Instant? = null
|
||||
var persistedInstant: Instant? = null
|
||||
)
|
||||
|
||||
@Entity
|
||||
@javax.persistence.Table(name = "${NODE_DATABASE_PREFIX}flow_results")
|
||||
class DBFlowResult(
|
||||
@Id
|
||||
@Column(name = "id", nullable = false)
|
||||
var id: BigInteger? = null,
|
||||
|
||||
@Type(type = "corda-blob")
|
||||
@Column(name = "result_value", nullable = false)
|
||||
var checkpoint: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
|
||||
@Column(name = "timestamp")
|
||||
val persistedInstant: Instant? = null
|
||||
)
|
||||
|
||||
@Entity
|
||||
@javax.persistence.Table(name = "${NODE_DATABASE_PREFIX}flow_exceptions")
|
||||
class DBFlowException(
|
||||
@Id
|
||||
@Column(name = "id", nullable = false)
|
||||
var id: BigInteger? = null,
|
||||
|
||||
@Column(name = "type", nullable = false)
|
||||
var type: Class<Exception>? = null,
|
||||
|
||||
@Type(type = "corda-blob")
|
||||
@Column(name = "exception_value", nullable = false)
|
||||
var value: ByteArray,
|
||||
|
||||
@Column(name = "exception_message")
|
||||
var message: String? = null,
|
||||
|
||||
@Column(name = "timestamp")
|
||||
val persistedInstant: Instant? = null
|
||||
)
|
||||
|
||||
@Entity
|
||||
@javax.persistence.Table(name = "${NODE_DATABASE_PREFIX}flow_metadata")
|
||||
class DBFlowMetadata(
|
||||
|
||||
@Id
|
||||
@Column(name = "id", nullable = false)
|
||||
var id: BigInteger? = null,
|
||||
|
||||
@Column(name = "flow_id", length = 64, nullable = false)
|
||||
var flowId: String? = null,
|
||||
|
||||
@Column(name = "flow_name", nullable = false)
|
||||
var flowName: String? = null,
|
||||
|
||||
@Column(name = "flow_identifier", nullable = true)
|
||||
var userSuppliedIdentifier: String? = null,
|
||||
|
||||
@Column(name = "started_type", nullable = true)
|
||||
var startType: StartReason? = null,
|
||||
|
||||
@Column(name = "flow_parameters", nullable = true)
|
||||
var initialParameters: ByteArray? = null,
|
||||
|
||||
@Column(name = "cordapp_name", nullable = true)
|
||||
var launchingCordapp: String? = null,
|
||||
|
||||
@Column(name = "platform_version", nullable = true)
|
||||
var platformVersion: Int? = null,
|
||||
|
||||
@Column(name = "rpc_user", nullable = true)
|
||||
var rpcUsername: String? = null,
|
||||
|
||||
@Column(name = "invocation_time", nullable = true)
|
||||
var invocationInstant: Instant? = null,
|
||||
|
||||
@Column(name = "received_time", nullable = true)
|
||||
var receivedInstant: Instant? = null,
|
||||
|
||||
@Column(name = "start_time", nullable = true)
|
||||
var startInstant: Instant? = null,
|
||||
|
||||
@Column(name = "finish_time", nullable = true)
|
||||
var finishInstant: Instant? = null
|
||||
|
||||
)
|
||||
|
||||
@Entity
|
||||
|
@ -34,6 +34,14 @@ class NodeSchemaService(private val extraSchemas: Set<MappedSchema> = emptySet()
|
||||
|
||||
object NodeCoreV1 : MappedSchema(schemaFamily = NodeCore.javaClass, version = 1,
|
||||
mappedTypes = listOf(DBCheckpointStorage.DBCheckpoint::class.java,
|
||||
|
||||
//new checkpoints - keeping old around to allow testing easily (for now)
|
||||
DBCheckpointStorage.DBFlowCheckpoint::class.java,
|
||||
DBCheckpointStorage.DBFlowCheckpointBlob::class.java,
|
||||
DBCheckpointStorage.DBFlowResult::class.java,
|
||||
DBCheckpointStorage.DBFlowException::class.java,
|
||||
DBCheckpointStorage.DBFlowMetadata::class.java,
|
||||
|
||||
DBTransactionStorage.DBTransaction::class.java,
|
||||
BasicHSMKeyManagementService.PersistentKey::class.java,
|
||||
NodeSchedulerService.PersistentScheduledState::class.java,
|
||||
|
@ -31,8 +31,8 @@
|
||||
|
||||
<include file="migration/node-core.changelog-v14-data.xml"/>
|
||||
|
||||
<!-- <include file="migration/node-core.changelog-v17.xml"/>-->
|
||||
<!-- <include file="migration/node-core.changelog-v17-postgres.xml"/>-->
|
||||
<!-- <include file="migration/node-core.changelog-v17-keys.xml"/>-->
|
||||
<include file="migration/node-core.changelog-v17.xml"/>
|
||||
<include file="migration/node-core.changelog-v17-postgres.xml"/>
|
||||
<include file="migration/node-core.changelog-v17-keys.xml"/>
|
||||
|
||||
</databaseChangeLog>
|
||||
|
@ -5,7 +5,7 @@
|
||||
logicalFilePath="migration/node-services.changelog-init.xml">
|
||||
|
||||
<changeSet author="R3.Corda" id="add_new_checkpoint_schema_primary_keys">
|
||||
<addPrimaryKey columnNames="flow_id" constraintName="node_checkpoints_pk" tableName="node_checkpoints"/>
|
||||
<addPrimaryKey columnNames="flow_id" constraintName="node_checkpoints_pk" tableName="node_checkpoints_new"/>
|
||||
<addPrimaryKey columnNames="id" constraintName="node_checkpoint_blobs_pk" tableName="node_checkpoint_blobs"/>
|
||||
<addPrimaryKey columnNames="id" constraintName="node_checkpoint_exceptions_pk" tableName="node_flow_exceptions"/>
|
||||
<addPrimaryKey columnNames="id" constraintName="node_checkpoint_results_pk" tableName="node_flow_results"/>
|
||||
@ -13,21 +13,21 @@
|
||||
</changeSet>
|
||||
|
||||
<changeSet author="R3.Corda" id="add_new_checkpoint_schema_foreign_keys">
|
||||
<addForeignKeyConstraint baseColumnNames="checkpoint_blob_id" baseTableName="node_checkpoints"
|
||||
<addForeignKeyConstraint baseColumnNames="checkpoint_blob_id" baseTableName="node_checkpoints_new"
|
||||
constraintName="node_checkpoint_blob_id_to_blob_table_fk"
|
||||
referencedColumnNames="id" referencedTableName="node_checkpoint_blobs"/>
|
||||
|
||||
<addForeignKeyConstraint baseColumnNames="error_id" baseTableName="node_checkpoints"
|
||||
<addForeignKeyConstraint baseColumnNames="error_id" baseTableName="node_checkpoints_new"
|
||||
constraintName="node_checkpoints_to_exceptions_fk"
|
||||
referencedColumnNames="id" referencedTableName="node_flow_exceptions"/>
|
||||
|
||||
<addForeignKeyConstraint baseColumnNames="result_id" baseTableName="node_checkpoints"
|
||||
<addForeignKeyConstraint baseColumnNames="result_id" baseTableName="node_checkpoints_new"
|
||||
constraintName="node_checkpoint_to_result_fk"
|
||||
referencedColumnNames="id" referencedTableName="node_flow_results"/>
|
||||
|
||||
<addForeignKeyConstraint baseColumnNames="flow_id" baseTableName="node_flow_metadata"
|
||||
constraintName="node_metadata_to_checkpoints_fk"
|
||||
referencedColumnNames="flow_id" referencedTableName="node_checkpoints"/>
|
||||
referencedColumnNames="flow_id" referencedTableName="node_checkpoints_new"/>
|
||||
|
||||
</changeSet>
|
||||
|
||||
|
@ -4,12 +4,8 @@
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd"
|
||||
logicalFilePath="migration/node-services.changelog-init.xml">
|
||||
|
||||
<changeSet author="R3.Corda" id="drop_existing_checkpoints_table" dbms="postgresql">
|
||||
<dropTable tableName="node_checkpoints"/>
|
||||
</changeSet>
|
||||
|
||||
<changeSet author="R3.Corda" id="add_new_checkpoints_table" dbms="postgresql">
|
||||
<createTable tableName="node_checkpoints">
|
||||
<changeSet author="R3.Corda" id="add_new_checkpoints_table-pg" dbms="postgresql">
|
||||
<createTable tableName="node_checkpoints_new">
|
||||
<column name="flow_id" type="NVARCHAR(64)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
@ -22,7 +18,7 @@
|
||||
<column name="error_id" type="BIGINT">
|
||||
<constraints nullable="true"/>
|
||||
</column>
|
||||
<column name="status" type="NVARCHAR(16)">
|
||||
<column name="status" type="TINYINT">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="compatible" type="BOOLEAN">
|
||||
@ -31,7 +27,8 @@
|
||||
<column name="progress_step" type="NVARCHAR(256)">
|
||||
<constraints nullable="true"/>
|
||||
</column>
|
||||
<column name="flow_io_request" type="NVARCHAR(32)">
|
||||
<!-- net.corda.core.internal.FlowIORequest.SendAndReceive -->
|
||||
<column name="flow_io_request" type="NVARCHAR(128)">
|
||||
<constraints nullable="true"/>
|
||||
</column>
|
||||
<column name="timestamp" type="java.sql.Types.TIMESTAMP">
|
||||
@ -40,7 +37,7 @@
|
||||
</createTable>
|
||||
</changeSet>
|
||||
|
||||
<changeSet author="R3.Corda" id="add_new_checkpoint_blobs_table" dbms="postgresql">
|
||||
<changeSet author="R3.Corda" id="add_new_checkpoint_blob_table-pg" dbms="postgresql">
|
||||
<createTable tableName="node_checkpoint_blobs">
|
||||
<column name="id" type="BIGINT">
|
||||
<constraints nullable="false"/>
|
||||
@ -61,7 +58,7 @@
|
||||
</changeSet>
|
||||
|
||||
|
||||
<changeSet author="R3.Corda" id="add_new_flow_result_table" dbms="postgresql">
|
||||
<changeSet author="R3.Corda" id="add_new_flow_result_table-pg" dbms="postgresql">
|
||||
<createTable tableName="node_flow_results">
|
||||
<column name="id" type="BIGINT">
|
||||
<constraints nullable="false"/>
|
||||
@ -75,12 +72,12 @@
|
||||
</createTable>
|
||||
</changeSet>
|
||||
|
||||
<changeSet author="R3.Corda" id="add_new_flow_exceptions_table" dbms="postgresql">
|
||||
<changeSet author="R3.Corda" id="add_new_flow_exceptions_table-pg" dbms="postgresql">
|
||||
<createTable tableName="node_flow_exceptions">
|
||||
<column name="id" type="BIGINT">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="type" type="NVARCHAR(128)">
|
||||
<column name="type" type="NVARCHAR(256)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="exception_value" type="varbinary(33554432)">
|
||||
@ -95,7 +92,7 @@
|
||||
</createTable>
|
||||
</changeSet>
|
||||
|
||||
<changeSet author="R3.Corda" id="add_new_flow_metadata_table" dbms="postgresql">
|
||||
<changeSet author="R3.Corda" id="add_new_flow_metadata_table-pg" dbms="postgresql">
|
||||
<createTable tableName="node_flow_metadata">
|
||||
<column name="invocation_id" type="BIGINT">
|
||||
<constraints nullable="false"/>
|
||||
@ -109,7 +106,7 @@
|
||||
<column name="flow_identifier" type="NVARCHAR(512)">
|
||||
<constraints nullable="true"/>
|
||||
</column>
|
||||
<column name="started_type" type="NVARCHAR(32)">
|
||||
<column name="started_type" type="TINYINT">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="flow_parameters" type="varbinary(33554432)">
|
||||
@ -118,7 +115,7 @@
|
||||
<column name="cordapp_name" type="NVARCHAR(64)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="platform_version" type="BIGINT">
|
||||
<column name="platform_version" type="TINYINT">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="rpc_user" type="NVARCHAR(64)">
|
||||
|
@ -4,12 +4,8 @@
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd"
|
||||
logicalFilePath="migration/node-services.changelog-init.xml">
|
||||
|
||||
<changeSet author="R3.Corda" id="drop_existing_checkpoints_table" dbms="!postgresql">
|
||||
<dropTable tableName="node_checkpoints"/>
|
||||
</changeSet>
|
||||
|
||||
<changeSet author="R3.Corda" id="add_new_checkpoints_table" dbms="!postgresql">
|
||||
<createTable tableName="node_checkpoints">
|
||||
<createTable tableName="node_checkpoints_new">
|
||||
<column name="flow_id" type="NVARCHAR(64)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
@ -22,7 +18,7 @@
|
||||
<column name="error_id" type="BIGINT">
|
||||
<constraints nullable="true"/>
|
||||
</column>
|
||||
<column name="status" type="BIGINT">
|
||||
<column name="status" type="TINYINT">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="compatible" type="BOOLEAN">
|
||||
@ -81,7 +77,7 @@
|
||||
<column name="id" type="BIGINT">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="type" type="NVARCHAR(128)">
|
||||
<column name="type" type="NVARCHAR(256)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="exception_value" type="blob">
|
||||
@ -110,7 +106,7 @@
|
||||
<column name="flow_identifier" type="NVARCHAR(512)">
|
||||
<constraints nullable="true"/>
|
||||
</column>
|
||||
<column name="started_type" type="NVARCHAR(32)">
|
||||
<column name="started_type" type="TINYINT">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="flow_parameters" type="blob">
|
||||
@ -119,7 +115,7 @@
|
||||
<column name="cordapp_name" type="NVARCHAR(64)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="platform_version" type="BIGINT">
|
||||
<column name="platform_version" type="TINYINT">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="rpc_user" type="NVARCHAR(64)">
|
||||
|
Loading…
Reference in New Issue
Block a user