Skip to content

Commit 3657a4a

Browse files
committed
Fix binary
1 parent a8e1a42 commit 3657a4a

3 files changed

Lines changed: 19 additions & 39 deletions

File tree

modules/core/src/main/java/org/apache/ignite/internal/CoreMessagesProvider.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ public CoreMessagesProvider(Marshaller dfltMarsh, Marshaller schemaAwareMarsh, C
632632
withNoSchema(MetadataRequestMessage.class);
633633
withNoSchema(MetadataResponseMessage.class);
634634
withNoSchema(MarshallerMappingItem.class);
635-
withNoSchema(BinaryMetadataVersionInfo.class);
635+
withSchemaResolvedClassLoader(BinaryMetadataVersionInfo.class);
636636
withNoSchema(BinaryMetadataVersionsData.class);
637637
withNoSchema(MappedName.class);
638638
withNoSchema(MarshallerMappingsData.class);
@@ -674,6 +674,11 @@ private <T extends Message> void withNoSchemaResolvedClassLoader(Class<T> cls) {
674674
register(cls, dfltMarsh, resolvedClsLdr);
675675
}
676676

677+
/** Registers message using {@link #schemaAwareMarsh} and {@link #resolvedClsLdr}. */
678+
private <T extends Message> void withSchemaResolvedClassLoader(Class<T> cls) {
679+
register(cls, schemaAwareMarsh, resolvedClsLdr);
680+
}
681+
677682
/** Registers message using incrementing {@link #msgIdx} as the message id/type. */
678683
private <T extends Message> void register(Class<T> cls, Marshaller marsh, ClassLoader clsLrd) {
679684
register(factory, cls, msgIdx++, marsh, clsLrd);

modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataTransport.java

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -841,15 +841,6 @@ private final class MetadataRequestListener implements GridMessageListener {
841841

842842
MetadataResponseMessage resp = new MetadataResponseMessage(typeId);
843843

844-
if (metaVerInfo != null) {
845-
try {
846-
metaVerInfo.marshalMetadata();
847-
}
848-
catch (IgniteCheckedException e) {
849-
U.error(log, "Failed to marshal binary metadata for [typeId=" + typeId + ']', e);
850-
}
851-
}
852-
853844
resp.metadataVersionInfo(metaVerInfo);
854845

855846
try {
@@ -890,16 +881,9 @@ private final class MetadataResponseListener implements GridMessageListener {
890881
return;
891882
}
892883

893-
try {
894-
metaVerInfo.unmarshalMetadata();
895-
896-
casBinaryMetadata(typeId, metaVerInfo);
884+
casBinaryMetadata(typeId, metaVerInfo);
897885

898-
fut.onDone(MetadataUpdateResult.createSuccessfulResult(-1));
899-
}
900-
catch (IgniteCheckedException e) {
901-
fut.onDone(MetadataUpdateResult.createFailureResult(new BinaryObjectException(e)));
902-
}
886+
fut.onDone(MetadataUpdateResult.createSuccessfulResult(-1));
903887
}
904888
}
905889

modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataVersionInfo.java

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,19 @@
1818

1919
import java.io.Serializable;
2020
import org.apache.ignite.IgniteCheckedException;
21+
import org.apache.ignite.internal.MarshallableMessage;
2122
import org.apache.ignite.internal.Order;
2223
import org.apache.ignite.internal.binary.BinaryMetadata;
2324
import org.apache.ignite.internal.util.typedef.internal.U;
24-
import org.apache.ignite.plugin.extensions.communication.Message;
25-
26-
import static org.apache.ignite.marshaller.Marshallers.jdk;
25+
import org.apache.ignite.marshaller.Marshaller;
2726

2827
/**
2928
* Wrapper for {@link BinaryMetadata} which is stored in metadata local cache on each node.
3029
* Used internally to track version counters (see javadoc for {@link MetadataUpdateProposedMessage} for more details).
3130
* The version refers solely to the internal protocol for updating BinaryMetadata and is unknown externally.
3231
* It can be updated dynamically from different nodes and threads on the same node.
3332
*/
34-
public final class BinaryMetadataVersionInfo implements Serializable, Message {
33+
public final class BinaryMetadataVersionInfo implements Serializable, MarshallableMessage {
3534
/** */
3635
private static final long serialVersionUID = 0L;
3736

@@ -130,24 +129,16 @@ boolean removing() {
130129
return removing;
131130
}
132131

133-
/**
134-
* Marshals binary metadata to byte array.
135-
*
136-
* @throws IgniteCheckedException If failed.
137-
*/
138-
public void marshalMetadata() throws IgniteCheckedException {
139-
if (metadataBytes == null)
140-
metadataBytes = U.marshal(jdk(), metadata);
132+
/** {@inheritDoc} */
133+
@Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException {
134+
if (metadata != null)
135+
metadataBytes = U.marshal(marsh, metadata);
141136
}
142137

143-
/**
144-
* Unmarshals binary metadata from byte array.
145-
*
146-
* @throws IgniteCheckedException If failed.
147-
*/
148-
public void unmarshalMetadata() throws IgniteCheckedException {
149-
if (metadata == null && metadataBytes != null) {
150-
metadata = U.unmarshal(jdk(), metadataBytes, U.gridClassLoader());
138+
/** {@inheritDoc} */
139+
@Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException {
140+
if (metadataBytes != null) {
141+
metadata = U.unmarshal(marsh, metadataBytes, clsLdr);
151142

152143
// It is not required anymore.
153144
metadataBytes = null;

0 commit comments

Comments
 (0)