# IGNITE-61 - JavaDoc

Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/9b6ad0e4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/9b6ad0e4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/9b6ad0e4

Branch: refs/heads/ignite-96
Commit: 9b6ad0e4c22117bd1b9bb91cea2b22ece63ce639
Parents: c82d0a2
Author: Valentin Kulichenko <vkuliche...@gridgain.com>
Authored: Sun Feb 8 20:20:15 2015 -0800
Committer: Valentin Kulichenko <vkuliche...@gridgain.com>
Committed: Sun Feb 8 20:20:15 2015 -0800

----------------------------------------------------------------------
 .../communication/MessageAdapter.java           |  30 +--
 .../communication/MessageFactory.java           |  14 +-
 .../extensions/communication/MessageReader.java | 172 ++++++++++++++++-
 .../communication/MessageReaderFactory.java     |  10 +-
 .../extensions/communication/MessageWriter.java | 188 ++++++++++++++++++-
 .../communication/MessageWriterFactory.java     |  10 +-
 6 files changed, 407 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9b6ad0e4/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageAdapter.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageAdapter.java
 
b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageAdapter.java
index d393e16..0603d67 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageAdapter.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageAdapter.java
@@ -21,23 +21,23 @@ import java.io.*;
 import java.nio.*;
 
 /**
- * Communication message adapter.
+ * Base class for all communication messages.
  */
 public abstract class MessageAdapter implements Serializable, Cloneable {
-    /** Writer. */
+    /** Message writer. */
     protected MessageWriter writer;
 
-    /** Reader. */
+    /** Message reader. */
     protected MessageReader reader;
 
-    /** */
+    /** Whether message type is already written. */
     protected boolean typeWritten;
 
-    /** */
+    /** Current write/read state. */
     protected int state;
 
     /**
-     * @param writer Writer.
+     * @param writer Message writer.
      */
     public final void setWriter(MessageWriter writer) {
         if (this.writer == null)
@@ -45,7 +45,7 @@ public abstract class MessageAdapter implements Serializable, 
Cloneable {
     }
 
     /**
-     * @param reader Reader.
+     * @param reader Message reader.
      */
     public final void setReader(MessageReader reader) {
         if (this.reader == null)
@@ -53,18 +53,24 @@ public abstract class MessageAdapter implements 
Serializable, Cloneable {
     }
 
     /**
+     * Writes this message to provided byte buffer.
+     *
      * @param buf Byte buffer.
      * @return Whether message was fully written.
      */
     public abstract boolean writeTo(ByteBuffer buf);
 
     /**
+     * Reads this message from provided byte buffer.
+     *
      * @param buf Byte buffer.
      * @return Whether message was fully read.
      */
     public abstract boolean readFrom(ByteBuffer buf);
 
     /**
+     * Gets message type.
+     *
      * @return Message type.
      */
     public abstract byte directType();
@@ -74,14 +80,16 @@ public abstract class MessageAdapter implements 
Serializable, Cloneable {
     @Override public abstract MessageAdapter clone();
 
     /**
-     * Clones all fields of the provided message to {@code this}.
+     * Clones all fields of the provided message to this message.
      *
-     * @param _msg Message to clone from.
+     * @param msg Message to clone from.
      */
-    protected abstract void clone0(MessageAdapter _msg);
+    protected abstract void clone0(MessageAdapter msg);
 
     /**
-     * @return {@code True} if should skip recovery for this message.
+     * Defines whether recovery for this message should be skipped.
+     *
+     * @return Whether recovery for this message should be skipped.
      */
     public boolean skipRecovery() {
         return false;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9b6ad0e4/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageFactory.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageFactory.java
 
b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageFactory.java
index d443209..f1aceda 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageFactory.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageFactory.java
@@ -18,14 +18,24 @@
 package org.apache.ignite.plugin.extensions.communication;
 
 import org.apache.ignite.plugin.*;
+import org.jetbrains.annotations.*;
 
 /**
- *
+ * Factory for communication messages.
+ * <p>
+ * A plugin can provide his own message factory as an extension
+ * if it uses any custom messages (all message must extend
+ * {@link MessageAdapter} class).
  */
 public interface MessageFactory extends Extension {
     /**
+     * Creates new message instance of provided type.
+     * <p>
+     * This method should return {@code null} if provided message type
+     * is unknown to this factory.
+     *
      * @param type Message type.
      * @return Message instance.
      */
-    public MessageAdapter create(byte type);
+    @Nullable public MessageAdapter create(byte type);
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9b6ad0e4/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java
 
b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java
index 5584ae7..a2c1a68 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java
@@ -23,60 +23,230 @@ import java.nio.*;
 import java.util.*;
 
 /**
- * TODO
+ * Communication message reader.
+ * <p>
+ * Allows to customize the binary format of communication messages.
  */
 public interface MessageReader {
+    /**
+     * Sets but buffer to read from.
+     *
+     * @param buf Byte buffer.
+     */
     public void setBuffer(ByteBuffer buf);
 
+    /**
+     * Reads {@code byte} value.
+     *
+     * @param name Field name.
+     * @return {@code byte} value.
+     */
     public byte readByte(String name);
 
+    /**
+     * Reads {@code short} value.
+     *
+     * @param name Field name.
+     * @return {@code short} value.
+     */
     public short readShort(String name);
 
+    /**
+     * Reads {@code int} value.
+     *
+     * @param name Field name.
+     * @return {@code int} value.
+     */
     public int readInt(String name);
 
+    /**
+     * Reads {@code long} value.
+     *
+     * @param name Field name.
+     * @return {@code long} value.
+     */
     public long readLong(String name);
 
+    /**
+     * Reads {@code float} value.
+     *
+     * @param name Field name.
+     * @return {@code float} value.
+     */
     public float readFloat(String name);
 
+    /**
+     * Reads {@code double} value.
+     *
+     * @param name Field name.
+     * @return {@code double} value.
+     */
     public double readDouble(String name);
 
+    /**
+     * Reads {@code char} value.
+     *
+     * @param name Field name.
+     * @return {@code char} value.
+     */
     public char readChar(String name);
 
+    /**
+     * Reads {@code boolean} value.
+     *
+     * @param name Field name.
+     * @return {@code boolean} value.
+     */
     public boolean readBoolean(String name);
 
+    /**
+     * Reads {@code byte} array.
+     *
+     * @param name Field name.
+     * @return {@code byte} array.
+     */
     public byte[] readByteArray(String name);
 
+    /**
+     * Reads {@code short} array.
+     *
+     * @param name Field name.
+     * @return {@code short} array.
+     */
     public short[] readShortArray(String name);
 
+    /**
+     * Reads {@code int} array.
+     *
+     * @param name Field name.
+     * @return {@code int} array.
+     */
     public int[] readIntArray(String name);
 
+    /**
+     * Reads {@code long} array.
+     *
+     * @param name Field name.
+     * @return {@code long} array.
+     */
     public long[] readLongArray(String name);
 
+    /**
+     * Reads {@code float} array.
+     *
+     * @param name Field name.
+     * @return {@code float} array.
+     */
     public float[] readFloatArray(String name);
 
+    /**
+     * Reads {@code double} array.
+     *
+     * @param name Field name.
+     * @return {@code double} array.
+     */
     public double[] readDoubleArray(String name);
 
+    /**
+     * Reads {@code char} array.
+     *
+     * @param name Field name.
+     * @return {@code char} array.
+     */
     public char[] readCharArray(String name);
 
+    /**
+     * Reads {@code boolean} array.
+     *
+     * @param name Field name.
+     * @return {@code boolean} array.
+     */
     public boolean[] readBooleanArray(String name);
 
+    /**
+     * Reads {@link String}.
+     *
+     * @param name Field name.
+     * @return {@link String}.
+     */
     public String readString(String name);
 
+    /**
+     * Reads {@link BitSet}.
+     *
+     * @param name Field name.
+     * @return {@link BitSet}.
+     */
     public BitSet readBitSet(String name);
 
+    /**
+     * Reads {@link UUID}.
+     *
+     * @param name Field name.
+     * @return {@link UUID}.
+     */
     public UUID readUuid(String name);
 
+    /**
+     * Reads {@link IgniteUuid}.
+     *
+     * @param name Field name.
+     * @return {@link IgniteUuid}.
+     */
     public IgniteUuid readIgniteUuid(String name);
 
+    /**
+     * Reads {@code enum} value.
+     *
+     * @param name Field name.
+     * @param enumCls {@code enum} type.
+     * @return {@code enum} value.
+     */
     public <T extends Enum<T>> T readEnum(String name, Class<T> enumCls);
 
+    /**
+     * Reads nested message.
+     *
+     * @param name Field name.
+     * @return Message.
+     */
     public <T extends MessageAdapter> T readMessage(String name);
 
+    /**
+     * Reads array of objects.
+     *
+     * @param name Field name.
+     * @param itemCls Array component type.
+     * @return Array of objects.
+     */
     public <T> T[] readObjectArray(String name, Class<T> itemCls);
 
+    /**
+     * Reads collection.
+     *
+     * @param name Field name.
+     * @param itemCls Collection item type.
+     * @return Collection.
+     */
     public <C extends Collection<T>, T> C readCollection(String name, Class<T> 
itemCls);
 
+    /**
+     * Reads map.
+     *
+     * @param name Field name.
+     * @param keyCls Map key type.
+     * @param valCls Map value type.
+     * @param linked Whether {@link LinkedHashMap} should be created.
+     * @return Map.
+     */
     public <M extends Map<K, V>, K, V> M readMap(String name, Class<K> keyCls, 
Class<V> valCls, boolean linked);
 
+    /**
+     * Tells whether last invocation of any of {@code readXXX(...)}
+     * methods has fully written the value. {@code False} is returned
+     * if there were not enough remaining bytes in byte buffer.
+     *
+     * @return Whether las value was fully read.
+     */
     public boolean isLastRead();
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9b6ad0e4/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReaderFactory.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReaderFactory.java
 
b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReaderFactory.java
index 51f3a96..4729551 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReaderFactory.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReaderFactory.java
@@ -20,8 +20,16 @@ package org.apache.ignite.plugin.extensions.communication;
 import org.apache.ignite.plugin.*;
 
 /**
- * TODO
+ * Factory for message readers.
+ * <p>
+ * A plugin can provide his own message reader factory as
+ * an extension to define a custom binary format.
  */
 public interface MessageReaderFactory extends Extension {
+    /**
+     * Creates new message reader instance.
+     *
+     * @return Message reader.
+     */
     public MessageReader reader();
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9b6ad0e4/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java
 
b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java
index 71bf1c2..89c55a3 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java
@@ -23,58 +23,244 @@ import java.nio.*;
 import java.util.*;
 
 /**
- * TODO
+ * Communication message writer.
+ * <p>
+ * Allows to customize the binary format of communication messages.
  */
 public interface MessageWriter {
+    /**
+     * Sets but buffer to write to.
+     *
+     * @param buf Byte buffer.
+     */
     public void setBuffer(ByteBuffer buf);
 
+    /**
+     * Writes {@code byte} value.
+     *
+     * @param name Field name.
+     * @param val {@code byte} value.
+     * @return Whether value was fully written.
+     */
     public boolean writeByte(String name, byte val);
 
+    /**
+     * Writes {@code short} value.
+     *
+     * @param name Field name.
+     * @param val {@code short} value.
+     * @return Whether value was fully written.
+     */
     public boolean writeShort(String name, short val);
 
+    /**
+     * Writes {@code int} value.
+     *
+     * @param name Field name.
+     * @param val {@code int} value.
+     * @return Whether value was fully written.
+     */
     public boolean writeInt(String name, int val);
 
+    /**
+     * Writes {@code long} value.
+     *
+     * @param name Field name.
+     * @param val {@code long} value.
+     * @return Whether value was fully written.
+     */
     public boolean writeLong(String name, long val);
 
+    /**
+     * Writes {@code float} value.
+     *
+     * @param name Field name.
+     * @param val {@code float} value.
+     * @return Whether value was fully written.
+     */
     public boolean writeFloat(String name, float val);
 
+    /**
+     * Writes {@code double} value.
+     *
+     * @param name Field name.
+     * @param val {@code double} value.
+     * @return Whether value was fully written.
+     */
     public boolean writeDouble(String name, double val);
 
+    /**
+     * Writes {@code char} value.
+     *
+     * @param name Field name.
+     * @param val {@code char} value.
+     * @return Whether value was fully written.
+     */
     public boolean writeChar(String name, char val);
 
+    /**
+     * Writes {@code boolean} value.
+     *
+     * @param name Field name.
+     * @param val {@code boolean} value.
+     * @return Whether value was fully written.
+     */
     public boolean writeBoolean(String name, boolean val);
 
+    /**
+     * Writes {@code byte} array.
+     *
+     * @param name Field name.
+     * @param val {@code byte} array.
+     * @return Whether array was fully written.
+     */
     public boolean writeByteArray(String name, byte[] val);
 
+    /**
+     * Writes {@code short} array.
+     *
+     * @param name Field name.
+     * @param val {@code short} array.
+     * @return Whether array was fully written.
+     */
     public boolean writeShortArray(String name, short[] val);
 
+    /**
+     * Writes {@code int} array.
+     *
+     * @param name Field name.
+     * @param val {@code int} array.
+     * @return Whether array was fully written.
+     */
     public boolean writeIntArray(String name, int[] val);
 
+    /**
+     * Writes {@code long} array.
+     *
+     * @param name Field name.
+     * @param val {@code long} array.
+     * @return Whether array was fully written.
+     */
     public boolean writeLongArray(String name, long[] val);
 
+    /**
+     * Writes {@code float} array.
+     *
+     * @param name Field name.
+     * @param val {@code float} array.
+     * @return Whether array was fully written.
+     */
     public boolean writeFloatArray(String name, float[] val);
 
+    /**
+     * Writes {@code double} array.
+     *
+     * @param name Field name.
+     * @param val {@code double} array.
+     * @return Whether array was fully written.
+     */
     public boolean writeDoubleArray(String name, double[] val);
 
+    /**
+     * Writes {@code char} array.
+     *
+     * @param name Field name.
+     * @param val {@code char} array.
+     * @return Whether array was fully written.
+     */
     public boolean writeCharArray(String name, char[] val);
 
+    /**
+     * Writes {@code boolean} array.
+     *
+     * @param name Field name.
+     * @param val {@code boolean} array.
+     * @return Whether array was fully written.
+     */
     public boolean writeBooleanArray(String name, boolean[] val);
 
+    /**
+     * Writes {@link String}.
+     *
+     * @param name Field name.
+     * @param val {@link String}.
+     * @return Whether value was fully written.
+     */
     public boolean writeString(String name, String val);
 
+    /**
+     * Writes {@link BitSet}.
+     *
+     * @param name Field name.
+     * @param val {@link BitSet}.
+     * @return Whether value was fully written.
+     */
     public boolean writeBitSet(String name, BitSet val);
 
+    /**
+     * Writes {@link UUID}.
+     *
+     * @param name Field name.
+     * @param val {@link UUID}.
+     * @return Whether value was fully written.
+     */
     public boolean writeUuid(String name, UUID val);
 
+    /**
+     * Writes {@link IgniteUuid}.
+     *
+     * @param name Field name.
+     * @param val {@link IgniteUuid}.
+     * @return Whether value was fully written.
+     */
     public boolean writeIgniteUuid(String name, IgniteUuid val);
 
+    /**
+     * Writes {@code enum} value.
+     *
+     * @param name Field name.
+     * @param val {@code enum} value.
+     * @return Whether value was fully written.
+     */
     public boolean writeEnum(String name, Enum<?> val);
 
+    /**
+     * Writes nested message.
+     *
+     * @param name Field name.
+     * @param val Message.
+     * @return Whether value was fully written.
+     */
     public boolean writeMessage(String name, MessageAdapter val);
 
+    /**
+     * Writes array of objects.
+     *
+     * @param name Field name.
+     * @param arr Array of objects.
+     * @param itemCls Array component type.
+     * @return Whether array was fully written.
+     */
     public <T> boolean writeObjectArray(String name, T[] arr, Class<T> 
itemCls);
 
+    /**
+     * Writes collection.
+     *
+     * @param name Field name.
+     * @param col Collection.
+     * @param itemCls Collection item type.
+     * @return Whether value was fully written.
+     */
     public <T> boolean writeCollection(String name, Collection<T> col, 
Class<T> itemCls);
 
+    /**
+     * Writes map.
+     *
+     * @param name Field name.
+     * @param map Map.
+     * @param keyCls Map key type.
+     * @param valCls Map value type.
+     * @return Whether value was fully written.
+     */
     public <K, V> boolean writeMap(String name, Map<K, V> map, Class<K> 
keyCls, Class<V> valCls);
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9b6ad0e4/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriterFactory.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriterFactory.java
 
b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriterFactory.java
index 128e322..1ab04e3 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriterFactory.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriterFactory.java
@@ -20,8 +20,16 @@ package org.apache.ignite.plugin.extensions.communication;
 import org.apache.ignite.plugin.*;
 
 /**
- * TODO
+ * Factory for message writers.
+ * <p>
+ * A plugin can provide his own message writer factory as
+ * an extension to define a custom binary format.
  */
 public interface MessageWriterFactory extends Extension {
+    /**
+     * Creates new message writer instance.
+     *
+     * @return Message writer.
+     */
     public MessageWriter writer();
 }

Reply via email to