Author: borges
Date: 2012-02-27 10:04:35 -0500 (Mon, 27 Feb 2012)
New Revision: 12204
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/ReplicationAddMessage.java
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/ReplicationAddTXMessage.java
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/ReplicationPrepareMessage.java
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/ReplicationSyncFileMessage.java
Log:
Add hashCode and equals to replication messages
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/ReplicationAddMessage.java
===================================================================
---
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/ReplicationAddMessage.java 2012-02-27
15:04:14 UTC (rev 12203)
+++
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/ReplicationAddMessage.java 2012-02-27
15:04:35 UTC (rev 12204)
@@ -13,9 +13,10 @@
package org.hornetq.core.protocol.core.impl.wireformat;
+import java.util.Arrays;
+
import org.hornetq.api.core.HornetQBuffer;
import org.hornetq.core.journal.EncodingSupport;
-import org.hornetq.core.logging.Logger;
import org.hornetq.core.protocol.core.impl.PacketImpl;
/**
@@ -28,12 +29,6 @@
public class ReplicationAddMessage extends PacketImpl
{
- // Constants -----------------------------------------------------
-
- private static final Logger log = Logger.getLogger(ReplicationAddMessage.class);
-
- // Attributes ----------------------------------------------------
-
private long id;
/** 0 - Bindings, 1 - MessagesJournal */
@@ -132,12 +127,67 @@
return recordData;
}
- // Package protected ---------------------------------------------
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((encodingData == null) ? 0 : encodingData.hashCode());
+ result = prime * result + (int)(id ^ (id >>> 32));
+ result = prime * result + (isUpdate ? 1231 : 1237);
+ result = prime * result + journalID;
+ result = prime * result + Arrays.hashCode(recordData);
+ result = prime * result + recordType;
+ return result;
+ }
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+ if (!super.equals(obj))
+ {
+ return false;
+ }
+ if (!(obj instanceof ReplicationAddMessage))
+ {
+ return false;
+ }
+ ReplicationAddMessage other = (ReplicationAddMessage)obj;
+ if (encodingData == null)
+ {
+ if (other.encodingData != null)
+ {
+ return false;
+ }
+ }
+ else if (!encodingData.equals(other.encodingData))
+ {
+ return false;
+ }
+ if (id != other.id)
+ {
+ return false;
+ }
+ if (isUpdate != other.isUpdate)
+ {
+ return false;
+ }
+ if (journalID != other.journalID)
+ {
+ return false;
+ }
+ if (!Arrays.equals(recordData, other.recordData))
+ {
+ return false;
+ }
+ if (recordType != other.recordType)
+ {
+ return false;
+ }
+ return true;
+ }
}
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/ReplicationAddTXMessage.java
===================================================================
---
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/ReplicationAddTXMessage.java 2012-02-27
15:04:14 UTC (rev 12203)
+++
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/ReplicationAddTXMessage.java 2012-02-27
15:04:35 UTC (rev 12204)
@@ -13,6 +13,8 @@
package org.hornetq.core.protocol.core.impl.wireformat;
+import java.util.Arrays;
+
import org.hornetq.api.core.HornetQBuffer;
import org.hornetq.core.journal.EncodingSupport;
import org.hornetq.core.protocol.core.impl.PacketImpl;
@@ -140,12 +142,72 @@
return recordData;
}
- // Package protected ---------------------------------------------
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((encodingData == null) ? 0 : encodingData.hashCode());
+ result = prime * result + (int)(id ^ (id >>> 32));
+ result = prime * result + (isUpdate ? 1231 : 1237);
+ result = prime * result + journalID;
+ result = prime * result + Arrays.hashCode(recordData);
+ result = prime * result + recordType;
+ result = prime * result + (int)(txId ^ (txId >>> 32));
+ return result;
+ }
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+ if (!super.equals(obj))
+ {
+ return false;
+ }
+ if (!(obj instanceof ReplicationAddTXMessage))
+ {
+ return false;
+ }
+ ReplicationAddTXMessage other = (ReplicationAddTXMessage)obj;
+ if (encodingData == null)
+ {
+ if (other.encodingData != null)
+ {
+ return false;
+ }
+ }
+ else if (!encodingData.equals(other.encodingData))
+ {
+ return false;
+ }
+ if (id != other.id)
+ {
+ return false;
+ }
+ if (isUpdate != other.isUpdate)
+ {
+ return false;
+ }
+ if (journalID != other.journalID)
+ {
+ return false;
+ }
+ if (!Arrays.equals(recordData, other.recordData))
+ {
+ return false;
+ }
+ if (recordType != other.recordType)
+ {
+ return false;
+ }
+ if (txId != other.txId)
+ {
+ return false;
+ }
+ return true;
+ }
}
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/ReplicationPrepareMessage.java
===================================================================
---
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/ReplicationPrepareMessage.java 2012-02-27
15:04:14 UTC (rev 12203)
+++
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/ReplicationPrepareMessage.java 2012-02-27
15:04:35 UTC (rev 12204)
@@ -13,6 +13,8 @@
package org.hornetq.core.protocol.core.impl.wireformat;
+import java.util.Arrays;
+
import org.hornetq.api.core.HornetQBuffer;
import org.hornetq.core.journal.EncodingSupport;
import org.hornetq.core.protocol.core.impl.PacketImpl;
@@ -99,12 +101,57 @@
return recordData;
}
- // Package protected ---------------------------------------------
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((encodingData == null) ? 0 : encodingData.hashCode());
+ result = prime * result + journalID;
+ result = prime * result + Arrays.hashCode(recordData);
+ result = prime * result + (int)(txId ^ (txId >>> 32));
+ return result;
+ }
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+ if (!super.equals(obj))
+ {
+ return false;
+ }
+ if (!(obj instanceof ReplicationPrepareMessage))
+ {
+ return false;
+ }
+ ReplicationPrepareMessage other = (ReplicationPrepareMessage)obj;
+ if (encodingData == null)
+ {
+ if (other.encodingData != null)
+ {
+ return false;
+ }
+ }
+ else if (!encodingData.equals(other.encodingData))
+ {
+ return false;
+ }
+ if (journalID != other.journalID)
+ {
+ return false;
+ }
+ if (!Arrays.equals(recordData, other.recordData))
+ {
+ return false;
+ }
+ if (txId != other.txId)
+ {
+ return false;
+ }
+ return true;
+ }
}
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/ReplicationSyncFileMessage.java
===================================================================
---
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/ReplicationSyncFileMessage.java 2012-02-27
15:04:14 UTC (rev 12203)
+++
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/ReplicationSyncFileMessage.java 2012-02-27
15:04:35 UTC (rev 12204)
@@ -1,6 +1,7 @@
package org.hornetq.core.protocol.core.impl.wireformat;
import java.nio.ByteBuffer;
+import java.util.Arrays;
import java.util.EnumSet;
import java.util.Set;
@@ -182,4 +183,80 @@
{
return pageStoreName;
}
+
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + Arrays.hashCode(byteArray);
+ result = prime * result + ((byteBuffer == null) ? 0 : byteBuffer.hashCode());
+ result = prime * result + dataSize;
+ result = prime * result + (int)(fileId ^ (fileId >>> 32));
+ result = prime * result + ((fileType == null) ? 0 : fileType.hashCode());
+ result = prime * result + ((journalType == null) ? 0 : journalType.hashCode());
+ result = prime * result + ((pageStoreName == null) ? 0 :
pageStoreName.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+ if (!super.equals(obj))
+ {
+ return false;
+ }
+ if (!(obj instanceof ReplicationSyncFileMessage))
+ {
+ return false;
+ }
+ ReplicationSyncFileMessage other = (ReplicationSyncFileMessage)obj;
+ if (!Arrays.equals(byteArray, other.byteArray))
+ {
+ return false;
+ }
+ if (byteBuffer == null)
+ {
+ if (other.byteBuffer != null)
+ {
+ return false;
+ }
+ }
+ else if (!byteBuffer.equals(other.byteBuffer))
+ {
+ return false;
+ }
+ if (dataSize != other.dataSize)
+ {
+ return false;
+ }
+ if (fileId != other.fileId)
+ {
+ return false;
+ }
+ if (fileType != other.fileType)
+ {
+ return false;
+ }
+ if (journalType != other.journalType)
+ {
+ return false;
+ }
+ if (pageStoreName == null)
+ {
+ if (other.pageStoreName != null)
+ {
+ return false;
+ }
+ }
+ else if (!pageStoreName.equals(other.pageStoreName))
+ {
+ return false;
+ }
+ return true;
+ }
}
Show replies by date