use of org.apache.ignite.internal.processors.query.schema.message.SchemaProposeDiscoveryMessage in project ignite by apache.
the class GridQueryProcessor method onSchemaFinishDiscovery.
/**
* Process schema finish message from discovery thread.
*
* @param msg Message.
*/
private void onSchemaFinishDiscovery(SchemaFinishDiscoveryMessage msg) {
UUID opId = msg.operation().id();
if (log.isDebugEnabled())
log.debug("Received schema finish message (discovery) [opId=" + opId + ", msg=" + msg + ']');
synchronized (stateMux) {
if (disconnected)
return;
boolean completedOpAdded = completedOpIds.add(opId);
assert completedOpAdded;
// Remove propose message so that it will not be shared with joining nodes.
SchemaProposeDiscoveryMessage proposeMsg = activeProposals.remove(opId);
assert proposeMsg != null;
// Apply changes to public cache schema if operation is successful and original cache is still there.
if (!msg.hasError()) {
DynamicCacheDescriptor cacheDesc = ctx.cache().cacheDescriptor(msg.operation().cacheName());
if (cacheDesc != null && F.eq(cacheDesc.deploymentId(), proposeMsg.deploymentId())) {
cacheDesc.schemaChangeFinish(msg);
try {
ctx.cache().saveCacheConfiguration(cacheDesc);
} catch (IgniteCheckedException e) {
U.error(log, "Error while saving cache configuration on disk, cfg = " + cacheDesc.cacheConfiguration(), e);
}
}
}
// Propose message will be used from exchange thread to
msg.proposeMessage(proposeMsg);
if (exchangeReady) {
SchemaOperation op = schemaOps.get(proposeMsg.schemaName());
if (F.eq(op.id(), opId)) {
// Completed top operation.
op.finishMessage(msg);
if (op.started())
op.doFinish();
} else {
// Completed operation in the middle, will schedule completion later.
while (op != null) {
if (F.eq(op.id(), opId))
break;
op = op.next();
}
assert op != null;
assert !op.started();
op.finishMessage(msg);
}
} else {
// Set next operation as top-level one.
String schemaName = proposeMsg.schemaName();
SchemaOperation op = schemaOps.remove(schemaName);
assert op != null;
assert F.eq(op.id(), opId);
// Chain to the next operation (if any).
SchemaOperation nextOp = op.next();
if (nextOp != null)
schemaOps.put(schemaName, nextOp);
}
// Clean stale IO messages from just-joined nodes.
cleanStaleStatusMessages(opId);
}
}
use of org.apache.ignite.internal.processors.query.schema.message.SchemaProposeDiscoveryMessage in project ignite by apache.
the class GridQueryProcessor method processStatusMessage.
/**
* Process status message.
*
* @param msg Status message.
*/
private void processStatusMessage(SchemaOperationStatusMessage msg) {
synchronized (stateMux) {
if (completedOpIds.contains(msg.operationId())) {
// Received message from a node which joined topology in the middle of operation execution.
if (log.isDebugEnabled())
log.debug("Received status message for completed operation (will ignore) [" + "opId=" + msg.operationId() + ", sndNodeId=" + msg.senderNodeId() + ']');
return;
}
UUID opId = msg.operationId();
SchemaProposeDiscoveryMessage proposeMsg = activeProposals.get(opId);
if (proposeMsg != null) {
SchemaOperation op = schemaOps.get(proposeMsg.schemaName());
if (op != null && F.eq(op.id(), opId) && op.started() && coordinator().isLocal()) {
if (log.isDebugEnabled())
log.debug("Received status message [opId=" + msg.operationId() + ", sndNodeId=" + msg.senderNodeId() + ']');
op.manager().onNodeFinished(msg.senderNodeId(), unmarshalSchemaError(msg.errorBytes()));
return;
}
}
// Put to pending set if operation is not visible/ready yet.
pendingMsgs.add(msg);
if (log.isDebugEnabled())
log.debug("Received status message (added to pending set) [opId=" + msg.operationId() + ", sndNodeId=" + msg.senderNodeId() + ']');
}
}
use of org.apache.ignite.internal.processors.query.schema.message.SchemaProposeDiscoveryMessage in project ignite by apache.
the class GridQueryProcessor method startSchemaChange.
/**
* Initiate actual schema change operation.
*
* @param schemaOp Schema operation.
*/
private void startSchemaChange(SchemaOperation schemaOp) {
assert Thread.holdsLock(stateMux);
assert !schemaOp.started();
// Get current cache state.
SchemaProposeDiscoveryMessage msg = schemaOp.proposeMessage();
String cacheName = msg.operation().cacheName();
DynamicCacheDescriptor cacheDesc = ctx.cache().cacheDescriptor(cacheName);
boolean cacheExists = cacheDesc != null && F.eq(msg.deploymentId(), cacheDesc.deploymentId());
boolean cacheRegistered = cacheExists && cacheNames.contains(cacheName);
// Validate schema state and decide whether we should proceed or not.
SchemaAbstractOperation op = msg.operation();
QueryTypeDescriptorImpl type = null;
SchemaOperationException err;
boolean nop = false;
if (cacheExists) {
if (cacheRegistered) {
// If cache is started, we perform validation against real schema.
T3<QueryTypeDescriptorImpl, Boolean, SchemaOperationException> res = prepareChangeOnStartedCache(op);
assert res.get2() != null;
type = res.get1();
nop = res.get2();
err = res.get3();
} else {
T2<Boolean, SchemaOperationException> res = prepareChangeOnNotStartedCache(op, cacheDesc);
assert res.get1() != null;
type = null;
nop = res.get1();
err = res.get2();
}
} else
err = new SchemaOperationException(SchemaOperationException.CODE_CACHE_NOT_FOUND, cacheName);
// Start operation.
SchemaOperationWorker worker = new SchemaOperationWorker(ctx, this, msg.deploymentId(), op, nop, err, cacheRegistered, type);
SchemaOperationManager mgr = new SchemaOperationManager(ctx, this, worker, ctx.clientNode() ? null : coordinator());
schemaOp.manager(mgr);
mgr.start();
// Unwind pending IO messages.
if (!ctx.clientNode() && coordinator().isLocal())
unwindPendingMessages(schemaOp.id(), mgr);
// Schedule operation finish handling if needed.
if (schemaOp.hasFinishMessage())
schemaOp.doFinish();
}
use of org.apache.ignite.internal.processors.query.schema.message.SchemaProposeDiscoveryMessage in project ignite by apache.
the class GridCacheProcessor method processCustomExchangeTask.
/**
* Process custom exchange task.
*
* @param task Task.
*/
void processCustomExchangeTask(CachePartitionExchangeWorkerTask task) {
if (task instanceof SchemaExchangeWorkerTask) {
SchemaAbstractDiscoveryMessage msg = ((SchemaExchangeWorkerTask) task).message();
if (msg instanceof SchemaProposeDiscoveryMessage) {
SchemaProposeDiscoveryMessage msg0 = (SchemaProposeDiscoveryMessage) msg;
ctx.query().onSchemaPropose(msg0);
} else
U.warn(log, "Unsupported schema discovery message: " + msg);
} else if (task instanceof SchemaNodeLeaveExchangeWorkerTask) {
SchemaNodeLeaveExchangeWorkerTask task0 = (SchemaNodeLeaveExchangeWorkerTask) task;
ctx.query().onNodeLeave(task0.node());
} else if (task instanceof ClientCacheChangeDummyDiscoveryMessage) {
ClientCacheChangeDummyDiscoveryMessage task0 = (ClientCacheChangeDummyDiscoveryMessage) task;
sharedCtx.affinity().processClientCachesRequests(task0);
} else if (task instanceof ClientCacheUpdateTimeout) {
ClientCacheUpdateTimeout task0 = (ClientCacheUpdateTimeout) task;
sharedCtx.affinity().sendClientCacheChangesMessage(task0);
} else if (task instanceof CacheStatisticsModeChangeTask) {
CacheStatisticsModeChangeTask task0 = (CacheStatisticsModeChangeTask) task;
processStatisticsModeChange(task0.message());
} else if (task instanceof TxTimeoutOnPartitionMapExchangeChangeTask) {
TxTimeoutOnPartitionMapExchangeChangeTask task0 = (TxTimeoutOnPartitionMapExchangeChangeTask) task;
sharedCtx.tm().processTxTimeoutOnPartitionMapExchangeChange(task0.message());
} else if (task instanceof StopCachesOnClientReconnectExchangeTask) {
StopCachesOnClientReconnectExchangeTask task0 = (StopCachesOnClientReconnectExchangeTask) task;
stopCachesOnClientReconnect(task0.stoppedCaches());
task0.onDone();
} else if (task instanceof WalStateNodeLeaveExchangeTask) {
WalStateNodeLeaveExchangeTask task0 = (WalStateNodeLeaveExchangeTask) task;
sharedCtx.walState().onNodeLeft(task0.node().id());
} else if (task instanceof FinishPreloadingTask) {
FinishPreloadingTask task0 = (FinishPreloadingTask) task;
CacheGroupContext grp = cacheGroup(task0.groupId());
if (grp != null)
grp.preloader().finishPreloading(task0.topologyVersion(), task0.rebalanceId());
} else
U.warn(log, "Unsupported custom exchange task: " + task);
}
use of org.apache.ignite.internal.processors.query.schema.message.SchemaProposeDiscoveryMessage in project ignite by apache.
the class GridQueryProcessor method collectGridNodeData.
/**
* {@inheritDoc}
*/
@Override
public void collectGridNodeData(DiscoveryDataBag dataBag) {
LinkedHashMap<UUID, SchemaProposeDiscoveryMessage> proposals;
// Collect active proposals.
synchronized (stateMux) {
proposals = new LinkedHashMap<>(activeProposals);
}
dataBag.addGridCommonData(DiscoveryDataExchangeType.QUERY_PROC.ordinal(), proposals);
// node from server node.
if (!dataBag.isJoiningNodeClient()) {
HashMap<String, Serializable> nodeSpecificMap = new HashMap<>();
Serializable oldVal = nodeSpecificMap.put(INLINE_SIZES_DISCO_BAG_KEY, collectSecondaryIndexesInlineSize());
assert oldVal == null : oldVal;
dataBag.addNodeSpecificData(DiscoveryDataExchangeType.QUERY_PROC.ordinal(), nodeSpecificMap);
}
}
Aggregations