Search in sources :

Example 6 with IgniteClientDisconnectedException

use of org.apache.ignite.IgniteClientDisconnectedException in project ignite by apache.

the class ServiceDeploymentOnClientDisconnectTest method testServiceDeploymentExchangeProcessingOnReconnect.

/**
 * @throws Exception In case of an error.
 */
@Test
public void testServiceDeploymentExchangeProcessingOnReconnect() throws Exception {
    IgniteEx client = client();
    IgniteFuture fut = client.services().deployNodeSingletonAsync("testService1", new LongInitializedTestService(10_000L));
    client.services().deployNodeSingletonAsync("testService2", new LongInitializedTestService(10_000L));
    server().close();
    IgniteFuture reconnectFut = null;
    try {
        fut.get();
        fail("Client disconnected exception was expected.");
    } catch (IgniteClientDisconnectedException e) {
        reconnectFut = e.reconnectFuture();
    }
    assertNotNull(reconnectFut);
    startGrid(0);
    reconnectFut.get(CLIENT_RECONNECT_WAIT_TIMEOUT);
    assertEquals(2, client.cluster().topologyVersion());
    assertEquals(0, client.services().serviceDescriptors().size());
    client.services().deployNodeSingleton("testService3", MyServiceFactory.create());
    final MyService proxy = client.services().serviceProxy("testService3", MyService.class, false, 2_000);
    assertNotNull(proxy);
    assertEquals(42, proxy.hello());
}
Also used : MyService(org.apache.ignite.internal.processors.service.inner.MyService) IgniteEx(org.apache.ignite.internal.IgniteEx) IgniteClientDisconnectedException(org.apache.ignite.IgniteClientDisconnectedException) IgniteFuture(org.apache.ignite.lang.IgniteFuture) LongInitializedTestService(org.apache.ignite.internal.processors.service.inner.LongInitializedTestService) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 7 with IgniteClientDisconnectedException

use of org.apache.ignite.IgniteClientDisconnectedException in project ignite by apache.

the class GridKernalGatewayImpl method readLock.

/**
 * {@inheritDoc}
 */
@SuppressWarnings({ "LockAcquiredButNotSafelyReleased" })
@Override
public void readLock() throws IgniteIllegalStateException {
    if (stackTrace == null)
        stackTrace = stackTrace();
    Lock lock = rwLock.readLock();
    lock.lock();
    GridKernalState state = this.state.get();
    if (state != GridKernalState.STARTED) {
        // Unlock just acquired lock.
        lock.unlock();
        if (state == GridKernalState.DISCONNECTED) {
            assert reconnectFut != null;
            throw new IgniteClientDisconnectedException(reconnectFut, "Client node disconnected: " + igniteInstanceName);
        }
        throw illegalState();
    }
}
Also used : IgniteClientDisconnectedException(org.apache.ignite.IgniteClientDisconnectedException) StripedCompositeReadWriteLock(org.apache.ignite.internal.util.StripedCompositeReadWriteLock) Lock(java.util.concurrent.locks.Lock) ReadWriteLock(java.util.concurrent.locks.ReadWriteLock)

Example 8 with IgniteClientDisconnectedException

use of org.apache.ignite.IgniteClientDisconnectedException in project ignite by apache.

the class IgniteKernal method ackNodeMetrics.

/**
 * Logs out node metrics.
 *
 * @param dblFmt Decimal format.
 * @param execSvc Executor service.
 * @param sysExecSvc System executor service.
 * @param customExecSvcs Custom named executors.
 */
