You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/05/19 19:55:44 UTC

[30/50] [abbrv] incubator-ignite git commit: ignite-430 review

ignite-430 review


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

Branch: refs/heads/ignite-648
Commit: fe78d42cfe77626b7250875e0c3f608b27dc9367
Parents: 7ee8517
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Thu May 14 16:36:06 2015 +0300
Committer: agura <ag...@gridgain.com>
Committed: Fri May 15 03:44:37 2015 +0300

----------------------------------------------------------------------
 .../socket/WordsSocketStreamerClient.java       |  86 --------------
 .../socket/ZWordsSocketStreamerClient.java      |  81 --------------
 .../socket/ZWordsSocketStreamerServer.java      | 111 -------------------
 .../examples/streaming/socket/package-info.java |  21 ----
 .../streaming/wordcount/QueryWords.java         |   6 +
 .../streaming/wordcount/StreamWords.java        |   6 +
 .../socket/WordsSocketStreamerClient.java       |  82 ++++++++++++++
 .../socket/WordsSocketStreamerServer.java       | 111 +++++++++++++++++++
 .../wordcount/socket/package-info.java          |  21 ++++
 9 files changed, 226 insertions(+), 299 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fe78d42c/examples/src/main/java/org/apache/ignite/examples/streaming/socket/WordsSocketStreamerClient.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/socket/WordsSocketStreamerClient.java b/examples/src/main/java/org/apache/ignite/examples/streaming/socket/WordsSocketStreamerClient.java
