Skip to content
Open
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 @@ -18,6 +18,8 @@
package org.apache.ignite.internal.managers.discovery;

import org.apache.ignite.internal.codegen.DiscoveryDataPacketSerializer;
import org.apache.ignite.internal.codegen.DistributedMetaStorageCasAckMessageSerializer;
import org.apache.ignite.internal.codegen.DistributedMetaStorageUpdateAckMessageSerializer;
import org.apache.ignite.internal.codegen.InetAddressMessageSerializer;
import org.apache.ignite.internal.codegen.InetSocketAddressMessageSerializer;
import org.apache.ignite.internal.codegen.NodeSpecificDataSerializer;
Expand Down Expand Up @@ -45,6 +47,8 @@
import org.apache.ignite.internal.codegen.TcpDiscoveryPingResponseSerializer;
import org.apache.ignite.internal.codegen.TcpDiscoveryRingLatencyCheckMessageSerializer;
import org.apache.ignite.internal.codegen.TcpDiscoveryStatusCheckMessageSerializer;
import org.apache.ignite.internal.processors.metastorage.persistence.DistributedMetaStorageCasAckMessage;
import org.apache.ignite.internal.processors.metastorage.persistence.DistributedMetaStorageUpdateAckMessage;
import org.apache.ignite.plugin.extensions.communication.MessageFactory;
import org.apache.ignite.plugin.extensions.communication.MessageFactoryProvider;
import org.apache.ignite.spi.discovery.tcp.internal.DiscoveryDataPacket;
Expand Down Expand Up @@ -110,5 +114,7 @@ public class DiscoveryMessageFactory implements MessageFactoryProvider {
factory.register((short)17, TcpDiscoveryNodeFailedMessage::new, new TcpDiscoveryNodeFailedMessageSerializer());
factory.register((short)18, TcpDiscoveryStatusCheckMessage::new, new TcpDiscoveryStatusCheckMessageSerializer());
factory.register((short)19, TcpDiscoveryNodeAddFinishedMessage::new, new TcpDiscoveryNodeAddFinishedMessageSerializer());
factory.register((short)20, DistributedMetaStorageUpdateAckMessage::new, new DistributedMetaStorageUpdateAckMessageSerializer());
factory.register((short)21, DistributedMetaStorageCasAckMessage::new, new DistributedMetaStorageCasAckMessageSerializer());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,27 @@
package org.apache.ignite.internal.processors.metastorage.persistence;

import java.util.UUID;
import org.apache.ignite.internal.Order;
import org.apache.ignite.internal.managers.discovery.DiscoveryMessageFactory;
import org.apache.ignite.internal.util.typedef.internal.S;

/** */
class DistributedMetaStorageCasAckMessage extends DistributedMetaStorageUpdateAckMessage {
public class DistributedMetaStorageCasAckMessage extends DistributedMetaStorageUpdateAckMessage {
/** */
private static final long serialVersionUID = 0L;

/** */
private final boolean updated;
@Order(2)
private boolean updated;

/** Empty constructor of {@link DiscoveryMessageFactory}. */
public DistributedMetaStorageCasAckMessage() {
// No-op.
}

/** */
public DistributedMetaStorageCasAckMessage(UUID reqId, String errorMsg, boolean updated) {
super(reqId, errorMsg);
public DistributedMetaStorageCasAckMessage(UUID reqId, boolean updated) {
super(reqId);

this.updated = updated;
}
Expand All @@ -40,6 +48,16 @@ public boolean updated() {
return updated;
}

/** */
public void updated(boolean updated) {
this.updated = updated;
}

/** {@inheritDoc} */
@Override public short directType() {
return 21;
}

/** {@inheritDoc} */
@Override public String toString() {
return S.toString(DistributedMetaStorageCasAckMessage.class, this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public boolean matches() {

/** {@inheritDoc} */
@Override @Nullable public DiscoveryCustomMessage ackMessage() {
return new DistributedMetaStorageCasAckMessage(requestId(), errorMessage(), matches);
return new DistributedMetaStorageCasAckMessage(requestId(), matches);
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1128,9 +1128,6 @@ private void onUpdateMessage(
ClusterNode node,
DistributedMetaStorageUpdateMessage msg
) {
if (msg.errorMessage() != null)
return;

lock.writeLock().lock();

try {
Expand Down Expand Up @@ -1166,17 +1163,11 @@ private void onAckMessage(
GridFutureAdapter<Boolean> fut = updateFuts.remove(msg.requestId());

if (fut != null) {
String errorMsg = msg.errorMessage();

if (errorMsg == null) {
Boolean res = msg instanceof DistributedMetaStorageCasAckMessage
? ((DistributedMetaStorageCasAckMessage)msg).updated()
: null;
Boolean res = msg instanceof DistributedMetaStorageCasAckMessage
? ((DistributedMetaStorageCasAckMessage)msg).updated()
: null;

fut.onDone(res);
}
else
fut.onDone(new IllegalStateException(errorMsg));
fut.onDone(res);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,47 +18,59 @@
package org.apache.ignite.internal.processors.metastorage.persistence;

import java.util.UUID;
import org.apache.ignite.internal.Order;
import org.apache.ignite.internal.managers.discovery.DiscoCache;
import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage;
import org.apache.ignite.internal.managers.discovery.DiscoveryMessageFactory;
import org.apache.ignite.internal.managers.discovery.GridDiscoveryManager;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.plugin.extensions.communication.Message;
import org.jetbrains.annotations.Nullable;

/** */
class DistributedMetaStorageUpdateAckMessage implements DiscoveryCustomMessage {
public class DistributedMetaStorageUpdateAckMessage implements DiscoveryCustomMessage, Message {
/** */
private static final long serialVersionUID = 0L;

/** */
private final IgniteUuid id = IgniteUuid.randomUuid();
@Order(0)
private IgniteUuid id;

/** Request ID. */
private final UUID reqId;
@Order(value = 1, method = "requestId")
private UUID reqId;

/** */
private final String errorMsg;
/** Empty constructor of {@link DiscoveryMessageFactory}. */
public DistributedMetaStorageUpdateAckMessage() {
// No-op.
}

/** */
public DistributedMetaStorageUpdateAckMessage(UUID reqId, String errorMsg) {
public DistributedMetaStorageUpdateAckMessage(UUID reqId) {
id = IgniteUuid.randomUuid();
this.reqId = reqId;
this.errorMsg = errorMsg;
}

/** {@inheritDoc} */
@Override public IgniteUuid id() {
return id;
}

/** */
/** @param id Message id. */
public void id(IgniteUuid id) {
this.id = id;
}

/** @return Request ID. */
public UUID requestId() {
return reqId;
}

/** */
public String errorMessage() {
return errorMsg;
/** @param reqId Request ID. */
public void requestId(UUID reqId) {
this.reqId = reqId;
}

/** {@inheritDoc} */
Expand All @@ -80,6 +92,11 @@ public String errorMessage() {
throw new UnsupportedOperationException();
}

/** {@inheritDoc} */
@Override public short directType() {
return 20;
}

/** {@inheritDoc} */
@Override public String toString() {
return S.toString(DistributedMetaStorageUpdateAckMessage.class, this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ class DistributedMetaStorageUpdateMessage implements DiscoveryCustomMessage {
/** */
private final byte[] valBytes;

/** */
private String errorMsg;

/** */
public DistributedMetaStorageUpdateMessage(UUID reqId, String key, byte[] valBytes) {
this.reqId = reqId;
Expand Down Expand Up @@ -81,19 +78,9 @@ public boolean isAckMessage() {
return false;
}

/** */
public void errorMessage(String errorMsg) {
this.errorMsg = errorMsg;
}

/** */
protected String errorMessage() {
return errorMsg;
}

/** {@inheritDoc} */
@Override @Nullable public DiscoveryCustomMessage ackMessage() {
return new DistributedMetaStorageUpdateAckMessage(reqId, errorMsg);
return new DistributedMetaStorageUpdateAckMessage(reqId);
}

/** {@inheritDoc} */
Expand Down