use of org.apache.ignite.IgniteClientDisconnectedException in project ignite by apache.
the class GridDiscoveryManager method sendCustomEvent.
/**
* @param msg Custom message.
* @throws IgniteCheckedException If failed.
*/
public void sendCustomEvent(DiscoveryCustomMessage msg) throws IgniteCheckedException {
try {
IgniteSecurity security = ctx.security();
getSpi().sendCustomEvent(security.enabled() ? new SecurityAwareCustomMessageWrapper(msg, security.securityContext().subject().id()) : new CustomMessageWrapper(msg));
} catch (IgniteClientDisconnectedException e) {
IgniteFuture<?> reconnectFut = ctx.cluster().clientReconnectFuture();
throw new IgniteClientDisconnectedCheckedException(reconnectFut, e.getMessage());
} catch (IgniteException e) {
throw new IgniteCheckedException(e);
}
}
use of org.apache.ignite.IgniteClientDisconnectedException in project ignite by apache.
the class CacheObjectBinaryProcessorImpl method metadata.
/**
* {@inheritDoc}
*/
@Nullable
@Override
public BinaryType metadata(final int typeId, final int schemaId) {
BinaryMetadataHolder holder = metadataLocCache.get(typeId);
if (ctx.clientNode()) {
if (holder == null || !holder.metadata().hasSchema(schemaId)) {
if (log.isDebugEnabled())
log.debug("Waiting for client metadata update" + " [typeId=" + typeId + ", schemaId=" + schemaId + ", pendingVer=" + (holder == null ? "NA" : holder.pendingVersion()) + ", acceptedVer=" + (holder == null ? "NA" : holder.acceptedVersion()) + ']');
try {
transport.requestUpToDateMetadata(typeId).get();
} catch (IgniteCheckedException ignored) {
// No-op.
}
holder = metadataLocCache.get(typeId);
IgniteFuture<?> reconnectFut0 = reconnectFut;
if (holder == null && reconnectFut0 != null)
throw new IgniteClientDisconnectedException(reconnectFut0, "Client node disconnected.");
if (log.isDebugEnabled())
log.debug("Finished waiting for client metadata update" + " [typeId=" + typeId + ", schemaId=" + schemaId + ", pendingVer=" + (holder == null ? "NA" : holder.pendingVersion()) + ", acceptedVer=" + (holder == null ? "NA" : holder.acceptedVersion()) + ']');
}
} else {
if (holder != null && IgniteThread.current() instanceof IgniteDiscoveryThread)
return holder.metadata().wrap(binaryCtx);
else if (holder != null && (holder.pendingVersion() - holder.acceptedVersion() > 0)) {
if (log.isDebugEnabled())
log.debug("Waiting for metadata update" + " [typeId=" + typeId + ", schemaId=" + schemaId + ", pendingVer=" + holder.pendingVersion() + ", acceptedVer=" + holder.acceptedVersion() + ']');
long t0 = System.nanoTime();
GridFutureAdapter<MetadataUpdateResult> fut = transport.awaitMetadataUpdate(typeId, holder.pendingVersion());
try {
fut.get();
} catch (IgniteCheckedException e) {
log.error("Failed to wait for metadata update [typeId=" + typeId + ", schemaId=" + schemaId + ']', e);
}
if (log.isDebugEnabled())
log.debug("Finished waiting for metadata update" + " [typeId=" + typeId + ", waitTime=" + NANOSECONDS.convert(System.nanoTime() - t0, MILLISECONDS) + "ms" + ", schemaId=" + schemaId + ", pendingVer=" + holder.pendingVersion() + ", acceptedVer=" + holder.acceptedVersion() + ']');
holder = metadataLocCache.get(typeId);
} else if (holder == null || !holder.metadata().hasSchema(schemaId)) {
// Last resort waiting.
U.warn(log, "Schema is missing while no metadata updates are in progress " + "(will wait for schema update within timeout defined by " + IGNITE_WAIT_SCHEMA_UPDATE + " system property)" + " [typeId=" + typeId + ", missingSchemaId=" + schemaId + ", pendingVer=" + (holder == null ? "NA" : holder.pendingVersion()) + ", acceptedVer=" + (holder == null ? "NA" : holder.acceptedVersion()) + ", binMetaUpdateTimeout=" + waitSchemaTimeout + ']');
long t0 = System.nanoTime();
GridFutureAdapter<?> fut = transport.awaitSchemaUpdate(typeId, schemaId);
try {
fut.get(waitSchemaTimeout);
} catch (IgniteFutureTimeoutCheckedException e) {
log.error("Timed out while waiting for schema update [typeId=" + typeId + ", schemaId=" + schemaId + ']');
} catch (IgniteCheckedException ignored) {
// No-op.
}
holder = metadataLocCache.get(typeId);
if (log.isDebugEnabled() && holder != null && holder.metadata().hasSchema(schemaId))
log.debug("Found the schema after wait" + " [typeId=" + typeId + ", waitTime=" + NANOSECONDS.convert(System.nanoTime() - t0, MILLISECONDS) + "ms" + ", schemaId=" + schemaId + ", pendingVer=" + holder.pendingVersion() + ", acceptedVer=" + holder.acceptedVersion() + ']');
}
}
if (holder != null && metadataFileStore != null) {
try {
metadataFileStore.waitForWriteCompletion(typeId, holder.pendingVersion());
} catch (IgniteCheckedException e) {
log.warning("Failed to wait for metadata write operation for [typeId=" + typeId + ", typeVer=" + holder.acceptedVersion() + ']', e);
return null;
}
}
return holder != null ? holder.metadata().wrap(binaryCtx) : null;
}
use of org.apache.ignite.IgniteClientDisconnectedException in project ignite by apache.
the class ConnectGateway method disconnected.
/**
* @param reconnectFut Reconnect future.
*/
public void disconnected(IgniteFuture<?> reconnectFut) {
lock.writeLock();
err = new IgniteClientDisconnectedException(reconnectFut, "Failed to connect, client node disconnected.");
lock.writeUnlock();
}
use of org.apache.ignite.IgniteClientDisconnectedException in project ignite by apache.
the class ZookeeperDiscoveryImpl method sendCustomMessage.
/**
* @param msg Message.
*/
public void sendCustomMessage(DiscoverySpiCustomMessage msg) {
assert msg != null;
List<ClusterNode> nodes = rtState.top.topologySnapshot();
boolean hasServerNode = false;
for (int i = 0, size = nodes.size(); i < size; i++) {
ClusterNode node = nodes.get(i);
if (!node.isClient())
hasServerNode = true;
}
if (!hasServerNode)
throw new IgniteException("Failed to send custom message: no server nodes in topology.");
byte[] msgBytes;
try {
msgBytes = marshalZip(msg);
} catch (IgniteCheckedException e) {
throw new IgniteSpiException("Failed to marshal custom message: " + msg, e);
}
while (!busyLock.enterBusy()) checkState();
try {
ZookeeperClient zkClient = rtState.zkClient;
saveCustomMessage(zkClient, msgBytes);
} catch (ZookeeperClientFailedException e) {
if (clientReconnectEnabled)
throw new IgniteClientDisconnectedException(null, "Client is disconnected.");
throw new IgniteException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IgniteInterruptedException(e);
} finally {
busyLock.leaveBusy();
}
}
use of org.apache.ignite.IgniteClientDisconnectedException in project ignite by apache.
the class GridAbstractTest method waitForTopology.
/**
* @param expSize Expected nodes number.
* @throws Exception If failed.
*/
protected void waitForTopology(final int expSize) throws Exception {
assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicate() {
@Override
public boolean apply() {
List<Ignite> nodes = G.allGrids();
if (nodes.size() != expSize) {
info("Wait all nodes [size=" + nodes.size() + ", exp=" + expSize + ']');
return false;
}
for (Ignite node : nodes) {
try {
IgniteFuture<?> reconnectFut = node.cluster().clientReconnectFuture();
if (reconnectFut != null && !reconnectFut.isDone()) {
info("Wait for size on node, reconnect is in progress [node=" + node.name() + ']');
return false;
}
int sizeOnNode = node.cluster().nodes().size();
if (sizeOnNode != expSize) {
info("Wait for size on node [node=" + node.name() + ", size=" + sizeOnNode + ", exp=" + expSize + ']');
return false;
}
} catch (IgniteClientDisconnectedException e) {
info("Wait for size on node, node disconnected [node=" + node.name() + ']');
return false;
}
}
return true;
}
}, 30_000));
}
Aggregations