You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2023/01/19 08:19:10 UTC

[syncope] branch master updated (0c64d0d259 -> ff5bb2f002)

This is an automated email from the ASF dual-hosted git repository.

ilgrosso pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/syncope.git


    from 0c64d0d259 Keeping up with latest pac4j SNAPSHOT
     new 63d9cbb8e5 Upgrading maven-checkstyle-plugin
     new ff5bb2f002 [SYNCOPE-1724] Providing SyncopeElasticsearchHealthContributor (#404)

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../core/starter/SyncopeCoreApplication.java       | 16 +++--
 .../starter/actuate/DomainsHealthIndicator.java    |  8 ++-
 .../core/starter/actuate/EntityCacheEndpoint.java  |  2 +-
 .../actuate/ExternalResourcesHealthIndicator.java  | 25 +++++---
 ext/elasticsearch/client-elasticsearch/pom.xml     |  7 +-
 .../client/ElasticsearchClientContext.java         |  8 +++
 .../SyncopeElasticsearchHealthContributor.java     | 74 ++++++++++++++++++++++
 .../java/job/ElasticsearchReindex.java             | 19 +++---
 pom.xml                                            |  4 +-
 9 files changed, 135 insertions(+), 28 deletions(-)
 create mode 100644 ext/elasticsearch/client-elasticsearch/src/main/java/org/apache/syncope/ext/elasticsearch/client/SyncopeElasticsearchHealthContributor.java


[syncope] 02/02: [SYNCOPE-1724] Providing SyncopeElasticsearchHealthContributor (#404)

Posted by il...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ilgrosso pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/syncope.git

commit ff5bb2f0027919a51df65ed2f288cf30a87de682
Author: Francesco Chicchiriccò <il...@users.noreply.github.com>
AuthorDate: Thu Jan 19 09:17:38 2023 +0100

    [SYNCOPE-1724] Providing SyncopeElasticsearchHealthContributor (#404)
---
 .../core/starter/SyncopeCoreApplication.java       | 16 +++--
 .../starter/actuate/DomainsHealthIndicator.java    |  8 ++-
 .../core/starter/actuate/EntityCacheEndpoint.java  |  2 +-
 .../actuate/ExternalResourcesHealthIndicator.java  | 25 +++++---
 ext/elasticsearch/client-elasticsearch/pom.xml     |  7 +-
 .../client/ElasticsearchClientContext.java         |  8 +++
 .../SyncopeElasticsearchHealthContributor.java     | 74 ++++++++++++++++++++++
 .../java/job/ElasticsearchReindex.java             | 19 +++---
 pom.xml                                            |  2 +-
 9 files changed, 134 insertions(+), 27 deletions(-)

diff --git a/core/starter/src/main/java/org/apache/syncope/core/starter/SyncopeCoreApplication.java b/core/starter/src/main/java/org/apache/syncope/core/starter/SyncopeCoreApplication.java
index 90aaa28943..808ecb3561 100644
--- a/core/starter/src/main/java/org/apache/syncope/core/starter/SyncopeCoreApplication.java
+++ b/core/starter/src/main/java/org/apache/syncope/core/starter/SyncopeCoreApplication.java
@@ -21,6 +21,7 @@ package org.apache.syncope.core.starter;
 import java.util.Map;
 import org.apache.cxf.spring.boot.autoconfigure.openapi.OpenApiAutoConfiguration;
 import org.apache.syncope.common.keymaster.client.api.ConfParamOps;
+import org.apache.syncope.common.keymaster.client.api.DomainOps;
 import org.apache.syncope.common.keymaster.client.api.startstop.KeymasterStop;
 import org.apache.syncope.common.lib.info.SystemInfo;
 import org.apache.syncope.core.persistence.api.DomainHolder;
@@ -39,6 +40,8 @@ import org.apache.syncope.core.persistence.api.dao.TaskDAO;
 import org.apache.syncope.core.persistence.api.dao.UserDAO;
 import org.apache.syncope.core.persistence.api.dao.VirSchemaDAO;
 import org.apache.syncope.core.provisioning.api.ConnIdBundleManager;
+import org.apache.syncope.core.provisioning.api.ConnectorManager;
+import org.apache.syncope.core.provisioning.api.data.ConnInstanceDataBinder;
 import org.apache.syncope.core.starter.actuate.DefaultSyncopeCoreInfoContributor;
 import org.apache.syncope.core.starter.actuate.DomainsHealthIndicator;
 import org.apache.syncope.core.starter.actuate.EntityCacheEndpoint;
@@ -152,8 +155,8 @@ public class SyncopeCoreApplication extends SpringBootServletInitializer {
 
     @ConditionalOnMissingBean
     @Bean
-    public DomainsHealthIndicator domainsHealthIndicator() {
-        return new DomainsHealthIndicator();
+    public DomainsHealthIndicator domainsHealthIndicator(final DomainHolder domainHolder) {
+        return new DomainsHealthIndicator(domainHolder);
     }
 
     @ConditionalOnMissingBean
@@ -165,8 +168,13 @@ public class SyncopeCoreApplication extends SpringBootServletInitializer {
     @ConditionalOnClass(name = { "org.apache.syncope.core.logic.ResourceLogic" })
     @ConditionalOnMissingBean
     @Bean
-    public ExternalResourcesHealthIndicator externalResourcesHealthIndicator() {
-        return new ExternalResourcesHealthIndicator();
+    public ExternalResourcesHealthIndicator externalResourcesHealthIndicator(
+            final DomainOps domainOps,
+            final ExternalResourceDAO resourceDAO,
+            final ConnInstanceDataBinder connInstanceDataBinder,
+            final ConnectorManager connectorManager) {
+
+        return new ExternalResourcesHealthIndicator(domainOps, resourceDAO, connInstanceDataBinder, connectorManager);
     }
 
     @ConditionalOnMissingBean
diff --git a/core/starter/src/main/java/org/apache/syncope/core/starter/actuate/DomainsHealthIndicator.java b/core/starter/src/main/java/org/apache/syncope/core/starter/actuate/DomainsHealthIndicator.java
index 72c136c288..53e2d8d2a8 100644
--- a/core/starter/src/main/java/org/apache/syncope/core/starter/actuate/DomainsHealthIndicator.java
+++ b/core/starter/src/main/java/org/apache/syncope/core/starter/actuate/DomainsHealthIndicator.java
@@ -23,7 +23,6 @@ import java.util.concurrent.atomic.AtomicReference;
 import org.apache.syncope.core.persistence.api.DomainHolder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.actuate.health.Health;
 import org.springframework.boot.actuate.health.HealthIndicator;
 import org.springframework.boot.actuate.health.Status;
@@ -33,8 +32,11 @@ public class DomainsHealthIndicator implements HealthIndicator {
 
     protected static final Logger LOG = LoggerFactory.getLogger(DomainsHealthIndicator.class);
 
-    @Autowired
-    protected DomainHolder domainHolder;
+    protected final DomainHolder domainHolder;
+
+    public DomainsHealthIndicator(final DomainHolder domainHolder) {
+        this.domainHolder = domainHolder;
+    }
 
     @Override
     public Health health() {
diff --git a/core/starter/src/main/java/org/apache/syncope/core/starter/actuate/EntityCacheEndpoint.java b/core/starter/src/main/java/org/apache/syncope/core/starter/actuate/EntityCacheEndpoint.java
index b12015354b..2587bf8477 100644
--- a/core/starter/src/main/java/org/apache/syncope/core/starter/actuate/EntityCacheEndpoint.java
+++ b/core/starter/src/main/java/org/apache/syncope/core/starter/actuate/EntityCacheEndpoint.java
@@ -31,7 +31,7 @@ import org.springframework.web.server.ResponseStatusException;
 @Endpoint(id = "entityCache")
 public class EntityCacheEndpoint {
 
-    private final EntityCacheDAO entityCacheDAO;
+    protected final EntityCacheDAO entityCacheDAO;
 
     public EntityCacheEndpoint(final EntityCacheDAO entityCacheDAO) {
         this.entityCacheDAO = entityCacheDAO;
diff --git a/core/starter/src/main/java/org/apache/syncope/core/starter/actuate/ExternalResourcesHealthIndicator.java b/core/starter/src/main/java/org/apache/syncope/core/starter/actuate/ExternalResourcesHealthIndicator.java
index e4addb2126..439edf525b 100644
--- a/core/starter/src/main/java/org/apache/syncope/core/starter/actuate/ExternalResourcesHealthIndicator.java
+++ b/core/starter/src/main/java/org/apache/syncope/core/starter/actuate/ExternalResourcesHealthIndicator.java
@@ -30,7 +30,6 @@ import org.apache.syncope.core.provisioning.api.data.ConnInstanceDataBinder;
 import org.apache.syncope.core.spring.security.AuthContextUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.actuate.health.Health;
 import org.springframework.boot.actuate.health.HealthIndicator;
 import org.springframework.boot.actuate.health.Status;
@@ -39,17 +38,25 @@ public class ExternalResourcesHealthIndicator implements HealthIndicator {
 
     protected static final Logger LOG = LoggerFactory.getLogger(ExternalResourcesHealthIndicator.class);
 
-    @Autowired
-    protected DomainOps domainOps;
+    protected final DomainOps domainOps;
 
-    @Autowired
-    protected ExternalResourceDAO resourceDAO;
+    protected final ExternalResourceDAO resourceDAO;
 
-    @Autowired
-    protected ConnInstanceDataBinder connInstanceDataBinder;
+    protected final ConnInstanceDataBinder connInstanceDataBinder;
 
-    @Autowired
-    protected ConnectorManager connectorManager;
+    protected final ConnectorManager connectorManager;
+
+    public ExternalResourcesHealthIndicator(
+            final DomainOps domainOps,
+            final ExternalResourceDAO resourceDAO,
+            final ConnInstanceDataBinder connInstanceDataBinder,
+            final ConnectorManager connectorManager) {
+
+        this.domainOps = domainOps;
+        this.resourceDAO = resourceDAO;
+        this.connInstanceDataBinder = connInstanceDataBinder;
+        this.connectorManager = connectorManager;
+    }
 
     @Override
     public Health health() {
diff --git a/ext/elasticsearch/client-elasticsearch/pom.xml b/ext/elasticsearch/client-elasticsearch/pom.xml
index b75fa9726d..d48d5edef3 100644
--- a/ext/elasticsearch/client-elasticsearch/pom.xml
+++ b/ext/elasticsearch/client-elasticsearch/pom.xml
@@ -43,7 +43,7 @@ under the License.
       <artifactId>syncope-core-spring</artifactId>
       <version>${project.version}</version>
     </dependency>
-      
+
     <dependency>
       <groupId>co.elastic.clients</groupId>
       <artifactId>elasticsearch-java</artifactId>
@@ -57,6 +57,11 @@ under the License.
       <groupId>com.fasterxml.jackson.core</groupId>
       <artifactId>jackson-databind</artifactId>
     </dependency>
+
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter-actuator</artifactId>
+    </dependency>
   </dependencies>
 
   <build>
diff --git a/ext/elasticsearch/client-elasticsearch/src/main/java/org/apache/syncope/ext/elasticsearch/client/ElasticsearchClientContext.java b/ext/elasticsearch/client-elasticsearch/src/main/java/org/apache/syncope/ext/elasticsearch/client/ElasticsearchClientContext.java
index 1995c1bf82..4f9b3d2af2 100644
--- a/ext/elasticsearch/client-elasticsearch/src/main/java/org/apache/syncope/ext/elasticsearch/client/ElasticsearchClientContext.java
+++ b/ext/elasticsearch/client-elasticsearch/src/main/java/org/apache/syncope/ext/elasticsearch/client/ElasticsearchClientContext.java
@@ -24,6 +24,7 @@ import org.apache.http.HttpHost;
 import org.apache.syncope.core.persistence.api.dao.AnyObjectDAO;
 import org.apache.syncope.core.persistence.api.dao.GroupDAO;
 import org.apache.syncope.core.persistence.api.dao.UserDAO;
+import org.springframework.boot.actuate.health.HealthContributor;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.context.annotation.Bean;
@@ -70,4 +71,11 @@ public class ElasticsearchClientContext {
     public ElasticsearchIndexLoader elasticsearchIndexLoader(final ElasticsearchIndexManager indexManager) {
         return new ElasticsearchIndexLoader(indexManager);
     }
+
+    @ConditionalOnMissingBean
+    @Bean(name = {
+        "syncopeElasticsearchHealthContributor", "elasticsearchHealthIndicator", "elasticsearchHealthContributor" })
+    public HealthContributor syncopeElasticsearchHealthContributor(final ElasticsearchClient client) {
+        return new SyncopeElasticsearchHealthContributor(client);
+    }
 }
diff --git a/ext/elasticsearch/client-elasticsearch/src/main/java/org/apache/syncope/ext/elasticsearch/client/SyncopeElasticsearchHealthContributor.java b/ext/elasticsearch/client-elasticsearch/src/main/java/org/apache/syncope/ext/elasticsearch/client/SyncopeElasticsearchHealthContributor.java
new file mode 100644
index 0000000000..163519c532
--- /dev/null
+++ b/ext/elasticsearch/client-elasticsearch/src/main/java/org/apache/syncope/ext/elasticsearch/client/SyncopeElasticsearchHealthContributor.java
@@ -0,0 +1,74 @@
+/*
+ * 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
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.syncope.ext.elasticsearch.client;
+
+import static co.elastic.clients.elasticsearch._types.HealthStatus.Green;
+import static co.elastic.clients.elasticsearch._types.HealthStatus.Red;
+import static co.elastic.clients.elasticsearch._types.HealthStatus.Yellow;
+
+import co.elastic.clients.elasticsearch.ElasticsearchClient;
+import co.elastic.clients.elasticsearch.cluster.HealthResponse;
+import org.springframework.boot.actuate.health.Health;
+import org.springframework.boot.actuate.health.HealthIndicator;
+
+public class SyncopeElasticsearchHealthContributor implements HealthIndicator {
+
+    protected final ElasticsearchClient client;
+
+    public SyncopeElasticsearchHealthContributor(final ElasticsearchClient client) {
+        this.client = client;
+    }
+
+    @Override
+    public Health health() {
+        Health.Builder builder = new Health.Builder();
+
+        try {
+            HealthResponse health = client.cluster().health();
+            switch (health.status()) {
+                case Green:
+                case Yellow:
+                    builder.up();
+                    break;
+
+                case Red:
+                default:
+                    builder.down();
+            }
+            builder.withDetail("cluster_name", health.clusterName());
+            builder.withDetail("status", health.status().jsonValue());
+            builder.withDetail("timed_out", health.timedOut());
+            builder.withDetail("number_of_nodes", health.numberOfNodes());
+            builder.withDetail("number_of_data_nodes", health.numberOfDataNodes());
+            builder.withDetail("active_primary_shards", health.activePrimaryShards());
+            builder.withDetail("relocating_shards", health.relocatingShards());
+            builder.withDetail("initializing_shards", health.initializingShards());
+            builder.withDetail("unassigned_shards", health.unassignedShards());
+            builder.withDetail("delayed_unassigned_shards", health.delayedUnassignedShards());
+            builder.withDetail("number_of_pending_tasks", health.numberOfPendingTasks());
+            builder.withDetail("number_of_in_flight_fetch", health.numberOfInFlightFetch());
+            builder.withDetail("task_max_waiting_in_queue_millis", health.taskMaxWaitingInQueueMillis());
+            builder.withDetail("active_shards_percent_as_number", health.activeShardsPercentAsNumber());
+        } catch (Exception e) {
+            builder.down(e);
+        }
+
+        return builder.build();
+    }
+}
diff --git a/ext/elasticsearch/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/job/ElasticsearchReindex.java b/ext/elasticsearch/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/job/ElasticsearchReindex.java
index 8addb804ef..8591fbf7f7 100644
--- a/ext/elasticsearch/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/job/ElasticsearchReindex.java
+++ b/ext/elasticsearch/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/job/ElasticsearchReindex.java
@@ -99,7 +99,7 @@ public class ElasticsearchReindex extends AbstractSchedTaskJobDelegate<SchedTask
             throws JobExecutionException {
 
         if (!dryRun) {
-            LOG.debug("Start rebuilding indexes");
+            setStatus("Start rebuilding indexes");
 
             try {
                 indexManager.createAnyIndex(
@@ -111,8 +111,9 @@ public class ElasticsearchReindex extends AbstractSchedTaskJobDelegate<SchedTask
                 indexManager.createAnyIndex(
                         AuthContextUtils.getDomain(), AnyTypeKind.ANY_OBJECT, anyObjectSettings(), anyObjectMapping());
 
-                LOG.debug("Indexing users...");
-                for (int page = 1; page <= (userDAO.count() / AnyDAO.DEFAULT_PAGE_SIZE) + 1; page++) {
+                int users = userDAO.count();
+                setStatus("Indexing " + users + " users...");
+                for (int page = 1; page <= (users / AnyDAO.DEFAULT_PAGE_SIZE) + 1; page++) {
                     for (String user : userDAO.findAllKeys(page, AnyDAO.DEFAULT_PAGE_SIZE)) {
                         IndexRequest<Map<String, Object>> request = new IndexRequest.Builder<Map<String, Object>>().
                                 index(ElasticsearchUtils.getAnyIndex(AuthContextUtils.getDomain(), AnyTypeKind.USER)).
@@ -128,8 +129,9 @@ public class ElasticsearchReindex extends AbstractSchedTaskJobDelegate<SchedTask
                     }
                 }
 
-                LOG.debug("Indexing groups...");
-                for (int page = 1; page <= (groupDAO.count() / AnyDAO.DEFAULT_PAGE_SIZE) + 1; page++) {
+                int groups = groupDAO.count();
+                setStatus("Indexing " + groups + " groups...");
+                for (int page = 1; page <= (groups / AnyDAO.DEFAULT_PAGE_SIZE) + 1; page++) {
                     for (String group : groupDAO.findAllKeys(page, AnyDAO.DEFAULT_PAGE_SIZE)) {
                         IndexRequest<Map<String, Object>> request = new IndexRequest.Builder<Map<String, Object>>().
                                 index(ElasticsearchUtils.getAnyIndex(AuthContextUtils.getDomain(), AnyTypeKind.GROUP)).
@@ -145,8 +147,9 @@ public class ElasticsearchReindex extends AbstractSchedTaskJobDelegate<SchedTask
                     }
                 }
 
-                LOG.debug("Indexing any objects...");
-                for (int page = 1; page <= (anyObjectDAO.count() / AnyDAO.DEFAULT_PAGE_SIZE) + 1; page++) {
+                int anyObjects = anyObjectDAO.count();
+                setStatus("Indexing " + anyObjects + " any objects...");
+                for (int page = 1; page <= (anyObjects / AnyDAO.DEFAULT_PAGE_SIZE) + 1; page++) {
                     for (String anyObject : anyObjectDAO.findAllKeys(page, AnyDAO.DEFAULT_PAGE_SIZE)) {
                         IndexRequest<Map<String, Object>> request = new IndexRequest.Builder<Map<String, Object>>().
                                 index(ElasticsearchUtils.getAnyIndex(
@@ -166,7 +169,7 @@ public class ElasticsearchReindex extends AbstractSchedTaskJobDelegate<SchedTask
                 indexManager.createAuditIndex(
                         AuthContextUtils.getDomain(), auditSettings(), auditMapping());
 
-                LOG.debug("Rebuild indexes for domain {} successfully completed", AuthContextUtils.getDomain());
+                setStatus("Rebuild indexes for domain " + AuthContextUtils.getDomain() + " successfully completed");
             } catch (Exception e) {
                 throw new JobExecutionException("While rebuilding index for domain " + AuthContextUtils.getDomain(), e);
             }
diff --git a/pom.xml b/pom.xml
index da8f4fd5bb..067716dc37 100644
--- a/pom.xml
+++ b/pom.xml
@@ -508,7 +508,7 @@ under the License.
     <jdbc.mysql.version>8.0.31</jdbc.mysql.version>
     <jdbc.mariadb.version>3.0.8</jdbc.mariadb.version>
     <jdbc.mssql.version>11.2.1.jre</jdbc.mssql.version>
-    <jdbc.oracle.version>21.7.0.0</jdbc.oracle.version>
+    <jdbc.oracle.version>21.8.0.0</jdbc.oracle.version>
 
     <conf.directory>${project.build.directory}/test-classes</conf.directory>
     <bundles.directory>${project.build.directory}/bundles</bundles.directory>


[syncope] 01/02: Upgrading maven-checkstyle-plugin

Posted by il...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ilgrosso pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/syncope.git

commit 63d9cbb8e56539f924db3f4e4565dd27a55b8480
Author: Francesco Chicchiriccò <il...@apache.org>
AuthorDate: Tue Jan 17 14:23:47 2023 +0100

    Upgrading maven-checkstyle-plugin
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 62cea3e12c..da8f4fd5bb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1669,7 +1669,7 @@ under the License.
         <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-checkstyle-plugin</artifactId>
-          <version>3.2.0</version>
+          <version>3.2.1</version>
           <dependencies>
             <dependency>
               <groupId>com.puppycrawl.tools</groupId>