I want to write nifi processor which can read xml file from hdfs directory and then extracting it's data into flowfile attributes, also if there is case when two nifi processor can get this file and read data or write something into it how can i do file lock so that at a time only one processor can use it? Can you reccomend me any article, code examples or some related materials which can help me. i'haven't write any custom processor yet.
I don't think you'd need a custom processor for this use case, you should be able to use ListHDFS -> FetchHDFS -> EvaluateXPath to read XML files from an HDFS location and then extract values as attributes. These processors, when configured correctly, will take care of the file handling and such, even across a NiFi cluster..
If i got code of this processor from github nifi code ListHDFS -> FetchHDFS -> EvaluateXPath->updateAttribute and reunite them in a way that they could work together can i make one perfectly working processor which can make all these tasks?
Why do you need this functionality in a single processor?
If it is for reusability, I'd suggest you to create a process group and use it wherever you need it. If it is for locking and synchronization, I'd suggest to use something like Zookeeper to keep a status of the ongoing process (here you can find some processor to interact with Zookeeper).
Anyway, if you still need to write your custom processor, then please check this tutorial: https://community.hortonworks.com/articles/4318/build-custom-nifi-processor.html