deleted file mode 100644
index c5ec079..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/streaming/socket/WordsSocketStreamerClient.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples.streaming.socket;
-
-import org.apache.ignite.examples.*;
-import org.apache.ignite.examples.streaming.wordcount.*;
-import org.apache.ignite.stream.socket.*;
-
-import java.io.*;
-import java.net.*;
-
-/**
- * Sends words to socket server based on {@link SocketStreamer} using message size based protocol.
- * <p>
- * To start the example, you should:
- * <ul>
- *     <li>Start a few nodes using {@link ExampleNodeStartup} or by starting remote nodes as specified below.</li>
- *     <li>Start socket server using {@link WordsSocketStreamerServer}.</li>
- *     <li>Start a few socket clients using {@link WordsSocketStreamerClient}.</li>
- *     <li>Start querying popular words using {@link QueryWords}.</li>
- * </ul>
- * <p>
- * You should start remote nodes by running {@link ExampleNodeStartup} in another JVM.
- */
-public class WordsSocketStreamerClient {
-    /** Port. */
-    private static final int PORT = 5555;
-
-    /**
-     * @param args Args.
-     */
-    public static void main(String[] args) throws IOException {
-        InetAddress addr = InetAddress.getLocalHost();
-
-        try (Socket sock = new Socket(addr, PORT);
-             OutputStream oos = new BufferedOutputStream(sock.getOutputStream())) {
-
-            System.out.println("Words streaming started.");
-
-            while (true) {
-                try (InputStream in = StreamWords.class.getResourceAsStream("../wordcount/alice-in-wonderland.txt");
-                     LineNumberReader rdr = new LineNumberReader(new InputStreamReader(in))) {
-                    for (String line = rdr.readLine(); line != null; line = rdr.readLine()) {
-                        for (String word : line.split(" ")) {
-                            if (!word.isEmpty()) {
-                                // Stream words into Ignite through socket.
-                                try (ByteArrayOutputStream bos = new ByteArrayOutputStream();
-                                     ObjectOutputStream out = new ObjectOutputStream(bos)) {
-
-                                    // Write message
-                                    out.writeObject(word);
-
-                                    byte[] arr = bos.toByteArray();
-
-                                    // Write message length
-                                    oos.write(arr.length >>> 24);
-                                    oos.write(arr.length >>> 16);
-                                    oos.write(arr.length >>> 8);
-                                    oos.write(arr.length);
-
-                                    oos.write(arr);
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        }
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fe78d42c/examples/src/main/java/org/apache/ignite/examples/streaming/socket/ZWordsSocketStreamerClient.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/socket/ZWordsSocketStreamerClient.java b/examples/src/main/java/org/apache/ignite/examples/streaming/socket/ZWordsSocketStreamerClient.java
deleted file mode 100644
index c17ccdc..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/streaming/socket/ZWordsSocketStreamerClient.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples.streaming.socket;
-
-import org.apache.ignite.examples.*;
-import org.apache.ignite.examples.streaming.wordcount.*;
-import org.apache.ignite.stream.socket.*;
-
-import java.io.*;
-import java.net.*;
-
-/**
- * Sends words to socket server based on {@link SocketStreamer} using message delimiter based protocol.
- * Example illustrates usage of TCP socket streamer in case of non-Java clients.
- * In this example words are zero-terminated strings.
- * <p>
- * To start the example, you should:
- * <ul>
- *     <li>Start a few nodes using {@link ExampleNodeStartup} or by starting remote nodes as specified below.</li>
- *     <li>Start socket server using {@link ZWordsSocketStreamerServer}.</li>
- *     <li>Start a few socket clients using {@link ZWordsSocketStreamerClient}.</li>
- *     <li>Start querying popular words using {@link QueryWords}.</li>
- * </ul>
- * <p>
- * You should start remote nodes by running {@link ExampleNodeStartup} in another JVM.
- */
-public class ZWordsSocketStreamerClient {
-    /** Port. */
-    private static final int PORT = 5555;
-
-    /** Delimiter. */
-    private static final byte[] DELIM = new byte[] {0};
-
-    /**
-     * @param args Args.
-     */
-    public static void main(String[] args) throws IOException {
-        InetAddress addr = InetAddress.getLocalHost();
-
-        try (Socket sock = new Socket(addr, PORT);
-             OutputStream oos = new BufferedOutputStream(sock.getOutputStream())) {
-
-            System.out.println("Words streaming started.");
-
-            while (true) {
-                try (InputStream in = StreamWords.class.getResourceAsStream("../wordcount/alice-in-wonderland.txt");
-                     LineNumberReader rdr = new LineNumberReader(new InputStreamReader(in))) {
-                    for (String line = rdr.readLine(); line != null; line = rdr.readLine()) {
-                        for (String word : line.split(" ")) {
-                            if (!word.isEmpty()) {
-                                // Stream words into Ignite through socket.
-                                byte[] arr = word.getBytes("ASCII");
-
-                                // Write message
-                                oos.write(arr);
-
-                                // Write message delimiter
-                                oos.write(DELIM);
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fe78d42c/examples/src/main/java/org/apache/ignite/examples/streaming/socket/ZWordsSocketStreamerServer.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/socket/ZWordsSocketStreamerServer.java b/examples/src/main/java/org/apache/ignite/examples/streaming/socket/ZWordsSocketStreamerServer.java
deleted file mode 100644
index a0ef9da..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/streaming/socket/ZWordsSocketStreamerServer.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples.streaming.socket;
-
-import org.apache.ignite.*;
-import org.apache.ignite.cache.affinity.*;
-import org.apache.ignite.examples.*;
-import org.apache.ignite.examples.streaming.wordcount.*;
-import org.apache.ignite.lang.*;
-import org.apache.ignite.stream.*;
-import org.apache.ignite.stream.socket.*;
-
-import java.io.*;
-import java.net.*;
-import java.util.*;
-
-/**
- * Receives words through socket using {@link SocketStreamer} and message delimiter based protocol
- * and streams them into Ignite cache. Example illustrates usage of TCP socket streamer in case of non-Java clients.
- * In this example words are zero-terminated strings.
- * <p>
- * To start the example, you should:
- * <ul>
- *     <li>Start a few nodes using {@link ExampleNodeStartup} or by starting remote nodes as specified below.</li>
- *     <li>Start socket server using {@link ZWordsSocketStreamerServer}.</li>
- *     <li>Start a few socket clients using {@link ZWordsSocketStreamerClient}.</li>
- *     <li>Start querying popular words using {@link QueryWords}.</li>
- * </ul>
- * <p>
- * You should start remote nodes by running {@link ExampleNodeStartup} in another JVM.
- */
-public class ZWordsSocketStreamerServer {
-    /** Port. */
-    private static final int PORT = 5555;
-
-    /** Delimiter. */
-    private static final byte[] DELIM = new byte[] {0};
-
-    /**
-     * @param args Args.
-     */
-    public static void main(String[] args) throws InterruptedException, IOException {
-        // Mark this cluster member as client.
-        Ignition.setClientMode(true);
-
-        Ignite ignite = Ignition.start("examples/config/example-ignite.xml");
-
-        if (!ExamplesUtils.hasServerNodes(ignite)) {
-            ignite.close();
-
-            return;
-        }
-
-        // The cache is configured with sliding window holding 1 second of the streaming data.
-        IgniteCache<AffinityUuid, String> stmCache = ignite.getOrCreateCache(CacheConfig.wordCache());
-
-        IgniteDataStreamer<AffinityUuid, String> stmr = ignite.dataStreamer(stmCache.getName());
-
-        InetAddress addr = InetAddress.getLocalHost();
-
-        // Configure socket streamer
-        SocketStreamer<String, AffinityUuid, String> sockStmr = new SocketStreamer<>();
-
-        sockStmr.setAddr(addr);
-
-        sockStmr.setPort(PORT);
-
-        sockStmr.setDelimiter(DELIM);
-
-        sockStmr.setIgnite(ignite);
-
-        sockStmr.setStreamer(stmr);
-
-        // Converter from zero-terminated string to Java strings.
-        sockStmr.setConverter(new SocketMessageConverter<String>() {
-            @Override public String convert(byte[] msg) {
-                try {
-                    return new String(msg, "ASCII");
-                }
-                catch (UnsupportedEncodingException e) {
-                    throw new IgniteException(e);
-                }
-            }
-        });
-
-        sockStmr.setTupleExtractor(new StreamTupleExtractor<String, AffinityUuid, String>() {
-            @Override public Map.Entry<AffinityUuid, String> extract(String word) {
-                // By using AffinityUuid we ensure that identical
-                // words are processed on the same cluster node.
-                return new IgniteBiTuple<>(new AffinityUuid(word), word);
-            }
-        });
-
-        sockStmr.start();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fe78d42c/examples/src/main/java/org/apache/ignite/examples/streaming/socket/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/socket/package-info.java b/examples/src/main/java/org/apache/ignite/examples/streaming/socket/package-info.java
deleted file mode 100644
index c516ab4..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/streaming/socket/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Contains {@link org.apache.ignite.stream.socket.SocketStreamer} usage examples.
- */
-package org.apache.ignite.examples.streaming.socket;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fe78d42c/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java
index 149aa79..faf8b51 100644
--- a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java
+++ b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java
@@ -36,6 +36,12 @@ import java.util.*;
  * You should start remote nodes by running {@link ExampleNodeStartup} in another JVM.
  */
 public class QueryWords {
+    /**
+     * Schedules words query execution.
+     *
+     * @param args Command line arguments (none required).
+     * @throws Exception If failed.
+     */
     public static void main(String[] args) throws Exception {
         // Mark this cluster member as client.
         Ignition.setClientMode(true);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fe78d42c/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/StreamWords.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/StreamWords.java b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/StreamWords.java
index cc3c0cb..26be178 100644
--- a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/StreamWords.java
+++ b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/StreamWords.java
@@ -35,6 +35,12 @@ import java.io.*;
  * You should start remote nodes by running {@link ExampleNodeStartup} in another JVM.
  */
 public class StreamWords {
+    /**
+     * Starts words streaming.
+     *
+     * @param args Command line arguments (none required).
+     * @throws Exception If failed.
+     */
     public static void main(String[] args) throws Exception {
         // Mark this cluster member as client.
         Ignition.setClientMode(true);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fe78d42c/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerClient.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerClient.java b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerClient.java
new file mode 100644
index 0000000..ea3beaa
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerClient.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.examples.streaming.wordcount.socket;
+
+import org.apache.ignite.examples.*;
+import org.apache.ignite.examples.streaming.wordcount.*;
+import org.apache.ignite.stream.socket.*;
+
+import java.io.*;
+import java.net.*;
+
+/**
+ * Sends words to socket server based on {@link SocketStreamer} using message delimiter based protocol.
+ * Example illustrates usage of TCP socket streamer in case of non-Java clients.
+ * In this example words are zero-terminated strings.
+ * <p>
+ * To start the example, you should:
+ * <ul>
+ *     <li>Start a few nodes using {@link ExampleNodeStartup} or by starting remote nodes as specified below.</li>
+ *     <li>Start socket server using {@link WordsSocketStreamerServer}.</li>
+ *     <li>Start a few socket clients using {@link WordsSocketStreamerClient}.</li>
+ *     <li>Start querying popular words using {@link QueryWords}.</li>
+ * </ul>
+ * <p>
+ * You should start remote nodes by running {@link ExampleNodeStartup} in another JVM.
+ */
+public class WordsSocketStreamerClient {
+    /** Port. */
+    private static final int PORT = 5555;
+
+    /** Delimiter. */
+    private static final byte[] DELIM = new byte[] {0};
+
+    /**
+     * @param args Args.
+     */
+    public static void main(String[] args) throws IOException {
+        InetAddress addr = InetAddress.getLocalHost();
+
+        try (
+            Socket sock = new Socket(addr, PORT);
+            OutputStream oos = new BufferedOutputStream(sock.getOutputStream())
+        ) {
+            System.out.println("Words streaming started.");
+
+            while (true) {
+                try (InputStream in = StreamWords.class.getResourceAsStream("../wordcount/alice-in-wonderland.txt");
+                     LineNumberReader rdr = new LineNumberReader(new InputStreamReader(in))) {
+                    for (String line = rdr.readLine(); line != null; line = rdr.readLine()) {
+                        for (String word : line.split(" ")) {
+                            if (!word.isEmpty()) {
+                                // Stream words into Ignite through socket.
+                                byte[] arr = word.getBytes("ASCII");
+
+                                // Write message
+                                oos.write(arr);
+
+                                // Write message delimiter
+                                oos.write(DELIM);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fe78d42c/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerServer.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerServer.java b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerServer.java
new file mode 100644
index 0000000..259c925
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerServer.java
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.examples.streaming.wordcount.socket;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.affinity.*;
+import org.apache.ignite.examples.*;
+import org.apache.ignite.examples.streaming.wordcount.*;
+import org.apache.ignite.lang.*;
+import org.apache.ignite.stream.*;
+import org.apache.ignite.stream.socket.*;
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+
+/**
+ * Receives words through socket using {@link SocketStreamer} and message delimiter based protocol
+ * and streams them into Ignite cache. Example illustrates usage of TCP socket streamer in case of non-Java clients.
+ * In this example words are zero-terminated strings.
+ * <p>
+ * To start the example, you should:
+ * <ul>
+ *     <li>Start a few nodes using {@link ExampleNodeStartup} or by starting remote nodes as specified below.</li>
+ *     <li>Start socket server using {@link WordsSocketStreamerServer}.</li>
+ *     <li>Start a few socket clients using {@link WordsSocketStreamerClient}.</li>
+ *     <li>Start querying popular words using {@link QueryWords}.</li>
+ * </ul>
+ * <p>
+ * You should start remote nodes by running {@link ExampleNodeStartup} in another JVM.
+ */
+public class WordsSocketStreamerServer {
+    /** Port. */
+    private static final int PORT = 5555;
+
+    /** Delimiter. */
+    private static final byte[] DELIM = new byte[] {0};
+
+    /**
+     * @param args Args.
+     */
+    public static void main(String[] args) throws InterruptedException, IOException {
+        // Mark this cluster member as client.
+        Ignition.setClientMode(true);
+
+        Ignite ignite = Ignition.start("examples/config/example-ignite.xml");
+
+        if (!ExamplesUtils.hasServerNodes(ignite)) {
+            ignite.close();
+
+            return;
+        }
+
+        // The cache is configured with sliding window holding 1 second of the streaming data.
+        IgniteCache<AffinityUuid, String> stmCache = ignite.getOrCreateCache(CacheConfig.wordCache());
+
+        IgniteDataStreamer<AffinityUuid, String> stmr = ignite.dataStreamer(stmCache.getName());
+
+        InetAddress addr = InetAddress.getLocalHost();
+
+        // Configure socket streamer
+        SocketStreamer<String, AffinityUuid, String> sockStmr = new SocketStreamer<>();
+
+        sockStmr.setAddr(addr);
+
+        sockStmr.setPort(PORT);
+
+        sockStmr.setDelimiter(DELIM);
+
+        sockStmr.setIgnite(ignite);
+
+        sockStmr.setStreamer(stmr);
+
+        // Converter from zero-terminated string to Java strings.
+        sockStmr.setConverter(new SocketMessageConverter<String>() {
+            @Override public String convert(byte[] msg) {
+                try {
+                    return new String(msg, "ASCII");
+                }
+                catch (UnsupportedEncodingException e) {
+                    throw new IgniteException(e);
+                }
+            }
+        });
+
+        sockStmr.setTupleExtractor(new StreamTupleExtractor<String, AffinityUuid, String>() {
+            @Override public Map.Entry<AffinityUuid, String> extract(String word) {
+                // By using AffinityUuid we ensure that identical
+                // words are processed on the same cluster node.
+                return new IgniteBiTuple<>(new AffinityUuid(word), word);
+            }
+        });
+
+        sockStmr.start();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fe78d42c/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/package-info.java b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/package-info.java
new file mode 100644
index 0000000..048299f
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Contains {@link org.apache.ignite.stream.socket.SocketStreamer} usage examples.
+ */
+package org.apache.ignite.examples.streaming.wordcount.socket;