Search in sources :

Example 6 with IgniteLogger

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();
}
Also used : Message(org.apache.ignite.plugin.extensions.communication.Message) GridNioRecoveryDescriptor(org.apache.ignite.internal.util.nio.GridNioRecoveryDescriptor) IgniteLogger(org.apache.ignite.IgniteLogger) UUID(java.util.UUID) GridCommunicationClient(org.apache.ignite.internal.util.nio.GridCommunicationClient) Map(java.util.Map) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap)

Example 7 with IgniteLogger

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);
}
Also used : GridDiscoveryManager(org.apache.ignite.internal.managers.discovery.GridDiscoveryManager) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) GridKernalContext(org.apache.ignite.internal.GridKernalContext) IgniteLogger(org.apache.ignite.IgniteLogger) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 8 with IgniteLogger

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();
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IgniteEx(org.apache.ignite.internal.IgniteEx) IgniteRunnable(org.apache.ignite.lang.IgniteRunnable) IgniteLogger(org.apache.ignite.IgniteLogger)

Example 9 with IgniteLogger

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();
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IgniteEx(org.apache.ignite.internal.IgniteEx) IgniteRunnable(org.apache.ignite.lang.IgniteRunnable) IgniteLogger(org.apache.ignite.IgniteLogger)

Example 10 with IgniteLogger

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");
}
Also used : IgniteLogger(org.apache.ignite.IgniteLogger)

Aggregations

IgniteLogger (org.apache.ignite.IgniteLogger)49 Ignite (org.apache.ignite.Ignite)11 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)11 IOException (java.io.IOException)9 LoggerResource (org.apache.ignite.resources.LoggerResource)9 Map (java.util.Map)6 IgniteInstanceResource (org.apache.ignite.resources.IgniteInstanceResource)6 HashMap (java.util.HashMap)5 UUID (java.util.UUID)5 IgniteException (org.apache.ignite.IgniteException)5 ClusterNode (org.apache.ignite.cluster.ClusterNode)5 File (java.io.File)4 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)4 Callable (java.util.concurrent.Callable)3 GridLoggerProxy (org.apache.ignite.internal.GridLoggerProxy)3 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)3 IgniteKernal (org.apache.ignite.internal.IgniteKernal)3 Nullable (org.jetbrains.annotations.Nullable)3 InvalidObjectException (java.io.InvalidObjectException)2 ArrayList (java.util.ArrayList)2