[Folderwatcher] Add Azure blob storage containers monitoring support#14926
[Folderwatcher] Add Azure blob storage containers monitoring support#14926lsiepel merged 4 commits intoopenhab:mainfrom
Conversation
| DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); | ||
| // This returns extra character before <xml. Need to find out why | ||
| String sResponse = contentResponse.getContentAsString(); | ||
| InputSource is = new InputSource(new StringReader(sResponse.substring(sResponse.indexOf("<")))); |
There was a problem hiding this comment.
There was a problem hiding this comment.
@wborn did you experience similar issue with Azure?
There was a problem hiding this comment.
Not really, maybe it's a BOM?
|
I added the tag "work in progress" as "WIP" is still in the PR title. |
|
Gentle ping @goopilot after 1.5 years without visible progress i wonder if you need any support and if we can bring this PR to the finish line. |
Thanks for reminding me, I'll work on it this month |
d1615d5 to
0f5d9d5
Compare
Signed-off-by: Alexandr Salamatov <goopilot@gmail.com>
|
@lsiepel could you have a look at it? I'm done with it. |
Currently away, will try to look at it in the next week |
lsiepel
left a comment
There was a problem hiding this comment.
Thanks for adding Azure blob. Overall looks good, but do have some comments. Please also update the readme documentation.
|
|
||
| public List<String> listBlob(String prefix, Map<String, String> headers, Map<String, String> params) | ||
| throws Exception { | ||
|
|
...folderwatcher/src/main/java/org/openhab/binding/folderwatcher/internal/api/AzureActions.java
Outdated
Show resolved
Hide resolved
...atcher/src/main/java/org/openhab/binding/folderwatcher/internal/api/auth/AWS4SignerBase.java
Outdated
Show resolved
Hide resolved
...atcher/src/main/java/org/openhab/binding/folderwatcher/internal/api/auth/AWS4SignerBase.java
Outdated
Show resolved
Hide resolved
| } | ||
|
|
||
| try { | ||
| previousBlobListing = WatcherCommon.initStorage(currentBlobListingFile, |
There was a problem hiding this comment.
This method needs to return fast and it looks like this initStorage is blocking. If so it should run in a async thread.
There was a problem hiding this comment.
@lsiepel The idea was that if storage (in this case it's a file) can't be created, then thing should fail initialization phase. But if I run it in the thread, then thing will be initiated before storage is created. Would you suggest to do storage init in a different function?
There was a problem hiding this comment.
Both can still be achieved. A common procedure is like this:
- Validat the configuration
- set the thing state to unknown
- Start an scheduledtask that initilizes/authenticates etc the connection, form within that task:
- Set the thing state accordingly
- Schedule the
refreshAzureBlobInformationtask if all is ok.
this way the initialize method exits fast, sets the thing to unknonw and whenever the authentication finishes, the thing state is set to online/offline etc.
There was a problem hiding this comment.
@lsiepel Thanks, I pushed changes, please have a look
|
|
||
| if (refreshAzureBlobInformation()) { | ||
| if (config.pollIntervalAzure > 0) { | ||
| executionJob = scheduler.scheduleWithFixedDelay(this::refreshAzureBlobInformation, |
There was a problem hiding this comment.
Set the thing state to unknown just before you start the scheduled task.
There was a problem hiding this comment.
This will be changed as part of the above comment (async init)
3f76708 to
92a2d32
Compare
Signed-off-by: Alexandr Salamatov <goopilot@gmail.com>
|
@lsiepel could you have a look at it? |
|
|
||
| if (config.azureAnonymous) { | ||
| azure = new AzureActions(httpClientFactory, config.azureAccountName, config.azureContainerName); | ||
| } else { | ||
| azure = new AzureActions(httpClientFactory, config.azureAccountName, config.azureContainerName, | ||
| config.azureAccessKey); | ||
| } | ||
| updateStatus(ThingStatus.UNKNOWN); | ||
| if (config.pollIntervalAzure > 0) { | ||
| executionJob = scheduler.scheduleWithFixedDelay(this::refreshAzureBlobInformation, 0, | ||
| config.pollIntervalAzure, TimeUnit.SECONDS); | ||
| } else { | ||
| updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, | ||
| "Polling interval must be greater then 0 seconds"); | ||
| return; | ||
| } |
There was a problem hiding this comment.
Improved implementation (might need spotless, as i wrote it here in github)
| if (config.azureAnonymous) { | |
| azure = new AzureActions(httpClientFactory, config.azureAccountName, config.azureContainerName); | |
| } else { | |
| azure = new AzureActions(httpClientFactory, config.azureAccountName, config.azureContainerName, | |
| config.azureAccessKey); | |
| } | |
| updateStatus(ThingStatus.UNKNOWN); | |
| if (config.pollIntervalAzure > 0) { | |
| executionJob = scheduler.scheduleWithFixedDelay(this::refreshAzureBlobInformation, 0, | |
| config.pollIntervalAzure, TimeUnit.SECONDS); | |
| } else { | |
| updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, | |
| "Polling interval must be greater then 0 seconds"); | |
| return; | |
| } | |
| if (config.azureAccountName.isBlank() || config.azureContainerName.isBlank()) { | |
| updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, | |
| "Account name or container configuration is invalid"); | |
| return; | |
| } else if (config.pollIntervalAzure == 0) { | |
| updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, | |
| "Polling interval must be greater then 0 seconds"); | |
| return; | |
| } | |
| if (config.azureAnonymous) { | |
| azure = new AzureActions(httpClientFactory, config.azureAccountName, config.azureContainerName); | |
| } else { | |
| azure = new AzureActions(httpClientFactory, config.azureAccountName, config.azureContainerName, | |
| config.azureAccessKey); | |
| } | |
| updateStatus(ThingStatus.UNKNOWN); | |
| executionJob = scheduler.scheduleWithFixedDelay(this::refreshAzureBlobInformation, 0, | |
| config.pollIntervalAzure, TimeUnit.SECONDS); |
Signed-off-by: Alexandr Salamatov <goopilot@gmail.com>
|
@lsiepel omg, for some reason I was sure I did it a long time ago. Can you have a look now? |
…penhab#14926) * Add Azure Thing Signed-off-by: Alexandr Salamatov <goopilot@gmail.com>

Signed-off-by: Alexandr Salamatov goopilot@gmail.com
Added support for monitoring of Azure blob storage containers