Conversation
…der response when the OIDC Identifying User claim is not found. Revised log message to print available claims. Added new StandardOidcIdentityProviderGroovyTest file. Updated deprecated methods in StandardOidcIdentityProvider. Changed log output to print all available claim names from JWTClaimsSet. Added unit test. Added comments in getAvailableClaims() method. Fixed typos in NiFi Docs Admin Guide. Added license to Groovy test. Fixed a checkstyle error. Refactor exchangeAuthorizationCode method. Added unit tests. Verified all unit tests added so far are passing. Refactored code. Added unit tests. Refactored OIDC provider to decouple constructor & network-dependent initialization. Added unit tests. Added unit tests. Refactored OIDC provider to separately authorize the client. Added unit tests. Added unit tests. NIFI-7332 Refactored exchangeAuthorizationCode method to separately retrieve the NiFi JWT. Signed-off-by: Nathan Gough <thenatog@gmail.com> This closes apache#4344.
exceptionfactory
left a comment
There was a problem hiding this comment.
Thanks for the contribution @xuanronaldo! Supporting integration with Apache IoTDB through the standard Java API looks like a very useful feature.
Unfortunately there several general issues that need to be resolved before a more thorough implementation review can go forward.
- The
Static Analysischeck indicates several style problems. At a quick glance, some of the problems appear to be related to the use of asterisk imports. Please run a Maven build with thecontrib-checkprofile to evaluate the issues - All
maven.compilerproperties must be removed. Although NiFi will be deprecating support for Java 8 soon, it is still a supported version, and that property cannot be overridden in specific modules - All packages must begin with
org.apache.nifi, instead oforg.apache.iotdb - All Maven
groupIdelements must containorg.apache.nifi, instead oforg.apache.iotdb
There are a couple other general recommendations worth noting:
- The Jackson library should be used for JSON processing unless there is a compelling reason to use a different library
- Use of inline anonymous class declarations for collections such as HashMap, HashSet, and ArrayList should be avoided. Although this has some convenience value, it is not recommended in either runtime code or test code.
Thanks again for working on this new feature. After addressing these issues, the changes should be in a good position for a more detailed review.
|
One additional note, Apache NiFi just released version 1.17.0, so the current main branch is now on 1.18.0-SNAPSHOT. Please rebase and update to the current version. Thanks! |
|
Ok, I got it. Thanks for your suggestions. I'm working on it. |
|
I have pushed the code, and all checks have passed. What should I do next to merge the branch? |
|
Thanks for making the updates @xuanronaldo. Merging requires approval from at least one committer. I will try to take a look at the latest version soon. |
exceptionfactory
left a comment
There was a problem hiding this comment.
Thanks for making the initial changes @xuanronaldo.
I took a closer look at the implementation and noted a number of areas for improvement. The division of the abstract class and concrete class is helpful to indicate the core functionality. The core logic in onTrigger was difficult to follow at points because of the layout and nesting, so some general refactoring would be helpful.
| <dependency> | ||
| <groupId>org.apache.nifi</groupId> | ||
| <artifactId>nifi-mock-record-utils</artifactId> | ||
| <version>${project.version}</version> |
There was a problem hiding this comment.
This dependency should be marked with a test scope.
| <dependency> | ||
| <groupId>org.apache.nifi</groupId> | ||
| <artifactId>nifi-standard-services-api-nar</artifactId> | ||
| <version>${project.version}</version> | ||
| <type>nar</type> | ||
| </dependency> |
There was a problem hiding this comment.
This dependency must be removed to nifi-iotdb-nar, instead of this jar module.
| <version>${jackson.bom.version}</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.fasterxml.jackson.core</groupId> | ||
| <artifactId>jackson-annotations</artifactId> | ||
| <version>${jackson.bom.version}</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.fasterxml.jackson.core</groupId> | ||
| <artifactId>jackson-databind</artifactId> | ||
| <version>${jackson.bom.version}</version> |
There was a problem hiding this comment.
The version property can be removed since the Bill-of-Materials dependency in the root configuration manages the version.
| <dependency> | ||
| <groupId>junit</groupId> | ||
| <artifactId>junit</artifactId> | ||
| </dependency> |
There was a problem hiding this comment.
JUnit 5 is included as a default dependency, so this dependency on JUnit 4 should be removed.
| import org.apache.nifi.serialization.record.RecordFieldType; | ||
| import org.apache.nifi.util.TestRunner; | ||
| import org.apache.nifi.util.TestRunners; | ||
| import org.junit.Assert; |
There was a problem hiding this comment.
Should be changed to JUnit 5 Assertions and it would be better to use static imports for assert methods.
There was a problem hiding this comment.
@xuanronaldo Please review this comment and update the assertions to use JUnit 5 instead of JUnit 4. Thanks!
| if (!result.getKey()) { | ||
| getLogger().error(result.getValue()); | ||
| inputStream.close(); | ||
| recordReader.close(); | ||
| processSession.transfer(flowFile, REL_FAILURE); | ||
| return; | ||
| } else { | ||
| if (result.getValue() != null) { | ||
| getLogger().warn(result.getValue()); | ||
| } | ||
| } |
There was a problem hiding this comment.
All log messages should have a readable message, in addition to passing the relevant value.
| inputStream.close(); | ||
| recordReader.close(); |
There was a problem hiding this comment.
Closing these objects should be unnecessary with the use of try-with-resources.
There was a problem hiding this comment.
I have tried to delete these, but it will throw an exception java.lang.IllegalStateException: FlowFile[0,16972544312800.mockFlowFile,0B] already in use for an active callback or InputStream created by ProcessSession.read(FlowFile) has not been closed.
There was a problem hiding this comment.
Thanks for the reply @xuanronaldo, does this occur when calling ProcessSession.transfer()? If you move it outside of the try-catch block, or change the read() signature to use a callback, that should resolve this error.
| timestamp = (Long) values[0]; | ||
| } | ||
|
|
||
| boolean flag = false; |
There was a problem hiding this comment.
The purpose of this variable is somewhat unclear based on the name.
| return; | ||
| } | ||
|
|
||
| HashMap<String, Tablet> tablets; |
There was a problem hiding this comment.
This variable, and perhaps others, should be declared and assigned in the same location for better readability.
Thanks for your suggestions. I will update the code asap. |
|
I have merged the main branch to resolve the problem which happened in workflow. Please approve running workflows agin. @exceptionfactory |
|
All checks have passed, could you please take a look at my latest commit? @exceptionfactory |
| import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType; | ||
| import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType; | ||
| import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding; | ||
| import org.junit.Assert; |
There was a problem hiding this comment.
See the other note about changing to use JUnit 5 Assertions.
exceptionfactory
left a comment
There was a problem hiding this comment.
Thanks for making the latest updates @xuanronaldo, this is looking closer to completion. I noted a few additional minor details, and I had a particular question about the expected format of the IoTDB Schema Template.
I plan to run through some additional tests soon.
| <dependency> | ||
| <groupId>org.apache.nifi</groupId> | ||
| <artifactId>nifi-dbcp-service-api</artifactId> | ||
| <version>${project.version}</version> | ||
| </dependency> |
There was a problem hiding this comment.
This dependency is not necessary and should be removed
| if (format == null && needInitFormatter) { | ||
| format = initFormatter((String) values[0]); | ||
| if (format == null) { | ||
| getLogger().error("{} Record [{}] time format not supported\", flowFile, recordNumber"); |
There was a problem hiding this comment.
The trailing slash character should be removed:
| getLogger().error("{} Record [{}] time format not supported\", flowFile, recordNumber"); | |
| getLogger().error("{} Record [{}] time format not supported", flowFile, recordNumber"); |
|
|
||
| long timestamp; | ||
| if (needInitFormatter) { | ||
| timestamp = Timestamp.valueOf(LocalDateTime.parse((String) values[0], format)).getTime(); |
There was a problem hiding this comment.
Recommend breaking this into multiple lines for better readability.
| FlowFile flowFile = processSession.get(); | ||
|
|
||
| if (flowFile == null) { | ||
| processSession.transfer(flowFile, REL_SUCCESS); |
There was a problem hiding this comment.
This transfer should be removed because flowFile is null.
|
|
||
| static final PropertyDescriptor SCHEMA = | ||
| new PropertyDescriptor.Builder() | ||
| .name("Schema") |
There was a problem hiding this comment.
Recommend naming this property Schema Template to align with the IoTDB terminology.
| "The schema that IoTDB needs doesn't support good by NiFi.\n" | ||
| + "Therefore, you can define the schema here.\n" | ||
| + "Besides, you can set encoding type and compression type by this method.\n" | ||
| + "If you don't set this property, the inferred schema will be used.\n") |
There was a problem hiding this comment.
The wording of this description is not quite clear, and does not need to state what NiFi does not support. Recommend adjusting the wording to include more details about the expected format, along the following lines:
The Apache IoTDB Schema Template defined using JSON. The Processor will infer the IoTDB Schema when this property is not configured.
The IoTDB Schema Template documentation provides some details, but is there an official format specification? It would be helpful to link to that documentation if available, otherwise it will be unclear how to define this property.
|
Okay, I got it. I will update the code asap. Thanks for your suggestions. |
|
Hi, @exceptionfactory . Sorry about committing the code so late. I got lots of work to do, recently. Besides, I have updated a document about |
exceptionfactory
left a comment
There was a problem hiding this comment.
Thanks for the update @xuanronaldo. The link listed in the Apache IoTDB documentation appears to describe this processor, as opposed to a generalized IoTDB Schema Template. These seems like the Schema Template is specific to this processor property, as opposed to being a generalized Apache IoTDB standard representation. Is that correct? Perhaps this is the best way to represent that IoTDB Schema, but if there is a schema representation that is specific to IoTDB, not NiFi, that would be ideal. I will take a closer look at the implementation and documentation.
It looks like the most recent commits resulted in introducing several unrelated changes, found in the nifi-hubspot-bundle and nifi-standard-bundle. Please review and revert these changes so that the latest version of the pull request is limited to IoTDB Processor changes. Thanks!
|
Yep, you are rigth @exceptionfactory . The |
…nifi into implement_put_iotdb
f9eb64f to
41f0c73
Compare
|
I have reverted these changes. However, several files were still marked for modification. I have no idea what to do. @exceptionfactory |
I see the files are still marked as changed. If it is necessary to squash all current changes in order to remove the merge commits and avoid including these files marked as changed, that would be fine too. Either way, the latest version should just reflect the new components. |
I have no idea about squash all current changes. Or I can create a new branch and submit another PR? |
|
Thanks for following up @xuanronaldo. Sure, if it is easier for you to create a new branch with the current version, that's fine as well. It is easy to link to this PR for background, and we can work from the new PR. |
PutIoTDB
Properties of PutIoTDB
for parsing the incoming data and determining the schema.
Therefore, you can define the schema here.
Besides, you can set encoding type and compression type by this method.
If you don't set this property, the inferred schema will be used.
It can be updated by expression language.
Inferred Schema of Flowfile
There are a couple of rules about flowfile:
Record Reader.Time, and it must be the first.STRINGorLONG.root..INT,LONG,FLOAT,DOUBLE,BOOLEAN,TEXT.Convert Schema by property
As mentioned above, converting schema by property which is more flexible and stronger than inferred schema.
The structure of property
Schema:{ "timeType": "long", "field": [{ "tsName": "root.sg.d1.s1", "dataType": "INT32", "encoding": "RLE", "compressionType": "GZIP" }, { "tsName": "root.sg.d1.s2", "dataType": "INT64", "encoding": "RLE", "compressionType": "GZIP" }] }Note
Time. The rest must be arranged in the same order as infieldof JSON.timeTypeandfields.longandstringfortimeType.tsNameanddataTypemust be set.root..dataTypesareINT32,INT64,FLOAT,DOUBLE,BOOLEAN,TEXT.encodingarePLAIN,DICTIONARY,RLE,DIFF,TS_2DIFF,BITMAP,GORILLA_V1,REGULAR,GORILLA.compressionTypeareUNCOMPRESSED,SNAPPY,GZIP,LZO,SDT,PAA,PLA,LZ4.Relationships