private void ackNodeMetrics(DecimalFormat dblFmt, ExecutorService execSvc, ExecutorService sysExecSvc, ExecutorService stripedExecSvc, Map<String, ? extends ExecutorService> customExecSvcs) {
    if (!log.isInfoEnabled())
        return;
    try {
        ClusterMetrics m = cluster().localNode().metrics();
        int localCpus = m.getTotalCpus();
        double cpuLoadPct = m.getCurrentCpuLoad() * 100;
        double avgCpuLoadPct = m.getAverageCpuLoad() * 100;
        double gcPct = m.getCurrentGcCpuLoad() * 100;
        // Heap params.
        long heapUsed = m.getHeapMemoryUsed();
        long heapMax = m.getHeapMemoryMaximum();
        long heapUsedInMBytes = heapUsed / MEGABYTE;
        long heapCommInMBytes = m.getHeapMemoryCommitted() / MEGABYTE;
        double freeHeapPct = heapMax > 0 ? ((double) ((heapMax - heapUsed) * 100)) / heapMax : -1;
        int hosts = 0;
        int servers = 0;
        int clients = 0;
        int cpus = 0;
        try {
            ClusterMetrics metrics = cluster().metrics();
            Collection<ClusterNode> nodes0 = cluster().nodes();
            hosts = U.neighborhood(nodes0).size();
            servers = cluster().forServers().nodes().size();
            clients = cluster().forClients().nodes().size();
            cpus = metrics.getTotalCpus();
        } catch (IgniteException ignore) {
        // No-op.
        }
        String dataStorageInfo = dataStorageReport(ctx.cache().context().database(), dblFmt, true);
        String id = U.id8(localNode().id());
        AffinityTopologyVersion topVer = ctx.discovery().topologyVersionEx();
        ClusterNode locNode = ctx.discovery().localNode();
        String networkDetails = "";
        if (!F.isEmpty(cfg.getLocalHost()))
            networkDetails += ", localHost=" + cfg.getLocalHost();
        if (locNode instanceof TcpDiscoveryNode)
            networkDetails += ", discoPort=" + ((TcpDiscoveryNode) locNode).discoveryPort();
        if (cfg.getCommunicationSpi() instanceof TcpCommunicationSpi)
            networkDetails += ", commPort=" + ((TcpCommunicationSpi) cfg.getCommunicationSpi()).boundPort();
        SB msg = new SB();
        msg.nl().a("Metrics for local node (to disable set 'metricsLogFrequency' to 0)").nl().a("    ^-- Node [id=").a(id).a(name() != null ? ", name=" + name() : "").a(", uptime=").a(upTimeFormatted()).a("]").nl().a("    ^-- Cluster [hosts=").a(hosts).a(", CPUs=").a(cpus).a(", servers=").a(servers).a(", clients=").a(clients).a(", topVer=").a(topVer.topologyVersion()).a(", minorTopVer=").a(topVer.minorTopologyVersion()).a("]").nl().a("    ^-- Network [addrs=").a(locNode.addresses()).a(networkDetails).a("]").nl().a("    ^-- CPU [CPUs=").a(localCpus).a(", curLoad=").a(dblFmt.format(cpuLoadPct)).a("%, avgLoad=").a(dblFmt.format(avgCpuLoadPct)).a("%, GC=").a(dblFmt.format(gcPct)).a("%]").nl().a("    ^-- Heap [used=").a(dblFmt.format(heapUsedInMBytes)).a("MB, free=").a(dblFmt.format(freeHeapPct)).a("%, comm=").a(dblFmt.format(heapCommInMBytes)).a("MB]").nl().a(dataStorageInfo).a("    ^-- Outbound messages queue [size=").a(m.getOutboundMessagesQueueSize()).a("]").nl().a("    ^-- ").a(createExecutorDescription("Public thread pool", execSvc)).nl().a("    ^-- ").a(createExecutorDescription("System thread pool", sysExecSvc)).nl().a("    ^-- ").a(createExecutorDescription("Striped thread pool", stripedExecSvc));
        if (customExecSvcs != null) {
            for (Map.Entry<String, ? extends ExecutorService> entry : customExecSvcs.entrySet()) msg.nl().a("    ^-- ").a(createExecutorDescription(entry.getKey(), entry.getValue()));
        }
        log.info(msg.toString());
        ctx.cache().context().database().dumpStatistics(log);
    } catch (IgniteClientDisconnectedException ignore) {
    // No-op.
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) IgniteClientDisconnectedException(org.apache.ignite.IgniteClientDisconnectedException) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) SB(org.apache.ignite.internal.util.typedef.internal.SB) ClusterMetrics(org.apache.ignite.cluster.ClusterMetrics) IgniteException(org.apache.ignite.IgniteException) Map(java.util.Map) HashMap(java.util.HashMap) TcpDiscoveryNode(org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode)

Example 9 with IgniteClientDisconnectedException

use of org.apache.ignite.IgniteClientDisconnectedException in project ignite by apache.

the class GridEncryptionManager method changeMasterKey.

/**
 * {@inheritDoc}
 */
