Skip to content

Commit

Permalink
update logger class
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaede10 committed Jul 16, 2024
1 parent 18be91f commit f8a531e
Show file tree
Hide file tree
Showing 18 changed files with 55 additions and 138 deletions.
6 changes: 3 additions & 3 deletions src/main/java/CommonClass/OpenMindParent.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
import org.apache.kafka.common.KafkaFuture;
import org.apache.kafka.common.TopicPartition;
import org.apache.kafka.common.TopicPartitionInfo;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.TermQueryBuilder;
import org.elasticsearch.script.Script;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fasterxml.jackson.databind.ObjectMapper;

Expand All @@ -36,7 +36,7 @@


public class OpenMindParent extends Thread {
private static Logger logger = LogManager.getLogger(OpenMindParent.class);
private static Logger logger = LoggerFactory.getLogger(OpenMindParent.class);
protected Properties properties = PropertiesUtils.readProperties();
protected ArrayList<KafkaConsumer<String, String>> KafkaConsumerList = new ArrayList<>();
protected String esIndex = properties.getProperty("es.index");
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/Utils/EsClientUtils.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package Utils;

import om.QualityObs;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import org.elasticsearch.action.bulk.BackoffPolicy;
import org.elasticsearch.action.bulk.BulkProcessor;
import org.elasticsearch.action.bulk.BulkRequest;
Expand All @@ -12,6 +11,8 @@
import org.elasticsearch.common.unit.ByteSizeUnit;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.unit.TimeValue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
Expand All @@ -26,7 +27,7 @@
* @description:
*/
public class EsClientUtils {
private static Logger logger= LogManager.getLogger(QualityObs.class);
private static Logger logger= LoggerFactory.getLogger(EsClientUtils.class);
public static BulkProcessor.Listener getBulkListener(){

BulkProcessor.Listener listener = new BulkProcessor.Listener() {
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/Utils/EsClientUtils2.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.action.bulk.BackoffPolicy;
import org.elasticsearch.action.bulk.BulkProcessor;
import org.elasticsearch.action.bulk.BulkRequest;
Expand All @@ -23,6 +22,8 @@
import org.elasticsearch.index.reindex.BulkByScrollResponse;
import org.elasticsearch.index.reindex.UpdateByQueryRequest;
import org.elasticsearch.script.Script;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.net.ssl.*;
import java.io.IOException;
Expand All @@ -36,7 +37,7 @@
* @description:
*/
public class EsClientUtils2 {
private static Logger logger = LogManager.getLogger(EsClientUtils2.class);
private static Logger logger = LoggerFactory.getLogger(EsClientUtils2.class);
private static BulkProcessor build = null;
private static RestHighLevelClient client = null;
private static CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
Expand Down Expand Up @@ -121,7 +122,7 @@ public static void insertOrUpdate(String index, String id, Map data) throws IOEx
UpdateRequest updateRequest = new UpdateRequest(index, id);
Object offset = data.remove("offset");
Object partition = data.remove("partition");
Logger logger = LogManager.getLogger("offset" + partition);
Logger logger = LoggerFactory.getLogger("offset" + partition);
logger.info("partation:"+partition+":offset:"+offset);
updateRequest.doc(data);
updateRequest.upsert(data);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/om/Customer.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.kafka.common.TopicPartition;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.action.bulk.BulkProcessor;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.client.RequestOptions;
Expand All @@ -25,6 +23,8 @@
import org.elasticsearch.index.reindex.BulkByScrollResponse;
import org.elasticsearch.index.reindex.UpdateByQueryRequest;
import org.elasticsearch.script.Script;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.net.ssl.SSLContext;
import java.io.IOException;
Expand All @@ -47,7 +47,7 @@ public class Customer extends Thread {
private Properties conf;
private KafkaConsumer kafkaConsumer;
private CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
private Logger logger = LogManager.getLogger(QualityObs.class);
private Logger logger = LoggerFactory.getLogger(Customer.class);
private Logger loggeroffset;
private RestHighLevelClient client;
private String esindex;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/om/Module/CiResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.time.*;
Expand All @@ -21,7 +21,7 @@
import java.util.Map;

public class CiResult extends Parent implements CommonInterface {
private static Logger logger = LogManager.getLogger(QualitySoftWare.class);
private static Logger logger = LoggerFactory.getLogger(CiResult.class);
public static Map<String, LocalDateTime> dateMap = new HashMap<>();
public static final String accessKey = "access_key";
public static final String commentKey = "comment_key";
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/om/Module/OneIdUserLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.ByteArrayInputStream;
import java.io.IOException;
Expand All @@ -31,7 +31,7 @@
import java.util.Map;

public class OneIdUserLog extends Parent implements CommonInterface {
private static final Logger logger = LogManager.getLogger(QualitySoftWare.class);
private static final Logger logger = LoggerFactory.getLogger(OneIdUserLog.class);
private static ObsClient obsClient = null;

public OneIdUserLog() throws IOException {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/om/Module/Openeuler_statewall_dbt.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.TermQueryBuilder;
import org.elasticsearch.script.Script;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.time.Duration;
Expand All @@ -37,7 +37,7 @@
*/
public class Openeuler_statewall_dbt extends Parent implements CommonInterface {

private static Logger logger = LogManager.getLogger(QualitySoftWare.class);
private static Logger logger = LoggerFactory.getLogger(Openeuler_statewall_dbt.class);
public static Map<String, LocalDateTime> dateMap = new HashMap<>();
public static final String accessKey = "access_key";
public static final String commentKey = "comment_key";
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/om/Module/PackageStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.time.Duration;
Expand All @@ -29,7 +29,7 @@
*/
public class PackageStatus extends Parent implements CommonInterface {

private static Logger logger = LogManager.getLogger(QualitySoftWare.class);
private static Logger logger = LoggerFactory.getLogger(PackageStatus.class);
public static Map<String, LocalDateTime> dateMap = new HashMap<>();
public static final String accessKey = "access_key";
public static final String commentKey = "comment_key";
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/om/Module/QualitySoftWare.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.TermQueryBuilder;
import org.elasticsearch.script.Script;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.time.Duration;
Expand All @@ -28,7 +28,7 @@
* @description:
*/
public class QualitySoftWare extends Parent implements CommonInterface {
private static Logger logger = LogManager.getLogger(QualitySoftWare.class);
private static Logger logger = LoggerFactory.getLogger(QualitySoftWare.class);
public static Map<String, LocalDateTime> dateMap = new HashMap<>();
public static final String accessKey = "access_key";
public static final String commentKey = "comment_key";
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/om/Module/Tracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.time.Duration;
Expand All @@ -18,7 +18,7 @@
import java.util.Map;

public class Tracker extends Parent implements CommonInterface {
private static Logger logger = LogManager.getLogger(Tracker.class);
private static Logger logger = LoggerFactory.getLogger(Tracker.class);

public Tracker() throws IOException {
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/om/Module/UserPermissionApply.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.time.Duration;
Expand All @@ -18,7 +18,7 @@
import java.util.Map;

public class UserPermissionApply extends Parent implements CommonInterface {
private static Logger logger = LogManager.getLogger(UserPermissionApply.class);
private static Logger logger = LoggerFactory.getLogger(UserPermissionApply.class);

public UserPermissionApply() throws IOException {
}
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/om/Module/openMind/DatasetEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
import Utils.EsClientUtils2;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.time.Duration;
import java.util.List;
Expand All @@ -16,7 +17,7 @@
import java.util.concurrent.TimeUnit;

public class DatasetEvent extends OpenMindParent implements CommonInterface {
private static Logger logger = LogManager.getLogger(ModelEvent.class);
private static Logger logger = LoggerFactory.getLogger(DatasetEvent.class);
private ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();

public DatasetEvent() throws IOException {
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/om/Module/openMind/ModelEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
import Utils.EsClientUtils2;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.time.Duration;
import java.util.List;
Expand All @@ -16,7 +17,7 @@
import java.util.concurrent.TimeUnit;

public class ModelEvent extends OpenMindParent implements CommonInterface {
private static Logger logger = LogManager.getLogger(ModelEvent.class);
private static Logger logger = LoggerFactory.getLogger(ModelEvent.class);
private ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();

public ModelEvent() throws IOException {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/om/Module/openMind/ModelFoundryDownload.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.text.SimpleDateFormat;
Expand All @@ -21,7 +21,7 @@
import java.util.Map;

public class ModelFoundryDownload extends OpenMindParent implements CommonInterface {
private static Logger logger = LogManager.getLogger(ModelFoundryDownload.class);
private static Logger logger = LoggerFactory.getLogger(ModelFoundryDownload.class);

public ModelFoundryDownload() throws IOException {
}
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/om/Module/openMind/SpaceEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
import Utils.EsClientUtils2;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.time.Duration;
import java.util.List;
Expand All @@ -16,7 +17,7 @@
import java.util.concurrent.TimeUnit;

public class SpaceEvent extends OpenMindParent implements CommonInterface {
private static Logger logger = LogManager.getLogger(SpaceEvent.class);
private static Logger logger = LoggerFactory.getLogger(SpaceEvent.class);
private ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();

public SpaceEvent() throws IOException {
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/om/QualityObs.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.kafka.common.TopicPartition;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.client.RestHighLevelClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.InputStream;
Expand All @@ -19,7 +19,7 @@
* @description:
*/
public class QualityObs extends Thread {
private static Logger logger = LogManager.getLogger(QualityObs.class);
private static Logger logger = LoggerFactory.getLogger(QualityObs.class);
static Properties conf;
static KafkaConsumer<String, String> kafkacustomer;
public static RestHighLevelClient client;
Expand Down Expand Up @@ -56,7 +56,7 @@ public void run() {
String partitionnum = stringStringEntry.getKey();
String offset = stringStringEntry.getValue();
TopicPartition topicPartition = new TopicPartition(conf.getProperty("kafka.topic.name").toString(), Integer.parseInt(partitionnum));
Customer customer = new Customer(topicPartition, conf, topicPartition.toString(), Integer.parseInt(offset),LogManager.getLogger("offset"+partitionnum), conf.getProperty("kafka.topic.name"));
Customer customer = new Customer(topicPartition, conf, topicPartition.toString(), Integer.parseInt(offset),LoggerFactory.getLogger("offset"+partitionnum), conf.getProperty("kafka.topic.name"));
customer.start();
customerThreads.add(customer);

Expand Down
4 changes: 0 additions & 4 deletions src/main/java/test/testkafka.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package test;

import om.Customer;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.kafka.common.TopicPartition;
import org.apache.logging.log4j.LogManager;

import java.util.Properties;

/**
Expand Down
Loading

0 comments on commit f8a531e

Please sign in to comment.