Skip to content

Commit

Permalink
replaced apache commons logging with solace logging
Browse files Browse the repository at this point in the history
  • Loading branch information
SravanThotakura05 committed Jan 1, 2024
1 parent fabf948 commit 02f0bac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
package io.quarkiverse.solace.incoming;

import io.quarkiverse.solace.i18n.SolaceLogging;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

class IncomingMessagesUnsignedCounterBarrier {
private final AtomicLong counter; // Treated as an unsigned long (i.e. range from 0 -> -1)
private final Lock awaitLock = new ReentrantLock();
private final Condition isZero = awaitLock.newCondition();

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

public IncomingMessagesUnsignedCounterBarrier(long initialValue) {
counter = new AtomicLong(initialValue);
}
Expand Down Expand Up @@ -64,7 +61,7 @@ public boolean awaitEmpty(long timeout, TimeUnit unit) throws InterruptedExcepti
awaitLock.lock();
try {
if (timeout > 0) {
logger.info(String.format("Waiting for %s items, time remaining: %s %s", counter.get(), timeout, unit));
SolaceLogging.log.info(String.format("Waiting for %s items, time remaining: %s %s", counter.get(), timeout, unit));
final long expiry = unit.toMillis(timeout) + System.currentTimeMillis();
while (isGreaterThanZero()) {
long realTimeout = expiry - System.currentTimeMillis();
Expand All @@ -76,7 +73,7 @@ public boolean awaitEmpty(long timeout, TimeUnit unit) throws InterruptedExcepti
return true;
} else if (timeout < 0) {
while (isGreaterThanZero()) {
logger.info(String.format("Waiting for %s items", counter.get()));
SolaceLogging.log.info(String.format("Waiting for %s items", counter.get()));
isZero.await(5, TimeUnit.SECONDS);
}
return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
package io.quarkiverse.solace.outgoing;

import io.quarkiverse.solace.i18n.SolaceLogging;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

class OutgoingMessagesUnsignedCounterBarrier {
private final AtomicLong counter; // Treated as an unsigned long (i.e. range from 0 -> -1)
private final Lock awaitLock = new ReentrantLock();
private final Condition isZero = awaitLock.newCondition();

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

public OutgoingMessagesUnsignedCounterBarrier(long initialValue) {
counter = new AtomicLong(initialValue);
}
Expand Down Expand Up @@ -64,7 +61,7 @@ public boolean awaitEmpty(long timeout, TimeUnit unit) throws InterruptedExcepti
awaitLock.lock();
try {
if (timeout > 0) {
logger.info(String.format("Waiting for %s items, time remaining: %s %s", counter.get(), timeout, unit));
SolaceLogging.log.info(String.format("Waiting for %s items, time remaining: %s %s", counter.get(), timeout, unit));
final long expiry = unit.toMillis(timeout) + System.currentTimeMillis();
while (isGreaterThanZero()) {
long realTimeout = expiry - System.currentTimeMillis();
Expand All @@ -76,7 +73,7 @@ public boolean awaitEmpty(long timeout, TimeUnit unit) throws InterruptedExcepti
return true;
} else if (timeout < 0) {
while (isGreaterThanZero()) {
logger.info(String.format("Waiting for %s items", counter.get()));
SolaceLogging.log.info(String.format("Waiting for %s items", counter.get()));
isZero.await(5, TimeUnit.SECONDS);
}
return true;
Expand Down

0 comments on commit 02f0bac

Please sign in to comment.