Skip to content

Commit

Permalink
add missing debug enable checks
Browse files Browse the repository at this point in the history
  • Loading branch information
RusJaI committed Jul 26, 2023
1 parent dc712ef commit 4b4e892
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

public class CDCInjectHandler {

private static final Log log = LogFactory.getLog(CDCInjectHandler.class);
private static final Log logger = LogFactory.getLog(CDCInjectHandler.class);

private String injectingSeq;
private String onErrorSeq;
Expand All @@ -76,7 +76,9 @@ public boolean invoke(Object object, String inboundEndpointName) throws SynapseE

ChangeEvent<String, String> eventRecord = (ChangeEvent<String, String>) object;
if (eventRecord == null || eventRecord.value() == null) {
log.debug("CDC Source Handler received empty event record");
if (logger.isDebugEnabled()) {
logger.debug("CDC Source Handler received empty event record");
}
} else {
InputStream in = null;
try {
Expand All @@ -93,8 +95,8 @@ public boolean invoke(Object object, String inboundEndpointName) throws SynapseE
msgCtx.setProperty(OPERATIONS, cdcEventOutput.getOp());
msgCtx.setProperty(TS_MS, cdcEventOutput.getTs_ms().toString());

if (log.isDebugEnabled()) {
log.debug("Processed event : " + eventRecord);
if (logger.isDebugEnabled()) {
logger.debug("Processed event : " + eventRecord);
}
MessageContext axis2MsgCtx = ((org.apache.synapse.core.axis2.Axis2MessageContext) msgCtx)
.getAxis2MessageContext();
Expand All @@ -111,7 +113,7 @@ public boolean invoke(Object object, String inboundEndpointName) throws SynapseE
documentElement = builder.processDocument(in, contentType, axis2MsgCtx);

} catch (Exception ex) {
log.error("Error while building the message", ex);
logger.error("Error while building the message", ex);
msgCtx.setProperty(SynapseConstants.ERROR_CODE, GenericConstants.INBOUND_BUILD_ERROR);
msgCtx.setProperty(SynapseConstants.ERROR_MESSAGE, ex.getMessage());
SequenceMediator faultSequence = getFaultSequence(msgCtx);
Expand All @@ -122,14 +124,14 @@ public boolean invoke(Object object, String inboundEndpointName) throws SynapseE
// Inject the message to the sequence.
msgCtx.setEnvelope(TransportUtils.createSOAPEnvelope(documentElement));
if (injectingSeq == null || injectingSeq.equals("")) {
log.error("Sequence name not specified. Sequence : " + injectingSeq);
logger.error("Sequence name not specified. Sequence : " + injectingSeq);
return false;
}
SequenceMediator seq = (SequenceMediator) synapseEnvironment.getSynapseConfiguration()
.getSequence(injectingSeq);
if (seq != null) {
if (log.isDebugEnabled()) {
log.debug("injecting message to sequence : " + injectingSeq);
if (logger.isDebugEnabled()) {
logger.debug("injecting message to sequence : " + injectingSeq);
}
if (!seq.isInitialized()) {
seq.init(synapseEnvironment);
Expand All @@ -142,7 +144,7 @@ public boolean invoke(Object object, String inboundEndpointName) throws SynapseE
return false;
}
} else {
log.error("Sequence: " + injectingSeq + " not found");
logger.error("Sequence: " + injectingSeq + " not found");
}

} catch (AxisFault e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
*/
public class CDCPollingConsumer {

private static final Log log = LogFactory.getLog(CDCPollingConsumer.class);
private static final Log logger = LogFactory.getLog(CDCPollingConsumer.class);
private Properties cdcProperties;
private ExecutorService executorService = null;
private String inboundEndpointName;
Expand Down Expand Up @@ -71,24 +71,24 @@ public void registerHandler(CDCInjectHandler injectHandler) {
*/
public void execute() {
try {
if (log.isDebugEnabled()) {
log.debug("Start : CDC Inbound EP : " + inboundEndpointName);
if (logger.isDebugEnabled()) {
logger.debug("Start : CDC Inbound EP : " + inboundEndpointName);
}
// Check if the cycles are running in correct interval and start
// scan
long currentTime = (new Date()).getTime();
if (lastRanTime == null || ((lastRanTime + (scanInterval)) <= currentTime)) {
lastRanTime = currentTime;
poll();
} else if (log.isDebugEnabled()) {
log.debug(
} else if (logger.isDebugEnabled()) {
logger.debug(
"Skip cycle since cuncurrent rate is higher than the scan interval : CDC Inbound EP : " + inboundEndpointName);
}
if (log.isDebugEnabled()) {
log.debug("End : CDC Inbound EP : " + inboundEndpointName);
if (logger.isDebugEnabled()) {
logger.debug("End : CDC Inbound EP : " + inboundEndpointName);
}
} catch (Exception e) {
log.error("Error while getting events. " + e.getMessage(), e);
logger.error("Error while getting events. " + e.getMessage(), e);
}
}

Expand All @@ -98,8 +98,8 @@ public void execute() {
*/
public ChangeEvent<String, String> poll() {

if (log.isDebugEnabled()) {
log.debug("Start : listening to DB events : ");
if (logger.isDebugEnabled()) {
logger.debug("Start : listening to DB events : ");
}

ConcurrentLinkedQueue<ChangeEvent<String, String>> eventQueue = inboundEpEventQueueMap.get(inboundEndpointName);
Expand All @@ -108,8 +108,8 @@ public ChangeEvent<String, String> poll() {
eventQueue.remove(eventQueue.peek());
}

if (log.isDebugEnabled()) {
log.debug("End : Listening to DB events : ");
if (logger.isDebugEnabled()) {
logger.debug("End : Listening to DB events : ");
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
import static org.wso2.carbon.inbound.endpoint.protocol.cdc.InboundCDCConstants.DEBEZIUM_VALUE_CONVERTER_SCHEMAS_ENABLE;
import static org.wso2.carbon.inbound.endpoint.protocol.cdc.InboundCDCConstants.TRUE;


public class CDCProcessor extends InboundRequestProcessorImpl implements TaskStartupObserver, InboundTaskProcessor {

private CDCPollingConsumer pollingConsumer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ public CDCTask(CDCPollingConsumer pollingConsumer, long interval) {
}

protected void taskExecute() {
logger.debug("CDC Task executing.");
if (logger.isDebugEnabled()) {
logger.debug("CDC Task executing.");
}
pollingConsumer.execute();
}

Expand All @@ -52,10 +54,14 @@ public Properties getInboundProperties() {
}

public void init(SynapseEnvironment synapseEnvironment) {
logger.debug("Initializing Task.");
if (logger.isDebugEnabled()) {
logger.debug("Initializing Task.");
}
}

public void destroy() {
logger.debug("Destroying Task. ");
if (logger.isDebugEnabled()) {
logger.debug("Destroying Task. ");
}
}
}

0 comments on commit 4b4e892

Please sign in to comment.