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());
}
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();
}
}
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.
}
}
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);
}
}
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);
}
Aggregations