Search in sources :

Example 1 with DownloaderProperties

use of com.hedera.mirror.importer.downloader.DownloaderProperties in project hedera-mirror-node by hashgraph.

the class MirrorDateRangePropertiesProcessor method newDateRangeFilter.

private DateRangeFilter newDateRangeFilter(StreamType streamType) {
    DownloaderProperties downloaderProperties = getDownloaderProperties(streamType);
    if (!downloaderProperties.isEnabled()) {
        return DateRangeFilter.empty();
    }
    Instant startDate = mirrorProperties.getStartDate();
    Instant endDate = mirrorProperties.getEndDate();
    Instant lastFileInstant = findLatest(streamType).map(StreamFile::getConsensusStart).map(nanos -> Instant.ofEpochSecond(0, nanos)).orElse(null);
    Instant filterStartDate = lastFileInstant;
    if (startDate != null && startDate.compareTo(endDate) > 0) {
        throw new InvalidConfigurationException(String.format("Date range constraint violation: " + "startDate (%s) > endDate (%s)", startDate, endDate));
    }
    if (startDate != null) {
        filterStartDate = max(startDate, lastFileInstant);
    } else {
        if (mirrorProperties.getNetwork() != MirrorProperties.HederaNetwork.DEMO && lastFileInstant == null) {
            filterStartDate = STARTUP_TIME;
        }
    }
    DateRangeFilter filter = new DateRangeFilter(filterStartDate, endDate);
    log.info("{}: parser will parse items in the range [{}, {}]", downloaderProperties.getStreamType(), filter.getStartAsInstant(), filter.getEndAsInstant());
    return filter;
}
Also used : DownloaderProperties(com.hedera.mirror.importer.downloader.DownloaderProperties) InvalidConfigurationException(com.hedera.mirror.importer.exception.InvalidConfigurationException) RequiredArgsConstructor(lombok.RequiredArgsConstructor) Value(lombok.Value) StreamFilename(com.hedera.mirror.importer.domain.StreamFilename) Duration(java.time.Duration) Map(java.util.Map) Named(javax.inject.Named) Utility(com.hedera.mirror.importer.util.Utility) DomainUtils(com.hedera.mirror.common.util.DomainUtils) ObjectUtils.max(org.apache.commons.lang3.ObjectUtils.max) EventFileRepository(com.hedera.mirror.importer.repository.EventFileRepository) ReflectUtils(org.springframework.cglib.core.ReflectUtils) DATA(com.hedera.mirror.importer.domain.StreamFilename.FileType.DATA) StreamType(com.hedera.mirror.common.domain.StreamType) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) StreamFile(com.hedera.mirror.common.domain.StreamFile) Instant(java.time.Instant) AccountBalanceFileRepository(com.hedera.mirror.importer.repository.AccountBalanceFileRepository) List(java.util.List) MirrorProperties(com.hedera.mirror.importer.MirrorProperties) RecordFileRepository(com.hedera.mirror.importer.repository.RecordFileRepository) Log4j2(lombok.extern.log4j.Log4j2) Optional(java.util.Optional) StreamFileRepository(com.hedera.mirror.importer.repository.StreamFileRepository) DownloaderProperties(com.hedera.mirror.importer.downloader.DownloaderProperties) Instant(java.time.Instant) StreamFile(com.hedera.mirror.common.domain.StreamFile) InvalidConfigurationException(com.hedera.mirror.importer.exception.InvalidConfigurationException)

Aggregations

StreamFile (com.hedera.mirror.common.domain.StreamFile)1 StreamType (com.hedera.mirror.common.domain.StreamType)1 DomainUtils (com.hedera.mirror.common.util.DomainUtils)1 MirrorProperties (com.hedera.mirror.importer.MirrorProperties)1 StreamFilename (com.hedera.mirror.importer.domain.StreamFilename)1 DATA (com.hedera.mirror.importer.domain.StreamFilename.FileType.DATA)1 DownloaderProperties (com.hedera.mirror.importer.downloader.DownloaderProperties)1 InvalidConfigurationException (com.hedera.mirror.importer.exception.InvalidConfigurationException)1 AccountBalanceFileRepository (com.hedera.mirror.importer.repository.AccountBalanceFileRepository)1 EventFileRepository (com.hedera.mirror.importer.repository.EventFileRepository)1 RecordFileRepository (com.hedera.mirror.importer.repository.RecordFileRepository)1 StreamFileRepository (com.hedera.mirror.importer.repository.StreamFileRepository)1 Utility (com.hedera.mirror.importer.util.Utility)1 Duration (java.time.Duration)1 Instant (java.time.Instant)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Named (javax.inject.Named)1