Skip to content
Browse files

Added Externalizable to UUID (https://issues.jboss.org/browse/JGRP-1407)

  • Loading branch information...
1 parent face2c8 commit ef4c3a3a8986768a86cf2cb26cbc70c12b4bcb5e @belaban committed Dec 28, 2011
View
1 src/org/jgroups/blocks/MethodCall.java
@@ -20,7 +20,6 @@
* It includes the name of the method (case sensitive) and a list of arguments.
* A method call is serializable and can be passed over the wire.
* @author Bela Ban
- * @version $Revision: 1.39 $
*/
public class MethodCall implements Externalizable {
View
10 src/org/jgroups/demos/wb/GraphPanel.java
@@ -56,7 +56,7 @@ Node findNodeAtPoint(Point p) {
if(nodes.size() < 1)
return null;
for(int i=nodes.size() - 1; i >= 0; i--) {
- n=(Node)nodes.get(i);
+ n=nodes.get(i);
if(x >= n.xloc && x <= (n.xloc + n.width) && y >= n.yloc && y <= (n.yloc + n.height))
return n;
}
@@ -94,7 +94,7 @@ public void removeNode(Object addr) {
synchronized(nodes) {
for(int i=0; i < nodes.size(); i++) {
- n=(Node)nodes.get(i);
+ n=nodes.get(i);
a=n.addr;
if(a == null)
continue;
@@ -116,7 +116,7 @@ public void adjustNodes(java.util.List<Address> v) {
synchronized(nodes) {
for(int i=0; i < nodes.size(); i++) {
- n=(Node)nodes.get(i);
+ n=nodes.get(i);
if(!v.contains(n.addr)) {
System.out.println("adjustNodes(): node " + n + " was removed");
nodes.remove(n);
@@ -170,7 +170,7 @@ public synchronized void update(Graphics g) {
FontMetrics fm=offgraphics.getFontMetrics();
for(int i=0; i < nodes.size(); i++) {
- paintNode(offgraphics, (Node)nodes.get(i), fm);
+ paintNode(offgraphics, nodes.get(i), fm);
}
g.drawImage(offscreen, 0, 0, null);
@@ -209,7 +209,7 @@ public void mousePressed(MouseEvent e) {
for(int i=0; i < nodes.size(); i++) {
- n=(Node)nodes.get(i);
+ n=nodes.get(i);
dist=(n.x - p.x) * (n.x - p.x) + (n.y - p.y) * (n.y - p.y);
if(dist < bestdist) {
pick=n;
View
13 src/org/jgroups/util/UUID.java
@@ -16,7 +16,7 @@
*
* @author Bela Ban
*/
-public class UUID implements Address, Streamable, Comparable<Address> {
+public class UUID implements Address, Streamable, Comparable<Address>, Externalizable {
protected long mostSigBits;
protected long leastSigBits;
@@ -267,6 +267,16 @@ public void readFrom(DataInput in) throws Exception {
mostSigBits=in.readLong();
}
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeLong(leastSigBits);
+ out.writeLong(mostSigBits);
+ }
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ leastSigBits=in.readLong();
+ mostSigBits=in.readLong();
+ }
+
public int size() {
return SIZE;
@@ -276,4 +286,5 @@ public UUID copy() {
return new UUID(mostSigBits, leastSigBits);
}
+
}
View
10 tests/junit-functional/org/jgroups/tests/MethodCallTest.java
@@ -2,6 +2,7 @@
package org.jgroups.tests;
+import org.jgroups.Address;
import org.jgroups.Global;
import org.jgroups.blocks.MethodCall;
import org.jgroups.util.Util;
@@ -253,6 +254,15 @@ public static void testMarshalling() throws Exception {
System.out.println("m: " + m);
}
+ public static void testMarshalling2() throws Exception {
+ Address addr=Util.createRandomAddress("A");
+ MethodCall call=new MethodCall("foo",
+ new Object[]{"hello", 23, addr},
+ new Class[]{String.class, int.class, Address.class});
+ MethodCall m=marshalAndUnmarshal(call);
+ System.out.println("m = " + m);
+ }
+
private static MethodCall marshalAndUnmarshal(MethodCall m) throws Exception {
byte[] buf=Util.objectToByteBuffer(m);

0 comments on commit ef4c3a3

Please sign in to comment.
Something went wrong with that request. Please try again.