use of com.hazelcast.logging.ILogger in project hazelcast by hazelcast.
the class SemaphoreDetachMemberOperation method run.
@Override
public void run() throws Exception {
SemaphoreService service = getService();
if (service.containsSemaphore(name)) {
SemaphoreContainer semaphoreContainer = service.getSemaphoreContainer(name);
response = semaphoreContainer.detachAll(detachedMemberUuid);
}
ILogger logger = getLogger();
if (logger.isFineEnabled()) {
logger.fine("Removing permits attached to " + detachedMemberUuid + ". Result: " + response);
}
}
use of com.hazelcast.logging.ILogger in project hazelcast by hazelcast.
the class ClientReplicatedMapProxy method addNearCacheInvalidateListener.
private void addNearCacheInvalidateListener() {
try {
EventHandler handler = new ReplicatedMapAddNearCacheEventHandler();
invalidationListenerId = registerListener(createNearCacheInvalidationListenerCodec(), handler);
} catch (Exception e) {
ILogger logger = getContext().getLoggingService().getLogger(ClientReplicatedMapProxy.class);
logger.severe("-----------------\nNear Cache is not initialized!\n-----------------", e);
}
}
use of com.hazelcast.logging.ILogger in project hazelcast by hazelcast.
the class XAResourceProxy method end.
@Override
public void end(Xid xid, int flags) throws XAException {
long threadId = currentThreadId();
TransactionContext threadContext = threadContextMap.remove(threadId);
ILogger logger = getContext().getLoggingService().getLogger(this.getClass());
if (threadContext == null && logger.isFinestEnabled()) {
logger.finest("There is no TransactionContext for the current thread: " + threadId);
}
List<TransactionContext> contexts = xidContextMap.get(xid);
if (contexts == null && logger.isFinestEnabled()) {
logger.finest("There is no TransactionContexts for the given xid: " + xid);
}
}
use of com.hazelcast.logging.ILogger in project hazelcast by hazelcast.
the class ClientClusterStateTest method testClusterShutdownDuringMapPutAll.
@Test
public void testClusterShutdownDuringMapPutAll() {
warmUpPartitions(instances);
waitAllForSafeState(instances);
HazelcastInstance client = factory.newHazelcastClient();
final IMap<Object, Object> map = client.getMap(randomMapName());
final HashMap values = new HashMap<Double, Double>();
for (int i = 0; i < 1000; i++) {
double value = Math.random();
values.put(value, value);
}
final int numThreads = 10;
final CountDownLatch threadsFinished = new CountDownLatch(numThreads);
final CountDownLatch threadsStarted = new CountDownLatch(numThreads);
ExecutorService executor = Executors.newCachedThreadPool();
for (int i = 0; i < numThreads; i++) {
executor.execute(new Runnable() {
@Override
public void run() {
ILogger logger = Logger.getLogger(getClass());
threadsStarted.countDown();
logger.info("putAll thread started");
while (true) {
try {
map.putAll(values);
Thread.sleep(100);
} catch (IllegalStateException e) {
logger.warning("Expected exception for Map putAll during cluster shutdown:", e);
break;
} catch (TargetDisconnectedException e) {
logger.warning("Expected exception for Map putAll during cluster shutdown:", e);
break;
} catch (InterruptedException e) {
// do nothing
}
}
threadsFinished.countDown();
logger.info("putAll thread finishing. Current finished thread count is:" + (numThreads - threadsFinished.getCount()));
}
});
}
try {
assertTrue("All threads could not be started", threadsStarted.await(1, TimeUnit.MINUTES));
} catch (InterruptedException e) {
fail("All threads could not be started due to InterruptedException. Could not start " + threadsStarted.getCount() + " threads out of " + numThreads);
}
instance.getCluster().shutdown();
executor.shutdown();
try {
assertTrue("All threads could not be finished", threadsFinished.await(2, TimeUnit.MINUTES));
} catch (InterruptedException e) {
fail("All threads could not be finished due to InterruptedException. Could not finish " + threadsFinished.getCount() + " threads out of " + numThreads);
} finally {
executor.shutdownNow();
}
}
use of com.hazelcast.logging.ILogger in project hazelcast by hazelcast.
the class ClientLoggerConfigurationTest method testLoggingWithConfiguration.
// Test with programmatic or system property configuration according to boolean parameter.
// the idea of the test is to configure a specific logging type for a client and then
// test its LoggingService produce instances of the expected Logger impl
protected void testLoggingWithConfiguration(boolean programmaticConfiguration) throws IOException {
hazelcastFactory = new TestHazelcastFactory();
Config cg = new Config();
cg.setProperty("hazelcast.logging.type", "jdk");
hazelcastFactory.newHazelcastInstance(cg);
ClientConfig config = new ClientConfig();
if (programmaticConfiguration) {
config.setProperty("hazelcast.logging.type", "log4j2");
} else {
System.setProperty("hazelcast.logging.type", "log4j2");
}
client = hazelcastFactory.newHazelcastClient(config);
ILogger clientLogger = client.getLoggingService().getLogger("loggerName");
// this part is fragile.
// client wraps the actual logger in its own class
ILogger actualLogger = (ILogger) getFromField(clientLogger, "logger");
Class<?> clientLoggerClass = actualLogger.getClass();
ILogger expectedLogger = new Log4j2Factory().getLogger("expectedLogger");
Class<?> expectedLoggerClass = expectedLogger.getClass();
assertSame(expectedLoggerClass, clientLoggerClass);
}
Aggregations