From d4293e8d29f7a992fe89db9d675ad010c23ed115 Mon Sep 17 00:00:00 2001 From: John Henderson Date: Fri, 16 Oct 2020 22:30:24 +0000 Subject: [PATCH 1/7] Merged in fix/prod-permissions-address (pull request #44) Adding permissions contract address * Adding permissions contract address Signed-off-by: John Henderson Approved-by: Arzon Barua --- src/main/resources/application.prod.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/application.prod.properties b/src/main/resources/application.prod.properties index 8b4c6e5..4dab5ee 100644 --- a/src/main/resources/application.prod.properties +++ b/src/main/resources/application.prod.properties @@ -33,3 +33,4 @@ ocn.node.signatures = true ocn.node.url = http://localhost:8080 ocn.node.web3.provider = https://rpc.energyweb.org/ ocn.node.web3.contracts.registry = 0x184aeD70F2aaB0Cd1FC62261C1170560cBfd0776 +ocn.node.web3.contracts.permissions = 0x9a59513F0C9Aa56CB4D3f3bAe0513868907BB978 From 5a9707d2d16cdf599f754f4769d685fef1794fa5 Mon Sep 17 00:00:00 2001 From: Arzon Barua Date: Sun, 18 Oct 2020 17:04:31 +0000 Subject: [PATCH 2/7] Merged in fix/readme-file (pull request #43) fixed readme * fixed readme Signed-off-by: Arzon * changed according to the feedback Signed-off-by: Arzon Approved-by: John Henderson --- README.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 18f54ee..a1a4dde 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ This is a community project, aimed at incorporating and building on the open OCP are welcome in the form of comments, pull requests and raised issues. Visit our [issue tracker](https://bitbucket.org/shareandcharge/ocn-node/issues) for an overview of current and past issues. Questions may also be asked on [Stack Overflow](https://stackoverflow.com/questions/tagged/shareandcharge), or in the -[Gitter community](https://gitter.im/shareandcharge/community). +[Slack community](https://app.slack.com/client/T0BNK39NX/CRP0VKEMD). Before contributing to the source code, please take the time to read over the [Developer Certificate of Origin](https://developercertificate.org/). For more information, see our @@ -28,7 +28,7 @@ the OCN Node can be initiated, providing access to all OCPI modules and interfac communication. When a counter-party is found (either offline or via the registry), requests are sent to them via the sender's OCN Node. -For more information about the OCN, check out the [wiki](https://bitbucket.org/shareandcharge/ocn-node/wiki/). +For more information about the OCN, check out the [wiki](https://shareandcharge.atlassian.net/wiki/spaces/OCN/pages/409731085/Getting+started). ## HTTP API Documentation @@ -68,13 +68,13 @@ see the subsequent section that follows. Once downloaded, extract the contents of the archive and change directory: ``` -tar zxvf ocn-node-1.1.0-rc0.tar.gz -cd ocn-node-1.1-0-rc0 +tar zxvf ocn-node-1.1.0.tar.gz +cd ocn-node-1.1-0 ``` Now we can run our node: ``` -java -jar ocn-node-1.1.0-rc0.jar +java -jar ocn-node-1.1.0.jar ``` ### Configuration @@ -156,8 +156,8 @@ Edit the service file to match your environment, replacing the user and properti ``` [Service] User=ubuntu -WorkingDirectory=/home/ubuntu/ocn-node-1.1.0-rc0 -ExecStart=/usr/bin/java -jar -Dspring.config.location=application.custom-prod-env.properties ocn-node-1.1.0-rc0.jar +WorkingDirectory=/home/ubuntu/ocn-node-1.1.0 +ExecStart=/usr/bin/java -jar -Dspring.config.location=application.custom-prod-env.properties ocn-node-1.1.0.jar ``` Then, copy the service file to the `/etc/systemd/system` directory: @@ -214,6 +214,7 @@ This is helpful for developing without having to worry about funding and managin ``` ocn.node.web3.provider = http://localhost:8544 ocn.node.web3.contracts.registry = 0x345ca3e014aaf5dca488057592ee47305d9b3e10 +ocn.node.web3.contracts.permissions = 0xf25186B5081Ff5cE73482AD761DB0eB0d25abfBF ``` ### Generating new build archives From 2e525a4a6400800e2538897dae3179ef7a2782ce Mon Sep 17 00:00:00 2001 From: John Henderson Date: Wed, 28 Oct 2020 05:23:59 +0000 Subject: [PATCH 3/7] Merged in bug/party-search-query (pull request #47) * Adding filter for deleted parties to PlannedPartySearch Signed-off-by: John Henderson Approved-by: Arzon Barua --- .../node/scheduledTasks/PlannedPartySearch.kt | 11 +++- .../scheduledTasks/PlannedPartySearchTest.kt | 52 +++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 src/test/kotlin/snc/openchargingnetwork/node/scheduledTasks/PlannedPartySearchTest.kt diff --git a/src/main/kotlin/snc/openchargingnetwork/node/scheduledTasks/PlannedPartySearch.kt b/src/main/kotlin/snc/openchargingnetwork/node/scheduledTasks/PlannedPartySearch.kt index c3a6fb0..907d730 100644 --- a/src/main/kotlin/snc/openchargingnetwork/node/scheduledTasks/PlannedPartySearch.kt +++ b/src/main/kotlin/snc/openchargingnetwork/node/scheduledTasks/PlannedPartySearch.kt @@ -51,8 +51,17 @@ class PlannedPartySearch(private val registry: Registry, } .filter { val isMyParty = it.nodeOperator == myAddress + isMyParty + } + .filter { + val partyHasBeenDeleted = it.nodeOperator == "0x0000000000000000000000000000000000000000" + !partyHasBeenDeleted + } + .filter { + // Doing completed registration check after deleted party check as null countryCode and partyId + // from deleted parties may cause an issue with query for postgresql val hasCompletedRegistration = roleRepo.existsByCountryCodeAndPartyIDAllIgnoreCase(it.party.country, it.party.id) - isMyParty && !hasCompletedRegistration + !hasCompletedRegistration } for (party in plannedParties) { diff --git a/src/test/kotlin/snc/openchargingnetwork/node/scheduledTasks/PlannedPartySearchTest.kt b/src/test/kotlin/snc/openchargingnetwork/node/scheduledTasks/PlannedPartySearchTest.kt new file mode 100644 index 0000000..21a8e5e --- /dev/null +++ b/src/test/kotlin/snc/openchargingnetwork/node/scheduledTasks/PlannedPartySearchTest.kt @@ -0,0 +1,52 @@ +package snc.openchargingnetwork.node.scheduledTasks + +import io.mockk.every +import io.mockk.mockk +import io.mockk.verify +import org.junit.jupiter.api.Test +import org.web3j.tuples.generated.Tuple7 +import snc.openchargingnetwork.contracts.Registry +import snc.openchargingnetwork.node.config.NodeProperties +import snc.openchargingnetwork.node.models.entities.NetworkClientInfoEntity +import snc.openchargingnetwork.node.repositories.NetworkClientInfoRepository +import snc.openchargingnetwork.node.repositories.RoleRepository + +class PlannedPartySearchTest { + + private val registry: Registry = mockk() + private val roleRepo: RoleRepository = mockk() + private val networkClientInfoRepo: NetworkClientInfoRepository = mockk() + private val properties: NodeProperties = mockk() + + private val plannedPartySearch: PlannedPartySearch + + init { + plannedPartySearch = PlannedPartySearch( + registry, + roleRepo, + networkClientInfoRepo, + properties + ) + } + + @Test + fun deletedParty_should_notBePlanned() { + every { properties.privateKey } returns "c6cbd7d76bc5baca530c875663711b947efa6a86a900a9e8645ce32e5821484e" + val address = "0xc0ffee254729296a45a3885639AC7E10F9d54979" + every { registry.parties.sendAsync().get() } returns listOf(address) + every { registry.getPartyDetailsByAddress(address).sendAsync().get() } returns + Tuple7( + ByteArray(2), + ByteArray(3), + emptyList(), + emptyList(), + emptyList(), + "0x0000000000000000000000000000000000000000", + "" + ) + + plannedPartySearch.run() + verify(exactly = 0) { roleRepo.existsByCountryCodeAndPartyIDAllIgnoreCase(any(), any()) } + verify(exactly = 0) { networkClientInfoRepo.save(any()) } + } +} From 60c34df0b441804092ef3d69b92749a27ceb0109 Mon Sep 17 00:00:00 2001 From: John Henderson Date: Sun, 15 Nov 2020 21:59:29 +0000 Subject: [PATCH 4/7] Merged in release/1.1.1 (pull request #51) Bumping version to 1.1.1 Signed-off-by: John Henderson Approved-by: Arzon Barua --- CHANGELOG.md | 5 +++++ Dockerfile | 2 +- README.md | 8 ++++---- build.gradle.kts | 2 +- infra/ocn-node.service | 4 ++-- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98af53a..a877168 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # OCN Node Changelog +## 1.1.1 +### Nov 07, 2020 + +Fixes bug with deleted parties being communicated as having a "planned" status (ocn-node issue #22) + ## 1.1.0 ### Oct 16, 2020 diff --git a/Dockerfile b/Dockerfile index fe42f29..bb87f98 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,4 +4,4 @@ COPY build /ocn-node COPY src/main/resources/* /ocn-node/ WORKDIR /ocn-node -CMD ["java", "-jar", "./libs/ocn-node-1.1.0.jar"] +CMD ["java", "-jar", "./libs/ocn-node-1.1.1.jar"] diff --git a/README.md b/README.md index a1a4dde..c645d4d 100644 --- a/README.md +++ b/README.md @@ -68,13 +68,13 @@ see the subsequent section that follows. Once downloaded, extract the contents of the archive and change directory: ``` -tar zxvf ocn-node-1.1.0.tar.gz -cd ocn-node-1.1-0 +tar zxvf ocn-node-1.1.1.tar.gz +cd ocn-node-1.1-1 ``` Now we can run our node: ``` -java -jar ocn-node-1.1.0.jar +java -jar ocn-node-1.1.1.jar ``` ### Configuration @@ -156,7 +156,7 @@ Edit the service file to match your environment, replacing the user and properti ``` [Service] User=ubuntu -WorkingDirectory=/home/ubuntu/ocn-node-1.1.0 +WorkingDirectory=/home/ubuntu/ocn-node-1.1.1 ExecStart=/usr/bin/java -jar -Dspring.config.location=application.custom-prod-env.properties ocn-node-1.1.0.jar ``` diff --git a/build.gradle.kts b/build.gradle.kts index 71d05a9..803c24e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -15,7 +15,7 @@ plugins { } group = "snc.openchargingnetwork.node" -version = "1.1.0" +version = "1.1.1" java.sourceCompatibility = JavaVersion.VERSION_1_8 val snippetsDir = "build/generated-snippets" diff --git a/infra/ocn-node.service b/infra/ocn-node.service index db2f124..5b6b524 100644 --- a/infra/ocn-node.service +++ b/infra/ocn-node.service @@ -5,8 +5,8 @@ After=network-online.target [Service] Type=simple User= -WorkingDirectory=/home//ocn-node-1.1.0-rc0 -ExecStart=/usr/bin/java -jar -Dspring.config.location=application.dev.properties ocn-node-1.1.0-rc0.jar +WorkingDirectory=/home//ocn-node-1.1.1 +ExecStart=/usr/bin/java -jar -Dspring.config.location=application.dev.properties ocn-node-1.1.1 Restart=on-failure [Install] From a84c0474cfa5d335962c413bbd8f4dbc07686129 Mon Sep 17 00:00:00 2001 From: John Henderson Date: Tue, 22 Dec 2020 19:08:54 +0000 Subject: [PATCH 5/7] Merged in 1.1.2-develop (pull request #56) 1.1.2 develop * Merged in develop (pull request #52) Merging develop into master for 1.1.1 release * Merged in release/1.1.1 (pull request #51) Bumping version to 1.1.1 Signed-off-by: John Henderson Approved-by: Arzon Barua * Merged in master (pull request #50) Merging master into develop Approved-by: Arzon Barua * Merged in bug/party-search-query (pull request #47) * Adding filter for deleted parties to PlannedPartySearch Signed-off-by: John Henderson Approved-by: Arzon Barua * Warn rather than thrown an exception when healthCheck() is called and a non 200 status code is returned. * Merged in 25-test-health-change (pull request #53) Warn rather than throw an exception when healthCheck() is called and a non 200 status code is returned. Approved-by: John Henderson * Bumping version number for 1.1.2 release Signed-off-by: John Henderson * Merging in changes in master that were made for 1.1.2 release Signed-off-by: John Henderson * Removed un-needed import and redundant qualifier in Verification.kt Signed-off-by: John Henderson Approved-by: Arzon Barua Approved-by: Adam Staveley --- CHANGELOG.md | 5 +++++ Dockerfile | 2 +- README.md | 8 ++++---- build.gradle.kts | 2 +- infra/ocn-node.service | 4 ++-- .../snc/openchargingnetwork/node/config/Verification.kt | 7 ++++++- 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a877168..b6ec2b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # OCN Node Changelog +## 1.1.2 +### Dec 17, 2020 + +Fixes issue where ocn-node startup could fail if behind a load balancer or gateway (ocn-node issue #25) + ## 1.1.1 ### Nov 07, 2020 diff --git a/Dockerfile b/Dockerfile index bb87f98..f12a05f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,4 +4,4 @@ COPY build /ocn-node COPY src/main/resources/* /ocn-node/ WORKDIR /ocn-node -CMD ["java", "-jar", "./libs/ocn-node-1.1.1.jar"] +CMD ["java", "-jar", "./libs/ocn-node-1.1.2.jar"] diff --git a/README.md b/README.md index c645d4d..835869b 100644 --- a/README.md +++ b/README.md @@ -68,13 +68,13 @@ see the subsequent section that follows. Once downloaded, extract the contents of the archive and change directory: ``` -tar zxvf ocn-node-1.1.1.tar.gz -cd ocn-node-1.1-1 +tar zxvf ocn-node-1.1.2.tar.gz +cd ocn-node-1.1-2 ``` Now we can run our node: ``` -java -jar ocn-node-1.1.1.jar +java -jar ocn-node-1.1.2.jar ``` ### Configuration @@ -156,7 +156,7 @@ Edit the service file to match your environment, replacing the user and properti ``` [Service] User=ubuntu -WorkingDirectory=/home/ubuntu/ocn-node-1.1.1 +WorkingDirectory=/home/ubuntu/ocn-node-1.1.2 ExecStart=/usr/bin/java -jar -Dspring.config.location=application.custom-prod-env.properties ocn-node-1.1.0.jar ``` diff --git a/build.gradle.kts b/build.gradle.kts index 803c24e..6ae2a64 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -15,7 +15,7 @@ plugins { } group = "snc.openchargingnetwork.node" -version = "1.1.1" +version = "1.1.2" java.sourceCompatibility = JavaVersion.VERSION_1_8 val snippetsDir = "build/generated-snippets" diff --git a/infra/ocn-node.service b/infra/ocn-node.service index 5b6b524..69edf00 100644 --- a/infra/ocn-node.service +++ b/infra/ocn-node.service @@ -5,8 +5,8 @@ After=network-online.target [Service] Type=simple User= -WorkingDirectory=/home//ocn-node-1.1.1 -ExecStart=/usr/bin/java -jar -Dspring.config.location=application.dev.properties ocn-node-1.1.1 +WorkingDirectory=/home//ocn-node-1.1.2 +ExecStart=/usr/bin/java -jar -Dspring.config.location=application.dev.properties ocn-node-1.1.2 Restart=on-failure [Install] diff --git a/src/main/kotlin/snc/openchargingnetwork/node/config/Verification.kt b/src/main/kotlin/snc/openchargingnetwork/node/config/Verification.kt index d0fc73c..c151673 100644 --- a/src/main/kotlin/snc/openchargingnetwork/node/config/Verification.kt +++ b/src/main/kotlin/snc/openchargingnetwork/node/config/Verification.kt @@ -25,10 +25,15 @@ import java.net.InetAddress import java.net.URL import java.net.UnknownHostException import javax.net.ssl.SSLException +import org.slf4j.LoggerFactory @Component class Verification(private val properties: NodeProperties) { + companion object { + private val logger = LoggerFactory.getLogger(Verification::class.java) + } + @EventListener(ApplicationReadyEvent::class) fun testRegistry() { if (properties.privateKey == null) { @@ -68,7 +73,7 @@ class Verification(private val properties: NodeProperties) { try { val response = khttp.get(healthURL) if (response.statusCode != 200) { - throw ConnectException("${response.statusCode} ${response.text}") + logger.warn("Received status code ${response.statusCode} from $healthURL application may not be healthy.") } } catch (e: ConnectException) { throw IllegalArgumentException("Unable to connect. Ensure $healthURL is reachable.") From 3989c0a7238ad92f9254c4abbf9789d35f06fcd6 Mon Sep 17 00:00:00 2001 From: John Henderson Date: Mon, 16 Nov 2020 04:58:15 +0000 Subject: [PATCH 6/7] Merged in develop (pull request #52) Merging develop into master for 1.1.1 release * Merged in release/1.1.1 (pull request #51) Bumping version to 1.1.1 Signed-off-by: John Henderson Approved-by: Arzon Barua * Merged in master (pull request #50) Merging master into develop Approved-by: Arzon Barua * Merged in bug/party-search-query (pull request #47) * Adding filter for deleted parties to PlannedPartySearch Signed-off-by: John Henderson Approved-by: Arzon Barua --- CHANGELOG.md | 10 +++--- README.md | 76 +++++++++++++++++++++--------------------- build.gradle.kts | 2 +- infra/ocn-node.service | 2 +- 4 files changed, 45 insertions(+), 45 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6ec2b6..4b5952b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,26 +23,26 @@ Fixes bug with deleted parties being communicated as having a "planned" status ( Fixes bug with handling request body when forwarding custom OCPI module requests. -## 1.1.0-rc1 +## 1.1.0-rc1 ### Jun 30, 2020 Adds the ability for requests to be forwarded to "Ocn Services" with matching permissions. The Ocn ServiceInterface, using the new Permissions contract in the OCN Registry, allows data to be shared and accessed using a permission system. -## 1.1.0-rc0 +## 1.1.0-rc0 ### Apr 28, 2020 Includes initial hubclientinfo OCPI module implementation. - Optional "Still-Alive" check requests connected parties versions endpoint at regular intervals. - Optional "Planned Party" search scans registry for newly planned parties at regular intervals. -- New configuration properties under `ocn.node`: `stillAliveEnabled`, `stillAliveRate`, +- New configuration properties under `ocn.node`: `stillAliveEnabled`, `stillAliveRate`, `plannedPartySearchEnabled`, `plannedPartySearchRate`. - + ## 1.0.0 ### Mar 03, 2020 Initial release of the Open Charging Network Node. - All OCPI modules included, except for hubclientinfo. - Custom OCPI module, *OcnRules*, for setting counter-party whitelist rules. -- Administrator API for generating TOKEN_A for planned parties. \ No newline at end of file +- Administrator API for generating TOKEN_A for planned parties. diff --git a/README.md b/README.md index 835869b..c9a40d6 100644 --- a/README.md +++ b/README.md @@ -1,72 +1,72 @@ # Open Charging Network Node -The Open Charging Network (OCN) node with Open Charge Point Interface (OCPI) v2.2 API. +The Open Charging Network (OCN) node with Open Charge Point Interface (OCPI) v2.2 API. -This is a community project, aimed at incorporating and building on the open OCPI standard. As with OCPI, contributions -are welcome in the form of comments, pull requests and raised issues. Visit our -[issue tracker](https://bitbucket.org/shareandcharge/ocn-node/issues) for an overview of current and past issues. -Questions may also be asked on [Stack Overflow](https://stackoverflow.com/questions/tagged/shareandcharge), or in the -[Slack community](https://app.slack.com/client/T0BNK39NX/CRP0VKEMD). +This is a community project, aimed at incorporating and building on the open OCPI standard. As with OCPI, contributions +are welcome in the form of comments, pull requests and raised issues. Visit our +[issue tracker](https://bitbucket.org/shareandcharge/ocn-node/issues) for an overview of current and past issues. +Questions may also be asked on [Stack Overflow](https://stackoverflow.com/questions/tagged/shareandcharge), or in the +[Slack community](https://app.slack.com/client/T0BNK39NX/CRP0VKEMD). -Before contributing to the source code, please take the time to read over the -[Developer Certificate of Origin](https://developercertificate.org/). For more information, see our +Before contributing to the source code, please take the time to read over the +[Developer Certificate of Origin](https://developercertificate.org/). For more information, see our [contributing guidelines](https://shareandcharge.atlassian.net/wiki/spaces/OCN/pages/360611849/Contributing+to+the+Open+Charging+Network). ## The Open Charging Network The OCN is a decentralized eRoaming hub. To participate in the OCN, a node must be used to broker OCPI requests -(e.g. start/stop charging requests, POI data retrieval) between parties. A node can be set up and run by anyone, however -to connect to a node, two steps are needed: +(e.g. start/stop charging requests, POI data retrieval) between parties. A node can be set up and run by anyone, however +to connect to a node, two steps are needed: -1. A registration token (so-called Token A in OCPI terminology) must be generated for the prospective platform by the +1. A registration token (so-called Token A in OCPI terminology) must be generated for the prospective platform by the node administrator. -2. The platform must register themselves in the [OCN Registry](https://bitbucket.org/shareandcharge/ocn-registry), +2. The platform must register themselves in the [OCN Registry](https://bitbucket.org/shareandcharge/ocn-registry), stating that they are using that particular node. -Once a registration token is obtained and the platform is listed in the registry, the OCPI credentials handshake with -the OCN Node can be initiated, providing access to all OCPI modules and interfaces used for peer-to-peer -communication. When a counter-party is found (either offline or via the registry), requests are sent to +Once a registration token is obtained and the platform is listed in the registry, the OCPI credentials handshake with +the OCN Node can be initiated, providing access to all OCPI modules and interfaces used for peer-to-peer +communication. When a counter-party is found (either offline or via the registry), requests are sent to them via the sender's OCN Node. For more information about the OCN, check out the [wiki](https://shareandcharge.atlassian.net/wiki/spaces/OCN/pages/409731085/Getting+started). ## HTTP API Documentation -The [HTTP API Documentation](https://shareandcharge.bitbucket.io) for the OCN Node describes endpoints which can be used +The [HTTP API Documentation](https://shareandcharge.bitbucket.io) for the OCN Node describes endpoints which can be used by administrators and users (OCPI parties). Outside of the full OCPI v2.2 API, OCN Nodes provide additional features, such as the custom OCPI module, _OcnRules_, as well as ways for admins to restrict use and users to query the OCN Registry. ## Dependencies -The OCN Node is built with Kotlin, targeting the JVM. See the sections on running and building a node for +The OCN Node is built with Kotlin, targeting the JVM. See the sections on running and building a node for further details. The choice of operating system is up to the administrator. By and large, the OCN Node has been developed and run on -Unix-like operating systems, particularly Ubuntu and Fedora. There is currently no guarantee that it will work on other -operating systems. +Unix-like operating systems, particularly Ubuntu and Fedora. There is currently no guarantee that it will work on other +operating systems. ## Tutorial: Running your own Local Open Charging Network -Before running a node and connecting it to a local, test or prod environment, it is recommended to first become -acquainted with how the network operates. -A [tutorial](https://bitbucket.org/shareandcharge/ocn-demo) has been provided to guide administrators and users +Before running a node and connecting it to a local, test or prod environment, it is recommended to first become +acquainted with how the network operates. +A [tutorial](https://bitbucket.org/shareandcharge/ocn-demo) has been provided to guide administrators and users of an OCN Node alike through various use case examples. ## Running a Node -First of all, ensure a [Java Runtime Environment](https://openjdk.java.net/install/) (at least version 8) is installed. +First of all, ensure a [Java Runtime Environment](https://openjdk.java.net/install/) (at least version 8) is installed. For example, via the Ubuntu package manager: ``` sudo apt install openjdk-8-jre ``` -Pre-built OCN Node packages can be found on the repository's +Pre-built OCN Node packages can be found on the repository's [downloads page](https://bitbucket.org/shareandcharge/ocn-node/downloads/). For the rest of this section it will be assumed that this was the method chosen by the user. For information about building the node, see the subsequent section that follows. -Once downloaded, extract the contents of the archive and change directory: +Once downloaded, extract the contents of the archive and change directory: ``` tar zxvf ocn-node-1.1.2.tar.gz cd ocn-node-1.1-2 @@ -79,9 +79,9 @@ java -jar ocn-node-1.1.2.jar ### Configuration -By default the OCN Node will use the `dev` profile's runtime properties. These are specified in -`application.dev.properties`. This can be used to get a node up and running and connected to the -OCN public test environment right away. +By default the OCN Node will use the `dev` profile's runtime properties. These are specified in +`application.dev.properties`. This can be used to get a node up and running and connected to the +OCN public test environment right away. However, sooner or later it is likely that configuration options must be changed to match the environment. For example, to configure our local development environment correctly, we might wish to create a new profile @@ -93,7 +93,7 @@ To do so, we can make a copy of the `dev` profile, naming it however we so desir cp application.dev.properties application.custom-local-env.properties ``` -We can then edit our `custom-local-env` properties file to point to the local blockchain node. +We can then edit our `custom-local-env` properties file to point to the local blockchain node. If we wish to setup the node for a production environment, an example `prod` profile has been provided too: @@ -101,7 +101,7 @@ If we wish to setup the node for a production environment, an example `prod` pro cp application.prod.properties application.custom-prod-env.properties ``` -For details on all available configuration values, please visit our comprehensive +For details on all available configuration values, please visit our comprehensive [OCN Node Configuration documentation](./CONFIGURATION.md). @@ -115,13 +115,13 @@ and follow the instructions in the README, or install the NPM package: npm i -g @shareandcharge/ocn-registry ``` -Once installed, add your OCN Node url using the private key as set in the node's configuration (note that the wallet +Once installed, add your OCN Node url using the private key as set in the node's configuration (note that the wallet key must be funded and the correct network chosen using the `-n` flag: ``` ocn-registry set-node https://ocn.server.net -n prod -s 0x1c3e5453c0f9aa74a8eb0216310b2b013f017813a648fce364bf41dbc0b37647 ``` -Alternatively, to register a node on the public test environment, use `-n volta`. +Alternatively, to register a node on the public test environment, use `-n volta`. If successful the node is now available for prospective platforms to link themselves to in the OCN Registry. @@ -159,7 +159,7 @@ User=ubuntu WorkingDirectory=/home/ubuntu/ocn-node-1.1.2 ExecStart=/usr/bin/java -jar -Dspring.config.location=application.custom-prod-env.properties ocn-node-1.1.0.jar ``` - + Then, copy the service file to the `/etc/systemd/system` directory: ``` sudo cp ocn-node.service /etc/systemd/system @@ -179,8 +179,8 @@ journalctl -fu ocn-node -n 1000 ## Development -To be able to build the project, the [Java Development Kit](https://openjdk.java.net/install/) is required. -Make sure at least version 8 is installed and you have the JDK, not only the JRE. +To be able to build the project, the [Java Development Kit](https://openjdk.java.net/install/) is required. +Make sure at least version 8 is installed and you have the JDK, not only the JRE. Gradle tasks are configured in `build.gradle.kts` using the Kotlin DSL. The project can be built with: ``` @@ -195,7 +195,7 @@ Gradle tasks are configured in `build.gradle.kts` using the Kotlin DSL. The proj ### Run integration tests -Integration tests depend on `ganache-cli`, a local development blockchain, which is installed using NPM. In one terminal +Integration tests depend on `ganache-cli`, a local development blockchain, which is installed using NPM. In one terminal window, run the following task, which will attempt to install ganache if not already present and then run it: ``` ./gradlew ganache @@ -226,5 +226,5 @@ Make sure the project has been built already, then run: ### Generating new API documentation -Documentation is generated automatically on build. The asciidoc template can be found in -`src/docs/asciidoc/index.adoc` and the output in `build/asciidoc/html5/index.html`. \ No newline at end of file +Documentation is generated automatically on build. The asciidoc template can be found in +`src/docs/asciidoc/index.adoc` and the output in `build/asciidoc/html5/index.html`. diff --git a/build.gradle.kts b/build.gradle.kts index 6ae2a64..93fe38f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -146,4 +146,4 @@ tasks.register("archive") { "CHANGELOG.md") } -} \ No newline at end of file +} diff --git a/infra/ocn-node.service b/infra/ocn-node.service index 69edf00..69d112f 100644 --- a/infra/ocn-node.service +++ b/infra/ocn-node.service @@ -10,4 +10,4 @@ ExecStart=/usr/bin/java -jar -Dspring.config.location=application.dev.properties Restart=on-failure [Install] -WantedBy=multi-user.target \ No newline at end of file +WantedBy=multi-user.target From 9ebfc9c3e67008a6dee970697263ea6b89962c60 Mon Sep 17 00:00:00 2001 From: Jon Hill Date: Thu, 17 Dec 2020 15:40:50 +0000 Subject: [PATCH 7/7] Warn rather than thrown an exception when healthCheck() is called and a non 200 status code is returned. --- .../snc/openchargingnetwork/node/config/Verification.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/snc/openchargingnetwork/node/config/Verification.kt b/src/main/kotlin/snc/openchargingnetwork/node/config/Verification.kt index c151673..0f73733 100644 --- a/src/main/kotlin/snc/openchargingnetwork/node/config/Verification.kt +++ b/src/main/kotlin/snc/openchargingnetwork/node/config/Verification.kt @@ -33,7 +33,7 @@ class Verification(private val properties: NodeProperties) { companion object { private val logger = LoggerFactory.getLogger(Verification::class.java) } - + @EventListener(ApplicationReadyEvent::class) fun testRegistry() { if (properties.privateKey == null) { @@ -82,4 +82,4 @@ class Verification(private val properties: NodeProperties) { } } -} \ No newline at end of file +}