Modify config Args setting to support kafka params.
@Getter
@Setter
private String kafkaEndpoint;
INSTANCE.kafkaEndpoint =
config.hasPath("kafka.endpoint.url") ? config.getString("kafka.endpoint.url") : "";
Add sendblock and sendbatchblock methods
//send block by num
@Autowired
private SendBlockByNumServlet sendBlockByNumServlet;
//send batchblock by num
@Autowired
private SendBatchBlockByNumServlet sendBatchBlockByNumServlet;
//send batchblock by id
@Autowired
private SendBlockByIdServlet sendBlockByIdServlet;
the new file to implement sending data to kafka through http.
the new file to implement sending batch block.
the new file to implement sending block by id.
the new file to implement sending block by num.
Add new methods:
public static String printBlockKafka(Block block)
public static JSONArray printTransactionListToKafkaJSON(List<TransactionCapsule> list)
public static JSONObject printTransactionToKafkaJSON(Transaction transaction)
the main call to send data to kafka:
if (!Args.getInstance().getKafkaEndpoint().equals("")) {
try {
logger.info("send switch fork block {} to kafka.", newBlock.getNum());
HttpUtil.postJsonContent(Args.getInstance().getKafkaEndpoint(), Util.printBlockKafka(newBlock.getInstance()));
} catch (Exception e) {
logger.error(e.getMessage());
}
}
if (!Args.getInstance().getKafkaEndpoint().equals("")) {
try {
logger.info("send block {} to kafka.", newBlock.getNum());
HttpUtil.postJsonContent(Args.getInstance().getKafkaEndpoint(), Util.printBlockKafka(newBlock.getInstance()));
} catch (Exception e) {
logger.error(e.getMessage());
}
}