Added new method HazelcastEventChannel.addTransientEntry(): the added entry
is transient and will automatically timeout after 1ms.

Change-Id: If940861ad34753c3423e96a37ec03ce0fc9f56d7
diff --git a/src/main/java/net/onrc/onos/datagrid/HazelcastEventChannel.java b/src/main/java/net/onrc/onos/datagrid/HazelcastEventChannel.java
index bef0243..4d4bf9a 100644
--- a/src/main/java/net/onrc/onos/datagrid/HazelcastEventChannel.java
+++ b/src/main/java/net/onrc/onos/datagrid/HazelcastEventChannel.java
@@ -4,6 +4,7 @@
 import java.util.LinkedList;
 import java.util.Set;
 import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.TimeUnit;
 
 import com.esotericsoftware.kryo.Kryo;
 import com.esotericsoftware.kryo.io.Input;
@@ -135,6 +136,42 @@
      */
     @Override
     public void addEntry(K key, V value) {
+        byte[] valueBytes = serializeValue(value);
+        //
+        // Put the entry in the map:
+        //  - Key : Type <K>
+        //  - Value : Serialized Value (byte[])
+        //
+        channelMap.putAsync(key, valueBytes);
+    }
+
+    /**
+     * Add a transient entry to the channel.
+     *
+     * The added entry is transient and will automatically timeout after 1ms.
+     *
+     * @param key   the key of the entry to add.
+     * @param value the value of the entry to add.
+     */
+    @Override
+    public void addTransientEntry(K key, V value) {
+        byte[] valueBytes = serializeValue(value);
+        //
+        // Put the entry in the map:
+        //  - Key : Type <K>
+        //  - Value : Serialized Value (byte[])
+        //  - Timeout: 1ms
+        //
+        channelMap.putAsync(key, valueBytes, 1L, TimeUnit.MILLISECONDS);
+    }
+
+    /**
+     * Serialize the value.
+     *
+     * @param value the value to serialize.
+     * @return the serialized value.
+     */
+    private byte[] serializeValue(V value) {
         //
         // Encode the value
         //
@@ -145,12 +182,7 @@
         byte[] valueBytes = output.toBytes();
         kryoFactory.deleteKryo(kryo);
 
-        //
-        // Put the entry in the map:
-        //  - Key : Type <K>
-        //  - Value : Serialized Value (byte[])
-        //
-        channelMap.putAsync(key, valueBytes);
+        return valueBytes;
     }
 
     /**