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 @@ -346,6 +346,7 @@ public CoreMessagesProvider(Marshaller dfltMarsh, Marshaller schemaAwareMarsh, C
withNoSchema(GridCacheVersion.class);
withNoSchema(GridCacheVersionEx.class);
withNoSchema(WALPointer.class);
withSchema(GridTopicMessage.class);

// [5700 - 5900]: Discovery originated messages.
msgIdx = 5700;
Expand Down Expand Up @@ -584,7 +585,7 @@ public CoreMessagesProvider(Marshaller dfltMarsh, Marshaller schemaAwareMarsh, C
withNoSchema(NodeIdMessage.class);
withNoSchema(HandshakeMessage.class);
withNoSchema(HandshakeWaitMessage.class);
withSchema(GridIoMessage.class);
withNoSchema(GridIoMessage.class);
withNoSchema(IgniteIoTestMessage.class);
withSchema(GridIoUserMessage.class);
withSchema(GridIoSecurityAwareMessage.class);
Expand Down
218 changes: 13 additions & 205 deletions modules/core/src/main/java/org/apache/ignite/internal/GridTopic.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.io.ObjectOutput;
import java.io.Serializable;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.UUID;
import org.apache.ignite.internal.util.distributed.DistributedProcess;
import org.apache.ignite.internal.util.typedef.internal.S;
Expand Down Expand Up @@ -161,7 +162,7 @@ public enum GridTopic {
private static final GridTopic[] VALS = values();

/** Default charset to work with strings. */
private static final Charset DFLT_CHARSET = Charset.forName("UTF-8");
private static final Charset DFLT_CHARSET = StandardCharsets.UTF_8;

/**
* Efficiently gets enumerated value from its ordinal.
Expand All @@ -177,7 +178,7 @@ public enum GridTopic {
* @param id Topic ID.
* @return Grid message topic with specified ID.
*/
public T1 topic(IgniteUuid id) {
public Object topic(IgniteUuid id) {
return new T1(this, id);
}

Expand Down Expand Up @@ -219,16 +220,6 @@ public Object topic(String id1, long id2) {
return new T6(this, UUID.nameUUIDFromBytes(id1.getBytes(DFLT_CHARSET)), id2);
}

/**
* @param id1 ID1.
* @param id2 ID2.
* @param id3 ID3.
* @return Grid message topic with specified IDs.
*/
public Object topic(String id1, int id2, long id3) {
return new T5(this, UUID.nameUUIDFromBytes(id1.getBytes(DFLT_CHARSET)), id2, id3);
}

/**
* @param id1 ID1.
* @param id2 ID2.
Expand All @@ -239,19 +230,8 @@ public Object topic(String id1, UUID id2, long id3) {
return new T4(this, UUID.nameUUIDFromBytes(id1.getBytes(DFLT_CHARSET)), id2, id3);
}

/**
* @param id1 ID1.
* @param id2 ID2.
* @param id3 ID3.
* @param id4 ID4.
* @return Grid message topic with specified IDs.
*/
public Object topic(String id1, UUID id2, int id3, long id4) {
return new T7(this, UUID.nameUUIDFromBytes(id1.getBytes(DFLT_CHARSET)), id2, id3, id4);
}

/** */
public static class T1 implements Externalizable {
private static class T1 implements Externalizable {
/** */
private static final long serialVersionUID = 0L;

Expand All @@ -272,21 +252,11 @@ public T1() {
* @param topic Topic.
* @param id ID.
*/
public T1(GridTopic topic, IgniteUuid id) {
private T1(GridTopic topic, IgniteUuid id) {
this.topic = topic;
this.id = id;
}

/** */
public GridTopic topic() {
return topic;
}

/** */
public IgniteUuid id() {
return id;
}

/** {@inheritDoc} */
@Override public int hashCode() {
return topic.ordinal() + id.hashCode();
Expand Down Expand Up @@ -379,7 +349,7 @@ private T2(GridTopic topic, IgniteUuid id1, UUID id2) {
}

/** {@inheritDoc} */
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
@Override public void readExternal(ObjectInput in) throws IOException {
topic = fromOrdinal(in.readByte());
id1 = U.readIgniteUuid(in);
id2 = U.readUuid(in);
Expand Down Expand Up @@ -443,7 +413,7 @@ private T3(GridTopic topic, UUID id1) {
}

/** {@inheritDoc} */
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
@Override public void readExternal(ObjectInput in) throws IOException {
topic = fromOrdinal(in.readByte());
id1 = U.readUuid(in);
}
Expand Down Expand Up @@ -495,7 +465,7 @@ private T4(GridTopic topic, UUID id1, UUID id2, long id3) {

/** {@inheritDoc} */
@Override public int hashCode() {
return topic.ordinal() + id1.hashCode() + id2.hashCode() + (int)(id3 ^ (id3 >>> 32));
return topic.ordinal() + id1.hashCode() + id2.hashCode() + Long.hashCode(id3);
}

/** {@inheritDoc} */
Expand All @@ -518,7 +488,7 @@ private T4(GridTopic topic, UUID id1, UUID id2, long id3) {
}

/** {@inheritDoc} */
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
@Override public void readExternal(ObjectInput in) throws IOException {
topic = fromOrdinal(in.readByte());
id1 = U.readUuid(in);
id2 = U.readUuid(in);
Expand All @@ -531,83 +501,6 @@ private T4(GridTopic topic, UUID id1, UUID id2, long id3) {
}
}

/**
*
*/
private static class T5 implements Externalizable {
/** */
private static final long serialVersionUID = 0L;

/** */
private GridTopic topic;

/** */
private UUID id1;

/** */
private int id2;

/** */
private long id3;

/**
* No-arg constructor needed for {@link Serializable}.
*/
public T5() {
// No-op.
}

/**
* @param topic Topic.
* @param id1 ID1.
* @param id2 ID2.
* @param id3 ID3.
*/
private T5(GridTopic topic, UUID id1, int id2, long id3) {
this.topic = topic;
this.id1 = id1;
this.id2 = id2;
this.id3 = id3;
}

/** {@inheritDoc} */
@Override public int hashCode() {
return topic.ordinal() + id1.hashCode() + id2 + (int)(id3 ^ (id3 >>> 32));
}

/** {@inheritDoc} */
@Override public boolean equals(Object obj) {
if (obj.getClass() == T5.class) {
T5 that = (T5)obj;

return topic == that.topic && id1.equals(that.id1) && id2 == that.id2 && id3 == that.id3;
}

return false;
}

/** {@inheritDoc} */
@Override public void writeExternal(ObjectOutput out) throws IOException {
out.writeByte(topic.ordinal());
U.writeUuid(out, id1);
out.writeInt(id2);
out.writeLong(id3);
}

/** {@inheritDoc} */
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
topic = fromOrdinal(in.readByte());
id1 = U.readUuid(in);
id2 = in.readInt();
id3 = in.readLong();
}

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

/**
*
*/
Expand Down Expand Up @@ -644,7 +537,7 @@ private T6(GridTopic topic, UUID id1, long id2) {

/** {@inheritDoc} */
@Override public int hashCode() {
return topic.ordinal() + id1.hashCode() + (int)(id2 ^ (id2 >>> 32));
return topic.ordinal() + id1.hashCode() + Long.hashCode(id2);
}

/** {@inheritDoc} */
Expand All @@ -666,7 +559,7 @@ private T6(GridTopic topic, UUID id1, long id2) {
}

/** {@inheritDoc} */
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
@Override public void readExternal(ObjectInput in) throws IOException {
topic = fromOrdinal(in.readByte());
id1 = U.readUuid(in);
id2 = in.readLong();
Expand All @@ -678,91 +571,6 @@ private T6(GridTopic topic, UUID id1, long id2) {
}
}

/**
*
*/
private static class T7 implements Externalizable {
/** */
private static final long serialVersionUID = 0L;

/** */
private GridTopic topic;

/** */
private UUID id1;

/** */
private UUID id2;

/** */
private int id3;

/** */
private long id4;

/**
* No-arg constructor needed for {@link Serializable}.
*/
public T7() {
// No-op.
}

/**
* @param topic Topic.
* @param id1 ID1.
* @param id2 ID2.
* @param id3 ID3.
* @param id4 ID4.
*/
private T7(GridTopic topic, UUID id1, UUID id2, int id3, long id4) {
this.topic = topic;
this.id1 = id1;
this.id2 = id2;
this.id3 = id3;
this.id4 = id4;
}

/** {@inheritDoc} */
@Override public int hashCode() {
return topic.ordinal() + id1.hashCode() + id2.hashCode() + id3 + (int)(id4 ^ (id4 >>> 32));
}

/** {@inheritDoc} */
@Override public boolean equals(Object obj) {
if (obj.getClass() == T7.class) {
T7 that = (T7)obj;

return topic == that.topic && id1.equals(that.id1) && id2.equals(that.id2) && id3 == that.id3 &&
id4 == that.id4;
}

return false;
}

/** {@inheritDoc} */
@Override public void writeExternal(ObjectOutput out) throws IOException {
out.writeByte(topic.ordinal());
U.writeUuid(out, id1);
U.writeUuid(out, id2);
out.writeInt(id3);
out.writeLong(id4);
}

/** {@inheritDoc} */
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
topic = fromOrdinal(in.readByte());
id1 = U.readUuid(in);
id2 = U.readUuid(in);
id3 = in.readInt();
id4 = in.readLong();
}

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

/**
*
*/
Expand Down Expand Up @@ -799,7 +607,7 @@ private T8(GridTopic topic, IgniteUuid id1, long id2) {

/** {@inheritDoc} */
@Override public int hashCode() {
return topic.ordinal() + id1.hashCode() + (int)(id2 ^ (id2 >>> 32));
return topic.ordinal() + id1.hashCode() + Long.hashCode(id2);
}

/** {@inheritDoc} */
Expand All @@ -821,7 +629,7 @@ private T8(GridTopic topic, IgniteUuid id1, long id2) {
}

/** {@inheritDoc} */
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
@Override public void readExternal(ObjectInput in) throws IOException {
topic = fromOrdinal(in.readByte());
id1 = U.readIgniteUuid(in);
id2 = in.readLong();
Expand Down
Loading
Loading