You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@knox.apache.org by GitBox <gi...@apache.org> on 2022/11/09 09:28:12 UTC
[GitHub] [knox] zeroflag opened a new pull request, #670: KNOX-2835 SQL DB based topology monitor
zeroflag opened a new pull request, #670:
URL: https://github.com/apache/knox/pull/670
## What changes were proposed in this pull request?
This is a similar implementation as the existing zookeeper based monitor, but it uses the SQL DB. Zookeeper is not always available and the DB is already used by the token state service.
The purpose of this monitor is to periodically check the DB for shared-providers and descriptors and update the local file system with the changes from the DB.
1. If a provider/descriptor is deleted from the db but exists on the file system the monitor is going to delete it from the file system
2. If a provider/descriptor exists in the DB but missing from the file system the monitor is going to download it from the DB to the FS.
3. If a provider/descriptor has a different content than the corresponding local file, then the monitor is going to update the local file with the content from he DB.
The provider logic is implementeed in DbRemoteConfigurationMonitor.
## How was this patch tested?
gateway-site.xml
```
<property>
<name>gateway.service.remoteconfigurationmonitor.impl</name>
<value>org.apache.knox.gateway.topology.monitor.db.DbRemoteConfigurationMonitor</value>
</property>
<property>
<name>gateway.database.type</name>
<value>mysql</value>
</property>
<property>
<name>gateway.database.connection.url</name>
<value>jdbc:mysql://root:root@localhost:3306/knox</value>
</property>
```
Creating provider with curl:
```bash
$ curl -X PUT -H "Content-Type: application/json" -v -k -u admin:admin-password -d "{'x':'y'}" https://localhost:8443/gateway/admin/api/v1/providerconfig/newprov
```
Checking the DB:
```
mysql> select * from knox_providers;
+--------------+-----------+---------------------+
| name | content | last_modified_time |
+--------------+-----------+---------------------+
| newprov.json | {'x':'y'} | 2022-11-09 09:45:28 |
+--------------+-----------+---------------------+
1 row in set (0.00 sec)
```
Checking the local FS:
```bash
$ cat conf/shared-providers/newprov.json
{'x':'y'}
```
Creating descriptor with curl:
```bash
$ curl -X PUT -H "Content-Type: application/json" -v -k -u admin:admin-password -d "{'x':'y'}" https://localhost:8443/gateway/admin/api/v1/descriptors/newdesc
```
Checking the DB:
```
mysql> select * from knox_descriptors;
+--------------+---------------+---------------------+
| name | content | last_modified_time |
+--------------+---------------+---------------------+
| newdesc.json | {'abc':'def'} | 2022-11-09 09:47:06 |
+--------------+---------------+---------------------+
```
Checking the local FS:
```bash
$ cat conf/descriptors/newdesc.json
{'abc':'def'}
```
Deleting provider with curl:
```bash
$ curl -X DELETE -H "Content-Type: application/json" -v -k -u admin:admin-password https://localhost:8443/gateway/admin/api/v1/providerconfig/newprov.json
```
Checking the DB and FS:
```bash
$ ls conf/shared-providers/
mysql> select * from knox_providers;
Empty set (0.00 sec)
```
Deleting descriptor with curl:
```bash
$ curl -X DELETE -H "Content-Type: application/json" -v -k -u admin:admin-password https://localhost:8443/gateway/admin/api/v1/descriptors/newdesc.json
```
Checking the DB and FS:
```bash
$ cat conf/descriptors/newdesc.json
mysql> select * from knox_descriptors;
Empty set (0.00 sec)
```
Repeated the same tests using the Admin UI.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@knox.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [knox] zeroflag merged pull request #670: KNOX-2835 SQL DB based topology monitor
Posted by GitBox <gi...@apache.org>.
zeroflag merged PR #670:
URL: https://github.com/apache/knox/pull/670
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@knox.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [knox] smolnar82 commented on a diff in pull request #670: KNOX-2835 SQL DB based topology monitor
Posted by GitBox <gi...@apache.org>.
smolnar82 commented on code in PR #670:
URL: https://github.com/apache/knox/pull/670#discussion_r1017963443
##########
gateway-server/src/main/java/org/apache/knox/gateway/topology/monitor/DefaultConfigurationMonitorProvider.java:
##########
@@ -16,16 +16,60 @@
*/
package org.apache.knox.gateway.topology.monitor;
+import java.io.File;
+import java.sql.SQLException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Map;
+
import org.apache.knox.gateway.config.GatewayConfig;
-import org.apache.knox.gateway.services.config.client.RemoteConfigurationRegistryClientService;
+import org.apache.knox.gateway.services.GatewayServices;
+import org.apache.knox.gateway.services.ServiceLifecycleException;
+import org.apache.knox.gateway.services.ServiceType;
+import org.apache.knox.gateway.services.factory.AbstractServiceFactory;
+import org.apache.knox.gateway.services.security.AliasService;
+import org.apache.knox.gateway.services.security.AliasServiceException;
+import org.apache.knox.gateway.topology.monitor.db.DbRemoteConfigurationMonitor;
+import org.apache.knox.gateway.topology.monitor.db.LocalDirectory;
+import org.apache.knox.gateway.topology.monitor.db.RemoteConfigDatabase;
+import org.apache.knox.gateway.util.JDBCUtils;
-public class DefaultConfigurationMonitorProvider implements RemoteConfigurationMonitorProvider {
+public class DefaultConfigurationMonitorProvider extends AbstractServiceFactory {
+ @Override
+ protected RemoteConfigurationMonitor createService(GatewayServices gatewayServices,
+ ServiceType serviceType,
+ GatewayConfig gatewayConfig,
+ Map<String, String> options,
+ String implementation) throws ServiceLifecycleException {
+ RemoteConfigurationMonitor service = null;
+ if (matchesImplementation(implementation, ZkRemoteConfigurationMonitor.class)) {
+ service = new ZkRemoteConfigurationMonitor(gatewayConfig, gatewayServices.getService(ServiceType.REMOTE_REGISTRY_CLIENT_SERVICE));
+ } else if (matchesImplementation(implementation, DbRemoteConfigurationMonitor.class)) {
+ service = createDbBasedMonitor(gatewayConfig, gatewayServices.getService(ServiceType.ALIAS_SERVICE));
Review Comment:
The abstract class has a protected method called `getAliasService` for the same; please re-use that.
##########
gateway-server/src/main/java/org/apache/knox/gateway/topology/monitor/db/DbRemoteConfigurationMonitor.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.knox.gateway.topology.monitor.db;
+
+import static java.util.stream.Collectors.toSet;
+
+import java.io.IOException;
+import java.time.Instant;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.knox.gateway.GatewayMessages;
+import org.apache.knox.gateway.config.GatewayConfig;
+import org.apache.knox.gateway.i18n.messages.MessagesFactory;
+import org.apache.knox.gateway.services.ServiceLifecycleException;
+import org.apache.knox.gateway.topology.monitor.RemoteConfigurationMonitor;
+
+public class DbRemoteConfigurationMonitor implements RemoteConfigurationMonitor {
+ private static final GatewayMessages LOG = MessagesFactory.get(GatewayMessages.class);
+ public static final int OFFSET_SECONDS = 5;
+ private final RemoteConfigDatabase db;
+ private final LocalDirectory providersDir;
+ private final LocalDirectory descriptorsDir;
+ private long intervalSeconds;
+ private final ScheduledExecutorService executor;
+ private Instant lastSyncTime;
+
+ public DbRemoteConfigurationMonitor(RemoteConfigDatabase db, LocalDirectory providersDir, LocalDirectory descriptorsDir, long intervalSeconds) {
+ this.db = db;
+ this.providersDir = providersDir;
+ this.descriptorsDir = descriptorsDir;
+ this.executor = Executors.newSingleThreadScheduledExecutor();
+ this.intervalSeconds = intervalSeconds;
+ }
+
+ @Override
+ public void init(GatewayConfig config, Map<String, String> options) throws ServiceLifecycleException {}
+
+ @Override
+ public void start() throws ServiceLifecycleException {
+ LOG.startingDbRemoteConfigurationMonitor(intervalSeconds);
+ executor.scheduleWithFixedDelay(this::sync, intervalSeconds, intervalSeconds, TimeUnit.SECONDS);
+ }
+
+ @Override
+ public void stop() throws ServiceLifecycleException {
+ executor.shutdown();
+ }
+
+ @Override
+ public boolean createProvider(String name, String content) {
+ return db.putProvider(name, content);
+ }
+
+ @Override
+ public boolean createDescriptor(String name, String content) {
+ return db.putDescriptor(name, content);
+ }
+
+ @Override
+ public boolean deleteProvider(String name) {
+ return db.deleteProvider(name);
+ }
+
+ @Override
+ public boolean deleteDescriptor(String name) {
+ return db.deleteDescriptor(name);
+ }
+
+ public void sync() {
+ try {
+ syncLocalWithRemote(db.selectProviders(), providersDir);
+ syncLocalWithRemote(db.selectDescriptors(), descriptorsDir);
+ lastSyncTime = Instant.now();
Review Comment:
You may add a DEBUG-level log message with the fact that sync was done.
##########
gateway-server/src/main/java/org/apache/knox/gateway/topology/monitor/db/DbRemoteConfigurationMonitor.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.knox.gateway.topology.monitor.db;
+
+import static java.util.stream.Collectors.toSet;
+
+import java.io.IOException;
+import java.time.Instant;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.knox.gateway.GatewayMessages;
+import org.apache.knox.gateway.config.GatewayConfig;
+import org.apache.knox.gateway.i18n.messages.MessagesFactory;
+import org.apache.knox.gateway.services.ServiceLifecycleException;
+import org.apache.knox.gateway.topology.monitor.RemoteConfigurationMonitor;
+
+public class DbRemoteConfigurationMonitor implements RemoteConfigurationMonitor {
+ private static final GatewayMessages LOG = MessagesFactory.get(GatewayMessages.class);
+ public static final int OFFSET_SECONDS = 5;
+ private final RemoteConfigDatabase db;
+ private final LocalDirectory providersDir;
+ private final LocalDirectory descriptorsDir;
+ private long intervalSeconds;
+ private final ScheduledExecutorService executor;
+ private Instant lastSyncTime;
+
+ public DbRemoteConfigurationMonitor(RemoteConfigDatabase db, LocalDirectory providersDir, LocalDirectory descriptorsDir, long intervalSeconds) {
+ this.db = db;
+ this.providersDir = providersDir;
+ this.descriptorsDir = descriptorsDir;
+ this.executor = Executors.newSingleThreadScheduledExecutor();
+ this.intervalSeconds = intervalSeconds;
+ }
+
+ @Override
+ public void init(GatewayConfig config, Map<String, String> options) throws ServiceLifecycleException {}
+
+ @Override
+ public void start() throws ServiceLifecycleException {
+ LOG.startingDbRemoteConfigurationMonitor(intervalSeconds);
+ executor.scheduleWithFixedDelay(this::sync, intervalSeconds, intervalSeconds, TimeUnit.SECONDS);
+ }
+
+ @Override
+ public void stop() throws ServiceLifecycleException {
+ executor.shutdown();
+ }
+
+ @Override
+ public boolean createProvider(String name, String content) {
+ return db.putProvider(name, content);
+ }
+
+ @Override
+ public boolean createDescriptor(String name, String content) {
+ return db.putDescriptor(name, content);
+ }
+
+ @Override
+ public boolean deleteProvider(String name) {
+ return db.deleteProvider(name);
+ }
+
+ @Override
+ public boolean deleteDescriptor(String name) {
+ return db.deleteDescriptor(name);
Review Comment:
DEBUG-level log about removing a descriptor from the DB.
##########
gateway-server/src/main/java/org/apache/knox/gateway/topology/monitor/DefaultConfigurationMonitorProvider.java:
##########
@@ -16,16 +16,60 @@
*/
package org.apache.knox.gateway.topology.monitor;
+import java.io.File;
+import java.sql.SQLException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Map;
+
import org.apache.knox.gateway.config.GatewayConfig;
-import org.apache.knox.gateway.services.config.client.RemoteConfigurationRegistryClientService;
+import org.apache.knox.gateway.services.GatewayServices;
+import org.apache.knox.gateway.services.ServiceLifecycleException;
+import org.apache.knox.gateway.services.ServiceType;
+import org.apache.knox.gateway.services.factory.AbstractServiceFactory;
+import org.apache.knox.gateway.services.security.AliasService;
+import org.apache.knox.gateway.services.security.AliasServiceException;
+import org.apache.knox.gateway.topology.monitor.db.DbRemoteConfigurationMonitor;
+import org.apache.knox.gateway.topology.monitor.db.LocalDirectory;
+import org.apache.knox.gateway.topology.monitor.db.RemoteConfigDatabase;
+import org.apache.knox.gateway.util.JDBCUtils;
-public class DefaultConfigurationMonitorProvider implements RemoteConfigurationMonitorProvider {
+public class DefaultConfigurationMonitorProvider extends AbstractServiceFactory {
Review Comment:
I think this should be called a service factory from now on: `RemoteConfigurationMonitorServiceFactory`.
##########
gateway-spi/src/main/java/org/apache/knox/gateway/topology/monitor/RemoteConfigurationMonitor.java:
##########
@@ -16,14 +16,11 @@
*/
package org.apache.knox.gateway.topology.monitor;
-import org.apache.knox.gateway.services.config.client.RemoteConfigurationRegistryClient;
-
-public interface RemoteConfigurationMonitor {
-
- void start() throws Exception;
-
- void stop() throws Exception;
-
- RemoteConfigurationRegistryClient getClient();
+import org.apache.knox.gateway.services.Service;
+public interface RemoteConfigurationMonitor extends Service {
Review Comment:
This should be called a service to align with current naming conventions: `RemoteConfigurationMonitorService`
##########
gateway-server/src/main/java/org/apache/knox/gateway/topology/monitor/db/DbRemoteConfigurationMonitor.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.knox.gateway.topology.monitor.db;
+
+import static java.util.stream.Collectors.toSet;
+
+import java.io.IOException;
+import java.time.Instant;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.knox.gateway.GatewayMessages;
+import org.apache.knox.gateway.config.GatewayConfig;
+import org.apache.knox.gateway.i18n.messages.MessagesFactory;
+import org.apache.knox.gateway.services.ServiceLifecycleException;
+import org.apache.knox.gateway.topology.monitor.RemoteConfigurationMonitor;
+
+public class DbRemoteConfigurationMonitor implements RemoteConfigurationMonitor {
+ private static final GatewayMessages LOG = MessagesFactory.get(GatewayMessages.class);
+ public static final int OFFSET_SECONDS = 5;
+ private final RemoteConfigDatabase db;
+ private final LocalDirectory providersDir;
+ private final LocalDirectory descriptorsDir;
+ private long intervalSeconds;
+ private final ScheduledExecutorService executor;
+ private Instant lastSyncTime;
+
+ public DbRemoteConfigurationMonitor(RemoteConfigDatabase db, LocalDirectory providersDir, LocalDirectory descriptorsDir, long intervalSeconds) {
+ this.db = db;
+ this.providersDir = providersDir;
+ this.descriptorsDir = descriptorsDir;
+ this.executor = Executors.newSingleThreadScheduledExecutor();
+ this.intervalSeconds = intervalSeconds;
+ }
+
+ @Override
+ public void init(GatewayConfig config, Map<String, String> options) throws ServiceLifecycleException {}
+
+ @Override
+ public void start() throws ServiceLifecycleException {
+ LOG.startingDbRemoteConfigurationMonitor(intervalSeconds);
+ executor.scheduleWithFixedDelay(this::sync, intervalSeconds, intervalSeconds, TimeUnit.SECONDS);
+ }
+
+ @Override
+ public void stop() throws ServiceLifecycleException {
+ executor.shutdown();
+ }
+
+ @Override
+ public boolean createProvider(String name, String content) {
+ return db.putProvider(name, content);
Review Comment:
DEBUG-level log about creating the provider in the DB.
##########
gateway-server/src/main/java/org/apache/knox/gateway/topology/monitor/db/DbRemoteConfigurationMonitor.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.knox.gateway.topology.monitor.db;
+
+import static java.util.stream.Collectors.toSet;
+
+import java.io.IOException;
+import java.time.Instant;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.knox.gateway.GatewayMessages;
+import org.apache.knox.gateway.config.GatewayConfig;
+import org.apache.knox.gateway.i18n.messages.MessagesFactory;
+import org.apache.knox.gateway.services.ServiceLifecycleException;
+import org.apache.knox.gateway.topology.monitor.RemoteConfigurationMonitor;
+
+public class DbRemoteConfigurationMonitor implements RemoteConfigurationMonitor {
+ private static final GatewayMessages LOG = MessagesFactory.get(GatewayMessages.class);
+ public static final int OFFSET_SECONDS = 5;
+ private final RemoteConfigDatabase db;
+ private final LocalDirectory providersDir;
+ private final LocalDirectory descriptorsDir;
+ private long intervalSeconds;
+ private final ScheduledExecutorService executor;
+ private Instant lastSyncTime;
+
+ public DbRemoteConfigurationMonitor(RemoteConfigDatabase db, LocalDirectory providersDir, LocalDirectory descriptorsDir, long intervalSeconds) {
+ this.db = db;
+ this.providersDir = providersDir;
+ this.descriptorsDir = descriptorsDir;
+ this.executor = Executors.newSingleThreadScheduledExecutor();
+ this.intervalSeconds = intervalSeconds;
+ }
+
+ @Override
+ public void init(GatewayConfig config, Map<String, String> options) throws ServiceLifecycleException {}
+
+ @Override
+ public void start() throws ServiceLifecycleException {
+ LOG.startingDbRemoteConfigurationMonitor(intervalSeconds);
+ executor.scheduleWithFixedDelay(this::sync, intervalSeconds, intervalSeconds, TimeUnit.SECONDS);
+ }
+
+ @Override
+ public void stop() throws ServiceLifecycleException {
+ executor.shutdown();
+ }
+
+ @Override
+ public boolean createProvider(String name, String content) {
+ return db.putProvider(name, content);
+ }
+
+ @Override
+ public boolean createDescriptor(String name, String content) {
+ return db.putDescriptor(name, content);
Review Comment:
DEBUG-level log about creating the descriptor in the DB.
##########
gateway-server/src/main/java/org/apache/knox/gateway/topology/monitor/db/DbRemoteConfigurationMonitor.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.knox.gateway.topology.monitor.db;
+
+import static java.util.stream.Collectors.toSet;
+
+import java.io.IOException;
+import java.time.Instant;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.knox.gateway.GatewayMessages;
+import org.apache.knox.gateway.config.GatewayConfig;
+import org.apache.knox.gateway.i18n.messages.MessagesFactory;
+import org.apache.knox.gateway.services.ServiceLifecycleException;
+import org.apache.knox.gateway.topology.monitor.RemoteConfigurationMonitor;
+
+public class DbRemoteConfigurationMonitor implements RemoteConfigurationMonitor {
+ private static final GatewayMessages LOG = MessagesFactory.get(GatewayMessages.class);
+ public static final int OFFSET_SECONDS = 5;
+ private final RemoteConfigDatabase db;
+ private final LocalDirectory providersDir;
+ private final LocalDirectory descriptorsDir;
+ private long intervalSeconds;
+ private final ScheduledExecutorService executor;
+ private Instant lastSyncTime;
+
+ public DbRemoteConfigurationMonitor(RemoteConfigDatabase db, LocalDirectory providersDir, LocalDirectory descriptorsDir, long intervalSeconds) {
+ this.db = db;
+ this.providersDir = providersDir;
+ this.descriptorsDir = descriptorsDir;
+ this.executor = Executors.newSingleThreadScheduledExecutor();
+ this.intervalSeconds = intervalSeconds;
+ }
+
+ @Override
+ public void init(GatewayConfig config, Map<String, String> options) throws ServiceLifecycleException {}
+
+ @Override
+ public void start() throws ServiceLifecycleException {
+ LOG.startingDbRemoteConfigurationMonitor(intervalSeconds);
+ executor.scheduleWithFixedDelay(this::sync, intervalSeconds, intervalSeconds, TimeUnit.SECONDS);
+ }
+
+ @Override
+ public void stop() throws ServiceLifecycleException {
+ executor.shutdown();
+ }
+
+ @Override
+ public boolean createProvider(String name, String content) {
+ return db.putProvider(name, content);
+ }
+
+ @Override
+ public boolean createDescriptor(String name, String content) {
+ return db.putDescriptor(name, content);
+ }
+
+ @Override
+ public boolean deleteProvider(String name) {
+ return db.deleteProvider(name);
Review Comment:
DEBUG-level log about removing the provider from the DB.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@knox.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org