Skip to content

Commit c5f078f

Browse files
committed
Updated slightly
1 parent 4920b7d commit c5f078f

4 files changed

Lines changed: 40 additions & 35 deletions

File tree

phoss-directory-indexer/src/main/java/com/helger/pd/indexer/shadow/IShadowEvent.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
import jakarta.annotation.Nonnull;
2626

2727
/**
28-
* Interface for a shadow event that represents an indexer operation to be
29-
* replicated to a downstream service during PD2 migration.
28+
* Interface for a shadow event that represents an indexer operation to be replicated to a
29+
* downstream service during PD2 migration.
3030
*
3131
* @author Mikael Aksamit (mikael@aksamit.se)
3232
*/
@@ -66,8 +66,7 @@ public interface IShadowEvent extends IHasID <String>
6666
String getRequestingHost ();
6767

6868
/**
69-
* @return The SHA-256 fingerprint of the client certificate. Never
70-
* <code>null</code>.
69+
* @return The SHA-256 fingerprint of the client certificate. Never <code>null</code>.
7170
*/
7271
@Nonnull
7372
@Nonempty

phoss-directory-indexer/src/main/java/com/helger/pd/indexer/shadow/ShadowEventDispatcherJob.java

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
*/
1717
package com.helger.pd.indexer.shadow;
1818

19+
import org.slf4j.Logger;
20+
import org.slf4j.LoggerFactory;
21+
1922
import com.helger.annotation.style.OverrideOnDemand;
2023
import com.helger.base.enforce.ValueEnforcer;
2124
import com.helger.base.string.StringHelper;
@@ -26,25 +29,29 @@
2629
import com.helger.http.CHttp;
2730
import com.helger.pd.indexer.mgr.PDMetaManager;
2831
import com.helger.pd.indexer.settings.PDServerConfiguration;
29-
import com.helger.quartz.*;
32+
import com.helger.quartz.DisallowConcurrentExecution;
33+
import com.helger.quartz.IJobExecutionContext;
34+
import com.helger.quartz.JobDataMap;
35+
import com.helger.quartz.JobExecutionException;
36+
import com.helger.quartz.SimpleScheduleBuilder;
37+
import com.helger.quartz.TriggerKey;
3038
import com.helger.schedule.quartz.GlobalQuartzScheduler;
3139
import com.helger.schedule.quartz.trigger.JDK8TriggerBuilder;
3240
import com.helger.servlet.mock.MockHttpServletRequest;
3341
import com.helger.servlet.mock.OfflineHttpServletRequest;
3442
import com.helger.web.scope.mgr.WebScopeManager;
3543
import com.helger.web.scope.util.AbstractScopeAwareJob;
44+
3645
import jakarta.annotation.Nonnull;
3746
import jakarta.servlet.ServletContext;
38-
import org.slf4j.Logger;
39-
import org.slf4j.LoggerFactory;
4047

