Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,22 @@
import org.apache.ignite.internal.processors.metastorage.persistence.DistributedMetaStorageUpdateAckMessageSerializer;
import org.apache.ignite.internal.processors.metastorage.persistence.DistributedMetaStorageUpdateMessage;
import org.apache.ignite.internal.processors.metastorage.persistence.DistributedMetaStorageUpdateMessageSerializer;
import org.apache.ignite.internal.processors.query.QueryField;
import org.apache.ignite.internal.processors.query.QueryFieldMarshallableSerializer;
import org.apache.ignite.internal.processors.query.schema.message.SchemaFinishDiscoveryMessage;
import org.apache.ignite.internal.processors.query.schema.message.SchemaFinishDiscoveryMessageSerializer;
import org.apache.ignite.internal.processors.query.schema.message.SchemaProposeDiscoveryMessage;
import org.apache.ignite.internal.processors.query.schema.message.SchemaProposeDiscoveryMessageSerializer;
import org.apache.ignite.internal.processors.query.schema.operation.SchemaAddQueryEntityOperation;
import org.apache.ignite.internal.processors.query.schema.operation.SchemaAddQueryEntityOperationMarshallableSerializer;
import org.apache.ignite.internal.processors.query.schema.operation.SchemaAlterTableAddColumnOperation;
import org.apache.ignite.internal.processors.query.schema.operation.SchemaAlterTableAddColumnOperationSerializer;
import org.apache.ignite.internal.processors.query.schema.operation.SchemaAlterTableDropColumnOperation;
import org.apache.ignite.internal.processors.query.schema.operation.SchemaAlterTableDropColumnOperationSerializer;
import org.apache.ignite.internal.processors.query.schema.operation.SchemaIndexCreateOperation;
import org.apache.ignite.internal.processors.query.schema.operation.SchemaIndexCreateOperationMarshallableSerializer;
import org.apache.ignite.internal.processors.query.schema.operation.SchemaIndexDropOperation;
import org.apache.ignite.internal.processors.query.schema.operation.SchemaIndexDropOperationSerializer;
import org.apache.ignite.marshaller.Marshaller;
import org.apache.ignite.plugin.extensions.communication.MessageFactory;
import org.apache.ignite.plugin.extensions.communication.MessageFactoryProvider;
Expand Down Expand Up @@ -152,6 +164,17 @@ public DiscoveryMessageFactory(Marshaller cstDataMarshall, ClassLoader cstDataMa

/** {@inheritDoc} */
@Override public void registerAll(MessageFactory factory) {
factory.register((short)-115, SchemaAlterTableAddColumnOperation::new,
new SchemaAlterTableAddColumnOperationSerializer());
factory.register((short)-114, SchemaIndexCreateOperation::new,
new SchemaIndexCreateOperationMarshallableSerializer(cstDataMarshall, cstDataMarshallClsLdr));
factory.register((short)-113, SchemaIndexDropOperation::new, new SchemaIndexDropOperationSerializer());
factory.register((short)-112, SchemaAlterTableDropColumnOperation::new,
new SchemaAlterTableDropColumnOperationSerializer());
factory.register((short)-111, SchemaAddQueryEntityOperation::new,
new SchemaAddQueryEntityOperationMarshallableSerializer(cstDataMarshall, cstDataMarshallClsLdr));
factory.register((short)-110, QueryField::new, new QueryFieldMarshallableSerializer(cstDataMarshall,
cstDataMarshallClsLdr));
factory.register((short)-109, User::new, new UserSerializer());
factory.register((short)-108, UserManagementOperation::new, new UserManagementOperationSerializer());
factory.register((short)-107, NodeSpecificData::new, new NodeSpecificDataSerializer());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,53 @@
package org.apache.ignite.internal.processors.query;

import java.io.Serializable;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.Order;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.marshaller.Marshaller;
import org.apache.ignite.plugin.extensions.communication.MarshallableMessage;

/**
* Query field metadata.
*/
public class QueryField implements Serializable {
public class QueryField implements Serializable, MarshallableMessage {
/** */
private static final long serialVersionUID = 0L;

/** Field name. */
private final String name;
@Order(0)
String name;

/** Alias. */
private final String alias;
@Order(1)
String alias;

/** Class name for this field's values. */
private final String typeName;
@Order(2)
String typeName;

/** Nullable flag. */
private final boolean nullable;
@Order(3)
boolean nullable;

/** Default value. */
private final Object dfltValue;
private Object dfltVal;

Check failure on line 52 in modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryField.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make non-static "dfltVal" transient or serializable.

See more on https://sonarcloud.io/project/issues?id=apache_ignite&issues=AZzgnToemSSzhfdqbG7C&open=AZzgnToemSSzhfdqbG7C&pullRequest=12881

/** Serialized form of 'default value'. */
@Order(4)
transient byte[] dfltValBytes;

/** Precision. */
private final int precision;
@Order(5)
int precision;

/** Scale. */
private final int scale;
@Order(6)
int scale;

/** */
public QueryField() { }

/**
* @param name Field name.
Expand All @@ -61,39 +79,39 @@
* @param name Field name.
* @param typeName Class name for this field's values.
* @param nullable Nullable flag.
* @param dfltValue Default value.
* @param dfltVal Default value.
*/
public QueryField(String name, String typeName, boolean nullable, Object dfltValue) {
this(name, typeName, nullable, dfltValue, -1, -1);
public QueryField(String name, String typeName, boolean nullable, Object dfltVal) {
this(name, typeName, nullable, dfltVal, -1, -1);
}

/**
* @param name Field name.
* @param typeName Class name for this field's values.
* @param nullable Nullable flag.
* @param dfltValue Default value.
* @param dfltVal Default value.
* @param precision Precision.
* @param scale Scale.
*/
public QueryField(String name, String typeName, boolean nullable, Object dfltValue, int precision, int scale) {
this(name, typeName, null, nullable, dfltValue, precision, scale);
public QueryField(String name, String typeName, boolean nullable, Object dfltVal, int precision, int scale) {
this(name, typeName, null, nullable, dfltVal, precision, scale);
}

/**
* @param name Field name.
* @param typeName Class name for this field's values.
* @param alias Alias.
* @param nullable Nullable flag.
* @param dfltValue Default value.
* @param dfltVal Default value.
* @param precision Precision.
* @param scale Scale.
*/
public QueryField(String name, String typeName, String alias, boolean nullable, Object dfltValue, int precision, int scale) {
public QueryField(String name, String typeName, String alias, boolean nullable, Object dfltVal, int precision, int scale) {
this.name = name;
this.typeName = typeName;
this.alias = alias;
this.nullable = nullable;
this.dfltValue = dfltValue;
this.dfltVal = dfltVal;
this.precision = precision;
this.scale = scale;
}
Expand Down Expand Up @@ -130,7 +148,7 @@
* @return Default value.
*/
public Object defaultValue() {
return dfltValue;
return dfltVal;
}

/**
Expand All @@ -147,8 +165,28 @@
return scale;
}

/** {@inheritDoc} */
@Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException {
if (dfltVal != null)
dfltValBytes = U.marshal(marsh, dfltVal);
}

/** {@inheritDoc} */
@Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException {
if (dfltValBytes != null) {
dfltVal = U.unmarshal(marsh, dfltValBytes, clsLdr);

dfltValBytes = null;
}
}

/** {@inheritDoc} */
@Override public String toString() {
return S.toString(QueryField.class, this);
}

/** {@inheritDoc} */
@Override public short directType() {
return -110;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,13 @@

package org.apache.ignite.internal.processors.query.schema.message;

import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.internal.Order;
import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage;
import org.apache.ignite.internal.processors.query.schema.SchemaOperationException;
import org.apache.ignite.internal.processors.query.schema.operation.SchemaAbstractOperation;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.marshaller.Marshallers;
import org.apache.ignite.plugin.extensions.communication.Message;
import org.jetbrains.annotations.Nullable;

Expand All @@ -44,22 +40,16 @@ public abstract class SchemaAbstractDiscoveryMessage implements DiscoveryCustomM

/** Operation. */
@GridToStringInclude
private SchemaAbstractOperation op;

/**
* Operation bytes. Serialized reprezentation of schema operation.
* TODO Should be removed in IGNITE-27559
*/
@Order(value = 1, method = "operationBytes")
byte[] opBytes;
@Order(1)
SchemaAbstractOperation op;

/** Error message. */
@Order(2)
String errMsg;
transient String errMsg;

/** Error code. */
@Order(3)
int errCode;
transient int errCode;

/** Error. */
SchemaOperationException err;
Expand Down Expand Up @@ -92,31 +82,7 @@ protected SchemaAbstractDiscoveryMessage(SchemaAbstractOperation op) {
* @return Operation.
*/
public SchemaAbstractOperation operation() {
try {
return op != null ? op : U.unmarshal(Marshallers.jdk(), opBytes, null);
}
catch (IgniteCheckedException e) {
throw new IgniteException("Failed to unmarshal schema operation", e);
}
}

/**
* @return Operation bytes.
*/
public byte[] operationBytes() {
try {
return opBytes != null ? opBytes : U.marshal(Marshallers.jdk(), op);
}
catch (IgniteCheckedException e) {
throw new IgniteException("Failed to marshal schema operation", e);
}
}

/**
* @param opBytes Operation bytes.
*/
public void operationBytes(byte[] opBytes) {
this.opBytes = opBytes;
return op;
}

/**
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,39 @@

import java.io.Serializable;
import java.util.UUID;
import org.apache.ignite.internal.Order;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.plugin.extensions.communication.Message;

/**
* Abstract operation on schema.
*/
public abstract class SchemaAbstractOperation implements Serializable {
public abstract class SchemaAbstractOperation implements Serializable, Message {
/** */
private static final long serialVersionUID = 0L;

/** Operation ID. */
private final UUID opId;
@Order(0)
UUID opId;

/** Cache name. */
private final String cacheName;
@Order(1)
String cacheName;

/** Schema name. */
private final String schemaName;
@Order(2)
String schemaName;

/** */
protected SchemaAbstractOperation() {}

/**
* Constructor.
*
* @param opId Operation ID.
* @param schemaName Schema name.
*/
public SchemaAbstractOperation(UUID opId, String cacheName, String schemaName) {
protected SchemaAbstractOperation(UUID opId, String cacheName, String schemaName) {
this.opId = opId;
this.cacheName = cacheName;
this.schemaName = schemaName;
Expand Down
Loading
Loading