Skip to content

Commit c9d1dbd

Browse files
committed
Merge branch 'develop' into feature/aux-search-filter
2 parents 39afce2 + e4d553c commit c9d1dbd

7 files changed

Lines changed: 96 additions & 11 deletions

File tree

solarnet/cloud-integrations/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ dependencyManagement {
1414
}
1515

1616
description = 'SolarNet: Cloud Integrations'
17-
version = '4.8.1'
17+
version = '4.8.2'
1818

1919
base {
2020
archivesName = 'solarnet-cloud-integrations'

solarnet/cloud-integrations/src/main/java/net/solarnetwork/central/c2c/biz/impl/DaoCloudDatumStreamRakeService.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,9 @@ public CloudDatumStreamRakeTaskEntity call() throws Exception {
291291
long errorCount = prevErrorCount != null ? prevErrorCount + 1L : 0L;
292292
var errMsg = "Error executing rake task.";
293293
var exMsg = (e instanceof RemoteServiceException ? e : t).getMessage();
294-
Map<String, Object> errData = Map.of(CONFIG_SUB_ID_DATA_KEY, taskInfo.getConfigId(),
295-
MESSAGE_DATA_KEY, Objects.requireNonNullElse(exMsg, ""),
296-
ERROR_COUNT_DATA_KEY, errorCount);
294+
Map<String, Object> errData = Map.of(CONFIG_ID_DATA_KEY, taskInfo.getDatumStreamId(),
295+
CONFIG_SUB_ID_DATA_KEY, taskInfo.getConfigId(), MESSAGE_DATA_KEY,
296+
Objects.requireNonNullElse(exMsg, ""), ERROR_COUNT_DATA_KEY, errorCount);
297297
var oldState = taskInfo.getState();
298298
taskInfo.setMessage(errMsg);
299299
taskInfo.putServiceProps(errData);
@@ -325,8 +325,8 @@ public CloudDatumStreamRakeTaskEntity call() throws Exception {
325325
e.toString());
326326
taskInfo.setState(Completed);
327327
}
328-
userEventAppenderBiz.addEvent(taskInfo.getUserId(), eventForUserRelatedKey(
329-
taskInfo.id(), INTEGRATION_RAKE_ERROR_TAGS, errMsg, errData));
328+
userEventAppenderBiz.addEvent(taskInfo.getUserId(),
329+
eventForUserRelatedKey(null, INTEGRATION_RAKE_ERROR_TAGS, errMsg, errData));
330330
if ( !taskDao.updateTask(taskInfo, oldState) ) {
331331
log.warn(
332332
"Unable to update datum stream {} rake task {} info with expected state {} with details: {}",

solarnet/cloud-integrations/src/test/java/net/solarnetwork/central/c2c/biz/impl/test/DaoCloudDatumStreamRakeServiceTests.java

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import static java.time.ZoneOffset.UTC;
2929
import static java.time.temporal.ChronoUnit.DAYS;
3030
import static java.time.temporal.ChronoUnit.HOURS;
31+
import static java.time.temporal.ChronoUnit.MINUTES;
3132
import static net.solarnetwork.central.datum.domain.DatumValidationType.TIME_GAP_VALIDATION_TYPE;
3233
import static net.solarnetwork.central.domain.BasicClaimableJobState.Claimed;
3334
import static net.solarnetwork.central.domain.BasicClaimableJobState.Executing;
@@ -40,6 +41,7 @@
4041
import static net.solarnetwork.util.NumberUtils.decimalArray;
4142
import static org.assertj.core.api.BDDAssertions.and;
4243
import static org.assertj.core.api.BDDAssertions.from;
44+
import static org.assertj.core.api.BDDAssertions.thenExceptionOfType;
4345
import static org.mockito.ArgumentMatchers.any;
4446
import static org.mockito.ArgumentMatchers.argThat;
4547
import static org.mockito.ArgumentMatchers.eq;
@@ -60,6 +62,7 @@
6062
import java.util.UUID;
6163
import java.util.concurrent.Callable;
6264
import java.util.concurrent.CompletableFuture;
65+
import java.util.concurrent.ExecutionException;
6366
import java.util.concurrent.ExecutorService;
6467
import java.util.concurrent.Future;
6568
import java.util.concurrent.RejectedExecutionException;
@@ -71,6 +74,9 @@
7174
import org.mockito.Captor;
7275
import org.mockito.Mock;
7376
import org.mockito.junit.jupiter.MockitoExtension;
77+
import org.springframework.http.HttpHeaders;
78+
import org.springframework.http.HttpStatus;
79+
import org.springframework.web.client.HttpClientErrorException;
7480
import net.solarnetwork.central.biz.UserEventAppenderBiz;
7581
import net.solarnetwork.central.c2c.biz.CloudDatumStreamService;
7682
import net.solarnetwork.central.c2c.biz.impl.DaoCloudDatumStreamRakeService;
@@ -1356,4 +1362,84 @@ public void executeTask_afterPollStartDate() throws Exception {
13561362
// @formatter:on
13571363
}
13581364

1365+
@Test
1366+
public void executeTask_http429() throws Exception {
1367+
// GIVEN
1368+
// submit task
1369+
var future = new CompletableFuture<CloudDatumStreamRakeTaskEntity>();
1370+
given(executor.submit(argThat((Callable<CloudDatumStreamRakeTaskEntity> call) -> {
1371+
try {
1372+
future.complete(call.call());
1373+
} catch ( Exception e ) {
1374+
future.completeExceptionally(e);
1375+
}
1376+
return true;
1377+
}))).willReturn(future);
1378+
1379+
final Instant sod = clock.instant().truncatedTo(ChronoUnit.DAYS);
1380+
1381+
final CloudDatumStreamConfiguration datumStream = new CloudDatumStreamConfiguration(TEST_USER_ID,
1382+
randomLong(), now(), randomString(), TEST_DATUM_STREAM_SERVICE_IDENTIFIER,
1383+
ObjectDatumKind.Node);
1384+
datumStream.setDatumStreamMappingId(randomLong());
1385+
datumStream.setSchedule("0 0/5 * * * *");
1386+
datumStream.setObjectId(randomLong());
1387+
datumStream.setSourceId(randomString());
1388+
1389+
// look up datum stream associated with task
1390+
given(datumStreamDao.get(datumStream.getId())).willReturn(datumStream);
1391+
1392+
// verify node ownership
1393+
final var nodeOwner = new BasicSolarNodeOwnership(datumStream.getObjectId(), TEST_USER_ID, "NZ",
1394+
UTC, true, false);
1395+
given(nodeOwnershipDao.ownershipForNodeId(datumStream.getObjectId())).willReturn(nodeOwner);
1396+
1397+
// load poll task to check its start date
1398+
final CloudDatumStreamPollTaskEntity pollTask = new CloudDatumStreamPollTaskEntity(
1399+
datumStream.getId(), Claimed, clock.instant(), clock.instant().truncatedTo(HOURS));
1400+
given(pollTaskDao.get(datumStream.getId())).willReturn(pollTask);
1401+
1402+
// update task state to "processing"
1403+
given(taskDao.updateTaskState(datumStream.getId(), Executing, Claimed)).willReturn(true);
1404+
1405+
// query for data associated with service configured on datum stream
1406+
final var ex = HttpClientErrorException.create(HttpStatus.TOO_MANY_REQUESTS,
1407+
"Too many requests.", new HttpHeaders(), null, null);
1408+
given(datumStreamService.datum(same(datumStream), any())).willThrow(ex);
1409+
1410+
// WHEN
1411+
var task = new CloudDatumStreamRakeTaskEntity(datumStream.getId(), now(),
1412+
datumStream.getConfigId(), Claimed, sod, Period.ofDays(1));
1413+
1414+
Future<CloudDatumStreamRakeTaskEntity> result = service.executeTask(task);
1415+
thenExceptionOfType(ExecutionException.class).isThrownBy(() -> {
1416+
result.get(1, TimeUnit.MINUTES);
1417+
}).withCauseInstanceOf(HttpClientErrorException.class);
1418+
1419+
// THEN
1420+
// @formatter:off
1421+
then(taskDao).should().updateTask(taskCaptor.capture(), eq(Executing));
1422+
and.then(taskCaptor.getValue())
1423+
.as("Task to update is copy of given task")
1424+
.isNotSameAs(task)
1425+
.as("Task to update has same ID as given task")
1426+
.isEqualTo(task)
1427+
.as("Update task state to Queued to run again")
1428+
.returns(Queued, from(CloudDatumStreamRakeTaskEntity::getState))
1429+
.as("Task execute date pushed by one minute")
1430+
.returns(clock.instant().plus(1, MINUTES), from(CloudDatumStreamRakeTaskEntity::getExecuteAt))
1431+
.as("Message generated for failed execution")
1432+
.returns("Error executing rake task.", from(CloudDatumStreamRakeTaskEntity::getMessage))
1433+
.as("Service properties generated for failed execution")
1434+
.returns(Map.of(
1435+
CONFIG_ID_DATA_KEY, task.getDatumStreamId(),
1436+
CONFIG_SUB_ID_DATA_KEY, task.getConfigId(),
1437+
ERROR_COUNT_DATA_KEY, 0L,
1438+
MESSAGE_DATA_KEY, ex.getMessage()
1439+
), from(CloudDatumStreamRakeTaskEntity::getServiceProperties))
1440+
;
1441+
1442+
// @formatter:on
1443+
}
1444+
13591445
}

solarnet/common/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ dependencyManagement {
1616
}
1717

1818
description = 'SolarNet: Common'
19-
version = '7.11.1'
19+
version = '7.11.2'
2020

2121
base {
2222
archivesName = 'solarnet-common'

solarnet/common/src/main/java/net/solarnetwork/central/domain/CommonUserEvents.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
import static net.solarnetwork.central.domain.LogEventInfo.event;
2626
import static net.solarnetwork.codec.jackson.JsonUtils.getJSONString;
27-
import java.util.HashMap;
2827
import java.util.LinkedHashMap;
2928
import java.util.List;
3029
import java.util.Map;
@@ -216,7 +215,7 @@ static void populateUserRelatedKeyEventParameters(@Nullable UserRelatedComposite
216215
*/
217216
static LogEventInfo eventForUserRelatedKey(@Nullable UserRelatedCompositeKey<?> configId,
218217
List<String> baseTags, @Nullable String message, String @Nullable... extraTags) {
219-
Map<String, Object> data = new HashMap<>(4);
218+
Map<String, Object> data = new LinkedHashMap<>(4);
220219
populateUserRelatedKeyEventParameters(configId, data);
221220
return event(baseTags, message, getJSONString(data, null), extraTags);
222221
}

solarnet/solarjobs/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ apply plugin: 'org.springframework.boot'
99
apply plugin: 'io.spring.dependency-management'
1010

1111
description = 'SolarJobs'
12-
version = '5.12.1'
12+
version = '5.12.2'
1313

1414
base {
1515
archivesName = 'solarjobs'

solarnet/solaruser/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ apply plugin: 'org.springframework.boot'
1111
apply plugin: 'io.spring.dependency-management'
1212

1313
description = 'SolarUser'
14-
version = '5.9.1'
14+
version = '5.9.2'
1515

1616
base {
1717
archivesName = 'solaruser'

0 commit comments

Comments
 (0)