4148
/**
42-
* Quartz job that dispatches pending shadow events from the outbox to the
43-
* downstream replicator service. Runs every minute.
49+
* Quartz job that dispatches pending shadow events from the outbox to the downstream replicator
50+
* service. Runs every minute.
4451
* <p>
45-
* Events that fail with retryable errors (network issues, 5xx) remain in the
46-
* queue for retry. Events that fail with non-retryable errors (4xx) are moved
47-
* to the dead-letter queue for manual investigation.
52+
* Events that fail with retryable errors (network issues, 5xx) remain in the queue for retry.
53+
* Events that fail with non-retryable errors (4xx) are moved to the dead-letter queue for manual
54+
* investigation.
4855
* </p>
4956
*
5057
* @author Mikael Aksamit
@@ -69,8 +76,8 @@ protected MockHttpServletRequest createMockHttpServletRequest ()
6976
}
7077

7178
@Override
72-
protected void onExecute (@Nonnull final JobDataMap aJobDataMap,
73-
@Nonnull final IJobExecutionContext aContext) throws JobExecutionException
79+
protected void onExecute (@Nonnull final JobDataMap aJobDataMap, @Nonnull final IJobExecutionContext aContext)
80+
throws JobExecutionException
7481
{
7582
if (!PDServerConfiguration.isIndexerShadowingEnabled ())
7683
{
@@ -122,13 +129,15 @@ protected void onExecute (@Nonnull final JobDataMap aJobDataMap,
122129

123130
if (nStatusCode >= CHttp.HTTP_OK && nStatusCode < CHttp.HTTP_MULTIPLE_CHOICES)
124131
{
132+
// 2xx
125133
aEventList.removeEvent (aEvent.getEventID ());
126134
nSuccessCount++;
127135
LOGGER.info ("Successfully dispatched shadow event " + aEvent.getEventID ());
128136
}
129137
else
130138
if (nStatusCode >= CHttp.HTTP_BAD_REQUEST && nStatusCode < CHttp.HTTP_INTERNAL_SERVER_ERROR)
131139
{
140+
// 4xx
132141
aEventList.removeEvent (aEvent.getEventID ());
133142
aFailedEventList.addFailedEvent ((ShadowEvent) aEvent);
134143
nNonRetryableFailureCount++;
@@ -141,11 +150,7 @@ protected void onExecute (@Nonnull final JobDataMap aJobDataMap,
141150
else
142151
{
143152
nRetryableFailureCount++;
144-
LOGGER.warn ("Shadow event " +
145-
aEvent.getEventID () +
146-
" failed with HTTP " +
147-
nStatusCode +
148-
" - will retry");
153+
LOGGER.warn ("Shadow event " + aEvent.getEventID () + " failed with HTTP " + nStatusCode + " - will retry");
149154
}
150155
}
151156
catch (final Exception ex)

phoss-directory-indexer/src/main/java/com/helger/pd/indexer/shadow/ShadowEventSender.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@
3737
import jakarta.annotation.Nonnull;
3838

3939
/**
40-
* Sends shadow events to the downstream replicator service via HTTP POST with
41-
* JSON payload.
40+
* Sends shadow events to the downstream replicator service via HTTP POST with JSON payload.
4241
*
4342
* @author Mikael Aksamit
4443
*/
@@ -86,8 +85,8 @@ private static IJsonObject _buildEventPayload (@Nonnull final IShadowEvent aEven
8685
* @throws IOException
8786
* If the HTTP request fails
8887
*/
89-
public static int sendEvent (@Nonnull @Nonempty final String sDownstreamURL,
90-
@Nonnull final IShadowEvent aEvent) throws IOException
88+
public static int sendEvent (@Nonnull @Nonempty final String sDownstreamURL, @Nonnull final IShadowEvent aEvent)
89+
throws IOException
9190
{
9291
final IJsonObject aPayload = _buildEventPayload (aEvent);
9392
final String sJsonPayload = aPayload.getAsJsonString ();
@@ -96,7 +95,8 @@ public static int sendEvent (@Nonnull @Nonempty final String sDownstreamURL,
9695
LOGGER.debug ("Sending shadow event " + aEvent.getEventID () + " to " + sDownstreamURL);
9796

9897
final HttpPost aPost = new HttpPost (sDownstreamURL);
99-
aPost.setEntity (new StringEntity (sJsonPayload, ContentType.APPLICATION_JSON.withCharset (StandardCharsets.UTF_8)));
98+
aPost.setEntity (new StringEntity (sJsonPayload,
99+
ContentType.APPLICATION_JSON.withCharset (StandardCharsets.UTF_8)));
100100

101101
final String sSecret = PDServerConfiguration.getIndexerShadowingSecret ();
102102
if (sSecret != null)
@@ -109,25 +109,25 @@ public static int sendEvent (@Nonnull @Nonempty final String sDownstreamURL,
109109
try (final HttpClientManager aHttpClientMgr = HttpClientManager.create (aSettings))
110110
{
111111
final Integer aStatusCode = aHttpClientMgr.execute (aPost, aResponse -> {
112-
final int nCode = aResponse.getCode ();
112+
final int nStatusCode = aResponse.getCode ();
113113

114-
if (nCode >= CHttp.HTTP_OK && nCode < CHttp.HTTP_MULTIPLE_CHOICES)
114+
if (nStatusCode >= CHttp.HTTP_OK && nStatusCode < CHttp.HTTP_MULTIPLE_CHOICES)
115115
{
116116
if (LOGGER.isDebugEnabled ())
117-
LOGGER.debug ("Successfully sent shadow event " + aEvent.getEventID () + " (HTTP " + nCode + ")");
117+
LOGGER.debug ("Successfully sent shadow event " + aEvent.getEventID () + " (HTTP " + nStatusCode + ")");
118118
}
119119
else
120120
{
121-
LOGGER.warn ("Downstream returned HTTP " + nCode + " for shadow event " + aEvent.getEventID ());
121+
LOGGER.warn ("Downstream returned HTTP " + nStatusCode + " for shadow event " + aEvent.getEventID ());
122122
}
123123

124-
return nCode;
124+
return Integer.valueOf (nStatusCode);
125125
});
126126

127127
if (aStatusCode == null)
128128
throw new IOException ("HTTP client returned null status code for shadow event " + aEvent.getEventID ());
129129

130-
return aStatusCode;
130+
return aStatusCode.intValue ();
131131
}
132132
}
133133
}

pom.xml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,24 @@
6666
<maven.compiler.source>${java.version}</maven.compiler.source>
6767
<maven.compiler.target>${java.version}</maven.compiler.target>
6868

69+
<jaxb-plugin.group>org.jvnet.jaxb</jaxb-plugin.group>
70+
<jaxb-plugin.artifact>jaxb-maven-plugin</jaxb-plugin.artifact>
71+
<jaxb-plugin.version>4.0.12</jaxb-plugin.version>
72+
<ph-jaxb-plugin.version>5.1.2</ph-jaxb-plugin.version>
73+
6974
<awssdk.version>2.42.25</awssdk.version>
7075
<!-- Peppol Directory runs on Lucene v8 -->
7176
<lucene.version>8.11.2</lucene.version>
7277
<jersey.version>3.1.11</jersey.version>
7378
<log4j.version>2.25.4</log4j.version>
74-
<jaxb-plugin.group>org.jvnet.jaxb</jaxb-plugin.group>
75-
<jaxb-plugin.artifact>jaxb-maven-plugin</jaxb-plugin.artifact>
76-
<jaxb-plugin.version>4.0.12</jaxb-plugin.version>
77-
<ph-jaxb-plugin.version>5.1.1</ph-jaxb-plugin.version>
7879
</properties>
7980

8081
<dependencyManagement>
8182
<dependencies>
8283
<dependency>
8384
<groupId>com.helger.peppol</groupId>
8485
<artifactId>peppol-commons-parent-pom</artifactId>
85-
<version>12.4.0</version>
86+
<version>12.4.1</version>
8687
<type>pom</type>
8788
<scope>import</scope>
8889
</dependency>

0 commit comments

Comments
 (0)