Skip to content

Commit

Permalink
feat: optimize state machines (#1396)
Browse files Browse the repository at this point in the history
* feat: optimize state machine with index on state and state_timestamp

* chore: deps file
  • Loading branch information
wolf4ood authored Jul 4, 2024
1 parent 6de540d commit de35e01
Show file tree
Hide file tree
Showing 11 changed files with 298 additions and 239 deletions.
442 changes: 205 additions & 237 deletions DEPENDENCIES

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--
-- Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
--
-- This program and the accompanying materials are made available under the
-- terms of the Apache License, Version 2.0 which is available at
-- https://www.apache.org/licenses/LICENSE-2.0
--
-- SPDX-License-Identifier: Apache-2.0
--
-- Contributors:
-- Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation
--

-- This will help to identify states that need to be transitioned without a table scan when the entries grow
CREATE INDEX IF NOT EXISTS contract_negotiation_state ON edc_contract_negotiation (state,state_timestamp);
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--
-- Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
--
-- This program and the accompanying materials are made available under the
-- terms of the Apache License, Version 2.0 which is available at
-- https://www.apache.org/licenses/LICENSE-2.0
--
-- SPDX-License-Identifier: Apache-2.0
--
-- Contributors:
-- Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation
--

-- This will help to identify states that need to be transitioned without a table scan when the entries grow
CREATE INDEX IF NOT EXISTS policy_monitor_state ON edc_policy_monitor (state,state_time_stamp);
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--
-- Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
--
-- This program and the accompanying materials are made available under the
-- terms of the Apache License, Version 2.0 which is available at
-- https://www.apache.org/licenses/LICENSE-2.0
--
-- SPDX-License-Identifier: Apache-2.0
--
-- Contributors:
-- Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation
--

-- This will help to identify states that need to be transitioned without a table scan when the entries grow
CREATE INDEX IF NOT EXISTS transfer_process_state ON edc_transfer_process (state,state_time_stamp);

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--
-- Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
--
-- This program and the accompanying materials are made available under the
-- terms of the Apache License, Version 2.0 which is available at
-- https://www.apache.org/licenses/LICENSE-2.0
--
-- SPDX-License-Identifier: Apache-2.0
--
-- Contributors:
-- Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation
--


ALTER TABLE edc_data_plane ADD COLUMN transfer_type_destination VARCHAR DEFAULT 'HttpData';
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--
-- Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
--
-- This program and the accompanying materials are made available under the
-- terms of the Apache License, Version 2.0 which is available at
-- https://www.apache.org/licenses/LICENSE-2.0
--
-- SPDX-License-Identifier: Apache-2.0
--
-- Contributors:
-- Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation
--


-- This will help to identify states that need to be transitioned without a table scan when the entries grow
CREATE INDEX IF NOT EXISTS data_plane_state ON edc_data_plane (state,state_time_stamp);
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.eclipse.edc.spi.security.Vault;
import org.eclipse.edc.spi.types.domain.DataAddress;
import org.eclipse.edc.spi.types.domain.transfer.DataFlowStartMessage;
import org.eclipse.edc.spi.types.domain.transfer.FlowType;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
Expand Down Expand Up @@ -268,6 +269,7 @@ private DataFlowStartMessage createFlowRequest(String blobName) {
.sourceDataAddress(blobSourceAddress(blobName))
.destinationDataAddress(blobDestinationAddress(blobName))
.processId("test-process-id")
.flowType(FlowType.PUSH)
.build();
}

Expand All @@ -283,6 +285,8 @@ private DataFlowStartMessage createMultipleFileFlowRequest(String blobPrefix) {
.type("AzureStorage").property("container", AZBLOB_CONSUMER_CONTAINER_NAME)
.property("account", AZBLOB_CONSUMER_ACCOUNT_NAME).property("keyName", AZBLOB_CONSUMER_KEY_ALIAS)
.build())
.processId("test-process-multiple-file-id").build();
.processId("test-process-multiple-file-id")
.flowType(FlowType.PUSH)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.eclipse.edc.spi.security.Vault;
import org.eclipse.edc.spi.types.domain.DataAddress;
import org.eclipse.edc.spi.types.domain.transfer.DataFlowStartMessage;
import org.eclipse.edc.spi.types.domain.transfer.FlowType;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
Expand Down Expand Up @@ -142,6 +143,7 @@ void transferFile_azureToS3MultipleFiles(Vault vault) {
.property(S3BucketSchema.ENDPOINT_OVERRIDE, s3EndpointOverride)
.build()
)
.flowType(FlowType.PUSH)
.processId("test-request-multiple")
.build();

Expand Down Expand Up @@ -193,6 +195,7 @@ void transferFile_azureToS3(Vault vault) {
.property(S3BucketSchema.ENDPOINT_OVERRIDE, s3EndpointOverride)
.build()
)
.flowType(FlowType.PUSH)
.processId("test-process-id")
.build();

Expand Down Expand Up @@ -257,6 +260,7 @@ void transferFile_s3ToAzureMultipleFiles(Vault vault) {
.property("keyName", AZBLOB_CONSUMER_KEY_ALIAS)
.build()
)
.flowType(FlowType.PUSH)
.processId("test-process-multiple-file-id")
.build();

Expand Down Expand Up @@ -322,6 +326,7 @@ void transferFile_s3ToAzureMultipleFiles_whenConsumerDefinesBloblName_success(Va
.property("blobName", "NOME_TEST")
.build()
)
.flowType(FlowType.PUSH)
.processId("test-process-multiple-file-id")
.build();

Expand Down Expand Up @@ -369,6 +374,7 @@ void transferFile_s3ToAzure(Vault vault) {
)
.destinationDataAddress(blobDestinationAddress(TESTFILE_NAME))
.processId("test-process-id")
.flowType(FlowType.PUSH)
.build();

var url = "http://localhost:%s/control/transfer".formatted(PROVIDER_CONTROL_PORT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.eclipse.edc.spi.monitor.Monitor;
import org.eclipse.edc.spi.types.domain.DataAddress;
import org.eclipse.edc.spi.types.domain.transfer.DataFlowStartMessage;
import org.eclipse.edc.spi.types.domain.transfer.FlowType;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
Expand Down Expand Up @@ -302,6 +303,7 @@ private DataFlowStartMessage createFlowRequest() {
.property(S3BucketSchema.ENDPOINT_OVERRIDE, consumerEndpointOverride)
.build()
)
.flowType(FlowType.PUSH)
.processId("test-process-id")
.build();
}
Expand Down Expand Up @@ -329,6 +331,7 @@ private DataFlowStartMessage createMultipleFileFlowRequest() {
.property(S3BucketSchema.ENDPOINT_OVERRIDE, consumerEndpointOverride)
.build()
)
.flowType(FlowType.PUSH)
.processId("test-process-multiple-file-id")
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ private DataFlowStartMessage createStartMessage(String processId, String audienc
.sourceDataAddress(DataAddress.Builder.newInstance().type("HttpData").property(EDC_NAMESPACE + "baseUrl", "http://foo.bar/").build())
.destinationDataAddress(DataAddress.Builder.newInstance().type("HttpData").property(EDC_NAMESPACE + "baseUrl", "http://fizz.buzz").build())
.flowType(FlowType.PULL)
.transferTypeDestination("HttpData")
.participantId("some-participantId")
.assetId("test-asset")
.callbackAddress(URI.create("https://foo.bar/callback"))
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
format.version = "1.1"

[versions]
edc = "0.7.1"
edc = "0.7.2-20240704-SNAPSHOT"
assertj = "3.26.0"
awaitility = "4.2.1"
aws = "2.26.14"
Expand Down

0 comments on commit de35e01

Please sign in to comment.