Github user kevdoran commented on a diff in the pull request:
https://github.com/apache/nifi-minifi-cpp/pull/114#discussion_r127531375
--- Diff: libminifi/src/RemoteProcessorGroupPort.cpp ---
@@ -150,6 +194,87 @@ void
RemoteProcessorGroupPort::onTrigger(core::ProcessContext *context, core::Pr
return;
}
+void RemoteProcessorGroupPort::refreshRemoteSite2SiteInfo() {
+ if (this->host_.empty() || this->port_ == -1 || this->protocol_.empty())
+ return;
+
+ std::string fullUrl = this->protocol_ + this->host_ + ":" +
std::to_string(this->port_) + "/nifi-api/controller/";
--- End diff --
I looked into it further and found out that `/controller` is a NiFi 0.x
endpoint. The `/site-to-site` endpoint was introduced in NiFi 1.x, and NiFi 1.x
maps `/controller` to `/site-to-site` so that NiFi 0.x instances can
communicate with NiFI 1.x instances.
I wasn't sure what minifi-cpp should do. `/controller` currently works for
both major versions of NiFi, but there is no guarantee it will forever, and
`/controller` is not documented in the 1.x REST API, making the intended
behavior of this client code a little less obvious/discoverable for future
developers (it was not obvious to me just from the API documentation). The
`/site-to-site` endpoint is documented, but would not be available on 0.x NiFi
instances.
I decided to look at the minifi-java implementation. It uses the
site-to-site client module from NiFi, which has this behavior: It tries
`/site-to-site` first, and if it gets a 404 (resource not found) error, then it
falls back to `/controller`. From
[SiteToSiteRestAPiClient](https://github.com/apache/nifi/blob/master/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/util/SiteToSiteRestApiClient.java):
```java
private ControllerDTO getController() throws IOException {
try {
HttpGet get = this.createGetControllerRequest();
return ((ControllerEntity)this.execute(get,
ControllerEntity.class)).getController();
} catch (SiteToSiteRestApiClient.HttpGetFailedException var3) {
if(404 == var3.getResponseCode()) {
logger.debug("getController received NOT_FOUND, trying to
access the old NiFi version resource url...");
HttpGet get = this.createGet("/controller");
return ((ControllerEntity)this.execute(get,
ControllerEntity.class)).getController();
} else {
throw var3;
}
}
}
private HttpGet createGetControllerRequest() {
HttpGet get = this.createGet("/site-to-site");
get.setHeader("x-nifi-site-to-site-protocol-version",
String.valueOf(this.transportProtocolVersionNegotiator.getVersion()));
return get;
}
```
That seems like a reasonable approach for minifi-cpp as well. I'm
interested in hearing thoughts from others. @apiri - should we try to keep
compatibility with 0.x NiFi's in this implementation? If not, we could just go
with `/site-to-site` in this implementation.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---