use of org.apache.ignite.IgniteLogger in project ignite by apache.
the class TcpCommunicationSpi method dumpStats.
/**
* Dumps SPI per-connection stats to logs.
*/
public void dumpStats() {
IgniteLogger log = this.log;
if (log != null) {
StringBuilder sb = new StringBuilder("Communication SPI recovery descriptors: ").append(U.nl());
for (Map.Entry<ConnectionKey, GridNioRecoveryDescriptor> entry : recoveryDescs.entrySet()) {
GridNioRecoveryDescriptor desc = entry.getValue();
sb.append(" [key=").append(entry.getKey()).append(", msgsSent=").append(desc.sent()).append(", msgsAckedByRmt=").append(desc.acked()).append(", msgsRcvd=").append(desc.received()).append(", lastAcked=").append(desc.lastAcknowledged()).append(", reserveCnt=").append(desc.reserveCount()).append(", descIdHash=").append(System.identityHashCode(desc)).append(']').append(U.nl());
}
for (Map.Entry<ConnectionKey, GridNioRecoveryDescriptor> entry : outRecDescs.entrySet()) {
GridNioRecoveryDescriptor desc = entry.getValue();
sb.append(" [key=").append(entry.getKey()).append(", msgsSent=").append(desc.sent()).append(", msgsAckedByRmt=").append(desc.acked()).append(", reserveCnt=").append(desc.reserveCount()).append(", connected=").append(desc.connected()).append(", reserved=").append(desc.reserved()).append(", descIdHash=").append(System.identityHashCode(desc)).append(']').append(U.nl());
}
for (Map.Entry<ConnectionKey, GridNioRecoveryDescriptor> entry : inRecDescs.entrySet()) {
GridNioRecoveryDescriptor desc = entry.getValue();
sb.append(" [key=").append(entry.getKey()).append(", msgsRcvd=").append(desc.received()).append(", lastAcked=").append(desc.lastAcknowledged()).append(", reserveCnt=").append(desc.reserveCount()).append(", connected=").append(desc.connected()).append(", reserved=").append(desc.reserved()).append(", handshakeIdx=").append(desc.handshakeIndex()).append(", descIdHash=").append(System.identityHashCode(desc)).append(']').append(U.nl());
}
sb.append("Communication SPI clients: ").append(U.nl());
for (Map.Entry<UUID, GridCommunicationClient[]> entry : clients.entrySet()) {
UUID nodeId = entry.getKey();
GridCommunicationClient[] clients0 = entry.getValue();
for (GridCommunicationClient client : clients0) {
if (client != null) {
sb.append(" [node=").append(nodeId).append(", client=").append(client).append(']').append(U.nl());
}
}
}
U.warn(log, sb.toString());
}
GridNioServer<Message> nioSrvr = this.nioSrvr;
if (nioSrvr != null)
nioSrvr.dumpStats();
}
use of org.apache.ignite.IgniteLogger in project ignite by apache.
the class GridManagerMxBeanIllegalArgumentHandleTest method testIllegalStateIsCatch.
/** Creates minimal disco manager mock, checks illegal state is not propagated */
public void testIllegalStateIsCatch() {
final IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setDiscoverySpi(new TcpDiscoverySpi());
final IgniteLogger log = Mockito.mock(IgniteLogger.class);
final GridKernalContext ctx = Mockito.mock(GridKernalContext.class);
when(ctx.config()).thenReturn(cfg);
when(ctx.log(Mockito.anyString())).thenReturn(log);
when(ctx.log(Mockito.any(Class.class))).thenReturn(log);
final GridDiscoveryManager mgr = new GridDiscoveryManager(ctx);
final long nHeapMax = mgr.metrics().getNonHeapMemoryMaximum();
if (correctSetupOfTestPerformed)
assertEquals(0, nHeapMax);
final long heapMax = mgr.metrics().getHeapMemoryMaximum();
if (correctSetupOfTestPerformed)
assertEquals(0, heapMax);
}
use of org.apache.ignite.IgniteLogger in project ignite by apache.
the class IgniteCacheLockPartitionOnAffinityRunTest method testSingleCache.
/**
* @throws Exception If failed.
*/
public void testSingleCache() throws Exception {
final PersonsCountGetter personsCntGetter = new PersonsCountGetter() {
@Override
public int getPersonsCount(IgniteEx ignite, IgniteLogger log, int orgId) throws Exception {
return getPersonsCountSingleCache(ignite, log, orgId);
}
};
// Run restart threads: start re-balancing.
beginNodesRestart();
IgniteInternalFuture<Long> affFut = null;
try {
final AtomicInteger threadNum = new AtomicInteger(0);
affFut = GridTestUtils.runMultiThreadedAsync(new Runnable() {
@Override
public void run() {
if (threadNum.getAndIncrement() % 2 == 0) {
while (System.currentTimeMillis() < endTime) {
for (final int orgId : orgIds) {
if (System.currentTimeMillis() >= endTime)
break;
grid(0).compute().affinityRun(Person.class.getSimpleName(), new Person(0, orgId).createKey(), new TestAffinityRun(personsCntGetter, orgId));
}
}
} else {
while (System.currentTimeMillis() < endTime) {
for (final int orgId : orgIds) {
if (System.currentTimeMillis() >= endTime)
break;
int personsCnt = grid(0).compute().affinityCall(Person.class.getSimpleName(), new Person(0, orgId).createKey(), new TestAffinityCall(personsCntGetter, orgId));
assertEquals(PERS_AT_ORG_CNT, personsCnt);
}
}
}
}
}, AFFINITY_THREADS_CNT, "affinity-run");
} finally {
if (affFut != null)
affFut.get();
}
}
use of org.apache.ignite.IgniteLogger in project ignite by apache.
the class IgniteCacheLockPartitionOnAffinityRunTest method testMultipleCaches.
/**
* @throws Exception If failed.
*/
public void testMultipleCaches() throws Exception {
final PersonsCountGetter personsCntGetter = new PersonsCountGetter() {
@Override
public int getPersonsCount(IgniteEx ignite, IgniteLogger log, int orgId) throws Exception {
return getPersonsCountMultipleCache(ignite, log, orgId);
}
};
// Run restart threads: start re-balancing.
beginNodesRestart();
IgniteInternalFuture<Long> affFut = null;
try {
final AtomicInteger threadNum = new AtomicInteger(0);
affFut = GridTestUtils.runMultiThreadedAsync(new Runnable() {
@Override
public void run() {
if (threadNum.getAndIncrement() % 2 == 0) {
while (System.currentTimeMillis() < endTime) {
for (final int orgId : orgIds) {
if (System.currentTimeMillis() >= endTime)
break;
grid(0).compute().affinityRun(Arrays.asList(Organization.class.getSimpleName(), Person.class.getSimpleName()), new Integer(orgId), new TestAffinityRun(personsCntGetter, orgId));
}
}
} else {
while (System.currentTimeMillis() < endTime) {
for (final int orgId : orgIds) {
if (System.currentTimeMillis() >= endTime)
break;
int personsCnt = grid(0).compute().affinityCall(Arrays.asList(Organization.class.getSimpleName(), Person.class.getSimpleName()), new Integer(orgId), new TestAffinityCall(personsCntGetter, orgId));
assertEquals(PERS_AT_ORG_CNT, personsCnt);
}
}
}
}
}, AFFINITY_THREADS_CNT, "affinity-run");
} finally {
if (affFut != null)
affFut.get();
}
}
use of org.apache.ignite.IgniteLogger in project ignite by apache.
the class GridToStringBuilderSelfTest method testToStringPerformance.
/**
* JUnit.
*/
public void testToStringPerformance() {
TestClass1 obj = new TestClass1();
IgniteLogger log = log();
// Warm up.
obj.toStringAutomatic();
long start = System.currentTimeMillis();
for (int i = 0; i < 100000; i++) obj.toStringManual();
log.info("Manual toString() took: " + (System.currentTimeMillis() - start) + "ms");
start = System.currentTimeMillis();
for (int i = 0; i < 100000; i++) obj.toStringAutomatic();
log.info("Automatic toString() took: " + (System.currentTimeMillis() - start) + "ms");
}
Aggregations