@Override
public IgniteFuture<Void> changeMasterKey(String masterKeyName) {
    if (ctx.clientNode()) {
        return new IgniteFinishedFutureImpl<>(new UnsupportedOperationException("Client and daemon nodes can not " + "perform this operation."));
    }
    if (!IgniteFeatures.allNodesSupports(ctx.grid().cluster().nodes(), MASTER_KEY_CHANGE)) {
        return new IgniteFinishedFutureImpl<>(new IllegalStateException("Not all nodes in the cluster support " + "the master key change process."));
    }
    // can be partially re-encrypted in case of node stop without the possibility of recovery.
    if (!ctx.state().clusterState().active()) {
        return new IgniteFinishedFutureImpl<>(new IgniteException("Master key change was rejected. " + "The cluster is inactive."));
    }
    if (masterKeyName.equals(getMasterKeyName())) {
        return new IgniteFinishedFutureImpl<>(new IgniteException("Master key change was rejected. " + "New name equal to the current."));
    }
    byte[] digest;
    try {
        digest = masterKeyDigest(masterKeyName);
    } catch (Exception e) {
        return new IgniteFinishedFutureImpl<>(new IgniteException("Master key change was rejected. " + "Unable to get the master key digest.", e));
    }
    MasterKeyChangeRequest request = new MasterKeyChangeRequest(UUID.randomUUID(), encryptKeyName(masterKeyName), digest);
    synchronized (opsMux) {
        if (disconnected) {
            return new IgniteFinishedFutureImpl<>(new IgniteClientDisconnectedException(ctx.cluster().clientReconnectFuture(), "Master key change was rejected. Client node disconnected."));
        }
        if (stopped) {
            return new IgniteFinishedFutureImpl<>(new IgniteException("Master key change was rejected. " + "Node is stopping."));
        }
        if (masterKeyChangeFut != null && !masterKeyChangeFut.isDone()) {
            return new IgniteFinishedFutureImpl<>(new IgniteException("Master key change was rejected. " + "The previous change was not completed."));
        }
        masterKeyChangeFut = new KeyChangeFuture(request.requestId());
        prepareMKChangeProc.start(request.requestId(), request);
        return new IgniteFutureImpl<>(masterKeyChangeFut);
    }
}
Also used : IgniteException(org.apache.ignite.IgniteException) IgniteFutureImpl(org.apache.ignite.internal.util.future.IgniteFutureImpl) IgniteClientDisconnectedException(org.apache.ignite.IgniteClientDisconnectedException) IgniteFinishedFutureImpl(org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl) IgniteClientDisconnectedException(org.apache.ignite.IgniteClientDisconnectedException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) IgniteSpiException(org.apache.ignite.spi.IgniteSpiException) IgniteFutureCancelledException(org.apache.ignite.lang.IgniteFutureCancelledException)

Example 10 with IgniteClientDisconnectedException

use of org.apache.ignite.IgniteClientDisconnectedException in project ignite by apache.

the class IgniteUtils method convertException.

/**
 * @param e Ignite checked exception.
 * @return Ignite runtime exception.
 */
public static IgniteException convertException(IgniteCheckedException e) {
    IgniteClientDisconnectedException e0 = e.getCause(IgniteClientDisconnectedException.class);
    if (e0 != null) {
        assert e0.reconnectFuture() != null : e0;
        throw e0;
    }
    IgniteClientDisconnectedCheckedException disconnectedErr = e.getCause(IgniteClientDisconnectedCheckedException.class);
    if (disconnectedErr != null) {
        assert disconnectedErr.reconnectFuture() != null : disconnectedErr;
        e = disconnectedErr;
    }
    C1<IgniteCheckedException, IgniteException> converter = exceptionConverters.get(e.getClass());
    if (converter != null)
        return converter.apply(e);
    if (e.getCause() instanceof IgniteException)
        return (IgniteException) e.getCause();
    return new IgniteException(e.getMessage(), e);
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) IgniteClientDisconnectedException(org.apache.ignite.IgniteClientDisconnectedException) IgniteClientDisconnectedCheckedException(org.apache.ignite.internal.IgniteClientDisconnectedCheckedException)

Aggregations

IgniteClientDisconnectedException (org.apache.ignite.IgniteClientDisconnectedException)55 Ignite (org.apache.ignite.Ignite)33 IgniteException (org.apache.ignite.IgniteException)26 Test (org.junit.Test)23 CacheException (javax.cache.CacheException)15 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)12 CountDownLatch (java.util.concurrent.CountDownLatch)10 Event (org.apache.ignite.events.Event)9 IgniteSpiException (org.apache.ignite.spi.IgniteSpiException)9 UUID (java.util.UUID)6 ClusterNode (org.apache.ignite.cluster.ClusterNode)6 IgniteDiscoverySpi (org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi)6 TransactionRollbackException (org.apache.ignite.transactions.TransactionRollbackException)6 IgniteCallable (org.apache.ignite.lang.IgniteCallable)5 DiscoverySpi (org.apache.ignite.spi.discovery.DiscoverySpi)5 Callable (java.util.concurrent.Callable)4 IgniteTransactions (org.apache.ignite.IgniteTransactions)4 DiscoveryEvent (org.apache.ignite.events.DiscoveryEvent)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3