-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
3,520 additions
and
3,522 deletions.
There are no files selected for viewing
136 changes: 68 additions & 68 deletions
136
src/main/java/org/cardanofoundation/job/listener/ReportsListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,68 @@ | ||
//package org.cardanofoundation.job.listener; | ||
// | ||
//import lombok.RequiredArgsConstructor; | ||
//import lombok.extern.slf4j.Slf4j; | ||
// | ||
//import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
//import org.springframework.kafka.annotation.KafkaListener; | ||
//import org.springframework.kafka.support.Acknowledgment; | ||
//import org.springframework.stereotype.Component; | ||
// | ||
//import org.apache.kafka.clients.consumer.ConsumerRecord; | ||
// | ||
//import org.cardanofoundation.explorer.common.entity.explorer.PoolReportHistory; | ||
//import org.cardanofoundation.explorer.common.entity.explorer.ReportHistory; | ||
//import org.cardanofoundation.explorer.common.entity.explorer.StakeKeyReportHistory; | ||
//import org.cardanofoundation.explorer.common.model.ReportMessage; | ||
//import org.cardanofoundation.job.repository.explorer.PoolReportHistoryRepository; | ||
//import org.cardanofoundation.job.repository.explorer.StakeKeyReportHistoryRepository; | ||
//import org.cardanofoundation.job.service.PoolReportService; | ||
//import org.cardanofoundation.job.service.StakeKeyReportService; | ||
// | ||
//@Component | ||
//@Slf4j | ||
//@RequiredArgsConstructor | ||
//@ConditionalOnProperty( | ||
// value = "kafka.configuration-enabled", | ||
// matchIfMissing = true, | ||
// havingValue = "true") | ||
//public class ReportsListener { | ||
// | ||
// private final StakeKeyReportHistoryRepository stakeKeyReportHistoryRepository; | ||
// private final PoolReportHistoryRepository poolReportHistoryRepository; | ||
// private final StakeKeyReportService stakeKeyReportService; | ||
// private final PoolReportService poolReportService; | ||
// | ||
// @KafkaListener(topics = "${kafka.listeners.topics.reports}") | ||
// public void consume( | ||
// ConsumerRecord<String, ReportMessage> consumerRecord, Acknowledgment acknowledgment) { | ||
// try { | ||
// ReportMessage reportMessage = consumerRecord.value(); | ||
// ReportHistory reportHistory = reportMessage.getReportHistory(); | ||
// log.info( | ||
// "Receive report history {} with type {}", reportHistory.getId(), reportHistory.getType()); | ||
// | ||
// switch (reportHistory.getType()) { | ||
// case STAKE_KEY: | ||
// StakeKeyReportHistory stakeKeyReportHistory = | ||
// stakeKeyReportHistoryRepository.findByReportHistoryId(reportHistory.getId()); | ||
// stakeKeyReportService.exportStakeKeyReport( | ||
// stakeKeyReportHistory, reportMessage.getZoneOffset(), reportMessage.getTimePattern()); | ||
// break; | ||
// case POOL_ID: | ||
// PoolReportHistory poolReportHistory = | ||
// poolReportHistoryRepository.findByReportHistoryId(reportHistory.getId()); | ||
// poolReportService.exportPoolReport( | ||
// poolReportHistory, reportMessage.getZoneOffset(), reportMessage.getTimePattern()); | ||
// break; | ||
// default: | ||
// break; | ||
// } | ||
// | ||
// acknowledgment.acknowledge(); | ||
// log.info("Acknowledge report history {}", reportHistory.getId()); | ||
// } catch (Exception e) { | ||
// log.error("Consume report history failure: {}", e.getMessage()); | ||
// } | ||
// } | ||
//} | ||
package org.cardanofoundation.job.listener; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.kafka.annotation.KafkaListener; | ||
import org.springframework.kafka.support.Acknowledgment; | ||
import org.springframework.stereotype.Component; | ||
|
||
import org.apache.kafka.clients.consumer.ConsumerRecord; | ||
|
||
import org.cardanofoundation.explorer.common.entity.explorer.PoolReportHistory; | ||
import org.cardanofoundation.explorer.common.entity.explorer.ReportHistory; | ||
import org.cardanofoundation.explorer.common.entity.explorer.StakeKeyReportHistory; | ||
import org.cardanofoundation.explorer.common.model.ReportMessage; | ||
import org.cardanofoundation.job.repository.explorer.PoolReportHistoryRepository; | ||
import org.cardanofoundation.job.repository.explorer.StakeKeyReportHistoryRepository; | ||
import org.cardanofoundation.job.service.PoolReportService; | ||
import org.cardanofoundation.job.service.StakeKeyReportService; | ||
|
||
@Component | ||
@Slf4j | ||
@RequiredArgsConstructor | ||
@ConditionalOnProperty( | ||
value = "kafka.configuration-enabled", | ||
matchIfMissing = true, | ||
havingValue = "true") | ||
public class ReportsListener { | ||
|
||
private final StakeKeyReportHistoryRepository stakeKeyReportHistoryRepository; | ||
private final PoolReportHistoryRepository poolReportHistoryRepository; | ||
private final StakeKeyReportService stakeKeyReportService; | ||
private final PoolReportService poolReportService; | ||
|
||
@KafkaListener(topics = "${kafka.listeners.topics.reports}") | ||
public void consume( | ||
ConsumerRecord<String, ReportMessage> consumerRecord, Acknowledgment acknowledgment) { | ||
try { | ||
ReportMessage reportMessage = consumerRecord.value(); | ||
ReportHistory reportHistory = reportMessage.getReportHistory(); | ||
log.info( | ||
"Receive report history {} with type {}", reportHistory.getId(), reportHistory.getType()); | ||
|
||
switch (reportHistory.getType()) { | ||
case STAKE_KEY: | ||
StakeKeyReportHistory stakeKeyReportHistory = | ||
stakeKeyReportHistoryRepository.findByReportHistoryId(reportHistory.getId()); | ||
stakeKeyReportService.exportStakeKeyReport( | ||
stakeKeyReportHistory, reportMessage.getZoneOffset(), reportMessage.getTimePattern()); | ||
break; | ||
case POOL_ID: | ||
PoolReportHistory poolReportHistory = | ||
poolReportHistoryRepository.findByReportHistoryId(reportHistory.getId()); | ||
poolReportService.exportPoolReport( | ||
poolReportHistory, reportMessage.getZoneOffset(), reportMessage.getTimePattern()); | ||
break; | ||
default: | ||
break; | ||
} | ||
|
||
acknowledgment.acknowledge(); | ||
log.info("Acknowledge report history {}", reportHistory.getId()); | ||
} catch (Exception e) { | ||
log.error("Consume report history failure: {}", e.getMessage()); | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/org/cardanofoundation/job/model/TokenTxCount.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.cardanofoundation.job.model; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class TokenTxCount { | ||
Long ident; | ||
Long txCount; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 0 additions & 23 deletions
23
...n/java/org/cardanofoundation/job/repository/ledgersync/AddressTokenBalanceRepository.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 0 additions & 45 deletions
45
...main/java/org/cardanofoundation/job/repository/ledgersync/AddressTxBalanceRepository.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.