You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by av...@apache.org on 2016/05/17 13:48:43 UTC

[01/14] ignite git commit: IGNITE-3144 Refactor Schema Import Utility. Split for two modules: schema-import and schema-import-db.

Repository: ignite
Updated Branches:
  refs/heads/master 608bd82be -> 88d9fe679


http://git-wip-us.apache.org/repos/asf/ignite/blob/fa197d2f/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java
index 36363dd..a02d31e 100644
--- a/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java
+++ b/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java
@@ -27,11 +27,8 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.lang.reflect.Field;
-import java.net.URL;
-import java.net.URLClassLoader;
 import java.nio.charset.Charset;
 import java.sql.Connection;
-import java.sql.Driver;
 import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -53,6 +50,7 @@ import javafx.beans.value.ObservableValue;
 import javafx.collections.FXCollections;
 import javafx.collections.ObservableList;
 import javafx.concurrent.Task;
+import javafx.embed.swing.SwingFXUtils;
 import javafx.event.ActionEvent;
 import javafx.event.EventHandler;
 import javafx.geometry.Insets;
@@ -90,34 +88,7 @@ import org.apache.ignite.schema.model.PojoDescriptor;
 import org.apache.ignite.schema.model.PojoField;
 import org.apache.ignite.schema.model.SchemaDescriptor;
 import org.apache.ignite.schema.parser.DatabaseMetadataParser;
-
-import static javafx.embed.swing.SwingFXUtils.fromFXImage;
-import static org.apache.ignite.schema.ui.Controls.booleanColumn;
-import static org.apache.ignite.schema.ui.Controls.borderPane;
-import static org.apache.ignite.schema.ui.Controls.button;
-import static org.apache.ignite.schema.ui.Controls.buttonsPane;
-import static org.apache.ignite.schema.ui.Controls.checkBox;
-import static org.apache.ignite.schema.ui.Controls.comboBox;
-import static org.apache.ignite.schema.ui.Controls.customColumn;
-import static org.apache.ignite.schema.ui.Controls.hBox;
-import static org.apache.ignite.schema.ui.Controls.image;
-import static org.apache.ignite.schema.ui.Controls.imageView;
-import static org.apache.ignite.schema.ui.Controls.label;
-import static org.apache.ignite.schema.ui.Controls.list;
-import static org.apache.ignite.schema.ui.Controls.paneEx;
-import static org.apache.ignite.schema.ui.Controls.passwordField;
-import static org.apache.ignite.schema.ui.Controls.progressIndicator;
-import static org.apache.ignite.schema.ui.Controls.scene;
-import static org.apache.ignite.schema.ui.Controls.splitPane;
-import static org.apache.ignite.schema.ui.Controls.stackPane;
-import static org.apache.ignite.schema.ui.Controls.tableColumn;
-import static org.apache.ignite.schema.ui.Controls.tableView;
-import static org.apache.ignite.schema.ui.Controls.text;
-import static org.apache.ignite.schema.ui.Controls.textColumn;
-import static org.apache.ignite.schema.ui.Controls.textField;
-import static org.apache.ignite.schema.ui.Controls.titledPane;
-import static org.apache.ignite.schema.ui.Controls.tooltip;
-import static org.apache.ignite.schema.ui.Controls.vBox;
+import org.apache.ignite.schema.parser.DbMetadataReader;
 
 /**
  * Schema Import utility application.
@@ -127,87 +98,30 @@ public class SchemaImportApp extends Application {
     /** Logger. */
     private static final Logger log = Logger.getLogger(SchemaImportApp.class.getName());
 
-    /** Ability to use xdg-open utility flag. */
-    private static final boolean HAS_XDG_OPEN = U.isUnix() && new File("/usr/bin/xdg-open").canExecute();
-
-    /** Presets for database settings. */
-    private static class Preset {
-        /** Name in preferences. */
-        private String pref;
-
-        /** RDBMS name to show on screen. */
-        private String name;
-
-        /** Path to JDBC driver jar. */
-        private String jar;
-
-        /** JDBC driver class name. */
-        private String drv;
-
-        /** JDBC URL. */
-        private String url;
-
-        /** User name. */
-        private String user;
-
-        /**
-         * Preset constructor.
-         *
-         * @param pref Name in preferences.
-         * @param name RDBMS name to show on screen.
-         * @param jar Path to JDBC driver jar..
-         * @param drv JDBC driver class name.
-         * @param url JDBC URL.
-         * @param user User name.
-         */
-        Preset(String pref, String name, String jar, String drv, String url, String user) {
-            this.pref = pref;
-            this.name = name;
-            this.jar = jar;
-            this.drv = drv;
-            this.url = url;
-            this.user = user;
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            return name;
-        }
-    }
-
-    /** Default presets for popular databases. */
-    private final Preset[] presets = {
-        new Preset("h2", "H2 Database", "h2.jar", "org.h2.Driver", "jdbc:h2:[database]", "sa"),
-        new Preset("db2", "DB2", "db2jcc4.jar", "com.ibm.db2.jcc.DB2Driver", "jdbc:db2://[host]:[port]/[database]",
-            "db2admin"),
-        new Preset("oracle", "Oracle", "ojdbc6.jar", "oracle.jdbc.OracleDriver",
-            "jdbc:oracle:thin:@[host]:[port]:[database]", "system"),
-        new Preset("mysql", "MySQL", "mysql-connector-java-5-bin.jar", "com.mysql.jdbc.Driver",
-            "jdbc:mysql://[host]:[port]/[database]", "root"),
-        new Preset("mssql", "Microsoft SQL Server", "sqljdbc41.jar", "com.microsoft.sqlserver.jdbc.SQLServerDriver",
-            "jdbc:sqlserver://[host]:[port][;databaseName=database]", "sa"),
-        new Preset("postgresql", "PostgreSQL", "postgresql-9.3.jdbc4.jar", "org.postgresql.Driver",
-            "jdbc:postgresql://[host]:[port]/[database]", "sa"),
-        new Preset("custom", "Custom server...", "custom-jdbc.jar", "org.custom.Driver", "jdbc:custom", "sa")
-    };
-
     /** */
     private static final String PREF_WINDOW_X = "window.x";
+
     /** */
     private static final String PREF_WINDOW_Y = "window.y";
+
     /** */
     private static final String PREF_WINDOW_WIDTH = "window.width";
+
     /** */
     private static final String PREF_WINDOW_HEIGHT = "window.height";
 
     /** */
     private static final String PREF_JDBC_DB_PRESET = "jdbc.db.preset";
+
     /** */
     private static final String PREF_JDBC_DRIVER_JAR = "jdbc.driver.jar";
+
     /** */
     private static final String PREF_JDBC_DRIVER_CLASS = "jdbc.driver.class";
+
     /** */
     private static final String PREF_JDBC_URL = "jdbc.url";
+
     /** */
     private static final String PREF_JDBC_USER = "jdbc.user";
 
@@ -216,8 +130,10 @@ public class SchemaImportApp extends Application {
 
     /** */
     private static final String PREF_POJO_PACKAGE = "pojo.package";
+
     /** */
     private static final String PREF_POJO_INCLUDE = "pojo.include";
+
     /** */
     private static final String PREF_POJO_CONSTRUCTOR = "pojo.constructor";
 
@@ -229,9 +145,32 @@ public class SchemaImportApp extends Application {
 
     /** */
     private static final String PREF_NAMING_PATTERN = "naming.pattern";
+
     /** */
     private static final String PREF_NAMING_REPLACE = "naming.replace";
 
+    /** Empty POJO fields model. */
+    private static final ObservableList<PojoField> NO_FIELDS = FXCollections.emptyObservableList();
+
+    /** Ability to use xdg-open utility flag. */
+    private static final boolean HAS_XDG_OPEN = U.isUnix() && new File("/usr/bin/xdg-open").canExecute();
+
+    /** Default presets for popular databases. */
+    private final Preset[] presets = {
+        new Preset("h2", "H2 Database", "h2.jar", "org.h2.Driver", "jdbc:h2:[database]", "sa"),
+        new Preset("db2", "DB2", "db2jcc4.jar", "com.ibm.db2.jcc.DB2Driver", "jdbc:db2://[host]:[port]/[database]",
+            "db2admin"),
+        new Preset("oracle", "Oracle", "ojdbc6.jar", "oracle.jdbc.OracleDriver",
+            "jdbc:oracle:thin:@[host]:[port]:[database]", "system"),
+        new Preset("mysql", "MySQL", "mysql-connector-java-5-bin.jar", "com.mysql.jdbc.Driver",
+            "jdbc:mysql://[host]:[port]/[database]", "root"),
+        new Preset("mssql", "Microsoft SQL Server", "sqljdbc41.jar", "com.microsoft.sqlserver.jdbc.SQLServerDriver",
+            "jdbc:sqlserver://[host]:[port][;databaseName=database]", "sa"),
+        new Preset("postgresql", "PostgreSQL", "postgresql-9.3.jdbc4.jar", "org.postgresql.Driver",
+            "jdbc:postgresql://[host]:[port]/[database]", "sa"),
+        new Preset("custom", "Custom server...", "custom-jdbc.jar", "org.custom.Driver", "jdbc:custom", "sa")
+    };
+
     /** */
     private Stage owner;
 
@@ -340,20 +279,15 @@ public class SchemaImportApp extends Application {
     /** Currently selected POJO. */
     private PojoDescriptor curPojo;
 
-    /** */
-    private final Map<String, Driver> drivers = new HashMap<>();
-
     /** Application preferences. */
     private final Properties prefs = new Properties();
 
     /** File path for storing on local file system. */
     private final File prefsFile = new File(System.getProperty("user.home"), ".ignite-schema-import");
 
-    /** Empty POJO fields model. */
-    private static final ObservableList<PojoField> NO_FIELDS = FXCollections.emptyObservableList();
-
     /** */
     private final ExecutorService exec = Executors.newSingleThreadExecutor(new ThreadFactory() {
+        /** {@inheritDoc} */
         @Override public Thread newThread(Runnable r) {
             Thread t = new Thread(r, "ignite-schema-import-worker");
 
@@ -364,6 +298,52 @@ public class SchemaImportApp extends Application {
     });
 
     /**
+     * Schema Import utility launcher.
+     *
+     * @param args Command line arguments passed to the application.
+     */
+    public static void main(String[] args) {
+        // Workaround for JavaFX ugly text AA.
+        System.setProperty("prism.lcdtext", "false");
+        System.setProperty("prism.text", "t2k");
+
+        // Workaround for AWT + JavaFX: we should initialize AWT before JavaFX.
+        java.awt.Toolkit.getDefaultToolkit();
+
+        // Workaround for JavaFX + Mac OS dock icon.
+        if (System.getProperty("os.name").toLowerCase().contains("mac os")) {
+            System.setProperty("javafx.macosx.embedded", "true");
+
+            try {
+                Class<?> appCls = Class.forName("com.apple.eawt.Application");
+
+                Object osxApp = appCls.getDeclaredMethod("getApplication").invoke(null);
+
+                appCls.getDeclaredMethod("setDockIconImage", java.awt.Image.class)
+                    .invoke(osxApp, SwingFXUtils.fromFXImage(Controls.image("ignite", 128), null));
+            }
+            catch (Exception ignore) {
+                // No-op.
+            }
+
+            // Workaround for JDK 7/JavaFX 2 application on Mac OSX El Capitan.
+            try {
+                Class<?> fontFinderCls = Class.forName("com.sun.t2k.MacFontFinder");
+
+                Field psNameToPathMap = fontFinderCls.getDeclaredField("psNameToPathMap");
+
+                psNameToPathMap.setAccessible(true);
+                psNameToPathMap.set(null, new HashMap<String, String>());
+            }
+            catch (Exception ignore) {
+                // No-op.
+            }
+        }
+
+        launch(args);
+    }
+
+    /**
      * Lock UI before start long task.
      *
      * @param layer Stack pane to add progress indicator.
@@ -431,7 +411,7 @@ public class SchemaImportApp extends Application {
         if (!pwd.isEmpty())
             jdbcInfo.put("password", pwd);
 
-        return connect(jdbcDrvJarPath, jdbcDrvCls, jdbcUrl, jdbcInfo);
+        return DbMetadataReader.getInstance().connect(jdbcDrvJarPath, jdbcDrvCls, jdbcUrl, jdbcInfo);
     }
 
     /**
@@ -497,7 +477,7 @@ public class SchemaImportApp extends Application {
 
                     prevBtn.setDisable(false);
                     nextBtn.setText("Generate");
-                    tooltip(nextBtn, "Generate XML and POJO files");
+                    Controls.tooltip(nextBtn, "Generate XML and POJO files");
                 }
                 finally {
                     unlockUI(connLayerPnl, connPnl, nextBtn);
@@ -610,10 +590,10 @@ public class SchemaImportApp extends Application {
 
         final File destFolder = new File(outFolder);
 
-        final boolean includeKeys = pojoIncludeKeysCh.isSelected();
-
         final boolean constructor = pojoConstructorCh.isSelected();
 
+        final boolean includeKeys = pojoIncludeKeysCh.isSelected();
+
         final boolean generateAliases = generateAliasesCh.isSelected();
 
         final boolean singleXml = xmlSingleFileCh.isSelected();
@@ -911,15 +891,16 @@ public class SchemaImportApp extends Application {
      * @return Header pane with title label.
      */
     private BorderPane createHeaderPane() {
-        dbIcon = hBox(0, true, imageView("data_connection", 48));
-        genIcon = hBox(0, true, imageView("text_tree", 48));
+        dbIcon = Controls.hBox(0, true, Controls.imageView("data_connection", 48));
+        genIcon = Controls.hBox(0, true, Controls.imageView("text_tree", 48));
 
-        titleLb = label("");
+        titleLb = Controls.label("");
         titleLb.setId("banner");
 
-        subTitleLb = label("");
+        subTitleLb = Controls.label("");
 
-        BorderPane bp = borderPane(null, vBox(5, titleLb, subTitleLb), null, dbIcon, hBox(0, true, imageView("ignite", 48)));
+        BorderPane bp = Controls.borderPane(null, Controls.vBox(5, titleLb, subTitleLb), null, dbIcon,
+            Controls.hBox(0, true, Controls.imageView("ignite", 48)));
         bp.setId("banner");
 
         return bp;
@@ -929,19 +910,19 @@ public class SchemaImportApp extends Application {
      * @return Panel with control buttons.
      */
     private Pane createButtonsPane() {
-        prevBtn = button("Prev", "Go to \"Database connection\" page", new EventHandler<ActionEvent>() {
+        prevBtn = Controls.button("Prev", "Go to \"Database connection\" page", new EventHandler<ActionEvent>() {
             @Override public void handle(ActionEvent evt) {
                 prev();
             }
         });
 
-        nextBtn = button("Next", "Go to \"POJO and XML generation\" page", new EventHandler<ActionEvent>() {
+        nextBtn = Controls.button("Next", "Go to \"POJO and XML generation\" page", new EventHandler<ActionEvent>() {
             @Override public void handle(ActionEvent evt) {
                 next();
             }
         });
 
-        return buttonsPane(Pos.BOTTOM_RIGHT, true, prevBtn, nextBtn);
+        return Controls.buttonsPane(Pos.BOTTOM_RIGHT, true, prevBtn, nextBtn);
     }
 
     /**
@@ -972,7 +953,7 @@ public class SchemaImportApp extends Application {
 
         prevBtn.setDisable(true);
         nextBtn.setText("Next");
-        tooltip(nextBtn, "Go to \"XML and POJO generation\" page");
+        Controls.tooltip(nextBtn, "Go to \"XML and POJO generation\" page");
     }
 
     /**
@@ -1015,57 +996,12 @@ public class SchemaImportApp extends Application {
     }
 
     /**
-     * Connect to database.
-     *
-     * @param jdbcDrvJarPath Path to JDBC driver.
-     * @param jdbcDrvCls JDBC class name.
-     * @param jdbcUrl JDBC connection URL.
-     * @param jdbcInfo Connection properties.
-     * @return Connection to database.
-     * @throws SQLException if connection failed.
-     */
-    private Connection connect(String jdbcDrvJarPath, String jdbcDrvCls, String jdbcUrl, Properties jdbcInfo)
-        throws SQLException {
-        Driver drv = drivers.get(jdbcDrvCls);
-
-        if (drv == null) {
-            if (jdbcDrvJarPath.isEmpty())
-                throw new IllegalStateException("Driver jar file name is not specified.");
-
-            File drvJar = new File(jdbcDrvJarPath);
-
-            if (!drvJar.exists())
-                throw new IllegalStateException("Driver jar file is not found.");
-
-            try {
-                URL u = new URL("jar:" + drvJar.toURI() + "!/");
-
-                URLClassLoader ucl = URLClassLoader.newInstance(new URL[] {u});
-
-                drv = (Driver)Class.forName(jdbcDrvCls, true, ucl).newInstance();
-
-                drivers.put(jdbcDrvCls, drv);
-            }
-            catch (Exception e) {
-                throw new IllegalStateException(e);
-            }
-        }
-
-        Connection conn = drv.connect(jdbcUrl, jdbcInfo);
-
-        if (conn == null)
-            throw new IllegalStateException("Connection was not established (JDBC driver returned null value).");
-
-        return conn;
-    }
-
-    /**
      * Create connection pane with controls.
      *
      * @return Pane with connection controls.
      */
     private Pane createConnectionPane() {
-        connPnl = paneEx(10, 10, 0, 10);
+        connPnl = Controls.paneEx(10, 10, 0, 10);
 
         connPnl.addColumn();
         connPnl.addColumn(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
@@ -1074,18 +1010,18 @@ public class SchemaImportApp extends Application {
         connPnl.addRows(9);
         connPnl.addRow(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
 
-        connPnl.add(text("This utility is designed to automatically generate configuration XML files and" +
+        connPnl.add(Controls.text("This utility is designed to automatically generate configuration XML files and" +
             " POJO classes from database schema information.", 550), 3);
 
         connPnl.wrap();
 
-        GridPaneEx presetPnl = paneEx(0, 0, 0, 0);
+        GridPaneEx presetPnl = Controls.paneEx(0, 0, 0, 0);
         presetPnl.addColumn(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
         presetPnl.addColumn();
 
-        rdbmsCb = presetPnl.add(comboBox("Select database server to get predefined settings", presets));
+        rdbmsCb = presetPnl.add(Controls.comboBox("Select database server to get predefined settings", presets));
 
-        presetPnl.add(button("Save preset", "Save current settings in preferences", new EventHandler<ActionEvent>() {
+        presetPnl.add(Controls.button("Save preset", "Save current settings in preferences", new EventHandler<ActionEvent>() {
             @Override public void handle(ActionEvent evt) {
                 Preset preset = rdbmsCb.getSelectionModel().getSelectedItem();
 
@@ -1093,12 +1029,12 @@ public class SchemaImportApp extends Application {
             }
         }));
 
-        connPnl.add(label("DB Preset:"));
+        connPnl.add(Controls.label("DB Preset:"));
         connPnl.add(presetPnl, 2);
 
-        jdbcDrvJarTf = connPnl.addLabeled("Driver JAR:", textField("Path to driver jar"));
+        jdbcDrvJarTf = connPnl.addLabeled("Driver JAR:", Controls.textField("Path to driver jar"));
 
-        connPnl.add(button("...", "Select JDBC driver jar or zip", new EventHandler<ActionEvent>() {
+        connPnl.add(Controls.button("...", "Select JDBC driver jar or zip", new EventHandler<ActionEvent>() {
             /** {@inheritDoc} */
             @Override public void handle(ActionEvent evt) {
                 FileChooser fc = new FileChooser();
@@ -1126,9 +1062,9 @@ public class SchemaImportApp extends Application {
             }
         }));
 
-        jdbcDrvClsTf = connPnl.addLabeled("JDBC Driver:", textField("Enter class name for JDBC driver"), 2);
+        jdbcDrvClsTf = connPnl.addLabeled("JDBC Driver:", Controls.textField("Enter class name for JDBC driver"), 2);
 
-        jdbcUrlTf = connPnl.addLabeled("JDBC URL:", textField("JDBC URL of the database connection string"), 2);
+        jdbcUrlTf = connPnl.addLabeled("JDBC URL:", Controls.textField("JDBC URL of the database connection string"), 2);
 
         rdbmsCb.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Preset>() {
             @Override public void changed(ObservableValue<? extends Preset> val, Preset oldVal, Preset newVal) {
@@ -1139,34 +1075,34 @@ public class SchemaImportApp extends Application {
             }
         });
 
-        userTf = connPnl.addLabeled("User:", textField("User name"), 2);
+        userTf = connPnl.addLabeled("User:", Controls.textField("User name"), 2);
 
-        pwdTf = connPnl.addLabeled("Password:", passwordField("User password"), 2);
+        pwdTf = connPnl.addLabeled("Password:", Controls.passwordField("User password"), 2);
 
-        parseCb = connPnl.addLabeled("Parse:", comboBox("Type of tables to parse", "Tables only", "Tables and Views"), 2);
+        parseCb = connPnl.addLabeled("Parse:", Controls.comboBox("Type of tables to parse", "Tables only", "Tables and Views"), 2);
 
-        GridPaneEx schemaPnl = paneEx(5, 5, 5, 5);
+        GridPaneEx schemaPnl = Controls.paneEx(5, 5, 5, 5);
         schemaPnl.addColumn(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
         schemaPnl.addColumn();
 
-        schemaLst = schemaPnl.add(list("Select schemas to load", new SchemaCell()));
+        schemaLst = schemaPnl.add(Controls.list("Select schemas to load", new SchemaCell()));
 
         schemaPnl.wrap();
 
-        schemaPnl.add(button("Load schemas", "Load schemas for specified database", new EventHandler<ActionEvent>() {
+        schemaPnl.add(Controls.button("Load schemas", "Load schemas for specified database", new EventHandler<ActionEvent>() {
             /** {@inheritDoc} */
             @Override public void handle(ActionEvent evt) {
                 loadSchemas();
             }
         }));
 
-        TitledPane titledPnl = connPnl.add(titledPane("Schemas", schemaPnl, false), 3);
+        TitledPane titledPnl = connPnl.add(Controls.titledPane("Schemas", schemaPnl, false), 3);
 
         titledPnl.setExpanded(true);
 
         GridPaneEx.setValignment(titledPnl, VPos.TOP);
 
-        connLayerPnl = stackPane(connPnl);
+        connLayerPnl = Controls.stackPane(connPnl);
 
         return connLayerPnl;
     }
@@ -1230,7 +1166,7 @@ public class SchemaImportApp extends Application {
      * Create generate pane with controls.
      */
     private void createGeneratePane() {
-        genPnl = paneEx(10, 10, 0, 10);
+        genPnl = Controls.paneEx(10, 10, 0, 10);
 
         genPnl.addColumn();
         genPnl.addColumn(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
@@ -1239,10 +1175,10 @@ public class SchemaImportApp extends Application {
         genPnl.addRow(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
         genPnl.addRows(8);
 
-        TableColumn<PojoDescriptor, Boolean> useCol = customColumn("Schema / Table", "use",
+        TableColumn<PojoDescriptor, Boolean> useCol = Controls.customColumn("Schema / Table", "use",
             "If checked then this table will be used for XML and POJOs generation", PojoDescriptorCell.cellFactory());
 
-        TableColumn<PojoDescriptor, String> keyClsCol = textColumn("Key Class Name", "keyClassName", "Key class name",
+        TableColumn<PojoDescriptor, String> keyClsCol = Controls.textColumn("Key Class Name", "keyClassName", "Key class name",
             new TextColumnValidator<PojoDescriptor>() {
                 @Override public boolean valid(PojoDescriptor rowVal, String newVal) {
                     boolean valid = checkClassName(rowVal, newVal, true);
@@ -1254,8 +1190,8 @@ public class SchemaImportApp extends Application {
                 }
             });
 
-        TableColumn<PojoDescriptor, String> valClsCol = textColumn("Value Class Name", "valueClassName", "Value class name",
-            new TextColumnValidator<PojoDescriptor>() {
+        TableColumn<PojoDescriptor, String> valClsCol = Controls.textColumn("Value Class Name", "valueClassName",
+            "Value class name", new TextColumnValidator<PojoDescriptor>() {
                 @Override public boolean valid(PojoDescriptor rowVal, String newVal) {
                     boolean valid = checkClassName(rowVal, newVal, false);
 
@@ -1266,26 +1202,26 @@ public class SchemaImportApp extends Application {
                 }
             });
 
-        pojosTbl = tableView("Tables not found in database", useCol, keyClsCol, valClsCol);
+        pojosTbl = Controls.tableView("Tables not found in database", useCol, keyClsCol, valClsCol);
 
-        TableColumn<PojoField, Boolean> useFldCol = customColumn("Use", "use",
+        TableColumn<PojoField, Boolean> useFldCol = Controls.customColumn("Use", "use",
             "Check to use this field for XML and POJO generation\n" +
             "Note that NOT NULL columns cannot be unchecked", PojoFieldUseCell.cellFactory());
         useFldCol.setMinWidth(50);
         useFldCol.setMaxWidth(50);
 
-        TableColumn<PojoField, Boolean> keyCol = booleanColumn("Key", "key",
+        TableColumn<PojoField, Boolean> keyCol = Controls.booleanColumn("Key", "key",
             "Check to include this field into key object");
 
-        TableColumn<PojoField, Boolean> akCol = booleanColumn("AK", "affinityKey",
+        TableColumn<PojoField, Boolean> akCol = Controls.booleanColumn("AK", "affinityKey",
             "Check to annotate key filed with @AffinityKeyMapped annotation in generated POJO class\n" +
             "Note that a class can have only ONE key field annotated with @AffinityKeyMapped annotation");
 
-        TableColumn<PojoField, String> dbNameCol = tableColumn("DB Name", "dbName", "Field name in database");
+        TableColumn<PojoField, String> dbNameCol = Controls.tableColumn("DB Name", "dbName", "Field name in database");
 
-        TableColumn<PojoField, String> dbTypeNameCol = tableColumn("DB Type", "dbTypeName", "Field type in database");
+        TableColumn<PojoField, String> dbTypeNameCol = Controls.tableColumn("DB Type", "dbTypeName", "Field type in database");
 
-        TableColumn<PojoField, String> javaNameCol = textColumn("Java Name", "javaName", "Field name in POJO class",
+        TableColumn<PojoField, String> javaNameCol = Controls.textColumn("Java Name", "javaName", "Field name in POJO class",
             new TextColumnValidator<PojoField>() {
                 @Override public boolean valid(PojoField rowVal, String newVal) {
                     if (newVal.trim().isEmpty()) {
@@ -1307,25 +1243,25 @@ public class SchemaImportApp extends Application {
                 }
             });
 
-        TableColumn<PojoField, String> javaTypeNameCol = customColumn("Java Type", "javaTypeName",
+        TableColumn<PojoField, String> javaTypeNameCol = Controls.customColumn("Java Type", "javaTypeName",
             "Field java type in POJO class", JavaTypeCell.cellFactory());
 
-        fieldsTbl = tableView("Select table to see table columns",
+        fieldsTbl = Controls.tableView("Select table to see table columns",
             useFldCol, keyCol, akCol, dbNameCol, dbTypeNameCol, javaNameCol, javaTypeNameCol);
 
-        genPnl.add(splitPane(pojosTbl, fieldsTbl, 0.6), 3);
+        genPnl.add(Controls.splitPane(pojosTbl, fieldsTbl, 0.6), 3);
 
-        final GridPaneEx keyValPnl = paneEx(0, 0, 0, 0);
+        final GridPaneEx keyValPnl = Controls.paneEx(0, 0, 0, 0);
         keyValPnl.addColumn(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
         keyValPnl.addColumn();
         keyValPnl.addColumn(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
         keyValPnl.addColumn();
 
-        pkgTf = genPnl.addLabeled("Package:", textField("Package that will be used for POJOs generation"), 2);
+        pkgTf = genPnl.addLabeled("Package:", Controls.textField("Package that will be used for POJOs generation"), 2);
 
-        outFolderTf = genPnl.addLabeled("Output Folder:", textField("Output folder for XML and POJOs files"));
+        outFolderTf = genPnl.addLabeled("Output Folder:", Controls.textField("Output folder for XML and POJOs files"));
 
-        genPnl.add(button("...", "Select output folder", new EventHandler<ActionEvent>() {
+        genPnl.add(Controls.button("...", "Select output folder", new EventHandler<ActionEvent>() {
             @Override public void handle(ActionEvent evt) {
                 DirectoryChooser dc = new DirectoryChooser();
 
@@ -1346,33 +1282,33 @@ public class SchemaImportApp extends Application {
             }
         }));
 
-        pojoIncludeKeysCh = genPnl.add(checkBox("Include key fields into value POJOs",
+        pojoIncludeKeysCh = genPnl.add(Controls.checkBox("Include key fields into value POJOs",
             "If selected then include key fields into value object", true), 3);
 
-        pojoConstructorCh = genPnl.add(checkBox("Generate constructors for POJOs",
+        pojoConstructorCh = genPnl.add(Controls.checkBox("Generate constructors for POJOs",
             "If selected then generate empty and full constructors for POJOs", false), 3);
 
-        generateAliasesCh = genPnl.add(checkBox("Generate aliases for SQL fields",
+        generateAliasesCh = genPnl.add(Controls.checkBox("Generate aliases for SQL fields",
             "If selected then generate aliases for SQL fields with db names", true), 3);
 
-        xmlSingleFileCh = genPnl.add(checkBox("Write all configurations to a single XML file",
+        xmlSingleFileCh = genPnl.add(Controls.checkBox("Write all configurations to a single XML file",
             "If selected then all configurations will be saved into the file 'ignite-type-metadata.xml'", true), 3);
 
-        GridPaneEx regexPnl = paneEx(5, 5, 5, 5);
+        GridPaneEx regexPnl = Controls.paneEx(5, 5, 5, 5);
         regexPnl.addColumn();
         regexPnl.addColumn(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
         regexPnl.addColumn();
         regexPnl.addColumn(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
 
-        regexTf = regexPnl.addLabeled("  Regexp:", textField("Regular expression. For example: (\\w+)"));
+        regexTf = regexPnl.addLabeled("  Regexp:", Controls.textField("Regular expression. For example: (\\w+)"));
 
-        replaceTf = regexPnl.addLabeled("  Replace with:", textField("Replace text. For example: $1_SomeText"));
+        replaceTf = regexPnl.addLabeled("  Replace with:", Controls.textField("Replace text. For example: $1_SomeText"));
 
-        final ComboBox<String> replaceCb = regexPnl.addLabeled("  Replace:", comboBox("Replacement target",
+        final ComboBox<String> replaceCb = regexPnl.addLabeled("  Replace:", Controls.comboBox("Replacement target",
             "Key class names", "Value class names", "Java names"));
 
-        regexPnl.add(buttonsPane(Pos.CENTER_LEFT, false,
-            button("Rename Selected", "Replaces each substring of this string that matches the given regular expression" +
+        regexPnl.add(Controls.buttonsPane(Pos.CENTER_LEFT, false,
+            Controls.button("Rename Selected", "Replaces each substring of this string that matches the given regular expression" +
                     " with the given replacement",
                 new EventHandler<ActionEvent>() {
                     @Override public void handle(ActionEvent evt) {
@@ -1429,49 +1365,50 @@ public class SchemaImportApp extends Application {
                         }
                     }
                 }),
-            button("Reset Selected", "Revert changes for selected items to initial auto-generated values", new EventHandler<ActionEvent>() {
-                @Override public void handle(ActionEvent evt) {
-                    String sel = replaceCb.getSelectionModel().getSelectedItem();
+            Controls.button("Reset Selected", "Revert changes for selected items to initial auto-generated values",
+                new EventHandler<ActionEvent>() {
+                    @Override public void handle(ActionEvent evt) {
+                        String sel = replaceCb.getSelectionModel().getSelectedItem();
 
-                    boolean isFields = "Java names".equals(sel) && curTbl == fieldsTbl;
+                        boolean isFields = "Java names".equals(sel) && curTbl == fieldsTbl;
 
-                    String src = isFields ? "fields" : "tables";
+                        String src = isFields ? "fields" : "tables";
 
-                    String target = "\"" + sel + "\"";
+                        String target = "\"" + sel + "\"";
 
-                    Collection<PojoDescriptor> selPojos = pojosTbl.getSelectionModel().getSelectedItems();
+                        Collection<PojoDescriptor> selPojos = pojosTbl.getSelectionModel().getSelectedItems();
 
-                    Collection<PojoField> selFields = fieldsTbl.getSelectionModel().getSelectedItems();
+                        Collection<PojoField> selFields = fieldsTbl.getSelectionModel().getSelectedItems();
 
-                    boolean isEmpty = isFields ? selFields.isEmpty() : selPojos.isEmpty();
+                        boolean isEmpty = isFields ? selFields.isEmpty() : selPojos.isEmpty();
 
-                    if (isEmpty) {
-                        MessageBox.warningDialog(owner, "Please select " + src + "to revert " + target + "!");
+                        if (isEmpty) {
+                            MessageBox.warningDialog(owner, "Please select " + src + "to revert " + target + "!");
 
-                        return;
-                    }
+                            return;
+                        }
 
-                    if (!MessageBox.confirmDialog(owner,
-                        "Are you sure you want to revert " + target + " for all selected " + src + "?"))
-                        return;
+                        if (!MessageBox.confirmDialog(owner,
+                            "Are you sure you want to revert " + target + " for all selected " + src + "?"))
+                            return;
 
-                    switch (replaceCb.getSelectionModel().getSelectedIndex()) {
-                        case 0:
-                            revertKeyClassNames(selPojos);
-                            break;
+                        switch (replaceCb.getSelectionModel().getSelectedIndex()) {
+                            case 0:
+                                revertKeyClassNames(selPojos);
+                                break;
 
-                        case 1:
-                            revertValueClassNames(selPojos);
-                            break;
+                            case 1:
+                                revertValueClassNames(selPojos);
+                                break;
 
-                        default:
-                            if (isFields)
-                                revertFieldsJavaNames(selFields);
-                            else
-                                revertPojosJavaNames(selPojos);
+                            default:
+                                if (isFields)
+                                    revertFieldsJavaNames(selFields);
+                                else
+                                    revertPojosJavaNames(selPojos);
+                        }
                     }
-                }
-            })
+                })
         ), 2).setPadding(new Insets(0, 0, 0, 10));
 
         pojosTbl.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<PojoDescriptor>() {
@@ -1525,10 +1462,10 @@ public class SchemaImportApp extends Application {
             }
         });
 
-        genPnl.add(titledPane("Rename \"Key class name\", \"Value class name\" or  \"Java name\" for selected tables",
+        genPnl.add(Controls.titledPane("Rename \"Key class name\", \"Value class name\" or  \"Java name\" for selected tables",
             regexPnl, true), 3);
 
-        genLayerPnl = stackPane(genPnl);
+        genLayerPnl = Controls.stackPane(genPnl);
     }
 
     /**
@@ -1790,21 +1727,21 @@ public class SchemaImportApp extends Application {
         primaryStage.setTitle("Apache Ignite Auto Schema Import Utility");
 
         primaryStage.getIcons().addAll(
-            image("ignite", 16),
-            image("ignite", 24),
-            image("ignite", 32),
-            image("ignite", 48),
-            image("ignite", 64),
-            image("ignite", 128));
+            Controls.image("ignite", 16),
+            Controls.image("ignite", 24),
+            Controls.image("ignite", 32),
+            Controls.image("ignite", 48),
+            Controls.image("ignite", 64),
+            Controls.image("ignite", 128));
 
-        pi = progressIndicator(50);
+        pi = Controls.progressIndicator(50);
 
         createGeneratePane();
 
         hdrPane = createHeaderPane();
-        rootPane = borderPane(hdrPane, createConnectionPane(), createButtonsPane(), null, null);
+        rootPane = Controls.borderPane(hdrPane, createConnectionPane(), createButtonsPane(), null, null);
 
-        primaryStage.setScene(scene(rootPane));
+        primaryStage.setScene(Controls.scene(rootPane));
 
         primaryStage.setWidth(650);
         primaryStage.setMinWidth(650);
@@ -1924,50 +1861,49 @@ public class SchemaImportApp extends Application {
         savePreferences();
     }
 
-    /**
-     * Schema Import utility launcher.
-     *
-     * @param args Command line arguments passed to the application.
-     */
-    public static void main(String[] args) {
-        // Workaround for JavaFX ugly text AA.
-        System.setProperty("prism.lcdtext", "false");
-        System.setProperty("prism.text", "t2k");
-
-        // Workaround for AWT + JavaFX: we should initialize AWT before JavaFX.
-        java.awt.Toolkit.getDefaultToolkit();
-
-        // Workaround for JavaFX + Mac OS dock icon.
-        if (System.getProperty("os.name").toLowerCase().contains("mac os")) {
-            System.setProperty("javafx.macosx.embedded", "true");
+    /** Presets for database settings. */
+    private static class Preset {
+        /** Name in preferences. */
+        private String pref;
 
-            try {
-                Class<?> appCls = Class.forName("com.apple.eawt.Application");
+        /** RDBMS name to show on screen. */
+        private String name;
 
-                Object osxApp = appCls.getDeclaredMethod("getApplication").invoke(null);
+        /** Path to JDBC driver jar. */
+        private String jar;
 
-                appCls.getDeclaredMethod("setDockIconImage", java.awt.Image.class)
-                    .invoke(osxApp, fromFXImage(image("ignite", 128), null));
-            }
-            catch (Exception ignore) {
-                // No-op.
-            }
+        /** JDBC driver class name. */
+        private String drv;
 
-            // Workaround for JDK 7/JavaFX 2 application on Mac OSX El Capitan.
-            try {
-                Class<?> fontFinderCls = Class.forName("com.sun.t2k.MacFontFinder");
+        /** JDBC URL. */
+        private String url;
 
-                Field psNameToPathMap = fontFinderCls.getDeclaredField("psNameToPathMap");
+        /** User name. */
+        private String user;
 
-                psNameToPathMap.setAccessible(true);
-                psNameToPathMap.set(null, new HashMap<String, String>());
-            }
-            catch (Exception ignore) {
-                // No-op.
-            }
+        /**
+         * Preset constructor.
+         *
+         * @param pref Name in preferences.
+         * @param name RDBMS name to show on screen.
+         * @param jar Path to JDBC driver jar..
+         * @param drv JDBC driver class name.
+         * @param url JDBC URL.
+         * @param user User name.
+         */
+        Preset(String pref, String name, String jar, String drv, String url, String user) {
+            this.pref = pref;
+            this.name = name;
+            this.jar = jar;
+            this.drv = drv;
+            this.url = url;
+            this.user = user;
         }
 
-        launch(args);
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            return name;
+        }
     }
 
     /**
@@ -2065,6 +2001,12 @@ public class SchemaImportApp extends Application {
      * Special table cell to select schema or table.
      */
     private static class PojoDescriptorCell extends TableCell<PojoDescriptor, Boolean> {
+        /** Previous POJO bound to cell. */
+        private PojoDescriptor prevPojo;
+
+        /** Previous cell graphic. */
+        private Pane prevGraphic;
+
         /**
          * Creates a ComboBox cell factory for use in TableColumn controls.
          *
@@ -2078,12 +2020,6 @@ public class SchemaImportApp extends Application {
             };
         }
 
-        /** Previous POJO bound to cell. */
-        private PojoDescriptor prevPojo;
-
-        /** Previous cell graphic. */
-        private Pane prevGraphic;
-
         /** {@inheritDoc} */
         @Override public void updateItem(Boolean item, boolean empty) {
             super.updateItem(item, empty);
@@ -2126,6 +2062,12 @@ public class SchemaImportApp extends Application {
      * Special table cell to select &quot;used&quot; fields for code generation.
      */
     private static class PojoFieldUseCell extends TableCell<PojoField, Boolean> {
+        /** Previous POJO field bound to cell. */
+        private PojoField prevField;
+
+        /** Previous cell graphic. */
+        private CheckBox prevGraphic;
+
         /**
          * Creates a ComboBox cell factory for use in TableColumn controls.
          *
@@ -2139,12 +2081,6 @@ public class SchemaImportApp extends Application {
             };
         }
 
-        /** Previous POJO field bound to cell. */
-        private PojoField prevField;
-
-        /** Previous cell graphic. */
-        private CheckBox prevGraphic;
-
         /** {@inheritDoc} */
         @Override public void updateItem(Boolean item, boolean empty) {
             super.updateItem(item, empty);

http://git-wip-us.apache.org/repos/asf/ignite/blob/fa197d2f/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index d5ee939..5945842 100644
--- a/pom.xml
+++ b/pom.xml
@@ -681,6 +681,7 @@
             </activation>
             <modules>
                 <module>modules/schema-import</module>
+                <module>modules/schema-import-db</module>
             </modules>
             <build>
                 <plugins>
@@ -737,6 +738,7 @@
             </activation>
             <modules>
                 <module>modules/schema-import</module>
+                <module>modules/schema-import-db</module>
             </modules>
             <build>
                 <plugins>


[11/14] ignite git commit: Merge remote-tracking branch 'origin/ignite-1.6' into ignite-1.6

Posted by av...@apache.org.
Merge remote-tracking branch 'origin/ignite-1.6' into ignite-1.6


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

Branch: refs/heads/master
Commit: a606f59b53aa4abaee7991cddd47bcfd212e58a1
Parents: 992fe66 b95487d
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Tue May 17 15:11:16 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue May 17 15:11:16 2016 +0300

----------------------------------------------------------------------
 .../cache/jta/websphere/package-info.java       | 22 ++++++++++++++++++++
 1 file changed, 22 insertions(+)
----------------------------------------------------------------------



[06/14] ignite git commit: ignite-1.6 Additional logging in benchmark.

Posted by av...@apache.org.
ignite-1.6 Additional logging in benchmark.


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

Branch: refs/heads/master
Commit: fb0b0e0124eb42a2d81011e2eea567a70228c55e
Parents: 21daa23
Author: sboikov <sb...@gridgain.com>
Authored: Tue May 17 13:55:04 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue May 17 13:55:04 2016 +0300

----------------------------------------------------------------------
 .../ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java    | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/fb0b0e01/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java
index 6c25ec0..da5cb1d 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java
@@ -27,6 +27,7 @@ import java.util.concurrent.atomic.AtomicInteger;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.cache.affinity.Affinity;
 import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.internal.util.typedef.T2;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
@@ -52,6 +53,10 @@ public abstract class IgniteCacheAbstractBenchmark<K, V> extends IgniteAbstractB
 
         cache = cache();
 
+        BenchmarkUtils.println(cfg, "Benchmark setUp [name=" + getClass().getSimpleName() +
+            ", cacheName="+ cache.getName() +
+            ", cacheCfg=" + cache.getConfiguration(CacheConfiguration.class) + ']');
+
         if (args.printPartitionStatistics()) {
             Map<ClusterNode, T2<List<Integer>, List<Integer>>> parts = new HashMap<>();
 


[10/14] ignite git commit: IGNITE-3149: IGFS: Simplified default configuration and added some sensible defaults which are set automatically.

Posted by av...@apache.org.
IGNITE-3149: IGFS: Simplified default configuration and added some sensible defaults which are set automatically.


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

Branch: refs/heads/master
Commit: 992fe660b5efc788ce8106c274cbc0aadf01d9f6
Parents: b369d03
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Tue May 17 15:11:01 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue May 17 15:11:01 2016 +0300

----------------------------------------------------------------------
 config/hadoop/default-config.xml                | 111 +++++--------------
 .../configuration/FileSystemConfiguration.java  |   4 +-
 .../configuration/HadoopConfiguration.java      |   2 +-
 .../igfs/IgfsGroupDataBlocksKeyMapper.java      |  43 ++++++-
 .../processors/igfs/IgfsDataManager.java        |   2 +-
 .../processors/igfs/IgfsDeleteWorker.java       |  10 +-
 .../internal/processors/igfs/IgfsProcessor.java |   2 +-
 .../internal/processors/igfs/IgfsUtils.java     |  14 +++
 8 files changed, 92 insertions(+), 96 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/992fe660/config/hadoop/default-config.xml
----------------------------------------------------------------------
diff --git a/config/hadoop/default-config.xml b/config/hadoop/default-config.xml
index 30413b0..d8d3636 100644
--- a/config/hadoop/default-config.xml
+++ b/config/hadoop/default-config.xml
@@ -50,54 +50,32 @@
     </bean>
 
     <!--
-        Abstract IGFS file system configuration to be used as a template.
-    -->
-    <bean id="igfsCfgBase" class="org.apache.ignite.configuration.FileSystemConfiguration" abstract="true">
-        <!-- Must correlate with cache affinity mapper. -->
-        <property name="blockSize" value="#{128 * 1024}"/>
-        <property name="perNodeBatchSize" value="512"/>
-        <property name="perNodeParallelBatchCount" value="16"/>
-
-        <property name="prefetchBlocks" value="32"/>
-    </bean>
-
-    <!--
-        Abstract cache configuration for IGFS file data to be used as a template.
-    -->
-    <bean id="dataCacheCfgBase" class="org.apache.ignite.configuration.CacheConfiguration" abstract="true">
-        <property name="cacheMode" value="PARTITIONED"/>
-        <property name="atomicityMode" value="TRANSACTIONAL"/>
-        <property name="writeSynchronizationMode" value="FULL_SYNC"/>
-        <property name="backups" value="0"/>
-        <property name="affinityMapper">
-            <bean class="org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper">
-                <!-- How many sequential blocks will be stored on the same node. -->
-                <constructor-arg value="512"/>
-            </bean>
-        </property>
-    </bean>
-
-    <!--
-        Abstract cache configuration for IGFS metadata to be used as a template.
-    -->
-    <bean id="metaCacheCfgBase" class="org.apache.ignite.configuration.CacheConfiguration" abstract="true">
-        <property name="cacheMode" value="REPLICATED"/>
-        <property name="atomicityMode" value="TRANSACTIONAL"/>
-        <property name="writeSynchronizationMode" value="FULL_SYNC"/>
-    </bean>
-
-    <!--
         Configuration of Ignite node.
     -->
     <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
         <!--
-            Apache Hadoop Accelerator configuration.
+            Configure caches where IGFS will store data.
         -->
-        <property name="hadoopConfiguration">
-            <bean class="org.apache.ignite.configuration.HadoopConfiguration">
-                <!-- Information about finished jobs will be kept for 30 seconds. -->
-                <property name="finishedJobInfoTtl" value="30000"/>
-            </bean>
+        <property name="cacheConfiguration">
+            <list>
+                <!--
+                    Configure metadata cache where file system structure will be stored. It must be TRANSACTIONAL,
+                    and must have backups to maintain file system consistency in case of node crash.
+                -->
+                <bean class="org.apache.ignite.configuration.CacheConfiguration">
+                    <property name="name" value="igfs-meta"/>
+                    <property name="cacheMode" value="REPLICATED"/>
+                    <property name="atomicityMode" value="TRANSACTIONAL"/>
+                </bean>
+
+                <!--
+                    Configure data cache where file's data will be stored.
+                -->
+                <bean class="org.apache.ignite.configuration.CacheConfiguration">
+                    <property name="name" value="igfs-data"/>
+                    <property name="atomicityMode" value="TRANSACTIONAL"/>
+                </bean>
+            </list>
         </property>
 
         <!--
@@ -114,7 +92,8 @@
         -->
         <property name="fileSystemConfiguration">
             <list>
-                <bean class="org.apache.ignite.configuration.FileSystemConfiguration" parent="igfsCfgBase">
+                <bean class="org.apache.ignite.configuration.FileSystemConfiguration">
+                    <!-- IGFS name you will use to access IGFS through Hadoop API. -->
                     <property name="name" value="igfs"/>
 
                     <!-- Caches with these names must be configured. -->
@@ -130,19 +109,17 @@
                         </bean>
                     </property>
 
-                    <!-- Sample secondary file system configuration.
-                        'uri'      - the URI of the secondary file system.
-                        'cfgPath'  - optional configuration path of the secondary file system,
-                            e.g. /opt/foo/core-site.xml. Typically left to be null.
-                        'userName' - optional user name to access the secondary file system on behalf of. Use it
-                            if Hadoop client and the Ignite node are running on behalf of different users.
+                    <!--
+                        Configure secondary file system if needed.
                     -->
                     <!--
                     <property name="secondaryFileSystem">
                         <bean class="org.apache.ignite.hadoop.fs.IgniteHadoopIgfsSecondaryFileSystem">
-                            <constructor-arg name="uri" value="hdfs://localhost:9000"/>
-                            <constructor-arg name="cfgPath"><null/></constructor-arg>
-                            <constructor-arg name="userName" value="client-user-name"/>
+                            <property name="fileSystemFactory">
+                                <bean class="org.apache.ignite.hadoop.fs.CachingHadoopFileSystemFactory">
+                                    <property name="uri" value="hdfs://your_hdfs_host:9000"/>
+                                </bean>
+                            </property>
                         </bean>
                     </property>
                     -->
@@ -151,34 +128,6 @@
         </property>
 
         <!--
-            Caches needed by IGFS.
-        -->
-        <property name="cacheConfiguration">
-            <list>
-                <!-- File system metadata cache. -->
-                <bean class="org.apache.ignite.configuration.CacheConfiguration" parent="metaCacheCfgBase">
-                    <property name="name" value="igfs-meta"/>
-                </bean>
-
-                <!-- File system files data cache. -->
-                <bean class="org.apache.ignite.configuration.CacheConfiguration" parent="dataCacheCfgBase">
-                    <property name="name" value="igfs-data"/>
-                </bean>
-            </list>
-        </property>
-
-        <!--
-            Disable events.
-        -->
-        <property name="includeEventTypes">
-            <list>
-                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FAILED"/>
-                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FINISHED"/>
-                <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_MAPPED"/>
-            </list>
-        </property>
-
-        <!--
             TCP discovery SPI can be configured with list of addresses if multicast is not available.
         -->
         <!--

http://git-wip-us.apache.org/repos/asf/ignite/blob/992fe660/modules/core/src/main/java/org/apache/ignite/configuration/FileSystemConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/FileSystemConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/FileSystemConfiguration.java
index 518bbf6..75a9db0 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/FileSystemConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/FileSystemConfiguration.java
@@ -59,10 +59,10 @@ public class FileSystemConfiguration {
     public static final String DFLT_IGFS_LOG_DIR = "work/igfs/log";
 
     /** Default per node buffer size. */
-    public static final int DFLT_PER_NODE_BATCH_SIZE = 100;
+    public static final int DFLT_PER_NODE_BATCH_SIZE = 512;
 
     /** Default number of per node parallel operations. */
-    public static final int DFLT_PER_NODE_PARALLEL_BATCH_CNT = 8;
+    public static final int DFLT_PER_NODE_PARALLEL_BATCH_CNT = 16;
 
     /** Default IGFS mode. */
     public static final IgfsMode DFLT_MODE = IgfsMode.DUAL_ASYNC;

http://git-wip-us.apache.org/repos/asf/ignite/blob/992fe660/modules/core/src/main/java/org/apache/ignite/configuration/HadoopConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/HadoopConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/HadoopConfiguration.java
index 51aa291..95ce9d3 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/HadoopConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/HadoopConfiguration.java
@@ -25,7 +25,7 @@ import org.apache.ignite.internal.util.typedef.internal.S;
  */
 public class HadoopConfiguration {
     /** Default finished job info time-to-live. */
-    public static final long DFLT_FINISHED_JOB_INFO_TTL = 10_000;
+    public static final long DFLT_FINISHED_JOB_INFO_TTL = 30_000;
 
     /** Default value for external execution flag. */
     public static final boolean DFLT_EXTERNAL_EXECUTION = false;

http://git-wip-us.apache.org/repos/asf/ignite/blob/992fe660/modules/core/src/main/java/org/apache/ignite/igfs/IgfsGroupDataBlocksKeyMapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/igfs/IgfsGroupDataBlocksKeyMapper.java b/modules/core/src/main/java/org/apache/ignite/igfs/IgfsGroupDataBlocksKeyMapper.java
index 317c645..b35b692 100644
--- a/modules/core/src/main/java/org/apache/ignite/igfs/IgfsGroupDataBlocksKeyMapper.java
+++ b/modules/core/src/main/java/org/apache/ignite/igfs/IgfsGroupDataBlocksKeyMapper.java
@@ -31,12 +31,12 @@ import org.apache.ignite.internal.util.typedef.internal.S;
  * {@code 64kb * 256 = 16Mb}. Larger group sizes would reduce number of splits required to run map-reduce
  * tasks, but will increase inequality of data size being stored on different nodes.
  * <p>
- * Note that {@link #groupSize()} parameter must correlate to Hadoop split size parameter defined
+ * Note that {@link #getGroupSize()} parameter must correlate to Hadoop split size parameter defined
  * in Hadoop via {@code mapred.max.split.size} property. Ideally you want all blocks accessed
  * within one split to be mapped to {@code 1} group, so they can be located on the same grid node.
  * For example, default Hadoop split size is {@code 64mb} and default {@code IGFS} block size
  * is {@code 64kb}. This means that to make sure that each split goes only through blocks on
- * the same node (without hopping between nodes over network), we have to make the {@link #groupSize()}
+ * the same node (without hopping between nodes over network), we have to make the {@link #getGroupSize()}
  * value be equal to {@code 64mb / 64kb = 1024}.
  * <p>
  * It is required for {@code IGFS} data cache to be configured with this mapper. Here is an
@@ -47,7 +47,7 @@ import org.apache.ignite.internal.util.typedef.internal.S;
  *     &lt;property name="affinityMapper"&gt;
  *         &lt;bean class="org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper"&gt;
  *             &lt;!-- How many sequential blocks will be stored on the same node. --&gt;
- *             &lt;constructor-arg value="512"/&gt;
+ *             &lt;property name="groupSize" value="512"/&gt;
  *         &lt;/bean&gt;
  *     &lt;/property&gt;
  *     ...
@@ -58,8 +58,18 @@ public class IgfsGroupDataBlocksKeyMapper extends GridCacheDefaultAffinityKeyMap
     /** */
     private static final long serialVersionUID = 0L;
 
+    /** Default group size.*/
+    public static final int DFLT_GRP_SIZE = 1024;
+
     /** Size of the group. */
-    private final int grpSize;
+    private int grpSize = DFLT_GRP_SIZE;
+
+    /**
+     * Default constructor.
+     */
+    public IgfsGroupDataBlocksKeyMapper() {
+        // No-op.
+    }
 
     /***
      * Constructs affinity mapper to group several data blocks with the same key.
@@ -89,12 +99,33 @@ public class IgfsGroupDataBlocksKeyMapper extends GridCacheDefaultAffinityKeyMap
     }
 
     /**
-     * @return Size of the group.
+     * Get group size.
+     * <p>
+     * Group size defines how many sequential file blocks will reside on the same node. This parameter
+     * must correlate to Hadoop split size parameter defined in Hadoop via {@code mapred.max.split.size}
+     * property. Ideally you want all blocks accessed within one split to be mapped to {@code 1} group,
+     * so they can be located on the same grid node. For example, default Hadoop split size is {@code 64mb}
+     * and default {@code IGFS} block size is {@code 64kb}. This means that to make sure that each split
+     * goes only through blocks on the same node (without hopping between nodes over network), we have to
+     * make the group size be equal to {@code 64mb / 64kb = 1024}.
+     * <p>
+     * Defaults to {@link #DFLT_GRP_SIZE}.
+     *
+     * @return Group size.
      */
-    public int groupSize() {
+    public int getGroupSize() {
         return grpSize;
     }
 
+    /**
+     * Set group size. See {@link #getGroupSize()} for more information.
+     *
+     * @param grpSize Group size.
+     */
+    public void setGroupSize(int grpSize) {
+        this.grpSize = grpSize;
+    }
+
     /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(IgfsGroupDataBlocksKeyMapper.class, this);

http://git-wip-us.apache.org/repos/asf/ignite/blob/992fe660/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
index 16fbeb8..77fb0a9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
@@ -253,7 +253,7 @@ public class IgfsDataManager extends IgfsManager {
             .internalCache(igfsCtx.configuration().getDataCacheName()).configuration().getAffinityMapper();
 
         grpSize = mapper instanceof IgfsGroupDataBlocksKeyMapper ?
-            ((IgfsGroupDataBlocksKeyMapper)mapper).groupSize() : 1;
+            ((IgfsGroupDataBlocksKeyMapper)mapper).getGroupSize() : 1;
 
         grpBlockSize = igfsCtx.configuration().getBlockSize() * grpSize;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/992fe660/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
index aef60dd..bac7569 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
@@ -27,7 +27,6 @@ import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException
 import org.apache.ignite.internal.managers.communication.GridIoPolicy;
 import org.apache.ignite.internal.util.future.GridCompoundFuture;
 import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.LT;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteUuid;
 
@@ -169,11 +168,14 @@ public class IgfsDeleteWorker extends IgfsThread {
         try {
             info = meta.info(trashId);
         }
-        catch (ClusterTopologyServerNotFoundException e) {
-            LT.warn(log, e, "Server nodes not found.");
+        catch (ClusterTopologyServerNotFoundException ignore) {
+            // Ignore.
         }
         catch (IgniteCheckedException e) {
-            U.error(log, "Cannot obtain trash directory info.", e);
+            U.warn(log, "Cannot obtain trash directory info (is node stopping?)");
+
+            if (log.isDebugEnabled())
+                U.error(log, "Cannot obtain trash directory info.", e);
         }
 
         if (info != null) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/992fe660/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
index f152170..82404e7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
@@ -162,7 +162,7 @@ public class IgfsProcessor extends IgfsProcessorAdapter {
             attrVals.add(new IgfsAttributes(
                 igfsCfg.getName(),
                 igfsCfg.getBlockSize(),
-                ((IgfsGroupDataBlocksKeyMapper)affMapper).groupSize(),
+                ((IgfsGroupDataBlocksKeyMapper)affMapper).getGroupSize(),
                 igfsCfg.getMetaCacheName(),
                 igfsCfg.getDataCacheName(),
                 igfsCfg.getDefaultMode(),

http://git-wip-us.apache.org/repos/asf/ignite/blob/992fe660/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
index 2b31868..45d4bb6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
@@ -23,6 +23,7 @@ import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.binary.BinaryRawReader;
 import org.apache.ignite.binary.BinaryRawWriter;
 import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.CacheWriteSynchronizationMode;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.cluster.ClusterTopologyException;
 import org.apache.ignite.configuration.CacheConfiguration;
@@ -30,6 +31,7 @@ import org.apache.ignite.configuration.FileSystemConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.events.IgfsEvent;
 import org.apache.ignite.igfs.IgfsException;
+import org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper;
 import org.apache.ignite.igfs.IgfsPath;
 import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.binary.BinaryUtils;
@@ -356,8 +358,12 @@ public class IgfsUtils {
             for (FileSystemConfiguration igfsCfg : igfsCfgs) {
                 if (igfsCfg != null) {
                     if (F.eq(ccfg.getName(), igfsCfg.getMetaCacheName())) {
+                        // No copy-on-read.
                         ccfg.setCopyOnRead(false);
 
+                        // Always full-sync to maintain consistency.
+                        ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
+
                         // Set co-located affinity mapper if needed.
                         if (igfsCfg.isColocateMetadata() && ccfg.getCacheMode() == CacheMode.REPLICATED &&
                             ccfg.getAffinityMapper() == null)
@@ -367,8 +373,16 @@ public class IgfsUtils {
                     }
 
                     if (F.eq(ccfg.getName(), igfsCfg.getDataCacheName())) {
+                        // No copy-on-read.
                         ccfg.setCopyOnRead(false);
 
+                        // Always full-sync to maintain consistency.
+                        ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
+
+                        // Set affinity mapper if needed.
+                        if (ccfg.getAffinityMapper() == null)
+                            ccfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper());
+
                         return;
                     }
                 }


[05/14] ignite git commit: ignite-1.6 Fixed NPE in GridDhtTxFinishFuture.onDone

Posted by av...@apache.org.
ignite-1.6 Fixed NPE in GridDhtTxFinishFuture.onDone


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

Branch: refs/heads/master
Commit: 21daa23ce0d1bdb1e1e28247aac7cd29ece5c898
Parents: e5c8dfe
Author: sboikov <sb...@gridgain.com>
Authored: Tue May 17 11:09:21 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue May 17 11:09:50 2016 +0300

----------------------------------------------------------------------
 .../processors/cache/distributed/dht/GridDhtTxFinishFuture.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/21daa23c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishFuture.java
index ebda52c..de04782 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishFuture.java
@@ -218,7 +218,7 @@ public final class GridDhtTxFinishFuture<K, V> extends GridCompoundIdentityFutur
                 if (finishErr == null)
                     finishErr = this.tx.commitError();
 
-                if (tx.syncMode() != PRIMARY_SYNC)
+                if (this.tx.syncMode() != PRIMARY_SYNC)
                     this.tx.sendFinishReply(commit, finishErr);
 
                 // Don't forget to clean up.


[12/14] ignite git commit: IGNITE-3098: UTF-16 surrogate pairs are not properly serialized by BinaryMarshaller

Posted by av...@apache.org.
IGNITE-3098: UTF-16 surrogate pairs are not properly serialized by BinaryMarshaller


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

Branch: refs/heads/master
Commit: e49522b4ec4fb67cd69a7101a1bc796746d82b4a
Parents: a606f59
Author: Denis Magda <dm...@gridgain.com>
Authored: Tue May 17 15:46:27 2016 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Tue May 17 15:46:27 2016 +0300

----------------------------------------------------------------------
 .../apache/ignite/IgniteSystemProperties.java   |   8 +
 .../apache/ignite/internal/IgniteKernal.java    |   7 +
 .../ignite/internal/IgniteNodeAttributes.java   |   4 +
 .../ignite/internal/binary/BinaryUtils.java     | 176 +++++++++++++++++--
 .../internal/binary/BinaryWriterExImpl.java     |   7 +-
 .../discovery/GridDiscoveryManager.java         |  21 +++
 .../ignite/spi/discovery/tcp/ServerImpl.java    |  44 +++++
 .../binary/BinaryMarshallerSelfTest.java        | 158 ++++++++++++-----
 .../GridDiscoveryManagerAttributesSelfTest.java |  63 +++++++
 9 files changed, 431 insertions(+), 57 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/e49522b4/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
index 35d190f..c28181e 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
@@ -394,6 +394,14 @@ public final class IgniteSystemProperties {
         "IGNITE_OPTIMIZED_MARSHALLER_USE_DEFAULT_SUID";
 
     /**
+     * Manages type of serialization mechanism for {@link String} that is marshalled/unmarshalled by BinaryMarshaller.
+     * Should be used for cases when a String contains a surrogate symbol without its pair one. This is frequently used
+     * in algorithms that encrypts data in String format.
+     */
+    public static final String IGNITE_BINARY_MARSHALLER_USE_STRING_SERIALIZATION_VER_2 =
+        "IGNITE_BINARY_MARSHALLER_USE_STRING_SERIALIZATION_VER_2";
+
+    /**
      * If set to {@code true}, then default selected keys set is used inside
      * {@code GridNioServer} which lead to some extra garbage generation when
      * processing selected keys.

http://git-wip-us.apache.org/repos/asf/ignite/blob/e49522b4/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index 0f180b2..18e5c62 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -84,6 +84,7 @@ import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.configuration.NearCacheConfiguration;
 import org.apache.ignite.internal.binary.BinaryEnumCache;
 import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.internal.binary.BinaryUtils;
 import org.apache.ignite.internal.cluster.ClusterGroupAdapter;
 import org.apache.ignite.internal.cluster.IgniteClusterEx;
 import org.apache.ignite.internal.managers.GridManager;
@@ -179,6 +180,7 @@ import static org.apache.ignite.IgniteSystemProperties.IGNITE_OPTIMIZED_MARSHALL
 import static org.apache.ignite.IgniteSystemProperties.IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK;
 import static org.apache.ignite.IgniteSystemProperties.IGNITE_STARVATION_CHECK_INTERVAL;
 import static org.apache.ignite.IgniteSystemProperties.IGNITE_SUCCESS_FILE;
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_BINARY_MARSHALLER_USE_STRING_SERIALIZATION_VER_2;
 import static org.apache.ignite.IgniteSystemProperties.getBoolean;
 import static org.apache.ignite.IgniteSystemProperties.snapshot;
 import static org.apache.ignite.internal.GridKernalState.DISCONNECTED;
@@ -207,6 +209,7 @@ import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MACS;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MARSHALLER;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MARSHALLER_COMPACT_FOOTER;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MARSHALLER_USE_DFLT_SUID;
+import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MARSHALLER_USE_BINARY_STRING_SER_VER_2;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_NODE_CONSISTENT_ID;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PEER_CLASSLOADING;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PHY_RAM;
@@ -1301,6 +1304,10 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
             add(ATTR_MARSHALLER_COMPACT_FOOTER, cfg.getBinaryConfiguration() == null ?
                 BinaryConfiguration.DFLT_COMPACT_FOOTER :
                 cfg.getBinaryConfiguration().isCompactFooter());
+
+            add(ATTR_MARSHALLER_USE_BINARY_STRING_SER_VER_2,
+                getBoolean(IGNITE_BINARY_MARSHALLER_USE_STRING_SERIALIZATION_VER_2,
+                    BinaryUtils.USE_STR_SERIALIZATION_VER_2));
         }
 
         add(ATTR_USER_NAME, System.getProperty("user.name"));

http://git-wip-us.apache.org/repos/asf/ignite/blob/e49522b4/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java
index 3493eae..0e6a254 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java
@@ -39,6 +39,10 @@ public final class IgniteNodeAttributes {
     /** Attribute for marshaller compact footers. */
     public static final String ATTR_MARSHALLER_COMPACT_FOOTER = ATTR_PREFIX + ".marshaller.compactFooter";
 
+    /** Internal attribute constant that controls which String serialization version to use. */
+    public static final String ATTR_MARSHALLER_USE_BINARY_STRING_SER_VER_2 = ATTR_PREFIX +
+        ".marshaller.utf8SerializationVer2";
+
     /** Internal attribute name constant. */
     public static final String ATTR_JIT_NAME = ATTR_PREFIX + ".jit.name";
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/e49522b4/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
index c0202dd..f1a7759 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
@@ -46,6 +46,7 @@ import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentSkipListSet;
 import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.binary.BinaryCollectionFactory;
 import org.apache.ignite.binary.BinaryInvalidTypeException;
 import org.apache.ignite.binary.BinaryMapFactory;
@@ -63,6 +64,7 @@ import org.apache.ignite.lang.IgniteUuid;
 import org.jetbrains.annotations.Nullable;
 import org.jsr166.ConcurrentHashMap8;
 
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_BINARY_MARSHALLER_USE_STRING_SERIALIZATION_VER_2;
 import static java.nio.charset.StandardCharsets.UTF_8;
 
 /**
@@ -75,6 +77,10 @@ public class BinaryUtils {
     /** */
     public static final Map<Byte, Class<?>> FLAG_TO_CLASS = new HashMap<>();
 
+    /** */
+    public static final boolean USE_STR_SERIALIZATION_VER_2 = IgniteSystemProperties.getBoolean(
+        IGNITE_BINARY_MARSHALLER_USE_STRING_SERIALIZATION_VER_2, false);
+
     /** {@code true} if serialized value of this type cannot contain references to objects. */
     private static final boolean[] PLAIN_TYPE_FLAG = new boolean[102];
 
@@ -415,7 +421,7 @@ public class BinaryUtils {
                 break;
 
             case GridBinaryMarshaller.TIMESTAMP:
-                writer.doWriteTimestamp((Timestamp) val);
+                writer.doWriteTimestamp((Timestamp)val);
 
                 break;
 
@@ -614,7 +620,8 @@ public class BinaryUtils {
     }
 
     /**
-     * Attempts to create a new map of the same type as {@code map} has. Otherwise returns new {@code HashMap} instance.
+     * Attempts to create a new map of the same type as {@code map} has. Otherwise returns new {@code HashMap}
+     * instance.
      *
      * @param map Original map.
      * @return New map.
@@ -648,8 +655,7 @@ public class BinaryUtils {
     }
 
     /**
-     * Attempts to create a new collection of the same known type. Will return null if collection type is
-     * unknown.
+     * Attempts to create a new collection of the same known type. Will return null if collection type is unknown.
      *
      * @param col Collection.
      * @return New empty collection.
@@ -674,7 +680,8 @@ public class BinaryUtils {
     }
 
     /**
-     * Attempts to create a new set of the same type as {@code set} has. Otherwise returns new {@code HashSet} instance.
+     * Attempts to create a new set of the same type as {@code set} has. Otherwise returns new {@code HashSet}
+     * instance.
      *
      * @param set Original set.
      * @return New set.
@@ -780,7 +787,7 @@ public class BinaryUtils {
 
         int len = length(in, start);
 
-        if (hasSchema(flags)){
+        if (hasSchema(flags)) {
             // Schema exists.
             if (hasRaw(flags))
                 // Raw offset is set, it is at the very end of the object.
@@ -1150,15 +1157,28 @@ public class BinaryUtils {
      * @return Value.
      */
     public static String doReadString(BinaryInputStream in) {
-        if (!in.hasArray())
-            return new String(doReadByteArray(in), UTF_8);
+        if (!in.hasArray()) {
+            byte[] arr = doReadByteArray(in);
+
+            if (USE_STR_SERIALIZATION_VER_2)
+                return utf8BytesToStr(arr, 0, arr.length);
+            else
+                return new String(arr, UTF_8);
+        }
 
         int strLen = in.readInt();
 
         int pos = in.position();
 
         // String will copy necessary array part for us.
-        String res = new String(in.array(), pos, strLen, UTF_8);
+        String res;
+
+        if (USE_STR_SERIALIZATION_VER_2) {
+            res = utf8BytesToStr(in.array(), pos, strLen);
+        }
+        else {
+            res = new String(in.array(), pos, strLen, UTF_8);
+        }
 
         in.position(pos + strLen);
 
@@ -1485,7 +1505,7 @@ public class BinaryUtils {
     private static Object[] doReadBinaryEnumArray(BinaryInputStream in, BinaryContext ctx) {
         int len = in.readInt();
 
-        Object[] arr = (Object[]) Array.newInstance(BinaryObject.class, len);
+        Object[] arr = (Object[])Array.newInstance(BinaryObject.class, len);
 
         for (int i = 0; i < len; i++) {
             byte flag = in.readByte();
@@ -1524,7 +1544,7 @@ public class BinaryUtils {
         throws BinaryObjectException {
         int len = in.readInt();
 
-        Object[] arr = (Object[]) Array.newInstance(cls, len);
+        Object[] arr = (Object[])Array.newInstance(cls, len);
 
         for (int i = 0; i < len; i++) {
             byte flag = in.readByte();
@@ -2013,6 +2033,140 @@ public class BinaryUtils {
     }
 
     /**
+     * Reconstructs string from UTF-8 bytes.
+     *
+     * @param arr array Byte array.
+     * @param off offset Offset in the array.
+     * @param len length Byte array lenght.
+     * @return string Resulting string.
+     */
+    public static String utf8BytesToStr(byte[] arr, int off, int len) {
+        int c, charArrCnt = 0, total = off + len;
+        int c2, c3;
+        char[] res = new char[len];
+
+        // try reading ascii
+        while (off < total) {
+            c = (int)arr[off] & 0xff;
+
+            if (c > 127)
+                break;
+
+            off++;
+
+            res[charArrCnt++] = (char)c;
+        }
+
+        // read other
+        while (off < total) {
+            c = (int)arr[off] & 0xff;
+
+            switch (c >> 4) {
+                case 0:
+                case 1:
+                case 2:
+                case 3:
+                case 4:
+                case 5:
+                case 6:
+                case 7:
+                    /* 0xxxxxxx*/
+                    off++;
+
+                    res[charArrCnt++] = (char)c;
+
+                    break;
+                case 12:
+                case 13:
+                    /* 110x xxxx   10xx xxxx*/
+                    off += 2;
+
+                    if (off > total)
+                        throw new BinaryObjectException("Malformed input: partial character at end");
+
+                    c2 = (int)arr[off - 1];
+
+                    if ((c2 & 0xC0) != 0x80)
+                        throw new BinaryObjectException("Malformed input around byte: " + off);
+
+                    res[charArrCnt++] = (char)(((c & 0x1F) << 6) | (c2 & 0x3F));
+
+                    break;
+                case 14:
+                    /* 1110 xxxx  10xx xxxx  10xx xxxx */
+                    off += 3;
+
+                    if (off > total)
+                        throw new BinaryObjectException("Malformed input: partial character at end");
+
+                    c2 = (int)arr[off - 2];
+
+                    c3 = (int)arr[off - 1];
+
+                    if (((c2 & 0xC0) != 0x80) || ((c3 & 0xC0) != 0x80))
+                        throw new BinaryObjectException("Malformed input around byte: " + (off - 1));
+
+                    res[charArrCnt++] = (char)(((c & 0x0F) << 12) |
+                        ((c2 & 0x3F) << 6) |
+                        ((c3 & 0x3F) << 0));
+
+                    break;
+                default:
+                    /* 10xx xxxx,  1111 xxxx */
+                    throw new BinaryObjectException("Malformed input around byte: " + off);
+            }
+        }
+
+        return len == charArrCnt ? new String(res) : new String(res, 0, charArrCnt);
+    }
+
+    /**
+     * Converts the string into UTF-8 byte array considering special symbols like the surrogates.
+     *
+     * @param val String to convert.
+     * @return Resulting byte array.
+     */
+    public static byte[] strToUtf8Bytes(String val) {
+        int strLen = val.length();
+        int utfLen = 0;
+        int c, cnt;
+
+        // Determine length of resulting byte array.
+        for (cnt = 0; cnt < strLen; cnt++) {
+            c = val.charAt(cnt);
+
+            if (c >= 0x0001 && c <= 0x007F)
+                utfLen++;
+            else if (c > 0x07FF)
+                utfLen += 3;
+            else
+                utfLen += 2;
+        }
+
+        byte[] arr = new byte[utfLen];
+
+        int position = 0;
+
+        for (cnt = 0; cnt < strLen; cnt++) {
+            c = val.charAt(cnt);
+
+            if (c >= 0x0001 && c <= 0x007F)
+                arr[position++] = (byte)c;
+            else if (c > 0x07FF) {
+                arr[position++] = (byte)(0xE0 | (c >> 12) & 0x0F);
+                arr[position++] = (byte)(0x80 | (c >> 6) & 0x3F);
+                arr[position++] = (byte)(0x80 | (c & 0x3F));
+            }
+            else {
+                arr[position++] = (byte)(0xC0 | ((c >> 6) & 0x1F));
+                arr[position++] = (byte)(0x80 | (c  & 0x3F));
+            }
+        }
+
+        return arr;
+    }
+
+    /**
      * Enum type.
      */
     private static class EnumType {

http://git-wip-us.apache.org/repos/asf/ignite/blob/e49522b4/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
index 8060a13..30710f4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
@@ -379,7 +379,12 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
         if (val == null)
             out.writeByte(GridBinaryMarshaller.NULL);
         else {
-            byte[] strArr = val.getBytes(UTF_8);
+            byte[] strArr;
+
+            if (BinaryUtils.USE_STR_SERIALIZATION_VER_2)
+                strArr = BinaryUtils.strToUtf8Bytes(val);
+            else
+                strArr = val.getBytes(UTF_8);
 
             out.unsafeEnsure(1 + 4);
             out.unsafeWriteByte(GridBinaryMarshaller.STRING);

http://git-wip-us.apache.org/repos/asf/ignite/blob/e49522b4/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
index dc664a8..6aa4d54 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
@@ -118,6 +118,7 @@ import org.jsr166.ConcurrentHashMap8;
 
 import static java.util.concurrent.TimeUnit.MILLISECONDS;
 import static org.apache.ignite.IgniteSystemProperties.IGNITE_OPTIMIZED_MARSHALLER_USE_DEFAULT_SUID;
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_BINARY_MARSHALLER_USE_STRING_SERIALIZATION_VER_2;
 import static org.apache.ignite.events.EventType.EVT_CLIENT_NODE_DISCONNECTED;
 import static org.apache.ignite.events.EventType.EVT_CLIENT_NODE_RECONNECTED;
 import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
@@ -128,6 +129,7 @@ import static org.apache.ignite.events.EventType.EVT_NODE_SEGMENTED;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_LATE_AFFINITY_ASSIGNMENT;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_DEPLOYMENT_MODE;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MACS;
+import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MARSHALLER_USE_BINARY_STRING_SER_VER_2;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MARSHALLER_USE_DFLT_SUID;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PEER_CLASSLOADING;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_USER_NAME;
@@ -1003,6 +1005,11 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
         Boolean locMarshUseDfltSuid = locNode.attribute(ATTR_MARSHALLER_USE_DFLT_SUID);
         boolean locMarshUseDfltSuidBool = locMarshUseDfltSuid == null ? true : locMarshUseDfltSuid;
 
+        Boolean locMarshStrSerVer2 = locNode.attribute(ATTR_MARSHALLER_USE_BINARY_STRING_SER_VER_2);
+        boolean locMarshStrSerVer2Bool = locMarshStrSerVer2 == null ?
+            false /* turned on and added to the attributes list by default only when BinaryMarshaller is used. */:
+            locMarshStrSerVer2;
+
         boolean locDelayAssign = locNode.attribute(ATTR_LATE_AFFINITY_ASSIGNMENT);
 
         for (ClusterNode n : nodes) {
@@ -1064,6 +1071,20 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
                     ", locNodeId=" + locNode.id() + ", rmtNodeId=" + n.id() + ']');
             }
 
+            Boolean rmtMarshStrSerVer2 = n.attribute(ATTR_MARSHALLER_USE_BINARY_STRING_SER_VER_2);
+            boolean rmtMarshStrSerVer2Bool = rmtMarshStrSerVer2 == null ? false : rmtMarshStrSerVer2;
+
+            if (locMarshStrSerVer2Bool != rmtMarshStrSerVer2Bool) {
+                throw new IgniteCheckedException("Local node's " + IGNITE_BINARY_MARSHALLER_USE_STRING_SERIALIZATION_VER_2 +
+                    " property value differs from remote node's value " +
+                    "(to make sure all nodes in topology have identical marshaller settings, " +
+                    "configure system property explicitly) " +
+                    "[locMarshStrSerVer2=" + locMarshStrSerVer2 + ", rmtMarshStrSerVer2=" + rmtMarshStrSerVer2 +
+                    ", locNodeAddrs=" + U.addressesAsString(locNode) +
+                    ", rmtNodeAddrs=" + U.addressesAsString(n) +
+                    ", locNodeId=" + locNode.id() + ", rmtNodeId=" + n.id() + ']');
+            }
+
             boolean rmtLateAssign;
 
             if (n.version().compareToIgnoreTimestamp(CacheAffinitySharedManager.LATE_AFF_ASSIGN_SINCE) >= 0)

http://git-wip-us.apache.org/repos/asf/ignite/blob/e49522b4/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index 84400ed..a4c7276 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -133,6 +133,7 @@ import org.jsr166.ConcurrentHashMap8;
 
 import static org.apache.ignite.IgniteSystemProperties.IGNITE_DISCOVERY_HISTORY_SIZE;
 import static org.apache.ignite.IgniteSystemProperties.IGNITE_OPTIMIZED_MARSHALLER_USE_DEFAULT_SUID;
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_BINARY_MARSHALLER_USE_STRING_SERIALIZATION_VER_2;
 import static org.apache.ignite.IgniteSystemProperties.getInteger;
 import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
 import static org.apache.ignite.events.EventType.EVT_NODE_JOINED;
@@ -142,6 +143,7 @@ import static org.apache.ignite.events.EventType.EVT_NODE_SEGMENTED;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_LATE_AFFINITY_ASSIGNMENT;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MARSHALLER;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MARSHALLER_COMPACT_FOOTER;
+import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MARSHALLER_USE_BINARY_STRING_SER_VER_2;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MARSHALLER_USE_DFLT_SUID;
 import static org.apache.ignite.spi.IgnitePortProtocol.TCP;
 import static org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoverySpiState.AUTH_FAILED;
@@ -3336,6 +3338,48 @@ class ServerImpl extends TcpDiscoveryImpl {
                     return;
                 }
 
+                // Validate String serialization mechanism used by the BinaryMarshaller.
+                final Boolean locMarshStrSerialVer2 = locNode.attribute(ATTR_MARSHALLER_USE_BINARY_STRING_SER_VER_2);
+                final boolean locMarshStrSerialVer2Bool = locMarshStrSerialVer2 != null ? locMarshStrSerialVer2 : false;
+
+                final Boolean rmtMarshStrSerialVer2 = node.attribute(ATTR_MARSHALLER_USE_BINARY_STRING_SER_VER_2);
+                final boolean rmtMarshStrSerialVer2Bool = rmtMarshStrSerialVer2 != null ? rmtMarshStrSerialVer2 : false;
+
+                if (locMarshStrSerialVer2Bool != rmtMarshStrSerialVer2Bool) {
+                    utilityPool.submit(
+                        new Runnable() {
+                            @Override public void run() {
+                                String errMsg = "Local node's " + IGNITE_BINARY_MARSHALLER_USE_STRING_SERIALIZATION_VER_2 +
+                                    " property value differs from remote node's value " +
+                                    "(to make sure all nodes in topology have identical marshaller settings, " +
+                                    "configure system property explicitly) " +
+                                    "[locMarshStrSerialVer2=" + locMarshStrSerialVer2 +
+                                    ", rmtMarshStrSerialVer2=" + rmtMarshStrSerialVer2 +
+                                    ", locNodeAddrs=" + U.addressesAsString(locNode) +
+                                    ", rmtNodeAddrs=" + U.addressesAsString(node) +
+                                    ", locNodeId=" + locNode.id() + ", rmtNodeId=" + msg.creatorNodeId() + ']';
+
+                                String sndMsg = "Local node's " + IGNITE_BINARY_MARSHALLER_USE_STRING_SERIALIZATION_VER_2 +
+                                    " property value differs from remote node's value " +
+                                    "(to make sure all nodes in topology have identical marshaller settings, " +
+                                    "configure system property explicitly) " +
+                                    "[locMarshStrSerialVer2=" + rmtMarshStrSerialVer2 +
+                                    ", rmtMarshStrSerialVer2=" + locMarshStrSerialVer2 +
+                                    ", locNodeAddrs=" + U.addressesAsString(node) + ", locPort=" + node.discoveryPort() +
+                                    ", rmtNodeAddr=" + U.addressesAsString(locNode) + ", locNodeId=" + node.id() +
+                                    ", rmtNodeId=" + locNode.id() + ']';
+
+                                nodeCheckError(
+                                    node,
+                                    errMsg,
+                                    sndMsg);
+                            }
+                        });
+
+                    // Ignore join request.
+                    return;
+                }
+
                 boolean rmtLateAssignBool;
 
                 if (node.version().compareToIgnoreTimestamp(CacheAffinitySharedManager.LATE_AFF_ASSIGN_SINCE) >= 0) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/e49522b4/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java
index eefe66c..936b1e6 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java
@@ -26,6 +26,7 @@ import java.lang.reflect.Field;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
 import java.lang.reflect.Proxy;
 import java.math.BigDecimal;
 import java.math.BigInteger;
@@ -89,10 +90,13 @@ import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.jsr166.ConcurrentHashMap8;
 
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_BINARY_MARSHALLER_USE_STRING_SERIALIZATION_VER_2;
 import static org.apache.ignite.internal.binary.streams.BinaryMemoryAllocator.INSTANCE;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertNotEquals;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
+
 /**
  * Binary marshaller tests.
  */
@@ -179,8 +183,69 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
     /**
      * @throws Exception If failed.
      */
-    public void testString() throws Exception {
-        assertEquals("str", marshalUnmarshal("str"));
+    public void testStringVer1() throws Exception {
+        doTestString(false);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testStringVer2() throws Exception {
+        doTestString(true);
+    }
+
+    /**
+     * @throws Exception If failed
+     */
+    private void doTestString(boolean ver2) throws Exception {
+        // Ascii check.
+        String str = "ascii0123456789";
+        assertEquals(str, marshalUnmarshal(str));
+
+        byte[] bytes = str.getBytes(UTF_8);
+        assertEquals(str, BinaryUtils.utf8BytesToStr(bytes, 0, bytes.length));
+
+        bytes = BinaryUtils.strToUtf8Bytes(str);
+        assertEquals(str, new String(bytes, UTF_8));
+
+        // Extended symbols set check set.
+        str = "\u7684\u7684abcd\u043a\u0438\u0440\u0438\u043b\u043b\u0438\u0446\u0430";
+        assertEquals(str, marshalUnmarshal(str));
+
+        bytes = str.getBytes(UTF_8);
+        assertEquals(str, BinaryUtils.utf8BytesToStr(bytes, 0, bytes.length));
+
+        bytes = BinaryUtils.strToUtf8Bytes(str);
+        assertEquals(str, new String(bytes, UTF_8));
+
+        // Special symbols check.
+        str = new String(new char[] {0xD800, '\u7684', 0xD800, 0xD800, 0xDC00, 0xDFFF});
+        if (ver2) {
+            bytes = BinaryUtils.strToUtf8Bytes(str);
+            assertEquals(str, BinaryUtils.utf8BytesToStr(bytes, 0, bytes.length));
+        }
+        else
+            assertNotEquals(str, marshalUnmarshal(str));
+
+        str = new String(new char[] {55296});
+        if (ver2) {
+            bytes = BinaryUtils.strToUtf8Bytes(str);
+            assertEquals(str, BinaryUtils.utf8BytesToStr(bytes, 0, bytes.length));
+        }
+        else
+            assertNotEquals(str, marshalUnmarshal(str));
+
+        bytes = str.getBytes(UTF_8);
+        assertNotEquals(str, new String(bytes, UTF_8));
+
+        bytes = str.getBytes(UTF_8);
+        assertNotEquals(str, BinaryUtils.utf8BytesToStr(bytes, 0, bytes.length));
+
+        str = new String(new char[] {0xD801, 0xDC37});
+        assertEquals(str, marshalUnmarshal(str));
+
+        bytes = str.getBytes(UTF_8);
+        assertEquals(str, new String(bytes, UTF_8));
     }
 
     /**
@@ -291,7 +356,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
      * @throws Exception If failed.
      */
     public void testDecimalArray() throws Exception {
-        BigDecimal[] arr = new BigDecimal[] {BigDecimal.ZERO, BigDecimal.ONE, BigDecimal.TEN} ;
+        BigDecimal[] arr = new BigDecimal[] {BigDecimal.ZERO, BigDecimal.ONE, BigDecimal.TEN};
 
         assertArrayEquals(arr, marshalUnmarshal(arr));
     }
@@ -912,9 +977,9 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
      */
     public void testClassWithoutPublicConstructor() throws Exception {
         BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
-                new BinaryTypeConfiguration(NoPublicConstructor.class.getName()),
-                new BinaryTypeConfiguration(NoPublicDefaultConstructor.class.getName()),
-                new BinaryTypeConfiguration(ProtectedConstructor.class.getName()))
+            new BinaryTypeConfiguration(NoPublicConstructor.class.getName()),
+            new BinaryTypeConfiguration(NoPublicDefaultConstructor.class.getName()),
+            new BinaryTypeConfiguration(ProtectedConstructor.class.getName()))
         );
 
         NoPublicConstructor npc = new NoPublicConstructor();
@@ -1034,8 +1099,10 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
             @Override public int fieldId(int typeId, String fieldName) {
                 assert typeId == 44444;
 
-                if ("val1".equals(fieldName)) return 55555;
-                else if ("val2".equals(fieldName)) return 66666;
+                if ("val1".equals(fieldName))
+                    return 55555;
+                else if ("val2".equals(fieldName))
+                    return 66666;
 
                 assert false : "Unknown field: " + fieldName;
 
@@ -1403,14 +1470,14 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
 
         BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(true), new BinaryBasicIdMapper(true),
             Arrays.asList(
-            new BinaryTypeConfiguration(Key.class.getName()),
-            new BinaryTypeConfiguration("org.gridgain.NonExistentClass3"),
-            new BinaryTypeConfiguration("NonExistentClass4"),
-            customType1,
-            customType2,
-            customType3,
-            customType4
-        ));
+                new BinaryTypeConfiguration(Key.class.getName()),
+                new BinaryTypeConfiguration("org.gridgain.NonExistentClass3"),
+                new BinaryTypeConfiguration("NonExistentClass4"),
+                customType1,
+                customType2,
+                customType3,
+                customType4
+            ));
 
         BinaryContext ctx = binaryContext(marsh);
 
@@ -1591,6 +1658,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
         // BinaryIdMapper.typeId() contract.
         assertEquals("nonexistentclass0".hashCode(), ctx.typeId("NonExistentClass0"));
     }
+
     /**
      * @throws Exception If failed.
      */
@@ -1693,7 +1761,6 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
         assertEquals(992, ctx.typeId("org.gridgain.NonExistentClass3"));
         assertEquals(993, ctx.typeId("NonExistentClass4"));
 
-
         // Custom types.
         assertEquals(300, ctx.typeId(Value.class.getName()));
         assertEquals(400, ctx.typeId("org.gridgain.NonExistentClass1"));
@@ -1990,7 +2057,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
 
         BinaryObject po = marshal(obj, marsh);
 
-        BinaryObject copy = copy(po, F.<String, Object>asMap("bArr", new byte[]{1, 2, 3}));
+        BinaryObject copy = copy(po, F.<String, Object>asMap("bArr", new byte[] {1, 2, 3}));
 
         assertArrayEquals(new byte[] {1, 2, 3}, copy.<byte[]>field("bArr"));
 
@@ -2027,7 +2094,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
 
         BinaryObject po = marshal(obj, marsh);
 
-        BinaryObject copy = copy(po, F.<String, Object>asMap("sArr", new short[]{1, 2, 3}));
+        BinaryObject copy = copy(po, F.<String, Object>asMap("sArr", new short[] {1, 2, 3}));
 
         assertArrayEquals(new short[] {1, 2, 3}, copy.<short[]>field("sArr"));
 
@@ -2048,7 +2115,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
 
         BinaryObject po = marshal(obj, marsh);
 
-        BinaryObject copy = copy(po, F.<String, Object>asMap("iArr", new int[]{1, 2, 3}));
+        BinaryObject copy = copy(po, F.<String, Object>asMap("iArr", new int[] {1, 2, 3}));
 
         assertArrayEquals(new int[] {1, 2, 3}, copy.<int[]>field("iArr"));
 
@@ -2069,7 +2136,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
 
         BinaryObject po = marshal(obj, marsh);
 
-        BinaryObject copy = copy(po, F.<String, Object>asMap("lArr", new long[]{1, 2, 3}));
+        BinaryObject copy = copy(po, F.<String, Object>asMap("lArr", new long[] {1, 2, 3}));
 
         assertArrayEquals(new long[] {1, 2, 3}, copy.<long[]>field("lArr"));
 
@@ -2090,7 +2157,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
 
         BinaryObject po = marshal(obj, marsh);
 
-        BinaryObject copy = copy(po, F.<String, Object>asMap("fArr", new float[]{1, 2, 3}));
+        BinaryObject copy = copy(po, F.<String, Object>asMap("fArr", new float[] {1, 2, 3}));
 
         assertArrayEquals(new float[] {1, 2, 3}, copy.<float[]>field("fArr"), 0);
 
@@ -2111,7 +2178,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
 
         BinaryObject po = marshal(obj, marsh);
 
-        BinaryObject copy = copy(po, F.<String, Object>asMap("dArr", new double[]{1, 2, 3}));
+        BinaryObject copy = copy(po, F.<String, Object>asMap("dArr", new double[] {1, 2, 3}));
 
         assertArrayEquals(new double[] {1, 2, 3}, copy.<double[]>field("dArr"), 0);
 
@@ -2132,13 +2199,13 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
 
         BinaryObject po = marshal(obj, marsh);
 
-        BinaryObject copy = copy(po, F.<String, Object>asMap("cArr", new char[]{1, 2, 3}));
+        BinaryObject copy = copy(po, F.<String, Object>asMap("cArr", new char[] {1, 2, 3}));
 
-        assertArrayEquals(new char[]{1, 2, 3}, copy.<char[]>field("cArr"));
+        assertArrayEquals(new char[] {1, 2, 3}, copy.<char[]>field("cArr"));
 
         SimpleObject obj0 = copy.deserialize();
 
-        assertArrayEquals(new char[]{1, 2, 3}, obj0.cArr);
+        assertArrayEquals(new char[] {1, 2, 3}, obj0.cArr);
     }
 
     /**
@@ -2153,7 +2220,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
 
         BinaryObject po = marshal(obj, marsh);
 
-        BinaryObject copy = copy(po, F.<String, Object>asMap("strArr", new String[]{"str1", "str2"}));
+        BinaryObject copy = copy(po, F.<String, Object>asMap("strArr", new String[] {"str1", "str2"}));
 
         assertArrayEquals(new String[] {"str1", "str2"}, copy.<String[]>field("strArr"));
 
@@ -2211,13 +2278,13 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
 
         map.put("str", "str555");
         map.put("inner", newObj);
-        map.put("bArr", new byte[]{6, 7, 9});
+        map.put("bArr", new byte[] {6, 7, 9});
 
         BinaryObject copy = copy(po, map);
 
         assertEquals("str555", copy.<String>field("str"));
         assertEquals(newObj, copy.<BinaryObject>field("inner").deserialize());
-        assertArrayEquals(new byte[]{6, 7, 9}, copy.<byte[]>field("bArr"));
+        assertArrayEquals(new byte[] {6, 7, 9}, copy.<byte[]>field("bArr"));
 
         SimpleObject obj0 = copy.deserialize();
 
@@ -2440,7 +2507,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
         DecimalReflective obj1 = new DecimalReflective();
 
         obj1.val = BigDecimal.ZERO;
-        obj1.valArr = new BigDecimal[] { BigDecimal.ONE, BigDecimal.TEN };
+        obj1.valArr = new BigDecimal[] {BigDecimal.ONE, BigDecimal.TEN};
 
         BinaryObjectImpl portObj = marshal(obj1, marsh);
 
@@ -2454,9 +2521,9 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
         DecimalMarshalAware obj2 = new DecimalMarshalAware();
 
         obj2.val = BigDecimal.ZERO;
-        obj2.valArr = new BigDecimal[] { BigDecimal.ONE, BigDecimal.TEN.negate() };
+        obj2.valArr = new BigDecimal[] {BigDecimal.ONE, BigDecimal.TEN.negate()};
         obj2.rawVal = BigDecimal.TEN;
-        obj2.rawValArr = new BigDecimal[] { BigDecimal.ZERO, BigDecimal.ONE };
+        obj2.rawValArr = new BigDecimal[] {BigDecimal.ZERO, BigDecimal.ONE};
 
         portObj = marshal(obj2, marsh);
 
@@ -2788,7 +2855,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
     /**
      * Some non-serializable class.
      */
-    @SuppressWarnings( {"PublicField","TransientFieldInNonSerializableClass","FieldMayBeStatic"})
+    @SuppressWarnings({"PublicField", "TransientFieldInNonSerializableClass", "FieldMayBeStatic"})
     private static class NonSerializableA {
         /** */
         private final long longVal = 0x33445566778899AAL;
@@ -2797,7 +2864,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
         protected Short shortVal = (short)0xAABB;
 
         /** */
-        public String[] strArr = {"AA","BB"};
+        public String[] strArr = {"AA", "BB"};
 
         /** */
         public boolean flag1 = true;
@@ -2821,7 +2888,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
          * @param strArr Array.
          * @param shortVal Short value.
          */
-        @SuppressWarnings( {"UnusedDeclaration"})
+        @SuppressWarnings({"UnusedDeclaration"})
         private NonSerializableA(@Nullable String[] strArr, @Nullable Short shortVal) {
             // No-op.
         }
@@ -2834,7 +2901,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
 
             assertEquals(shortVal.shortValue(), (short)0xAABB);
 
-            assertTrue(Arrays.equals(strArr, new String[] {"AA","BB"}));
+            assertTrue(Arrays.equals(strArr, new String[] {"AA", "BB"}));
 
             assertEquals(0, intVal);
 
@@ -2849,7 +2916,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
     /**
      * Some non-serializable class.
      */
-    @SuppressWarnings( {"PublicField","TransientFieldInNonSerializableClass","PackageVisibleInnerClass"})
+    @SuppressWarnings({"PublicField", "TransientFieldInNonSerializableClass", "PackageVisibleInnerClass"})
     static class NonSerializableB extends NonSerializableA {
         /** */
         public Short shortValue = 0x1122;
@@ -2893,7 +2960,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
     /**
      * Some non-serializable class.
      */
-    @SuppressWarnings( {"TransientFieldInNonSerializableClass","PublicField"})
+    @SuppressWarnings({"TransientFieldInNonSerializableClass", "PublicField"})
     private static class NonSerializable extends NonSerializableB {
         /** */
         private int idVal = -17;
@@ -2918,7 +2985,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
          *
          * @param aVal Unused.
          */
-        @SuppressWarnings( {"UnusedDeclaration"})
+        @SuppressWarnings({"UnusedDeclaration"})
         private NonSerializable(NonSerializableA aVal) {
         }
 
@@ -3108,7 +3175,8 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
     /**
      *
      */
-    protected BinaryMarshaller binaryMarshaller(BinaryNameMapper nameMapper, BinaryIdMapper mapper, Collection<BinaryTypeConfiguration> cfgs)
+    protected BinaryMarshaller binaryMarshaller(BinaryNameMapper nameMapper, BinaryIdMapper mapper,
+        Collection<BinaryTypeConfiguration> cfgs)
         throws IgniteCheckedException {
         return binaryMarshaller(nameMapper, mapper, null, cfgs);
     }
@@ -3250,7 +3318,6 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
         outer.inner = inner;
         outer.bdArr = new BigDecimal[] {new BigDecimal(5000), BigDecimal.TEN};
 
-
         outer.col.add("str4");
         outer.col.add("str5");
         outer.col.add("str6");
@@ -4329,7 +4396,9 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
             // No-op.
         }
 
-        /**n
+        /**
+         * n
+         *
          * @param key Key.
          */
         private Key(int key) {
@@ -4440,7 +4509,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
      */
     private static class ProtectedConstructor {
         /**
-         *  Protected constructor.
+         * Protected constructor.
          */
         protected ProtectedConstructor() {
             // No-op.
@@ -4496,8 +4565,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
         /** */
         private String s;
 
-        /** Initializer. */
-        {
+        /** Initializer. */ {
             StringBuilder builder = new StringBuilder();
 
             for (int i = 0; i < 10000; i++) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/e49522b4/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java
index 3a2f3ba..28380df 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java
@@ -21,6 +21,7 @@ import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.configuration.DeploymentMode;
 import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
 import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
@@ -28,6 +29,7 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 
 import static org.apache.ignite.IgniteSystemProperties.IGNITE_OPTIMIZED_MARSHALLER_USE_DEFAULT_SUID;
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_BINARY_MARSHALLER_USE_STRING_SERIALIZATION_VER_2;
 import static org.apache.ignite.configuration.DeploymentMode.CONTINUOUS;
 import static org.apache.ignite.configuration.DeploymentMode.SHARED;
 
@@ -47,6 +49,9 @@ public abstract class GridDiscoveryManagerAttributesSelfTest extends GridCommonA
     /** */
     private static boolean p2pEnabled;
 
+    /** */
+    private static boolean binaryMarshallerEnabled;
+
     /** {@inheritDoc} */
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
         IgniteConfiguration cfg = super.getConfiguration(gridName);
@@ -54,6 +59,9 @@ public abstract class GridDiscoveryManagerAttributesSelfTest extends GridCommonA
         if (gridName.equals(getTestGridName(1)))
             cfg.setClientMode(true);
 
+        if (binaryMarshallerEnabled)
+            cfg.setMarshaller(new BinaryMarshaller());
+
         cfg.setIncludeProperties(PREFER_IPV4);
         cfg.setDeploymentMode(mode);
         cfg.setPeerClassLoadingEnabled(p2pEnabled);
@@ -161,6 +169,61 @@ public abstract class GridDiscoveryManagerAttributesSelfTest extends GridCommonA
         }
     }
 
+    public void testUseStringSerVer2() throws Exception {
+        String old = System.getProperty(IGNITE_BINARY_MARSHALLER_USE_STRING_SERIALIZATION_VER_2);
+
+        binaryMarshallerEnabled = true;
+
+        try {
+            doTestUseStrSerVer2(Boolean.TRUE.toString(), Boolean.FALSE.toString(), true);
+            doTestUseStrSerVer2(Boolean.FALSE.toString(), Boolean.TRUE.toString(), true);
+
+            doTestUseStrSerVer2(Boolean.TRUE.toString(), Boolean.TRUE.toString(), false);
+            doTestUseStrSerVer2(Boolean.FALSE.toString(), Boolean.FALSE.toString(), false);
+        }
+        finally {
+            if (old != null)
+                System.setProperty(IGNITE_BINARY_MARSHALLER_USE_STRING_SERIALIZATION_VER_2, old);
+            else
+                System.clearProperty(IGNITE_BINARY_MARSHALLER_USE_STRING_SERIALIZATION_VER_2);
+
+            binaryMarshallerEnabled = false;
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    private void doTestUseStrSerVer2(String first, String second, boolean fail) throws Exception {
+        try {
+            if (first != null)
+                System.setProperty(IGNITE_BINARY_MARSHALLER_USE_STRING_SERIALIZATION_VER_2, first);
+            else
+                System.clearProperty(IGNITE_BINARY_MARSHALLER_USE_STRING_SERIALIZATION_VER_2);
+
+            startGrid(0);
+
+            if (second != null)
+                System.setProperty(IGNITE_BINARY_MARSHALLER_USE_STRING_SERIALIZATION_VER_2, second);
+            else
+                System.clearProperty(IGNITE_BINARY_MARSHALLER_USE_STRING_SERIALIZATION_VER_2);
+
+            try {
+                startGrid(1);
+
+                if (fail)
+                    fail("Node should not join");
+            }
+            catch (Exception e) {
+                if (!fail)
+                    fail("Node should join");
+            }
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+
     /**
      * @throws Exception If failed.
      */


[13/14] ignite git commit: GG-11142 In case cross tx CacheFileLocalStore writes all entries (from different caches) in stores involved in transactions

Posted by av...@apache.org.
GG-11142 In case cross tx CacheFileLocalStore writes all entries (from different caches) in stores involved in transactions


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

Branch: refs/heads/master
Commit: f07f988fe5b0b481ba53f4954416544ff63ad6d0
Parents: e49522b
Author: Anton Vinogradov <av...@apache.org>
Authored: Tue May 17 16:44:28 2016 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Tue May 17 16:45:38 2016 +0300

----------------------------------------------------------------------
 .../cache/CrossCacheTxRandomOperationsTest.java        | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/f07f988f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CrossCacheTxRandomOperationsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CrossCacheTxRandomOperationsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CrossCacheTxRandomOperationsTest.java
index 2577d93..67ec371 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CrossCacheTxRandomOperationsTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CrossCacheTxRandomOperationsTest.java
@@ -150,7 +150,7 @@ public class CrossCacheTxRandomOperationsTest extends GridCommonAbstractTest {
      * @param fairAff If {@code true} uses {@link FairAffinityFunction}, otherwise {@link RendezvousAffinityFunction}.
      * @return Cache configuration.
      */
-    private CacheConfiguration cacheConfiguration(String name,
+    protected CacheConfiguration cacheConfiguration(String name,
         CacheMode cacheMode,
         CacheWriteSynchronizationMode writeSync,
         boolean fairAff) {
@@ -170,6 +170,13 @@ public class CrossCacheTxRandomOperationsTest extends GridCommonAbstractTest {
     }
 
     /**
+     */
+    protected void createCache(CacheMode cacheMode, CacheWriteSynchronizationMode writeSync, boolean fairAff,
+        Ignite ignite, String name) {
+        ignite.createCache(cacheConfiguration(name, cacheMode, writeSync, fairAff));
+    }
+
+    /**
      * @param cacheMode Cache mode.
      * @param writeSync Write synchronization mode.
      * @param crossCacheTx If {@code true} uses cross cache transaction.
@@ -183,8 +190,8 @@ public class CrossCacheTxRandomOperationsTest extends GridCommonAbstractTest {
         Ignite ignite = ignite(0);
 
         try {
-            ignite.createCache(cacheConfiguration(CACHE1, cacheMode, writeSync, fairAff));
-            ignite.createCache(cacheConfiguration(CACHE2, cacheMode, writeSync, fairAff));
+            createCache(cacheMode, writeSync, fairAff, ignite, CACHE1);
+            createCache(cacheMode, writeSync, fairAff, ignite, CACHE2);
 
             txOperations(PESSIMISTIC, REPEATABLE_READ, crossCacheTx, false);
             txOperations(PESSIMISTIC, REPEATABLE_READ, crossCacheTx, true);


[02/14] ignite git commit: IGNITE-3144 Refactor Schema Import Utility. Split for two modules: schema-import and schema-import-db.

Posted by av...@apache.org.
IGNITE-3144 Refactor Schema Import Utility. Split for two modules: schema-import and schema-import-db.


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

Branch: refs/heads/master
Commit: fa197d2f71430cb5e8765335eff6a9c2d4f6ec10
Parents: c9f9d24
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Tue May 17 14:22:23 2016 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Tue May 17 14:22:23 2016 +0700

----------------------------------------------------------------------
 assembly/dependencies-schema-import.xml         |   1 +
 assembly/release-schema-import.xml              |   2 +-
 modules/schema-import-db/README.txt             |   4 +
 modules/schema-import-db/pom.xml                |  44 ++
 .../apache/ignite/schema/parser/DbColumn.java   |  76 +++
 .../ignite/schema/parser/DbMetadataReader.java  | 147 ++++++
 .../apache/ignite/schema/parser/DbTable.java    |  82 +++
 .../parser/dialect/DB2MetadataDialect.java      |  33 ++
 .../parser/dialect/DatabaseMetadataDialect.java |  75 +++
 .../parser/dialect/JdbcMetadataDialect.java     | 197 +++++++
 .../parser/dialect/MySQLMetadataDialect.java    |  62 +++
 .../parser/dialect/OracleMetadataDialect.java   | 364 +++++++++++++
 modules/schema-import/pom.xml                   |   6 +
 .../schema/parser/DatabaseMetadataParser.java   |  44 +-
 .../apache/ignite/schema/parser/DbColumn.java   |  76 ---
 .../apache/ignite/schema/parser/DbTable.java    |  82 ---
 .../parser/dialect/DB2MetadataDialect.java      |  33 --
 .../parser/dialect/DatabaseMetadataDialect.java |  75 ---
 .../parser/dialect/JdbcMetadataDialect.java     | 197 -------
 .../parser/dialect/MySQLMetadataDialect.java    |  61 ---
 .../parser/dialect/OracleMetadataDialect.java   | 364 -------------
 .../ignite/schema/ui/SchemaImportApp.java       | 526 ++++++++-----------
 pom.xml                                         |   2 +
 23 files changed, 1328 insertions(+), 1225 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/fa197d2f/assembly/dependencies-schema-import.xml
----------------------------------------------------------------------
diff --git a/assembly/dependencies-schema-import.xml b/assembly/dependencies-schema-import.xml
index 53c32c2..d7aa3ae 100644
--- a/assembly/dependencies-schema-import.xml
+++ b/assembly/dependencies-schema-import.xml
@@ -33,6 +33,7 @@
         <moduleSet>
             <includes>
                 <include>org.apache.ignite:ignite-schema-import</include>
+                <include>org.apache.ignite:ignite-schema-import-db</include>
             </includes>
             <sources>
                 <includeModuleDirectory>false</includeModuleDirectory>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fa197d2f/assembly/release-schema-import.xml
----------------------------------------------------------------------
diff --git a/assembly/release-schema-import.xml b/assembly/release-schema-import.xml
index b746c83..38457b9 100644
--- a/assembly/release-schema-import.xml
+++ b/assembly/release-schema-import.xml
@@ -21,7 +21,7 @@
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2
           http://maven.apache.org/xsd/assembly-1.1.2.xsd">
-    <id>scala</id>
+    <id>release-schema-import</id>
 
     <includeBaseDirectory>false</includeBaseDirectory>
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/fa197d2f/modules/schema-import-db/README.txt
----------------------------------------------------------------------
diff --git a/modules/schema-import-db/README.txt b/modules/schema-import-db/README.txt
new file mode 100644
index 0000000..556e1c6
--- /dev/null
+++ b/modules/schema-import-db/README.txt
@@ -0,0 +1,4 @@
+Apache Ignite Schema Import DB Module
+------------------------------------------
+
+Utility classes to extract database metadata.

http://git-wip-us.apache.org/repos/asf/ignite/blob/fa197d2f/modules/schema-import-db/pom.xml
----------------------------------------------------------------------
diff --git a/modules/schema-import-db/pom.xml b/modules/schema-import-db/pom.xml
new file mode 100644
index 0000000..337f39a
--- /dev/null
+++ b/modules/schema-import-db/pom.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  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.
+-->
+
+<!--
+    POM file.
+-->
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.ignite</groupId>
+        <artifactId>ignite-parent</artifactId>
+        <version>1</version>
+        <relativePath>../../parent</relativePath>
+    </parent>
+
+    <artifactId>ignite-schema-import-db</artifactId>
+    <version>1.6.0-SNAPSHOT</version>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.ignite</groupId>
+            <artifactId>ignite-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fa197d2f/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/DbColumn.java
----------------------------------------------------------------------
diff --git a/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/DbColumn.java b/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/DbColumn.java
new file mode 100644
index 0000000..8b0c813
--- /dev/null
+++ b/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/DbColumn.java
@@ -0,0 +1,76 @@
+/*
+ * 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.schema.parser;
+
+/**
+ * Database table column.
+ */
+public class DbColumn {
+    /** Column name. */
+    private final String name;
+
+    /** Column JDBC type. */
+    private final int type;
+
+    /** Is this column belongs to primary key. */
+    private final boolean key;
+
+    /** Is {@code NULL} allowed for column in database. */
+    private final boolean nullable;
+
+    /**
+     * @param name Column name.
+     * @param type Column JDBC type.
+     * @param key {@code true} if this column belongs to primary key.
+     * @param nullable {@code true} if {@code NULL } allowed for column in database.
+     */
+    public DbColumn(String name, int type, boolean key, boolean nullable) {
+        this.name = name;
+        this.type = type;
+        this.key = key;
+        this.nullable = nullable;
+    }
+
+    /**
+     * @return Column name.
+     */
+    public String name() {
+        return name;
+    }
+
+    /**
+     * @return Column JDBC type.
+     */
+    public int type() {
+        return type;
+    }
+
+    /**
+     * @return {@code true} if this column belongs to primary key.
+     */
+    public boolean key() {
+        return key;
+    }
+
+    /**
+     * @return nullable {@code true} if {@code NULL } allowed for column in database.
+     */
+    public boolean nullable() {
+        return nullable;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/fa197d2f/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/DbMetadataReader.java
----------------------------------------------------------------------
diff --git a/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/DbMetadataReader.java b/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/DbMetadataReader.java
new file mode 100644
index 0000000..5b45f33
--- /dev/null
+++ b/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/DbMetadataReader.java
@@ -0,0 +1,147 @@
+/*
+ * 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.schema.parser;
+
+import org.apache.ignite.schema.parser.dialect.*;
+
+import java.io.*;
+import java.net.*;
+import java.sql.*;
+import java.util.*;
+import java.util.logging.*;
+
+/**
+ * Singleton to extract database metadata.
+ */
+public class DbMetadataReader {
+    /** Logger. */
+    private static final Logger log = Logger.getLogger(DbMetadataReader.class.getName());
+
+    /** */
+    private static final DbMetadataReader INSTANCE = new DbMetadataReader();
+
+    /** */
+    private final Map<String, Driver> drivers = new HashMap<>();
+
+    /**
+     * Default constructor.
+     */
+    private DbMetadataReader() {
+        // No-op.
+    }
+
+    /**
+     * @return Instance.
+     */
+    public static DbMetadataReader getInstance() {
+        return INSTANCE;
+    }
+
+    /**
+     * Get specified dialect object for selected database.
+     *
+     * @param conn Connection to database.
+     * @return Specific dialect object.
+     */
+    private DatabaseMetadataDialect dialect(Connection conn) {
+        try {
+            String dbProductName = conn.getMetaData().getDatabaseProductName();
+
+            if ("Oracle".equals(dbProductName))
+                return new OracleMetadataDialect();
+            else if (dbProductName.startsWith("DB2/"))
+                return new DB2MetadataDialect();
+            else if (dbProductName.equals("MySQL"))
+                return new MySQLMetadataDialect();
+            else
+                return new JdbcMetadataDialect();
+        }
+        catch (SQLException e) {
+            log.log(Level.SEVERE, "Failed to resolve dialect (JdbcMetaDataDialect will be used.", e);
+
+            return new JdbcMetadataDialect();
+        }
+    }
+
+    /**
+     * Get list of schemas from database.
+     *
+     * @param conn Connection to database.
+     * @return List of schema names.
+     * @throws SQLException If schemas loading failed.
+     */
+    public Collection<String> schemas(Connection conn) throws SQLException  {
+        return dialect(conn).schemas(conn);
+    }
+
+    /**
+     * Extract DB metadata.
+     *
+     * @param conn Connection.
+     * @param schemas List of database schemas to process. In case of empty list all schemas will be processed.
+     * @param tblsOnly Tables only flag.
+     */
+    public Collection<DbTable> metadata(Connection conn, List<String> schemas, boolean tblsOnly) throws SQLException {
+        return dialect(conn).tables(conn, schemas, tblsOnly);
+    }
+
+    /**
+     * Connect to database.
+     *
+     * @param jdbcDrvJarPath Path to JDBC driver.
+     * @param jdbcDrvCls JDBC class name.
+     * @param jdbcUrl JDBC connection URL.
+     * @param jdbcInfo Connection properties.
+     * @return Connection to database.
+     * @throws SQLException if connection failed.
+     */
+    public Connection connect(String jdbcDrvJarPath, String jdbcDrvCls, String jdbcUrl, Properties jdbcInfo)
+        throws SQLException {
+        Driver drv = drivers.get(jdbcDrvCls);
+
+        if (drv == null) {
+            if (jdbcDrvJarPath.isEmpty())
+                throw new IllegalStateException("Driver jar file name is not specified.");
+
+            File drvJar = new File(jdbcDrvJarPath);
+
+            if (!drvJar.exists())
+                throw new IllegalStateException("Driver jar file is not found.");
+
+            try {
+                URL u = new URL("jar:" + drvJar.toURI() + "!/");
+
+                URLClassLoader ucl = URLClassLoader.newInstance(new URL[] {u});
+
+                drv = (Driver)Class.forName(jdbcDrvCls, true, ucl).newInstance();
+
+                drivers.put(jdbcDrvCls, drv);
+            }
+            catch (Exception e) {
+                throw new IllegalStateException(e);
+            }
+        }
+
+        Connection conn = drv.connect(jdbcUrl, jdbcInfo);
+
+        if (conn == null)
+            throw new IllegalStateException("Connection was not established (JDBC driver returned null value).");
+
+        return conn;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/fa197d2f/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/DbTable.java
----------------------------------------------------------------------
diff --git a/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/DbTable.java b/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/DbTable.java
new file mode 100644
index 0000000..39f6f7b
--- /dev/null
+++ b/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/DbTable.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.schema.parser;
+
+import org.apache.ignite.cache.QueryIndex;
+
+import java.util.Collection;
+
+/**
+ * Database table.
+ */
+public class DbTable {
+    /** Schema name. */
+    private final String schema;
+
+    /** Table name. */
+    private final String tbl;
+
+    /** Columns. */
+    private final Collection<DbColumn> cols;
+
+    /** Indexes. */
+    private final Collection<QueryIndex> idxs;
+
+    /**
+     * Default columns.
+     *
+     * @param schema Schema name.
+     * @param tbl Table name.
+     * @param cols Columns.
+     * @param idxs Indexes;
+     */
+    public DbTable(String schema, String tbl, Collection<DbColumn> cols, Collection<QueryIndex> idxs) {
+        this.schema = schema;
+        this.tbl = tbl;
+        this.cols = cols;
+        this.idxs = idxs;
+    }
+
+    /**
+     * @return Schema name.
+     */
+    public String schema() {
+        return schema;
+    }
+
+    /**
+     * @return Table name.
+     */
+    public String table() {
+        return tbl;
+    }
+
+    /**
+     * @return Columns.
+     */
+    public Collection<DbColumn> columns() {
+        return cols;
+    }
+
+    /**
+     * @return Indexes.
+     */
+    public Collection<QueryIndex> indexes() {
+        return idxs;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/fa197d2f/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/dialect/DB2MetadataDialect.java
----------------------------------------------------------------------
diff --git a/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/dialect/DB2MetadataDialect.java b/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/dialect/DB2MetadataDialect.java
new file mode 100644
index 0000000..b191ec3
--- /dev/null
+++ b/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/dialect/DB2MetadataDialect.java
@@ -0,0 +1,33 @@
+/*
+ * 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.schema.parser.dialect;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * DB2 specific metadata dialect.
+ */
+public class DB2MetadataDialect extends JdbcMetadataDialect {
+    /** {@inheritDoc} */
+    @Override public Set<String> systemSchemas() {
+        return new HashSet<>(Arrays.asList("SYSIBM", "SYSCAT", "SYSSTAT", "SYSTOOLS", "SYSFUN", "SYSIBMADM",
+            "SYSIBMINTERNAL", "SYSIBMTS", "SYSPROC", "SYSPUBLIC"));
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/fa197d2f/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/dialect/DatabaseMetadataDialect.java
----------------------------------------------------------------------
diff --git a/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/dialect/DatabaseMetadataDialect.java b/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/dialect/DatabaseMetadataDialect.java
new file mode 100644
index 0000000..f34eee4
--- /dev/null
+++ b/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/dialect/DatabaseMetadataDialect.java
@@ -0,0 +1,75 @@
+/*
+ * 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.schema.parser.dialect;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.ignite.cache.QueryIndex;
+import org.apache.ignite.schema.parser.DbColumn;
+import org.apache.ignite.schema.parser.DbTable;
+
+/**
+ * Base class for database metadata dialect.
+ */
+public abstract class DatabaseMetadataDialect {
+    /**
+     * Gets schemas from database.
+     *
+     * @param conn Database connection.
+     * @return Collection of schema descriptors.
+     * @throws SQLException If failed to get schemas.
+     */
+    public abstract Collection<String> schemas(Connection conn) throws SQLException;
+
+    /**
+     * Gets tables from database.
+     *
+     * @param conn Database connection.
+     * @param schemas Collection of schema names to load.
+     * @param tblsOnly If {@code true} then gets only tables otherwise gets tables and views.
+     * @return Collection of table descriptors.
+     * @throws SQLException If failed to get tables.
+     */
+    public abstract Collection<DbTable> tables(Connection conn, List<String> schemas, boolean tblsOnly)
+        throws SQLException;
+
+    /**
+     * @return Collection of database system schemas.
+     */
+    public Set<String> systemSchemas() {
+        return Collections.singleton("INFORMATION_SCHEMA");
+    }
+
+    /**
+     * Create table descriptor.
+     *
+     * @param schema Schema name.
+     * @param tbl Table name.
+     * @param cols Table columns.
+     * @param idxs Table indexes.
+     * @return New {@code DbTable} instance.
+     */
+    protected DbTable table(String schema, String tbl, Collection<DbColumn> cols, Collection<QueryIndex>idxs) {
+        return new DbTable(schema, tbl, cols, idxs);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/fa197d2f/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/dialect/JdbcMetadataDialect.java
----------------------------------------------------------------------
diff --git a/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/dialect/JdbcMetadataDialect.java b/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/dialect/JdbcMetadataDialect.java
new file mode 100644
index 0000000..0b54b25
--- /dev/null
+++ b/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/dialect/JdbcMetadataDialect.java
@@ -0,0 +1,197 @@
+/*
+ * 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.schema.parser.dialect;
+
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.ignite.cache.QueryIndex;
+import org.apache.ignite.cache.QueryIndexType;
+import org.apache.ignite.schema.parser.DbColumn;
+import org.apache.ignite.schema.parser.DbTable;
+
+/**
+ * Metadata dialect that uses standard JDBC for reading metadata.
+ */
+public class JdbcMetadataDialect extends DatabaseMetadataDialect {
+    /** */
+    private static final String[] TABLES_ONLY = {"TABLE"};
+
+    /** */
+    private static final String[] TABLES_AND_VIEWS = {"TABLE", "VIEW"};
+
+    /** Schema catalog index. */
+    private static final int TBL_CATALOG_IDX = 1;
+
+    /** Schema name index. */
+    private static final int TBL_SCHEMA_IDX = 2;
+
+    /** Table name index. */
+    private static final int TBL_NAME_IDX = 3;
+
+    /** Primary key column name index. */
+    private static final int PK_COL_NAME_IDX = 4;
+
+    /** Column name index. */
+    private static final int COL_NAME_IDX = 4;
+
+    /** Column data type index. */
+    private static final int COL_DATA_TYPE_IDX = 5;
+
+    /** Column nullable index. */
+    private static final int COL_NULLABLE_IDX = 11;
+
+    /** Index name index. */
+    private static final int IDX_NAME_IDX = 6;
+
+    /** Index column name index. */
+    private static final int IDX_COL_NAME_IDX = 9;
+
+    /** Index column descend index. */
+    private static final int IDX_ASC_OR_DESC_IDX = 10;
+
+    /** {@inheritDoc} */
+    @Override public Collection<String> schemas(Connection conn) throws SQLException {
+        Collection<String> schemas = new ArrayList<>();
+
+        ResultSet rs = conn.getMetaData().getSchemas();
+
+        Set<String> sys = systemSchemas();
+
+        while(rs.next()) {
+            String schema = rs.getString(1);
+
+            // Skip system schemas.
+            if (sys.contains(schema))
+                continue;
+
+            schemas.add(schema);
+        }
+
+        return schemas;
+    }
+
+    /**
+     * @return If {@code true} use catalogs for table division.
+     */
+    protected boolean useCatalog() {
+        return false;
+    }
+
+    /**
+     * @return If {@code true} use schemas for table division.
+     */
+    protected boolean useSchema() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Collection<DbTable> tables(Connection conn, List<String> schemas, boolean tblsOnly)
+        throws SQLException {
+        DatabaseMetaData dbMeta = conn.getMetaData();
+
+        Set<String> sys = systemSchemas();
+
+        Collection<DbTable> tbls = new ArrayList<>();
+
+        if (schemas.isEmpty())
+            schemas.add(null);
+
+        for (String toSchema: schemas) {
+            try (ResultSet tblsRs = dbMeta.getTables(useCatalog() ? toSchema : null, useSchema() ? toSchema : null, "%",
+                    tblsOnly ? TABLES_ONLY : TABLES_AND_VIEWS)) {
+                while (tblsRs.next()) {
+                    String tblCatalog = tblsRs.getString(TBL_CATALOG_IDX);
+                    String tblSchema = tblsRs.getString(TBL_SCHEMA_IDX);
+                    String tblName = tblsRs.getString(TBL_NAME_IDX);
+
+                    // In case of MySql we should use catalog.
+                    String schema = tblSchema != null ? tblSchema : tblCatalog;
+
+                    // Skip system schemas.
+                    if (sys.contains(schema))
+                        continue;
+
+                    Set<String> pkCols = new HashSet<>();
+
+                    try (ResultSet pkRs = dbMeta.getPrimaryKeys(tblCatalog, tblSchema, tblName)) {
+                        while (pkRs.next())
+                            pkCols.add(pkRs.getString(PK_COL_NAME_IDX));
+                    }
+
+                    List<DbColumn> cols = new ArrayList<>();
+
+                    try (ResultSet colsRs = dbMeta.getColumns(tblCatalog, tblSchema, tblName, null)) {
+                        while (colsRs.next()) {
+                            String colName = colsRs.getString(COL_NAME_IDX);
+
+                            cols.add(new DbColumn(
+                                    colName,
+                                    colsRs.getInt(COL_DATA_TYPE_IDX),
+                                    pkCols.contains(colName),
+                                    colsRs.getInt(COL_NULLABLE_IDX) == DatabaseMetaData.columnNullable));
+                        }
+                    }
+
+                    Map<String, QueryIndex> idxs = new LinkedHashMap<>();
+
+                    try (ResultSet idxRs = dbMeta.getIndexInfo(tblCatalog, tblSchema, tblName, false, true)) {
+                        while (idxRs.next()) {
+                            String idxName = idxRs.getString(IDX_NAME_IDX);
+
+                            String colName = idxRs.getString(IDX_COL_NAME_IDX);
+
+                            if (idxName == null || colName == null)
+                                continue;
+
+                            QueryIndex idx = idxs.get(idxName);
+
+                            if (idx == null) {
+                                idx = new QueryIndex();
+                                idx.setName(idxName);
+                                idx.setIndexType(QueryIndexType.SORTED);
+                                idx.setFields(new LinkedHashMap<String, Boolean>());
+
+                                idxs.put(idxName, idx);
+                            }
+
+                            String askOrDesc = idxRs.getString(IDX_ASC_OR_DESC_IDX);
+
+                            Boolean asc = askOrDesc == null || "A".equals(askOrDesc);
+
+                            idx.getFields().put(colName, asc);
+                        }
+                    }
+
+                    tbls.add(table(schema, tblName, cols, idxs.values()));
+                }
+            }
+        }
+
+        return tbls;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/fa197d2f/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/dialect/MySQLMetadataDialect.java
----------------------------------------------------------------------
diff --git a/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/dialect/MySQLMetadataDialect.java b/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/dialect/MySQLMetadataDialect.java
new file mode 100644
index 0000000..3332046
--- /dev/null
+++ b/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/dialect/MySQLMetadataDialect.java
@@ -0,0 +1,62 @@
+/*
+ * 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.schema.parser.dialect;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * MySQL specific metadata dialect.
+ */
+public class MySQLMetadataDialect extends JdbcMetadataDialect {
+    /** {@inheritDoc} */
+    @Override public Collection<String> schemas(Connection conn) throws SQLException {
+        List<String> schemas = new ArrayList<>();
+
+        ResultSet rs = conn.getMetaData().getCatalogs();
+
+        Set<String> sys = systemSchemas();
+
+        while(rs.next()) {
+            String schema = rs.getString(1);
+
+            // Skip system schemas.
+            if (sys.contains(schema))
+                continue;
+
+            schemas.add(schema);
+        }
+
+        return schemas;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected boolean useCatalog() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected boolean useSchema() {
+        return false;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/fa197d2f/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/dialect/OracleMetadataDialect.java
----------------------------------------------------------------------
diff --git a/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/dialect/OracleMetadataDialect.java b/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/dialect/OracleMetadataDialect.java
new file mode 100644
index 0000000..ed5cdc5
--- /dev/null
+++ b/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/dialect/OracleMetadataDialect.java
@@ -0,0 +1,364 @@
+/*
+ * 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.schema.parser.dialect;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.ignite.cache.QueryIndex;
+import org.apache.ignite.cache.QueryIndexType;
+import org.apache.ignite.schema.parser.DbColumn;
+import org.apache.ignite.schema.parser.DbTable;
+
+import static java.sql.Types.BIGINT;
+import static java.sql.Types.BLOB;
+import static java.sql.Types.BOOLEAN;
+import static java.sql.Types.CHAR;
+import static java.sql.Types.CLOB;
+import static java.sql.Types.DATE;
+import static java.sql.Types.DOUBLE;
+import static java.sql.Types.FLOAT;
+import static java.sql.Types.INTEGER;
+import static java.sql.Types.LONGVARBINARY;
+import static java.sql.Types.LONGVARCHAR;
+import static java.sql.Types.NUMERIC;
+import static java.sql.Types.OTHER;
+import static java.sql.Types.SMALLINT;
+import static java.sql.Types.SQLXML;
+import static java.sql.Types.TIMESTAMP;
+import static java.sql.Types.TINYINT;
+import static java.sql.Types.VARCHAR;
+
+/**
+ * Oracle specific metadata dialect.
+ */
+public class OracleMetadataDialect extends DatabaseMetadataDialect {
+    /** SQL to get columns metadata. */
+    private static final String SQL_COLUMNS = "SELECT a.owner, a.table_name, a.column_name, a.nullable," +
+        " a.data_type, a.data_precision, a.data_scale " +
+        "FROM all_tab_columns a %s " +
+        " %s " +
+        " ORDER BY a.owner, a.table_name, a.column_id";
+
+    /** SQL to get list of PRIMARY KEYS columns. */
+    private static final String SQL_PRIMARY_KEYS = "SELECT b.column_name" +
+        " FROM all_constraints a" +
+        "  INNER JOIN all_cons_columns b ON a.owner = b.owner AND a.constraint_name = b.constraint_name" +
+        " WHERE a.owner = ? and a.table_name = ? AND a.constraint_type = 'P'";
+
+    /** SQL to get indexes metadata. */
+    private static final String SQL_INDEXES = "SELECT i.index_name, u.column_expression, i.column_name, i.descend" +
+        " FROM all_ind_columns i" +
+        " LEFT JOIN user_ind_expressions u on u.index_name = i.index_name and i.table_name = u.table_name" +
+        " WHERE i.index_owner = ? and i.table_name = ?" +
+        " ORDER BY i.index_name, i.column_position";
+
+    /** Owner index. */
+    private static final int OWNER_IDX = 1;
+
+    /** Table name index. */
+    private static final int TBL_NAME_IDX = 2;
+
+    /** Column name index. */
+    private static final int COL_NAME_IDX = 3;
+
+    /** Nullable index. */
+    private static final int NULLABLE_IDX = 4;
+
+    /** Data type index. */
+    private static final int DATA_TYPE_IDX = 5;
+
+    /** Numeric precision index. */
+    private static final int DATA_PRECISION_IDX = 6;
+
+    /** Numeric scale index. */
+    private static final int DATA_SCALE_IDX = 7;
+
+    /** Index name index. */
+    private static final int IDX_NAME_IDX = 1;
+
+    /** Index name index. */
+    private static final int IDX_EXPR_IDX = 2;
+
+    /** Index column name index. */
+    private static final int IDX_COL_NAME_IDX = 3;
+
+    /** Index column sort order index. */
+    private static final int IDX_COL_DESCEND_IDX = 4;
+
+    /** {@inheritDoc} */
+    @Override public Set<String> systemSchemas() {
+        return new HashSet<>(Arrays.asList("ANONYMOUS", "CTXSYS", "DBSNMP", "EXFSYS", "LBACSYS", "MDSYS", "MGMT_VIEW",
+            "OLAPSYS", "OWBSYS", "ORDPLUGINS", "ORDSYS", "OUTLN", "SI_INFORMTN_SCHEMA", "SYS", "SYSMAN", "SYSTEM",
+            "TSMSYS", "WK_TEST", "WKSYS", "WKPROXY", "WMSYS", "XDB",
+
+            "APEX_040000", "APEX_PUBLIC_USER", "DIP", "FLOWS_30000", "FLOWS_FILES", "MDDATA", "ORACLE_OCM",
+            "SPATIAL_CSW_ADMIN_USR", "SPATIAL_WFS_ADMIN_USR", "XS$NULL",
+
+            "BI", "HR", "OE", "PM", "IX", "SH"));
+    }
+
+    /** {@inheritDoc} */
+    @Override public Collection<String> schemas(Connection conn) throws SQLException {
+        Collection<String> schemas = new ArrayList<>();
+
+        ResultSet rs = conn.getMetaData().getSchemas();
+
+        Set<String> sysSchemas = systemSchemas();
+
+        while(rs.next()) {
+            String schema = rs.getString(1);
+
+            if (!sysSchemas.contains(schema) && !schema.startsWith("FLOWS_"))
+                schemas.add(schema);
+        }
+
+        return schemas;
+    }
+
+    /**
+     * @param rs Result set with column type metadata from Oracle database.
+     * @return JDBC type.
+     * @throws SQLException If failed to decode type.
+     */
+    private int decodeType(ResultSet rs) throws SQLException {
+        String type = rs.getString(DATA_TYPE_IDX);
+
+        if (type.startsWith("TIMESTAMP"))
+            return TIMESTAMP;
+        else {
+            switch (type) {
+                case "CHAR":
+                case "NCHAR":
+                    return CHAR;
+
+                case "VARCHAR2":
+                case "NVARCHAR2":
+                    return VARCHAR;
+
+                case "LONG":
+                    return LONGVARCHAR;
+
+                case "LONG RAW":
+                    return LONGVARBINARY;
+
+                case "FLOAT":
+                    return FLOAT;
+
+                case "NUMBER":
+                    int precision = rs.getInt(DATA_PRECISION_IDX);
+                    int scale = rs.getInt(DATA_SCALE_IDX);
+
+                    if (scale > 0) {
+                        if (scale < 4 && precision < 19)
+                            return FLOAT;
+
+                        if (scale > 4 || precision > 19)
+                            return DOUBLE;
+
+                        return NUMERIC;
+                    }
+                    else {
+                        if (precision < 1)
+                            return INTEGER;
+
+                        if (precision < 2)
+                            return BOOLEAN;
+
+                        if (precision < 4)
+                            return TINYINT;
+
+                        if (precision < 6)
+                            return SMALLINT;
+
+                        if (precision < 11)
+                            return INTEGER;
+
+                        if (precision < 20)
+                            return BIGINT;
+
+                        return NUMERIC;
+                    }
+
+                case "DATE":
+                    return DATE;
+
+                case "BFILE":
+                case "BLOB":
+                    return BLOB;
+
+                case "CLOB":
+                case "NCLOB":
+                    return CLOB;
+
+                case "XMLTYPE":
+                    return SQLXML;
+            }
+        }
+
+        return OTHER;
+    }
+
+    /**
+     * Retrieve primary key columns.
+     *
+     * @param stmt Prepared SQL statement to execute.
+     * @param owner DB owner.
+     * @param tbl Table name.
+     * @return Primary key columns.
+     * @throws SQLException If failed to retrieve primary key columns.
+     */
+    private Set<String> primaryKeys(PreparedStatement stmt, String owner, String tbl) throws SQLException {
+        Set<String> pkCols = new HashSet<>();
+
+        stmt.setString(1, owner);
+        stmt.setString(2, tbl);
+
+        try (ResultSet pkRs = stmt.executeQuery()) {
+            while(pkRs.next())
+                pkCols.add(pkRs.getString(1));
+        }
+
+        return pkCols;
+    }
+
+    /**
+     * Retrieve index columns.
+     *
+     * @param stmt Prepared SQL statement to execute.
+     * @param owner DB owner.
+     * @param tbl Table name.
+     * @return Indexes.
+     * @throws SQLException If failed to retrieve indexes columns.
+     */
+    private Collection<QueryIndex> indexes(PreparedStatement stmt, String owner, String tbl)
+        throws SQLException {
+        Map<String, QueryIndex> idxs = new LinkedHashMap<>();
+
+        stmt.setString(1, owner);
+        stmt.setString(2, tbl);
+
+        try (ResultSet idxsRs = stmt.executeQuery()) {
+            while (idxsRs.next()) {
+                String idxName = idxsRs.getString(IDX_NAME_IDX);
+
+                QueryIndex idx = idxs.get(idxName);
+
+                if (idx == null) {
+                    idx = new QueryIndex();
+                    idx.setName(idxName);
+                    idx.setIndexType(QueryIndexType.SORTED);
+                    idx.setFields(new LinkedHashMap<String, Boolean>());
+
+                    idxs.put(idxName, idx);
+                }
+
+                String expr = idxsRs.getString(IDX_EXPR_IDX);
+
+                String col = expr == null ? idxsRs.getString(IDX_COL_NAME_IDX) : expr.replaceAll("\"", "");
+
+                idx.getFields().put(col, !"DESC".equals(idxsRs.getString(IDX_COL_DESCEND_IDX)));
+            }
+        }
+
+        return idxs.values();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Collection<DbTable> tables(Connection conn, List<String> schemas, boolean tblsOnly)
+        throws SQLException {
+        Collection<DbTable> tbls = new ArrayList<>();
+
+        PreparedStatement pkStmt = conn.prepareStatement(SQL_PRIMARY_KEYS);
+
+        PreparedStatement idxStmt = conn.prepareStatement(SQL_INDEXES);
+
+        if (schemas.isEmpty())
+            schemas.add(null);
+
+        Set<String> sysSchemas = systemSchemas();
+
+        try (Statement colsStmt = conn.createStatement()) {
+            for (String schema: schemas) {
+                if (systemSchemas().contains(schema) || (schema != null && schema.startsWith("FLOWS_")))
+                    continue;
+
+                Collection<DbColumn> cols = new ArrayList<>();
+
+                Set<String> pkCols = Collections.emptySet();
+                Collection<QueryIndex> idxs = Collections.emptyList();
+
+                String sql = String.format(SQL_COLUMNS,
+                        tblsOnly ? "INNER JOIN all_tables b on a.table_name = b.table_name and a.owner = b.owner" : "",
+                        schema != null ? String.format(" WHERE a.owner = '%s' ", schema) : "");
+
+                try (ResultSet colsRs = colsStmt.executeQuery(sql)) {
+                    String prevSchema = "";
+                    String prevTbl = "";
+
+                    boolean first = true;
+
+                    while (colsRs.next()) {
+                        String owner = colsRs.getString(OWNER_IDX);
+                        String tbl = colsRs.getString(TBL_NAME_IDX);
+
+                        if (sysSchemas.contains(owner) || (schema != null && schema.startsWith("FLOWS_")))
+                            continue;
+
+                        boolean changed = !owner.equals(prevSchema) || !tbl.equals(prevTbl);
+
+                        if (changed) {
+                            if (first)
+                                first = false;
+                            else
+                                tbls.add(table(prevSchema, prevTbl, cols, idxs));
+
+                            prevSchema = owner;
+                            prevTbl = tbl;
+                            cols = new ArrayList<>();
+                            pkCols = primaryKeys(pkStmt, owner, tbl);
+                            idxs = indexes(idxStmt, owner, tbl);
+                        }
+
+                        String colName = colsRs.getString(COL_NAME_IDX);
+
+                        cols.add(new DbColumn(colName, decodeType(colsRs), pkCols.contains(colName),
+                                !"N".equals(colsRs.getString(NULLABLE_IDX))));
+                    }
+
+                    if (!cols.isEmpty())
+                        tbls.add(table(prevSchema, prevTbl, cols, idxs));
+                }
+            }
+        }
+
+        return tbls;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/fa197d2f/modules/schema-import/pom.xml
----------------------------------------------------------------------
diff --git a/modules/schema-import/pom.xml b/modules/schema-import/pom.xml
index 7156e32..7e83a84 100644
--- a/modules/schema-import/pom.xml
+++ b/modules/schema-import/pom.xml
@@ -42,6 +42,12 @@
         </dependency>
 
         <dependency>
+            <groupId>org.apache.ignite</groupId>
+            <artifactId>ignite-schema-import-db</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
             <groupId>com.h2database</groupId>
             <artifactId>h2</artifactId>
             <version>${h2.version}</version>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fa197d2f/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/DatabaseMetadataParser.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/DatabaseMetadataParser.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/DatabaseMetadataParser.java
index c4490ef..b86346f 100644
--- a/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/DatabaseMetadataParser.java
+++ b/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/DatabaseMetadataParser.java
@@ -26,52 +26,16 @@ import java.util.Comparator;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
 import javafx.collections.FXCollections;
 import javafx.collections.ObservableList;
 import org.apache.ignite.cache.QueryIndex;
 import org.apache.ignite.schema.model.PojoDescriptor;
 import org.apache.ignite.schema.model.SchemaDescriptor;
-import org.apache.ignite.schema.parser.dialect.DB2MetadataDialect;
-import org.apache.ignite.schema.parser.dialect.DatabaseMetadataDialect;
-import org.apache.ignite.schema.parser.dialect.JdbcMetadataDialect;
-import org.apache.ignite.schema.parser.dialect.MySQLMetadataDialect;
-import org.apache.ignite.schema.parser.dialect.OracleMetadataDialect;
 
 /**
  * Database metadata parser.
  */
 public class DatabaseMetadataParser {
-    /** Logger. */
-    private static final Logger log = Logger.getLogger(DatabaseMetadataParser.class.getName());
-
-    /**
-     * Get specified dialect object for selected database.
-     *
-     * @param conn Connection to database.
-     * @return Specific dialect object.
-     */
-    private static DatabaseMetadataDialect dialect(Connection conn) {
-        try {
-            String dbProductName = conn.getMetaData().getDatabaseProductName();
-
-            if ("Oracle".equals(dbProductName))
-                return new OracleMetadataDialect();
-            else if (dbProductName.startsWith("DB2/"))
-                return new DB2MetadataDialect();
-            else if ("MySQL".equals(dbProductName))
-                return new MySQLMetadataDialect();
-            else
-                return new JdbcMetadataDialect();
-        }
-        catch (SQLException e) {
-            log.log(Level.SEVERE, "Failed to resolve dialect (JdbcMetaDataDialect will be used.", e);
-
-            return new JdbcMetadataDialect();
-        }
-    }
-
     /**
      * Get list of schemas from database.
      *
@@ -80,7 +44,7 @@ public class DatabaseMetadataParser {
      * @throws SQLException If schemas loading failed.
      */
     public static ObservableList<SchemaDescriptor> schemas(Connection conn) throws SQLException  {
-        List<String> dbSchemas = dialect(conn).schemas(conn);
+        Collection<String> dbSchemas = DbMetadataReader.getInstance().schemas(conn);
 
         List<SchemaDescriptor> uiSchemas = new ArrayList<>(dbSchemas.size());
 
@@ -94,20 +58,18 @@ public class DatabaseMetadataParser {
      * Parse database metadata.
      *
      * @param conn Connection to database.
-     * @param schemas Collection of schema names to load.
+     * @param schemas Collection of schema names to process.
      * @param tblsOnly If {@code true} then process tables only else process tables and views.
      * @return Collection of POJO descriptors.
      * @throws SQLException If parsing failed.
      */
     public static ObservableList<PojoDescriptor> parse(Connection conn, List<String> schemas, boolean tblsOnly)
         throws SQLException {
-        DatabaseMetadataDialect dialect = dialect(conn);
-
         Map<String, PojoDescriptor> parents = new HashMap<>();
 
         Map<String, Collection<PojoDescriptor>> childrens = new HashMap<>();
 
-        for (DbTable tbl : dialect.tables(conn, schemas, tblsOnly)) {
+        for (DbTable tbl : DbMetadataReader.getInstance().metadata(conn, schemas, tblsOnly)) {
             String schema = tbl.schema();
 
             PojoDescriptor parent = parents.get(schema);

http://git-wip-us.apache.org/repos/asf/ignite/blob/fa197d2f/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/DbColumn.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/DbColumn.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/DbColumn.java
deleted file mode 100644
index 9a548f4..0000000
--- a/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/DbColumn.java
+++ /dev/null
@@ -1,76 +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.schema.parser;
-
-/**
- * Database table column.
- */
-public class DbColumn {
-    /** Column name. */
-    private final String name;
-
-    /** Column JDBC type. */
-    private final int type;
-
-    /** Is this column belongs to primary key. */
-    private final boolean key;
-
-    /** Is {@code NULL} allowed for column in database. */
-    private final boolean nullable;
-
-    /**
-     * @param name Column name.
-     * @param type Column JDBC type.
-     * @param key {@code true} if this column belongs to primary key.
-     * @param nullable {@code true} if {@code NULL } allowed for column in database.
-     */
-    public DbColumn(String name, int type, boolean key, boolean nullable) {
-        this.name = name;
-        this.type = type;
-        this.key = key;
-        this.nullable = nullable;
-    }
-
-    /**
-     * @return Column name.
-     */
-    public String name() {
-        return name;
-    }
-
-    /**
-     * @return Column JDBC type.
-     */
-    public int type() {
-        return type;
-    }
-
-    /**
-     * @return {@code true} if this column belongs to primary key.
-     */
-    public boolean key() {
-        return key;
-    }
-
-    /**
-     * @return nullable {@code true} if {@code NULL } allowed for column in database.
-     */
-    public boolean nullable() {
-        return nullable;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/fa197d2f/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/DbTable.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/DbTable.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/DbTable.java
deleted file mode 100644
index 39f6f7b..0000000
--- a/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/DbTable.java
+++ /dev/null
@@ -1,82 +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.schema.parser;
-
-import org.apache.ignite.cache.QueryIndex;
-
-import java.util.Collection;
-
-/**
- * Database table.
- */
-public class DbTable {
-    /** Schema name. */
-    private final String schema;
-
-    /** Table name. */
-    private final String tbl;
-
-    /** Columns. */
-    private final Collection<DbColumn> cols;
-
-    /** Indexes. */
-    private final Collection<QueryIndex> idxs;
-
-    /**
-     * Default columns.
-     *
-     * @param schema Schema name.
-     * @param tbl Table name.
-     * @param cols Columns.
-     * @param idxs Indexes;
-     */
-    public DbTable(String schema, String tbl, Collection<DbColumn> cols, Collection<QueryIndex> idxs) {
-        this.schema = schema;
-        this.tbl = tbl;
-        this.cols = cols;
-        this.idxs = idxs;
-    }
-
-    /**
-     * @return Schema name.
-     */
-    public String schema() {
-        return schema;
-    }
-
-    /**
-     * @return Table name.
-     */
-    public String table() {
-        return tbl;
-    }
-
-    /**
-     * @return Columns.
-     */
-    public Collection<DbColumn> columns() {
-        return cols;
-    }
-
-    /**
-     * @return Indexes.
-     */
-    public Collection<QueryIndex> indexes() {
-        return idxs;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/fa197d2f/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/dialect/DB2MetadataDialect.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/dialect/DB2MetadataDialect.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/dialect/DB2MetadataDialect.java
deleted file mode 100644
index b191ec3..0000000
--- a/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/dialect/DB2MetadataDialect.java
+++ /dev/null
@@ -1,33 +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.schema.parser.dialect;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * DB2 specific metadata dialect.
- */
-public class DB2MetadataDialect extends JdbcMetadataDialect {
-    /** {@inheritDoc} */
-    @Override public Set<String> systemSchemas() {
-        return new HashSet<>(Arrays.asList("SYSIBM", "SYSCAT", "SYSSTAT", "SYSTOOLS", "SYSFUN", "SYSIBMADM",
-            "SYSIBMINTERNAL", "SYSIBMTS", "SYSPROC", "SYSPUBLIC"));
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/fa197d2f/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/dialect/DatabaseMetadataDialect.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/dialect/DatabaseMetadataDialect.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/dialect/DatabaseMetadataDialect.java
deleted file mode 100644
index bdf309b..0000000
--- a/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/dialect/DatabaseMetadataDialect.java
+++ /dev/null
@@ -1,75 +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.schema.parser.dialect;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.ignite.cache.QueryIndex;
-import org.apache.ignite.schema.parser.DbColumn;
-import org.apache.ignite.schema.parser.DbTable;
-
-/**
- * Base class for database metadata dialect.
- */
-public abstract class DatabaseMetadataDialect {
-    /**
-     * Gets schemas from database.
-     *
-     * @param conn Database connection.
-     * @return Collection of schema descriptors.
-     * @throws SQLException If failed to get schemas.
-     */
-    public abstract List<String> schemas(Connection conn) throws SQLException;
-
-    /**
-     * Gets tables from database.
-     *
-     * @param conn Database connection.
-     * @param schemas Collection of schema names to load.
-     * @param tblsOnly If {@code true} then gets only tables otherwise gets tables and views.
-     * @return Collection of table descriptors.
-     * @throws SQLException If failed to get tables.
-     */
-    public abstract Collection<DbTable> tables(Connection conn, List<String> schemas, boolean tblsOnly)
-        throws SQLException;
-
-    /**
-     * @return Collection of database system schemas.
-     */
-    public Set<String> systemSchemas() {
-        return Collections.singleton("INFORMATION_SCHEMA");
-    }
-
-    /**
-     * Create table descriptor.
-     *
-     * @param schema Schema name.
-     * @param tbl Table name.
-     * @param cols Table columns.
-     * @param idxs Table indexes.
-     * @return New {@code DbTable} instance.
-     */
-    protected DbTable table(String schema, String tbl, Collection<DbColumn> cols, Collection<QueryIndex>idxs) {
-        return new DbTable(schema, tbl, cols, idxs);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/fa197d2f/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/dialect/JdbcMetadataDialect.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/dialect/JdbcMetadataDialect.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/dialect/JdbcMetadataDialect.java
deleted file mode 100644
index 45f0f9f..0000000
--- a/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/dialect/JdbcMetadataDialect.java
+++ /dev/null
@@ -1,197 +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.schema.parser.dialect;
-
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.ignite.cache.QueryIndex;
-import org.apache.ignite.cache.QueryIndexType;
-import org.apache.ignite.schema.parser.DbColumn;
-import org.apache.ignite.schema.parser.DbTable;
-
-/**
- * Metadata dialect that uses standard JDBC for reading metadata.
- */
-public class JdbcMetadataDialect extends DatabaseMetadataDialect {
-    /** */
-    private static final String[] TABLES_ONLY = {"TABLE"};
-
-    /** */
-    private static final String[] TABLES_AND_VIEWS = {"TABLE", "VIEW"};
-
-    /** Schema catalog index. */
-    private static final int TBL_CATALOG_IDX = 1;
-
-    /** Schema name index. */
-    private static final int TBL_SCHEMA_IDX = 2;
-
-    /** Table name index. */
-    private static final int TBL_NAME_IDX = 3;
-
-    /** Primary key column name index. */
-    private static final int PK_COL_NAME_IDX = 4;
-
-    /** Column name index. */
-    private static final int COL_NAME_IDX = 4;
-
-    /** Column data type index. */
-    private static final int COL_DATA_TYPE_IDX = 5;
-
-    /** Column nullable index. */
-    private static final int COL_NULLABLE_IDX = 11;
-
-    /** Index name index. */
-    private static final int IDX_NAME_IDX = 6;
-
-    /** Index column name index. */
-    private static final int IDX_COL_NAME_IDX = 9;
-
-    /** Index column descend index. */
-    private static final int IDX_ASC_OR_DESC_IDX = 10;
-
-    /** {@inheritDoc} */
-    @Override public List<String> schemas(Connection conn) throws SQLException {
-        List<String> schemas = new ArrayList<>();
-
-        ResultSet rs = conn.getMetaData().getSchemas();
-
-        Set<String> sys = systemSchemas();
-
-        while(rs.next()) {
-            String schema = rs.getString(1);
-
-            // Skip system schemas.
-            if (sys.contains(schema))
-                continue;
-
-            schemas.add(schema);
-        }
-
-        return schemas;
-    }
-
-    /**
-     * @return If {@code true} use catalogs for table division.
-     */
-    protected boolean useCatalog() {
-        return false;
-    }
-
-    /**
-     * @return If {@code true} use schemas for table division.
-     */
-    protected boolean useSchema() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Collection<DbTable> tables(Connection conn, List<String> schemas, boolean tblsOnly)
-        throws SQLException {
-        DatabaseMetaData dbMeta = conn.getMetaData();
-
-        Set<String> sys = systemSchemas();
-
-        Collection<DbTable> tbls = new ArrayList<>();
-
-        if (schemas.isEmpty())
-            schemas.add(null);
-
-        for (String toSchema: schemas) {
-            try (ResultSet tblsRs = dbMeta.getTables(useCatalog() ? toSchema : null, useSchema() ? toSchema : null, "%",
-                    tblsOnly ? TABLES_ONLY : TABLES_AND_VIEWS)) {
-                while (tblsRs.next()) {
-                    String tblCatalog = tblsRs.getString(TBL_CATALOG_IDX);
-                    String tblSchema = tblsRs.getString(TBL_SCHEMA_IDX);
-                    String tblName = tblsRs.getString(TBL_NAME_IDX);
-
-                    // In case of MySql we should use catalog.
-                    String schema = tblSchema != null ? tblSchema : tblCatalog;
-
-                    // Skip system schemas.
-                    if (sys.contains(schema))
-                        continue;
-
-                    Set<String> pkCols = new HashSet<>();
-
-                    try (ResultSet pkRs = dbMeta.getPrimaryKeys(tblCatalog, tblSchema, tblName)) {
-                        while (pkRs.next())
-                            pkCols.add(pkRs.getString(PK_COL_NAME_IDX));
-                    }
-
-                    List<DbColumn> cols = new ArrayList<>();
-
-                    try (ResultSet colsRs = dbMeta.getColumns(tblCatalog, tblSchema, tblName, null)) {
-                        while (colsRs.next()) {
-                            String colName = colsRs.getString(COL_NAME_IDX);
-
-                            cols.add(new DbColumn(
-                                    colName,
-                                    colsRs.getInt(COL_DATA_TYPE_IDX),
-                                    pkCols.contains(colName),
-                                    colsRs.getInt(COL_NULLABLE_IDX) == DatabaseMetaData.columnNullable));
-                        }
-                    }
-
-                    Map<String, QueryIndex> idxs = new LinkedHashMap<>();
-
-                    try (ResultSet idxRs = dbMeta.getIndexInfo(tblCatalog, tblSchema, tblName, false, true)) {
-                        while (idxRs.next()) {
-                            String idxName = idxRs.getString(IDX_NAME_IDX);
-
-                            String colName = idxRs.getString(IDX_COL_NAME_IDX);
-
-                            if (idxName == null || colName == null)
-                                continue;
-
-                            QueryIndex idx = idxs.get(idxName);
-
-                            if (idx == null) {
-                                idx = new QueryIndex();
-                                idx.setName(idxName);
-                                idx.setIndexType(QueryIndexType.SORTED);
-                                idx.setFields(new LinkedHashMap<String, Boolean>());
-
-                                idxs.put(idxName, idx);
-                            }
-
-                            String askOrDesc = idxRs.getString(IDX_ASC_OR_DESC_IDX);
-
-                            Boolean asc = askOrDesc == null || "A".equals(askOrDesc);
-
-                            idx.getFields().put(colName, asc);
-                        }
-                    }
-
-                    tbls.add(table(schema, tblName, cols, idxs.values()));
-                }
-            }
-        }
-
-        return tbls;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/fa197d2f/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/dialect/MySQLMetadataDialect.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/dialect/MySQLMetadataDialect.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/dialect/MySQLMetadataDialect.java
deleted file mode 100644
index 090925e..0000000
--- a/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/dialect/MySQLMetadataDialect.java
+++ /dev/null
@@ -1,61 +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.schema.parser.dialect;
-
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-/**
- * MySQL specific metadata dialect.
- */
-public class MySQLMetadataDialect extends JdbcMetadataDialect {
-    /** {@inheritDoc} */
-    @Override public List<String> schemas(Connection conn) throws SQLException {
-        List<String> schemas = new ArrayList<>();
-
-        ResultSet rs = conn.getMetaData().getCatalogs();
-
-        Set<String> sys = systemSchemas();
-
-        while(rs.next()) {
-            String schema = rs.getString(1);
-
-            // Skip system schemas.
-            if (sys.contains(schema))
-                continue;
-
-            schemas.add(schema);
-        }
-
-        return schemas;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected boolean useCatalog() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected boolean useSchema() {
-        return false;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/fa197d2f/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/dialect/OracleMetadataDialect.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/dialect/OracleMetadataDialect.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/dialect/OracleMetadataDialect.java
deleted file mode 100644
index 0d4e8d6..0000000
--- a/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/dialect/OracleMetadataDialect.java
+++ /dev/null
@@ -1,364 +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.schema.parser.dialect;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.ignite.cache.QueryIndex;
-import org.apache.ignite.cache.QueryIndexType;
-import org.apache.ignite.schema.parser.DbColumn;
-import org.apache.ignite.schema.parser.DbTable;
-
-import static java.sql.Types.BIGINT;
-import static java.sql.Types.BLOB;
-import static java.sql.Types.BOOLEAN;
-import static java.sql.Types.CHAR;
-import static java.sql.Types.CLOB;
-import static java.sql.Types.DATE;
-import static java.sql.Types.DOUBLE;
-import static java.sql.Types.FLOAT;
-import static java.sql.Types.INTEGER;
-import static java.sql.Types.LONGVARBINARY;
-import static java.sql.Types.LONGVARCHAR;
-import static java.sql.Types.NUMERIC;
-import static java.sql.Types.OTHER;
-import static java.sql.Types.SMALLINT;
-import static java.sql.Types.SQLXML;
-import static java.sql.Types.TIMESTAMP;
-import static java.sql.Types.TINYINT;
-import static java.sql.Types.VARCHAR;
-
-/**
- * Oracle specific metadata dialect.
- */
-public class OracleMetadataDialect extends DatabaseMetadataDialect {
-    /** SQL to get columns metadata. */
-    private static final String SQL_COLUMNS = "SELECT a.owner, a.table_name, a.column_name, a.nullable," +
-        " a.data_type, a.data_precision, a.data_scale " +
-        "FROM all_tab_columns a %s " +
-        " %s " +
-        " ORDER BY a.owner, a.table_name, a.column_id";
-
-    /** SQL to get list of PRIMARY KEYS columns. */
-    private static final String SQL_PRIMARY_KEYS = "SELECT b.column_name" +
-        " FROM all_constraints a" +
-        "  INNER JOIN all_cons_columns b ON a.owner = b.owner AND a.constraint_name = b.constraint_name" +
-        " WHERE a.owner = ? and a.table_name = ? AND a.constraint_type = 'P'";
-
-    /** SQL to get indexes metadata. */
-    private static final String SQL_INDEXES = "SELECT i.index_name, u.column_expression, i.column_name, i.descend" +
-        " FROM all_ind_columns i" +
-        " LEFT JOIN user_ind_expressions u on u.index_name = i.index_name and i.table_name = u.table_name" +
-        " WHERE i.index_owner = ? and i.table_name = ?" +
-        " ORDER BY i.index_name, i.column_position";
-
-    /** Owner index. */
-    private static final int OWNER_IDX = 1;
-
-    /** Table name index. */
-    private static final int TBL_NAME_IDX = 2;
-
-    /** Column name index. */
-    private static final int COL_NAME_IDX = 3;
-
-    /** Nullable index. */
-    private static final int NULLABLE_IDX = 4;
-
-    /** Data type index. */
-    private static final int DATA_TYPE_IDX = 5;
-
-    /** Numeric precision index. */
-    private static final int DATA_PRECISION_IDX = 6;
-
-    /** Numeric scale index. */
-    private static final int DATA_SCALE_IDX = 7;
-
-    /** Index name index. */
-    private static final int IDX_NAME_IDX = 1;
-
-    /** Index name index. */
-    private static final int IDX_EXPR_IDX = 2;
-
-    /** Index column name index. */
-    private static final int IDX_COL_NAME_IDX = 3;
-
-    /** Index column sort order index. */
-    private static final int IDX_COL_DESCEND_IDX = 4;
-
-    /** {@inheritDoc} */
-    @Override public Set<String> systemSchemas() {
-        return new HashSet<>(Arrays.asList("ANONYMOUS", "CTXSYS", "DBSNMP", "EXFSYS", "LBACSYS", "MDSYS", "MGMT_VIEW",
-            "OLAPSYS", "OWBSYS", "ORDPLUGINS", "ORDSYS", "OUTLN", "SI_INFORMTN_SCHEMA", "SYS", "SYSMAN", "SYSTEM",
-            "TSMSYS", "WK_TEST", "WKSYS", "WKPROXY", "WMSYS", "XDB",
-
-            "APEX_040000", "APEX_PUBLIC_USER", "DIP", "FLOWS_30000", "FLOWS_FILES", "MDDATA", "ORACLE_OCM",
-            "SPATIAL_CSW_ADMIN_USR", "SPATIAL_WFS_ADMIN_USR", "XS$NULL",
-
-            "BI", "HR", "OE", "PM", "IX", "SH"));
-    }
-
-    /** {@inheritDoc} */
-    @Override public List<String> schemas(Connection conn) throws SQLException {
-        List<String> schemas = new ArrayList<>();
-
-        ResultSet rs = conn.getMetaData().getSchemas();
-
-        Set<String> sysSchemas = systemSchemas();
-
-        while(rs.next()) {
-            String schema = rs.getString(1);
-
-            if (!sysSchemas.contains(schema) && !schema.startsWith("FLOWS_"))
-                schemas.add(schema);
-        }
-
-        return schemas;
-    }
-
-    /**
-     * @param rs Result set with column type metadata from Oracle database.
-     * @return JDBC type.
-     * @throws SQLException If failed to decode type.
-     */
-    private int decodeType(ResultSet rs) throws SQLException {
-        String type = rs.getString(DATA_TYPE_IDX);
-
-        if (type.startsWith("TIMESTAMP"))
-            return TIMESTAMP;
-        else {
-            switch (type) {
-                case "CHAR":
-                case "NCHAR":
-                    return CHAR;
-
-                case "VARCHAR2":
-                case "NVARCHAR2":
-                    return VARCHAR;
-
-                case "LONG":
-                    return LONGVARCHAR;
-
-                case "LONG RAW":
-                    return LONGVARBINARY;
-
-                case "FLOAT":
-                    return FLOAT;
-
-                case "NUMBER":
-                    int precision = rs.getInt(DATA_PRECISION_IDX);
-                    int scale = rs.getInt(DATA_SCALE_IDX);
-
-                    if (scale > 0) {
-                        if (scale < 4 && precision < 19)
-                            return FLOAT;
-
-                        if (scale > 4 || precision > 19)
-                            return DOUBLE;
-
-                        return NUMERIC;
-                    }
-                    else {
-                        if (precision < 1)
-                            return INTEGER;
-
-                        if (precision < 2)
-                            return BOOLEAN;
-
-                        if (precision < 4)
-                            return TINYINT;
-
-                        if (precision < 6)
-                            return SMALLINT;
-
-                        if (precision < 11)
-                            return INTEGER;
-
-                        if (precision < 20)
-                            return BIGINT;
-
-                        return NUMERIC;
-                    }
-
-                case "DATE":
-                    return DATE;
-
-                case "BFILE":
-                case "BLOB":
-                    return BLOB;
-
-                case "CLOB":
-                case "NCLOB":
-                    return CLOB;
-
-                case "XMLTYPE":
-                    return SQLXML;
-            }
-        }
-
-        return OTHER;
-    }
-
-    /**
-     * Retrieve primary key columns.
-     *
-     * @param stmt Prepared SQL statement to execute.
-     * @param owner DB owner.
-     * @param tbl Table name.
-     * @return Primary key columns.
-     * @throws SQLException If failed to retrieve primary key columns.
-     */
-    private Set<String> primaryKeys(PreparedStatement stmt, String owner, String tbl) throws SQLException {
-        Set<String> pkCols = new HashSet<>();
-
-        stmt.setString(1, owner);
-        stmt.setString(2, tbl);
-
-        try (ResultSet pkRs = stmt.executeQuery()) {
-            while(pkRs.next())
-                pkCols.add(pkRs.getString(1));
-        }
-
-        return pkCols;
-    }
-
-    /**
-     * Retrieve index columns.
-     *
-     * @param stmt Prepared SQL statement to execute.
-     * @param owner DB owner.
-     * @param tbl Table name.
-     * @return Indexes.
-     * @throws SQLException If failed to retrieve indexes columns.
-     */
-    private Collection<QueryIndex> indexes(PreparedStatement stmt, String owner, String tbl)
-        throws SQLException {
-        Map<String, QueryIndex> idxs = new LinkedHashMap<>();
-
-        stmt.setString(1, owner);
-        stmt.setString(2, tbl);
-
-        try (ResultSet idxsRs = stmt.executeQuery()) {
-            while (idxsRs.next()) {
-                String idxName = idxsRs.getString(IDX_NAME_IDX);
-
-                QueryIndex idx = idxs.get(idxName);
-
-                if (idx == null) {
-                    idx = new QueryIndex();
-                    idx.setName(idxName);
-                    idx.setIndexType(QueryIndexType.SORTED);
-                    idx.setFields(new LinkedHashMap<String, Boolean>());
-
-                    idxs.put(idxName, idx);
-                }
-
-                String expr = idxsRs.getString(IDX_EXPR_IDX);
-
-                String col = expr == null ? idxsRs.getString(IDX_COL_NAME_IDX) : expr.replaceAll("\"", "");
-
-                idx.getFields().put(col, !"DESC".equals(idxsRs.getString(IDX_COL_DESCEND_IDX)));
-            }
-        }
-
-        return idxs.values();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Collection<DbTable> tables(Connection conn, List<String> schemas, boolean tblsOnly)
-        throws SQLException {
-        Collection<DbTable> tbls = new ArrayList<>();
-
-        PreparedStatement pkStmt = conn.prepareStatement(SQL_PRIMARY_KEYS);
-
-        PreparedStatement idxStmt = conn.prepareStatement(SQL_INDEXES);
-
-        if (schemas.isEmpty())
-            schemas.add(null);
-
-        Set<String> sysSchemas = systemSchemas();
-
-        try (Statement colsStmt = conn.createStatement()) {
-            for (String schema: schemas) {
-                if (systemSchemas().contains(schema) || (schema != null && schema.startsWith("FLOWS_")))
-                    continue;
-
-                Collection<DbColumn> cols = new ArrayList<>();
-
-                Set<String> pkCols = Collections.emptySet();
-                Collection<QueryIndex> idxs = Collections.emptyList();
-
-                String sql = String.format(SQL_COLUMNS,
-                        tblsOnly ? "INNER JOIN all_tables b on a.table_name = b.table_name and a.owner = b.owner" : "",
-                        schema != null ? String.format(" WHERE a.owner = '%s' ", schema) : "");
-
-                try (ResultSet colsRs = colsStmt.executeQuery(sql)) {
-                    String prevSchema = "";
-                    String prevTbl = "";
-
-                    boolean first = true;
-
-                    while (colsRs.next()) {
-                        String owner = colsRs.getString(OWNER_IDX);
-                        String tbl = colsRs.getString(TBL_NAME_IDX);
-
-                        if (sysSchemas.contains(owner) || (schema != null && schema.startsWith("FLOWS_")))
-                            continue;
-
-                        boolean changed = !owner.equals(prevSchema) || !tbl.equals(prevTbl);
-
-                        if (changed) {
-                            if (first)
-                                first = false;
-                            else
-                                tbls.add(table(prevSchema, prevTbl, cols, idxs));
-
-                            prevSchema = owner;
-                            prevTbl = tbl;
-                            cols = new ArrayList<>();
-                            pkCols = primaryKeys(pkStmt, owner, tbl);
-                            idxs = indexes(idxStmt, owner, tbl);
-                        }
-
-                        String colName = colsRs.getString(COL_NAME_IDX);
-
-                        cols.add(new DbColumn(colName, decodeType(colsRs), pkCols.contains(colName),
-                                !"N".equals(colsRs.getString(NULLABLE_IDX))));
-                    }
-
-                    if (!cols.isEmpty())
-                        tbls.add(table(prevSchema, prevTbl, cols, idxs));
-                }
-            }
-        }
-
-        return tbls;
-    }
-}


[09/14] ignite git commit: IGNITE-3148: add package-info.java for org.apache.ignite.cache.jta.websphere

Posted by av...@apache.org.
IGNITE-3148: add package-info.java for org.apache.ignite.cache.jta.websphere


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

Branch: refs/heads/master
Commit: b95487d61145cbf75a80c993a5b9ddbe27804220
Parents: b369d03
Author: ashutak <as...@gridgain.com>
Authored: Tue May 17 15:07:24 2016 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Tue May 17 15:07:24 2016 +0300

----------------------------------------------------------------------
 .../cache/jta/websphere/package-info.java       | 22 ++++++++++++++++++++
 1 file changed, 22 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b95487d6/modules/jta/src/main/java/org/apache/ignite/cache/jta/websphere/package-info.java
----------------------------------------------------------------------
diff --git a/modules/jta/src/main/java/org/apache/ignite/cache/jta/websphere/package-info.java b/modules/jta/src/main/java/org/apache/ignite/cache/jta/websphere/package-info.java
new file mode 100644
index 0000000..26b2c34
--- /dev/null
+++ b/modules/jta/src/main/java/org/apache/ignite/cache/jta/websphere/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * 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 description. -->
+ * Contains WebSphere integrations.
+ */
+package org.apache.ignite.cache.jta.websphere;


[03/14] ignite git commit: ignite-1.6 Fixed race in IgniteSourceTask initialization, fixed code style issues.

Posted by av...@apache.org.
ignite-1.6 Fixed race in IgniteSourceTask initialization, fixed code style issues.


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

Branch: refs/heads/master
Commit: d549daf7b35496398844e47e4bf1bdacab6e814e
Parents: fa197d2
Author: sboikov <sb...@gridgain.com>
Authored: Tue May 17 10:56:02 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue May 17 10:56:02 2016 +0300

----------------------------------------------------------------------
 .../stream/kafka/connect/IgniteSourceTask.java  | 122 ++++++++++++-------
 .../kafka/connect/IgniteSinkConnectorTest.java  |   8 +-
 .../connect/IgniteSourceConnectorMock.java      |   1 -
 .../connect/IgniteSourceConnectorTest.java      |  16 +--
 .../kafka/connect/IgniteSourceTaskMock.java     |   4 +-
 .../kafka/connect/TestCacheEventFilter.java     |   6 +-
 6 files changed, 93 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/d549daf7/modules/kafka/src/main/java/org/apache/ignite/stream/kafka/connect/IgniteSourceTask.java
----------------------------------------------------------------------
diff --git a/modules/kafka/src/main/java/org/apache/ignite/stream/kafka/connect/IgniteSourceTask.java b/modules/kafka/src/main/java/org/apache/ignite/stream/kafka/connect/IgniteSourceTask.java
index 0d312ca..2f6a728 100644
--- a/modules/kafka/src/main/java/org/apache/ignite/stream/kafka/connect/IgniteSourceTask.java
+++ b/modules/kafka/src/main/java/org/apache/ignite/stream/kafka/connect/IgniteSourceTask.java
@@ -50,6 +50,9 @@ public class IgniteSourceTask extends SourceTask {
     /** Logger. */
     private static final Logger log = LoggerFactory.getLogger(IgniteSourceTask.class);
 
+    /** Tasks static monitor. */
+    private static final Object lock = new Object();
+
     /** Event buffer size. */
     private static int evtBufSize = 100000;
 
@@ -63,7 +66,7 @@ public class IgniteSourceTask extends SourceTask {
     private static volatile boolean stopped = true;
 
     /** Ignite grid configuration file. */
-    private static String igniteConfigFile;
+    private static String igniteCfgFile;
 
     /** Cache name. */
     private static String cacheName;
@@ -74,9 +77,6 @@ public class IgniteSourceTask extends SourceTask {
     /** Local listener. */
     private static TaskLocalListener locLsnr = new TaskLocalListener();
 
-    /** Remote filter. */
-    private static TaskRemoteFilter rmtLsnr;
-
     /** User-defined filter. */
     private static IgnitePredicate<CacheEvent> filter;
 
@@ -100,51 +100,54 @@ public class IgniteSourceTask extends SourceTask {
      * @param props Task properties.
      */
     @Override public void start(Map<String, String> props) {
-        // Each task has the same parameters -- avoid setting more than once.
-        if (cacheName != null)
-            return;
-
-        cacheName = props.get(IgniteSourceConstants.CACHE_NAME);
-        igniteConfigFile = props.get(IgniteSourceConstants.CACHE_CFG_PATH);
-        topics = props.get(IgniteSourceConstants.TOPIC_NAMES).split("\\s*,\\s*");
-
-        if (props.containsKey(IgniteSourceConstants.INTL_BUF_SIZE))
-            evtBufSize = Integer.parseInt(props.get(IgniteSourceConstants.INTL_BUF_SIZE));
-
-        if (props.containsKey(IgniteSourceConstants.INTL_BATCH_SIZE))
-            evtBatchSize = Integer.parseInt(props.get(IgniteSourceConstants.INTL_BATCH_SIZE));
-
-        if (props.containsKey(IgniteSourceConstants.CACHE_FILTER_CLASS)) {
-            String filterCls = props.get(IgniteSourceConstants.CACHE_FILTER_CLASS);
-            if (filterCls != null && !filterCls.isEmpty()) {
-                try {
-                    Class<? extends IgnitePredicate<CacheEvent>> clazz =
-                        (Class<? extends IgnitePredicate<CacheEvent>>)Class.forName(filterCls);
-
-                    filter = clazz.newInstance();
-                }
-                catch (Exception e) {
-                    log.error("Failed to instantiate the provided filter! " +
-                        "User-enabled filtering is ignored!", e);
+        synchronized (lock) {
+            // Each task has the same parameters -- avoid setting more than once.
+            // Nothing to do if the task has been already started.
+            if (!stopped)
+                return;
+
+            cacheName = props.get(IgniteSourceConstants.CACHE_NAME);
+            igniteCfgFile = props.get(IgniteSourceConstants.CACHE_CFG_PATH);
+            topics = props.get(IgniteSourceConstants.TOPIC_NAMES).split("\\s*,\\s*");
+
+            if (props.containsKey(IgniteSourceConstants.INTL_BUF_SIZE))
+                evtBufSize = Integer.parseInt(props.get(IgniteSourceConstants.INTL_BUF_SIZE));
+
+            if (props.containsKey(IgniteSourceConstants.INTL_BATCH_SIZE))
+                evtBatchSize = Integer.parseInt(props.get(IgniteSourceConstants.INTL_BATCH_SIZE));
+
+            if (props.containsKey(IgniteSourceConstants.CACHE_FILTER_CLASS)) {
+                String filterCls = props.get(IgniteSourceConstants.CACHE_FILTER_CLASS);
+                if (filterCls != null && !filterCls.isEmpty()) {
+                    try {
+                        Class<? extends IgnitePredicate<CacheEvent>> clazz =
+                            (Class<? extends IgnitePredicate<CacheEvent>>)Class.forName(filterCls);
+
+                        filter = clazz.newInstance();
+                    }
+                    catch (Exception e) {
+                        log.error("Failed to instantiate the provided filter! " +
+                            "User-enabled filtering is ignored!", e);
+                    }
                 }
             }
-        }
 
-        rmtLsnr = new TaskRemoteFilter(cacheName);
+            TaskRemoteFilter rmtLsnr = new TaskRemoteFilter(cacheName);
 
-        try {
-            int[] evts = cacheEvents(props.get(IgniteSourceConstants.CACHE_EVENTS));
+            try {
+                int[] evts = cacheEvents(props.get(IgniteSourceConstants.CACHE_EVENTS));
 
-            rmtLsnrId = IgniteGrid.getIgnite().events(IgniteGrid.getIgnite().cluster().forCacheNodes(cacheName))
-                .remoteListen(locLsnr, rmtLsnr, evts);
-        }
-        catch (Exception e) {
-            log.error("Failed to register event listener!", e);
+                rmtLsnrId = IgniteGrid.getIgnite().events(IgniteGrid.getIgnite().cluster().forCacheNodes(cacheName))
+                    .remoteListen(locLsnr, rmtLsnr, evts);
+            }
+            catch (Exception e) {
+                log.error("Failed to register event listener!", e);
 
-            throw new ConnectException(e);
-        }
-        finally {
-            stopped = false;
+                throw new ConnectException(e);
+            }
+            finally {
+                stopped = false;
+            }
         }
     }
 
@@ -228,10 +231,19 @@ public class IgniteSourceTask extends SourceTask {
     }
 
     /**
+     * Used by unit test to avoid restart node and valid state of the <code>stopped</code> flag.
+     *
+     * @param stopped Stopped flag.
+     */
+    protected static void setStopped(boolean stopped) {
+        IgniteSourceTask.stopped = stopped ;
+    }
+
+    /**
      * Local listener buffering cache events to be further sent to Kafka.
      */
     private static class TaskLocalListener implements IgniteBiPredicate<UUID, CacheEvent> {
-
+        /** {@inheritDoc} */
         @Override public boolean apply(UUID id, CacheEvent evt) {
             try {
                 if (!evtBuf.offer(evt, 10, TimeUnit.MILLISECONDS))
@@ -249,19 +261,23 @@ public class IgniteSourceTask extends SourceTask {
      * Remote filter.
      */
     private static class TaskRemoteFilter implements IgnitePredicate<CacheEvent> {
+        /** */
         @IgniteInstanceResource
         Ignite ignite;
 
         /** Cache name. */
         private final String cacheName;
 
+        /**
+         * @param cacheName Cache name.
+         */
         TaskRemoteFilter(String cacheName) {
             this.cacheName = cacheName;
         }
 
+        /** {@inheritDoc} */
         @Override public boolean apply(CacheEvent evt) {
-
-            Affinity affinity = ignite.affinity(cacheName);
+            Affinity<Object> affinity = ignite.affinity(cacheName);
 
             if (affinity.isPrimary(ignite.cluster().localNode(), evt.key())) {
                 // Process this event. Ignored on backups.
@@ -281,11 +297,13 @@ public class IgniteSourceTask extends SourceTask {
     private static class IgniteGrid {
         /** Constructor. */
         private IgniteGrid() {
+            // No-op.
         }
 
         /** Instance holder. */
         private static class Holder {
-            private static final Ignite IGNITE = Ignition.start(igniteConfigFile);
+            /** */
+            private static final Ignite IGNITE = Ignition.start(igniteCfgFile);
         }
 
         /**
@@ -300,15 +318,25 @@ public class IgniteSourceTask extends SourceTask {
 
     /** Cache events available for listening. */
     private enum CacheEvt {
+        /** */
         CREATED(EventType.EVT_CACHE_ENTRY_CREATED),
+        /** */
         DESTROYED(EventType.EVT_CACHE_ENTRY_DESTROYED),
+        /** */
         PUT(EventType.EVT_CACHE_OBJECT_PUT),
+        /** */
         READ(EventType.EVT_CACHE_OBJECT_READ),
+        /** */
         REMOVED(EventType.EVT_CACHE_OBJECT_REMOVED),
+        /** */
         LOCKED(EventType.EVT_CACHE_OBJECT_LOCKED),
+        /** */
         UNLOCKED(EventType.EVT_CACHE_OBJECT_UNLOCKED),
+        /** */
         SWAPPED(EventType.EVT_CACHE_OBJECT_SWAPPED),
+        /** */
         UNSWAPPED(EventType.EVT_CACHE_OBJECT_UNSWAPPED),
+        /** */
         EXPIRED(EventType.EVT_CACHE_OBJECT_EXPIRED);
 
         /** Internal Ignite event id. */

http://git-wip-us.apache.org/repos/asf/ignite/blob/d549daf7/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/connect/IgniteSinkConnectorTest.java
----------------------------------------------------------------------
diff --git a/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/connect/IgniteSinkConnectorTest.java b/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/connect/IgniteSinkConnectorTest.java
index 6e6d65d..1814c69 100644
--- a/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/connect/IgniteSinkConnectorTest.java
+++ b/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/connect/IgniteSinkConnectorTest.java
@@ -93,12 +93,12 @@ public class IgniteSinkConnectorTest extends GridCommonAbstractTest {
         for (String topic : TOPICS)
             kafkaBroker.createTopic(topic, PARTITIONS, REPLICATION_FACTOR);
 
-        WorkerConfig workerConfig = new StandaloneConfig(makeWorkerProps());
+        WorkerConfig workerCfg = new StandaloneConfig(makeWorkerProps());
 
-        OffsetBackingStore offsetBackingStore = mock(OffsetBackingStore.class);
-        offsetBackingStore.configure(anyObject(Map.class));
+        OffsetBackingStore offBackingStore = mock(OffsetBackingStore.class);
+        offBackingStore.configure(anyObject(Map.class));
 
-        worker = new Worker(workerConfig, offsetBackingStore);
+        worker = new Worker(workerCfg, offBackingStore);
         worker.start();
 
         herder = new StandaloneHerder(worker);

http://git-wip-us.apache.org/repos/asf/ignite/blob/d549daf7/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/connect/IgniteSourceConnectorMock.java
----------------------------------------------------------------------
diff --git a/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/connect/IgniteSourceConnectorMock.java b/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/connect/IgniteSourceConnectorMock.java
index d983c67..0157a17 100644
--- a/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/connect/IgniteSourceConnectorMock.java
+++ b/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/connect/IgniteSourceConnectorMock.java
@@ -23,7 +23,6 @@ import org.apache.kafka.connect.connector.Task;
  * Source connector mock for tests for using the task mock.
  */
 public class IgniteSourceConnectorMock extends IgniteSourceConnector {
-
     /** {@inheritDoc} */
     @Override public Class<? extends Task> taskClass() {
         return IgniteSourceTaskMock.class;

http://git-wip-us.apache.org/repos/asf/ignite/blob/d549daf7/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/connect/IgniteSourceConnectorTest.java
----------------------------------------------------------------------
diff --git a/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/connect/IgniteSourceConnectorTest.java b/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/connect/IgniteSourceConnectorTest.java
index 13b6887..87b11b9 100644
--- a/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/connect/IgniteSourceConnectorTest.java
+++ b/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/connect/IgniteSourceConnectorTest.java
@@ -96,12 +96,12 @@ public class IgniteSourceConnectorTest extends GridCommonAbstractTest {
     @Override protected void beforeTest() throws Exception {
         kafkaBroker = new TestKafkaBroker();
 
-        WorkerConfig workerConfig = new StandaloneConfig(makeWorkerProps());
+        WorkerConfig workerCfg = new StandaloneConfig(makeWorkerProps());
 
-        MemoryOffsetBackingStore offsetBackingStore = new MemoryOffsetBackingStore();
-        offsetBackingStore.configure(workerConfig.originals());
+        MemoryOffsetBackingStore offBackingStore = new MemoryOffsetBackingStore();
+        offBackingStore.configure(workerCfg.originals());
 
-        worker = new Worker(workerConfig, offsetBackingStore);
+        worker = new Worker(workerCfg, offBackingStore);
         worker.start();
 
         herder = new StandaloneHerder(worker);
@@ -210,6 +210,7 @@ public class IgniteSourceConnectorTest extends GridCommonAbstractTest {
      * Sends messages to the grid.
      *
      * @return Map of key value messages.
+     * @throws IOException If failed.
      */
     private Map<String, String> sendData() throws IOException {
         Map<String, String> keyValMap = new HashMap<>();
@@ -257,7 +258,7 @@ public class IgniteSourceConnectorTest extends GridCommonAbstractTest {
         long start = System.currentTimeMillis();
 
         try {
-            while (false || (System.currentTimeMillis() - start) < 10000) {
+            while ((System.currentTimeMillis() - start) < 10000) {
                 ConsumerRecords<String, CacheEvent> records = consumer.poll(10);
                 for (ConsumerRecord<String, CacheEvent> record : records) {
                     System.out.println("Event: offset = " + record.offset() + ", key = " + record.key()
@@ -274,9 +275,9 @@ public class IgniteSourceConnectorTest extends GridCommonAbstractTest {
             consumer.close();
 
             if (conditioned)
-                assertTrue(evtCnt == (EVENT_CNT * TOPICS.length) / 2);
+                assertEquals((EVENT_CNT * TOPICS.length) / 2, evtCnt);
             else
-                assertTrue(evtCnt == EVENT_CNT * TOPICS.length);
+                assertEquals(EVENT_CNT * TOPICS.length, evtCnt);
         }
     }
 
@@ -306,6 +307,7 @@ public class IgniteSourceConnectorTest extends GridCommonAbstractTest {
      * Creates properties for Kafka Connect workers.
      *
      * @return Worker configurations.
+     * @throws IOException If failed.
      */
     private Map<String, String> makeWorkerProps() throws IOException {
         Map<String, String> props = new HashMap<>();

http://git-wip-us.apache.org/repos/asf/ignite/blob/d549daf7/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/connect/IgniteSourceTaskMock.java
----------------------------------------------------------------------
diff --git a/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/connect/IgniteSourceTaskMock.java b/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/connect/IgniteSourceTaskMock.java
index 5237e98..4535ad5 100644
--- a/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/connect/IgniteSourceTaskMock.java
+++ b/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/connect/IgniteSourceTaskMock.java
@@ -21,11 +21,11 @@ package org.apache.ignite.stream.kafka.connect;
  * Source task mock for tests. It avoids closing the grid from test to test.
  */
 public class IgniteSourceTaskMock extends IgniteSourceTask {
-
     /** {@inheritDoc} */
     @Override public void stop() {
+        // Don't stop the grid for tests.
         stopRemoteListen();
 
-        // don't stop the grid for tests.
+        setStopped(true);
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/d549daf7/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/connect/TestCacheEventFilter.java
----------------------------------------------------------------------
diff --git a/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/connect/TestCacheEventFilter.java b/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/connect/TestCacheEventFilter.java
index 8978db0..bf28a2b 100644
--- a/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/connect/TestCacheEventFilter.java
+++ b/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/connect/TestCacheEventFilter.java
@@ -24,8 +24,8 @@ import org.apache.ignite.lang.IgnitePredicate;
  * Test user-defined filter.
  */
 class TestCacheEventFilter implements IgnitePredicate<CacheEvent> {
-
-    @Override public boolean apply(CacheEvent event) {
-        return ((String)event.key()).startsWith("conditioned_");
+    /** {@inheritDoc} */
+    @Override public boolean apply(CacheEvent evt) {
+        return ((String)evt.key()).startsWith("conditioned_");
     }
 }


[04/14] ignite git commit: ignite-1.6 Check for empty message buffer in GridContinuousProcessor.addBackupNotification.

Posted by av...@apache.org.
ignite-1.6 Check for empty message buffer in GridContinuousProcessor.addBackupNotification.


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

Branch: refs/heads/master
Commit: e5c8dfe243951543bc2a6032efb5f9c087f5b184
Parents: d549daf
Author: sboikov <sb...@gridgain.com>
Authored: Tue May 17 11:01:29 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue May 17 11:01:29 2016 +0300

----------------------------------------------------------------------
 .../internal/processors/continuous/GridContinuousProcessor.java | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/e5c8dfe2/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
index fb727cb..0db9b27 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
@@ -733,7 +733,10 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
         if (info != null) {
             final GridContinuousBatch batch = info.addAll(objs);
 
-            sendNotification(nodeId, routineId, null, batch.collect(), orderedTopic, true, null);
+            Collection<Object> toSnd = batch.collect();
+
+            if (!toSnd.isEmpty())
+                sendNotification(nodeId, routineId, null, toSnd, orderedTopic, true, null);
         }
     }
 


[07/14] ignite git commit: IGNITE-3087 - WebSessions: session objects are no longer deserialized on the server.

Posted by av...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/b369d030/modules/web/src/test/webapp2/META-INF/ignite-webapp-config.xml
----------------------------------------------------------------------
diff --git a/modules/web/src/test/webapp2/META-INF/ignite-webapp-config.xml b/modules/web/src/test/webapp2/META-INF/ignite-webapp-config.xml
new file mode 100644
index 0000000..53848fe
--- /dev/null
+++ b/modules/web/src/test/webapp2/META-INF/ignite-webapp-config.xml
@@ -0,0 +1,279 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xsi:schemaLocation="
+        http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans.xsd
+        http://www.springframework.org/schema/util
+        http://www.springframework.org/schema/util/spring-util.xsd">
+    <!--
+        Configuration below demonstrates how to setup caches within grid nodes.
+    -->
+    <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+        <property name="deploymentMode" value="SHARED"/>
+
+        <!--
+            For better performance set this property to false in case
+            peer deployment is not used.
+            Default value is false.
+        -->
+        <property name="peerClassLoadingEnabled" value="true"/>
+
+        <!--
+            Configure optimized marshaller.
+        -->
+        <property name="marshaller">
+            <bean class="org.apache.ignite.marshaller.optimized.OptimizedMarshaller">
+                <!--
+                    For better performance set this property to true in case
+                    all marshalled classes implement java.io.Serializable.
+                    Default value is true.
+
+                    Note, that it is recommended to implement java.io.Externalizable
+                    instead of java.io.Serializable for smaller network footprint
+                    and even better performance.
+                -->
+                <property name="requireSerializable" value="false"/>
+            </bean>
+        </property>
+
+        <!-- Set to local host address just for examples. -->
+        <property name="localHost" value="127.0.0.1"/>
+
+        <!-- Configure REST TCP server address. -->
+        <property name="connectorConfiguration">
+            <bean class="org.apache.ignite.configuration.ConnectorConfiguration">
+                <property name="host" value="127.0.0.1"/>
+            </bean>
+        </property>
+
+        <!--
+            Enable cache events.
+        -->
+        <property name="includeEventTypes">
+            <util:constant static-field="org.apache.ignite.events.EventType.EVTS_CACHE"/>
+        </property>
+
+        <property name="cacheConfiguration">
+            <!--
+                Specify list of cache configurations here. Any property from
+                CacheConfiguration interface can be configured here.
+                Note that absolutely all configuration properties are optional.
+            -->
+            <list>
+                <!--
+                    Partitioned cache example configuration (Atomic mode).
+                -->
+                <bean class="org.apache.ignite.configuration.CacheConfiguration">
+                    <property name="name" value="partitioned"/>
+
+                    <property name="cacheMode" value="PARTITIONED"/>
+
+                    <!-- Only atomic updates will be supported. -->
+                    <property name="atomicityMode" value="ATOMIC"/>
+
+                    <!-- Enable primary sync write mode. -->
+                    <property name="writeSynchronizationMode" value="PRIMARY_SYNC"/>
+
+                    <!-- Initial cache size. -->
+                    <property name="startSize" value="1500000"/>
+
+                    <!--
+                        This shows how to configure number of backups. The below configuration
+                        sets the number of backups to 1 (which is default).
+                    -->
+                    <property name="backups" value="1"/>
+
+                    <!-- Set synchronous rebalancing (default is asynchronous). -->
+                    <property name="rebalanceMode" value="SYNC"/>
+                </bean>
+
+                <!--
+                    Partitioned cache example configuration (Transactional mode).
+                -->
+                <bean class="org.apache.ignite.configuration.CacheConfiguration">
+                    <property name="name" value="partitioned_tx"/>
+
+                    <property name="cacheMode" value="PARTITIONED"/>
+
+                    <!-- Transactional updates supported. -->
+                    <property name="atomicityMode" value="TRANSACTIONAL"/>
+
+                    <!-- Enable near cache to cache recently accessed data. -->
+                    <property name="nearConfiguration">
+                        <bean class="org.apache.ignite.configuration.NearCacheConfiguration"/>
+                    </property>
+
+                    <!-- Initial cache size. -->
+                    <property name="startSize" value="1500000"/>
+
+                    <!--
+                        Setting this value will cause local node to wait for remote commits.
+                        However, it's important to set it this way in the examples as we assert on
+                        conditions that usually assume full completion of transactions on all nodes.
+                    -->
+                    <property name="writeSynchronizationMode" value="FULL_SYNC"/>
+
+                    <!--
+                        This shows how to configure number of backups. The below configuration
+                        sets the number of backups to 1 (which is default).
+                    -->
+                    <property name="backups" value="1"/>
+
+                    <!-- Set synchronous rebalancing (default is asynchronous). -->
+                    <property name="rebalanceMode" value="SYNC"/>
+                </bean>
+
+                <!--
+                    Replicated cache example configuration.
+                -->
+                <bean class="org.apache.ignite.configuration.CacheConfiguration">
+                    <property name="name" value="replicated"/>
+
+                    <!--
+                        Setting this value will cause local node to wait for remote commits.
+                        However, it's important to set it this way in the examples as we assert on
+                        conditions that usually assume full completion of transactions on all nodes.
+                    -->
+                    <property name="writeSynchronizationMode" value="FULL_SYNC"/>
+
+                    <!-- REPLICATED cache mode. -->
+                    <property name="cacheMode" value="REPLICATED"/>
+
+                    <!-- Set synchronous rebalancing (default is asynchronous). -->
+                    <property name="rebalanceMode" value="SYNC"/>
+
+                    <!-- Initial cache size. -->
+                    <property name="startSize" value="150000"/>
+                </bean>
+
+                <!--
+                    Local cache example configuration.
+                -->
+                <bean class="org.apache.ignite.configuration.CacheConfiguration">
+                    <!-- Cache name is 'local'. -->
+                    <property name="name" value="local"/>
+
+                    <!-- LOCAL cache mode. -->
+                    <property name="cacheMode" value="LOCAL"/>
+
+                    <!-- Initial cache size. -->
+                    <property name="startSize" value="150000"/>
+                </bean>
+            </list>
+        </property>
+
+        <!--
+            Uncomment this to provide TCP discovery SPI (Amazon EC2).
+        -->
+        <!--
+        <property name="discoverySpi">
+            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+                <property name="ipFinder">
+                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.s3.TcpDiscoveryS3IpFinder">
+                        <property name="awsCredentials">
+                            <bean class="com.amazonaws.auth.BasicAWSCredentials">
+                                <constructor-arg value="YOUR_ACCESS_KEY_ID" />
+                                <constructor-arg value="YOUR_SECRET_ACCESS_KEY" />
+                            </bean>
+                        </property>
+                        <property name="bucketName" value="YOUR_BUCKET_NAME_IP_FINDER"/>
+                    </bean>
+                </property>
+                <property name="heartbeatFrequency" value="2000"/>
+            </bean>
+        </property>
+        -->
+
+        <!--
+            Uncomment this to provide TCP discovery SPI (Local network).
+
+            If path to shared file system is not explicitly provided,
+            then only local nodes will be able to discover each other.
+        -->
+        <!--
+        <property name="discoverySpi">
+            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+                <property name="ipFinder">
+                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.sharedfs.TcpDiscoverySharedFsIpFinder">
+                        <property name="path" value="work/disco/tcp"/>
+                    </bean>
+                </property>
+            </bean>
+        </property>
+        -->
+
+        <!--
+            TCP discovery SPI configuration with predefined addresses.
+            Use the addresses list to provide IP addresses of initial nodes in the grid
+            (at least one address must be provided).
+
+            Note:
+            =====
+            If running in distributed environment, you should change IP addresses to the actual IP addresses
+            of the servers on your network. Not all addresses need to be specified, only the addresses
+            of one or more servers which will always be started first.
+        -->
+        <property name="discoverySpi">
+            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+                <property name="ipFinder">
+                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+                        <property name="addresses">
+                            <list>
+                                <!--
+                                    List all IP/port configurations that potentially
+                                    can be started first in examples. We are assuming
+                                    grid of size 10 or less.
+                                -->
+                                <value>127.0.0.1:47500</value>
+                                <value>127.0.0.1:47501</value>
+                                <value>127.0.0.1:47502</value>
+                                <value>127.0.0.1:47503</value>
+                                <value>127.0.0.1:47504</value>
+                                <value>127.0.0.1:47505</value>
+                                <value>127.0.0.1:47506</value>
+                                <value>127.0.0.1:47507</value>
+                                <value>127.0.0.1:47508</value>
+                                <value>127.0.0.1:47509</value>
+                            </list>
+                        </property>
+                    </bean>
+                    <!--
+                    Uncomment this to provide IP finder using multicast for nodes discovery.
+                    In addition to addresses received via multicast this finder can work with pre-configured
+                    list of addresses.
+                    -->
+                    <!--
+                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
+                        <property name="addresses">
+                            <list>
+                                <value>host1:port1</value>
+                                <value>host2:port2</value>
+                            </list>
+                        </property>
+                    </bean>
+                    -->
+                </property>
+            </bean>
+        </property>
+    </bean>
+</beans>

http://git-wip-us.apache.org/repos/asf/ignite/blob/b369d030/modules/web/src/test/webapp2/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/modules/web/src/test/webapp2/WEB-INF/web.xml b/modules/web/src/test/webapp2/WEB-INF/web.xml
new file mode 100644
index 0000000..d51b87d
--- /dev/null
+++ b/modules/web/src/test/webapp2/WEB-INF/web.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  ~ 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.
+  -->
+
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+                             http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+         version="3.0">
+
+    <!-- Declare listener for web sessions caching. -->
+    <listener>
+        <listener-class>org.apache.ignite.startup.servlet.ServletContextListenerStartup</listener-class>
+    </listener>
+
+    <!-- Declare filter for web sessions caching. -->
+    <filter>
+        <filter-name>IgniteWebSessionsFilter</filter-name>
+        <filter-class>org.apache.ignite.cache.websession.WebSessionFilter</filter-class>
+        <init-param>
+            <param-name>IgniteWebSessionsKeepBinary</param-name>
+            <param-value>false</param-value>
+        </init-param>
+    </filter>
+
+    <filter-mapping>
+        <filter-name>IgniteWebSessionsFilter</filter-name>
+        <url-pattern>/*</url-pattern>
+    </filter-mapping>
+</web-app>


[08/14] ignite git commit: IGNITE-3087 - WebSessions: session objects are no longer deserialized on the server.

Posted by av...@apache.org.
IGNITE-3087 - WebSessions: session objects are no longer deserialized on the server.


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

Branch: refs/heads/master
Commit: b369d0306a49bf24a9a6ad09dd8a06929bdc572e
Parents: fb0b0e0
Author: dkarachentsev <dk...@gridgain.com>
Authored: Tue May 17 13:58:39 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue May 17 13:58:39 2016 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheTtlManager.java   |   5 +-
 .../WebSessionAttributeProcessor.java           | 134 +++++
 .../internal/websession/WebSessionEntity.java   | 193 +++++++
 .../ignite/cache/websession/WebSession.java     |  14 +-
 .../cache/websession/WebSessionFilter.java      | 499 ++++++++++++++++---
 .../cache/websession/WebSessionListener.java    | 117 +----
 .../ignite/cache/websession/WebSessionV2.java   | 405 +++++++++++++++
 .../IgniteWebSessionSelfTestSuite.java          |  35 ++
 .../internal/websession/WebSessionSelfTest.java | 268 ++++++++--
 .../webapp2/META-INF/ignite-webapp-config.xml   | 279 +++++++++++
 modules/web/src/test/webapp2/WEB-INF/web.xml    |  45 ++
 11 files changed, 1774 insertions(+), 220 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b369d030/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManager.java
index 657cf8d..4e1fc6d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManager.java
@@ -293,9 +293,8 @@ public class GridCacheTtlManager extends GridCacheManagerAdapter {
         @Override public boolean add(EntryWrapper e) {
             boolean res = super.add(e);
 
-            assert res : "Failed to add entry wrapper:"  + e;
-
-            size.increment();
+            if (res)
+                size.increment();
 
             return res;
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/b369d030/modules/core/src/main/java/org/apache/ignite/internal/websession/WebSessionAttributeProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/websession/WebSessionAttributeProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/websession/WebSessionAttributeProcessor.java
new file mode 100644
index 0000000..bef42e4
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/websession/WebSessionAttributeProcessor.java
@@ -0,0 +1,134 @@
+/*
+ * 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.internal.websession;
+
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.binary.Binarylizable;
+import org.apache.ignite.internal.util.typedef.F;
+
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+import java.io.Serializable;
+import java.util.Map;
+
+/**
+ * Updates web session attributes according to {@link #updatesMap} and {@link #accessTime},
+ * {@link #maxInactiveInterval}.
+ */
+public class WebSessionAttributeProcessor implements EntryProcessor<String, WebSessionEntity, Void>,
+    Serializable, Binarylizable {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Attribute updates. */
+    private Map<String, byte[]> updatesMap;
+
+    /** Access time update. */
+    private long accessTime;
+
+    /** Max inactive interval update. */
+    private int maxInactiveInterval;
+
+    /** Indicates whether apply or not max inactive interval update. */
+    private boolean maxIntervalChanged;
+
+    /**
+     * Empty constructor for serialization.
+     */
+    public WebSessionAttributeProcessor() {
+        // No-op.
+    }
+
+    /**
+     * Constructs attribute processor.
+     *
+     * @param updatesMap Updates that should be performed on entity attributes.
+     * @param accessTime Access time.
+     * @param maxInactiveInterval Max inactive interval.
+     * @param maxIntervalChanged {@code True} if max inactive interval should be updated.
+     */
+    public WebSessionAttributeProcessor(final Map<String, byte[]> updatesMap, final long accessTime,
+        final int maxInactiveInterval, final boolean maxIntervalChanged) {
+        this.updatesMap = updatesMap;
+        this.accessTime = accessTime;
+        this.maxInactiveInterval = maxInactiveInterval;
+        this.maxIntervalChanged = maxIntervalChanged;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeBinary(final BinaryWriter writer) throws BinaryObjectException {
+        final BinaryRawWriter rawWriter = writer.rawWriter();
+
+        rawWriter.writeMap(updatesMap);
+        rawWriter.writeLong(accessTime);
+        rawWriter.writeBoolean(maxIntervalChanged);
+
+        if (maxIntervalChanged)
+            rawWriter.writeInt(maxInactiveInterval);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readBinary(final BinaryReader reader) throws BinaryObjectException {
+        final BinaryRawReader rawReader = reader.rawReader();
+
+        updatesMap = rawReader.readMap();
+        accessTime = rawReader.readLong();
+        maxIntervalChanged = rawReader.readBoolean();
+
+        if (maxIntervalChanged)
+            maxInactiveInterval = rawReader.readInt();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Void process(final MutableEntry<String, WebSessionEntity> entry,
+        final Object... arguments) throws EntryProcessorException {
+        final WebSessionEntity entity = entry.getValue();
+
+        final WebSessionEntity newEntity = new WebSessionEntity(entity);
+
+        if (newEntity.accessTime() < accessTime)
+            newEntity.accessTime(accessTime);
+
+        if (maxIntervalChanged)
+            newEntity.maxInactiveInterval(maxInactiveInterval);
+
+        if (!F.isEmpty(updatesMap)) {
+            for (final Map.Entry<String, byte[]> update : updatesMap.entrySet()) {
+                final String name = update.getKey();
+
+                assert name != null;
+
+                final byte[] val = update.getValue();
+
+                if (val != null)
+                    newEntity.putAttribute(name, val);
+                else
+                    newEntity.removeAttribute(name);
+            }
+        }
+
+        entry.setValue(newEntity);
+
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/b369d030/modules/core/src/main/java/org/apache/ignite/internal/websession/WebSessionEntity.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/websession/WebSessionEntity.java b/modules/core/src/main/java/org/apache/ignite/internal/websession/WebSessionEntity.java
new file mode 100644
index 0000000..c504ee0
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/websession/WebSessionEntity.java
@@ -0,0 +1,193 @@
+/*
+ * 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.internal.websession;
+
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.binary.Binarylizable;
+import org.apache.ignite.internal.util.tostring.GridToStringExclude;
+import org.apache.ignite.internal.util.typedef.internal.S;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Entity
+ */
+public class WebSessionEntity implements Serializable, Binarylizable {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Session ID. */
+    private String id;
+
+    /** Creation time. */
+    private long createTime;
+
+    /** Last access time. */
+    private long accessTime;
+
+    /** Maximum inactive interval. */
+    private int maxInactiveInterval;
+
+    /** Attributes. */
+    @GridToStringExclude
+    private Map<String, byte[]> attrs;
+
+    /**
+     * Constructor.
+     */
+    public WebSessionEntity() {
+        // No-op.
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param id Session ID.
+     * @param createTime Session create time.
+     * @param accessTime Session last access time.
+     * @param maxInactiveInterval Session will be removed if not accessed more then this value.
+     */
+    public WebSessionEntity(final String id, final long createTime, final long accessTime,
+        final int maxInactiveInterval) {
+        this.id = id;
+        this.createTime = createTime;
+        this.accessTime = accessTime;
+        this.maxInactiveInterval = maxInactiveInterval;
+    }
+
+    /**
+     * Constructor.
+     */
+    public WebSessionEntity(final WebSessionEntity other) {
+        this(other.id(), other.createTime(), other.accessTime(), other.maxInactiveInterval());
+
+        if (!other.attributes().isEmpty())
+            attrs = new HashMap<>(other.attributes());
+    }
+
+    /**
+     * @return Session ID.
+     */
+    public String id() {
+        return id;
+    }
+
+    /**
+     * @return Create time.
+     */
+    public long createTime() {
+        return createTime;
+    }
+
+    /**
+     * @return Access time.
+     */
+    public long accessTime() {
+        return accessTime;
+    }
+
+    /**
+     * Set access time.
+     *
+     * @param accessTime Access time.
+     */
+    public void accessTime(final long accessTime) {
+        this.accessTime = accessTime;
+    }
+
+    /**
+     * @return Max inactive interval.
+     */
+    public int maxInactiveInterval() {
+        return maxInactiveInterval;
+    }
+
+    /**
+     * Set max inactive interval;
+     *
+     * @param maxInactiveInterval Max inactive interval.
+     */
+    public void maxInactiveInterval(final int maxInactiveInterval) {
+        this.maxInactiveInterval = maxInactiveInterval;
+    }
+
+    /**
+     * @return Session attributes or {@link Collections#emptyMap()}.
+     */
+    public Map<String, byte[]> attributes() {
+        return attrs == null ? Collections.<String, byte[]>emptyMap() : attrs;
+    }
+
+    /**
+     * Add attribute to attribute map.
+     *
+     * @param name Attribute name.
+     * @param val Attribute value.
+     */
+    public void putAttribute(final String name, final byte[] val) {
+        if (attrs == null)
+            attrs = new HashMap<>();
+
+        attrs.put(name, val);
+    }
+
+    /**
+     * Remove attribute.
+     *
+     * @param name Attribute name.
+     */
+    public void removeAttribute(final String name) {
+        if (attrs != null)
+            attrs.remove(name);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeBinary(final BinaryWriter writer) throws BinaryObjectException {
+        final BinaryRawWriter rawWriter = writer.rawWriter();
+
+        rawWriter.writeString(id);
+        rawWriter.writeLong(createTime);
+        rawWriter.writeLong(accessTime);
+        rawWriter.writeInt(maxInactiveInterval);
+        rawWriter.writeMap(attrs);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readBinary(final BinaryReader reader) throws BinaryObjectException {
+        final BinaryRawReader rawReader = reader.rawReader();
+
+        id = rawReader.readString();
+        createTime = rawReader.readLong();
+        accessTime = rawReader.readLong();
+        maxInactiveInterval = rawReader.readInt();
+        attrs = rawReader.readMap();
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(WebSessionEntity.class, this,
+            "attributes", attrs != null ? attrs.keySet() : Collections.<String>emptySet());
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/b369d030/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSession.java
----------------------------------------------------------------------
diff --git a/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSession.java b/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSession.java
index 675c4ca..2e43f2f 100644
--- a/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSession.java
+++ b/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSession.java
@@ -79,9 +79,9 @@ class WebSession implements HttpSession, Externalizable {
     @GridToStringExclude
     private transient ServletContext ctx;
 
-    /** Listener. */
+    /** Web session filter. */
     @GridToStringExclude
-    private transient WebSessionListener lsnr;
+    private transient WebSessionFilter filter;
 
     /** New session flag. */
     private transient boolean isNew;
@@ -155,12 +155,12 @@ class WebSession implements HttpSession, Externalizable {
     }
 
     /**
-     * @param lsnr Listener.
+     * @param filter Filter.
      */
-    public void listener(WebSessionListener lsnr) {
-        assert lsnr != null;
+    public void filter(final WebSessionFilter filter) {
+        assert filter != null;
 
-        this.lsnr = lsnr;
+        this.filter = filter;
     }
 
     /**
@@ -310,7 +310,7 @@ class WebSession implements HttpSession, Externalizable {
 
         updates = null;
 
-        lsnr.destroySession(id);
+        filter.destroySession(id);
 
         genSes.invalidate();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/b369d030/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionFilter.java
----------------------------------------------------------------------
diff --git a/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionFilter.java b/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionFilter.java
index f718035..785f472 100644
--- a/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionFilter.java
+++ b/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionFilter.java
@@ -19,6 +19,7 @@ package org.apache.ignite.cache.websession;
 
 import java.io.IOException;
 import java.util.Collection;
+import java.util.Map;
 import javax.cache.CacheException;
 import javax.cache.expiry.Duration;
 import javax.cache.expiry.ExpiryPolicy;
@@ -42,13 +43,17 @@ import org.apache.ignite.IgniteTransactions;
 import org.apache.ignite.cluster.ClusterTopologyException;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.internal.util.typedef.C1;
+import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.G;
 import org.apache.ignite.internal.util.typedef.T2;
 import org.apache.ignite.internal.util.typedef.X;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.internal.websession.WebSessionAttributeProcessor;
+import org.apache.ignite.internal.websession.WebSessionEntity;
 import org.apache.ignite.lang.IgniteClosure;
 import org.apache.ignite.lang.IgniteFuture;
+import org.apache.ignite.marshaller.Marshaller;
 import org.apache.ignite.startup.servlet.ServletContextListenerStartup;
 import org.apache.ignite.transactions.Transaction;
 
@@ -182,21 +187,27 @@ public class WebSessionFilter implements Filter {
     /** Web sessions caching retry on fail timeout parameter name. */
     public static final String WEB_SES_RETRIES_TIMEOUT_NAME_PARAM = "IgniteWebSessionsRetriesTimeout";
 
+    /** */
+    public static final String WEB_SES_KEEP_BINARY_PARAM = "IgniteWebSessionsKeepBinary";
+
     /** Default retry on fail flag value. */
     public static final int DFLT_MAX_RETRIES_ON_FAIL = 3;
 
     /** Default retry on fail timeout flag value. */
     public static final int DFLT_RETRIES_ON_FAIL_TIMEOUT = 10000;
 
+    /** Default keep binary flag. */
+    public static final boolean DFLT_KEEP_BINARY_FLAG = true;
+
     /** Cache. */
     private IgniteCache<String, WebSession> cache;
 
+    /** Binary cache */
+    private IgniteCache<String, WebSessionEntity> binaryCache;
+
     /** Transactions. */
     private IgniteTransactions txs;
 
-    /** Listener. */
-    private WebSessionListener lsnr;
-
     /** Logger. */
     private IgniteLogger log;
 
@@ -221,6 +232,12 @@ public class WebSessionFilter implements Filter {
     /** */
     private int retriesTimeout;
 
+    /** */
+    private boolean keepBinary = DFLT_KEEP_BINARY_FLAG;
+
+    /** */
+    private Marshaller marshaller;
+
     /** {@inheritDoc} */
     @Override public void init(FilterConfig cfg) throws ServletException {
         ctx = cfg.getServletContext();
@@ -256,6 +273,11 @@ public class WebSessionFilter implements Filter {
             throw new IgniteException("Retries timeout parameter is invalid: " + retriesTimeoutStr, e);
         }
 
+        final String binParam = cfg.getInitParameter(WEB_SES_KEEP_BINARY_PARAM);
+
+        if (!F.isEmpty(binParam))
+            keepBinary = Boolean.parseBoolean(binParam);
+
         webSesIgnite = G.ignite(gridName);
 
         if (webSesIgnite == null)
@@ -266,9 +288,9 @@ public class WebSessionFilter implements Filter {
 
         log = webSesIgnite.log();
 
-        initCache();
+        marshaller = webSesIgnite.configuration().getMarshaller();
 
-        lsnr = new WebSessionListener(webSesIgnite, this, retries);
+        initCache();
 
         String srvInfo = ctx.getServerInfo();
 
@@ -304,17 +326,12 @@ public class WebSessionFilter implements Filter {
     }
 
     /**
-     * @return Cache.
-     */
-    IgniteCache<String, WebSession> getCache(){
-        return cache;
-    }
-
-    /**
      * Init cache.
      */
+    @SuppressWarnings("unchecked")
     void initCache() {
         cache = webSesIgnite.cache(cacheName);
+        binaryCache = webSesIgnite.cache(cacheName);
 
         if (cache == null)
             throw new IgniteException("Cache for web sessions is not started (is it configured?): " + cacheName);
@@ -357,13 +374,13 @@ public class WebSessionFilter implements Filter {
             try {
                 if (txEnabled) {
                     try (Transaction tx = txs.txStart(PESSIMISTIC, REPEATABLE_READ)) {
-                        sesId = doFilter0(httpReq, res, chain);
+                        sesId = doFilterDispatch(httpReq, res, chain);
 
                         tx.commit();
                     }
                 }
                 else
-                    sesId = doFilter0(httpReq, res, chain);
+                    sesId = doFilterDispatch(httpReq, res, chain);
             }
             catch (Exception e) {
                 U.error(log, "Failed to update web session: " + sesId, e);
@@ -374,6 +391,25 @@ public class WebSessionFilter implements Filter {
     }
 
     /**
+     * Use {@link WebSession} or {@link WebSessionV2} according to {@link #keepBinary} flag.
+     *
+     * @param httpReq Request.
+     * @param res Response.
+     * @param chain Filter chain.
+     * @return Session ID.
+     * @throws IOException
+     * @throws ServletException
+     * @throws CacheException
+     */
+    private String doFilterDispatch(HttpServletRequest httpReq, ServletResponse res, FilterChain chain)
+        throws IOException, ServletException, CacheException {
+        if (keepBinary)
+            return doFilterV2(httpReq, res, chain);
+
+        return doFilterV1(httpReq, res, chain);
+    }
+
+    /**
      * @param httpReq Request.
      * @param res Response.
      * @param chain Filter chain.
@@ -382,32 +418,23 @@ public class WebSessionFilter implements Filter {
      * @throws ServletException In case of servlet error.
      * @throws CacheException In case of other error.
      */
-    private String doFilter0(HttpServletRequest httpReq, ServletResponse res, FilterChain chain) throws IOException,
+    private String doFilterV1(HttpServletRequest httpReq, ServletResponse res, FilterChain chain) throws IOException,
         ServletException, CacheException {
         WebSession cached = null;
 
         String sesId = httpReq.getRequestedSessionId();
 
         if (sesId != null) {
-            if (sesIdTransformer != null)
-                sesId = sesIdTransformer.apply(sesId);
+            sesId = transformSessionId(sesId);
 
             for (int i = 0; i < retries; i++) {
                 try {
                     cached = cache.get(sesId);
+
+                    break;
                 }
                 catch (CacheException | IgniteException | IllegalStateException e) {
-                    if (log.isDebugEnabled())
-                        log.debug(e.getMessage());
-
-                    if (i == retries - 1)
-                        throw new IgniteException("Failed to handle request [session= " + sesId + "]", e);
-                    else {
-                        if (log.isDebugEnabled())
-                            log.debug("Failed to handle request (will retry): " + sesId);
-
-                        handleCacheOperationException(e);
-                    }
+                    handleLoadSessionException(sesId, i, e);
                 }
             }
 
@@ -436,16 +463,15 @@ public class WebSessionFilter implements Filter {
                 cached = createSession(httpReq);
             }
         }
-        else {
+        else
             cached = createSession(httpReq);
 
-            sesId = cached.getId();
-        }
-
         assert cached != null;
 
+        sesId = cached.getId();
+
         cached.servletContext(ctx);
-        cached.listener(lsnr);
+        cached.filter(this);
         cached.resetUpdates();
         cached.genSes(httpReq.getSession(false));
 
@@ -456,13 +482,131 @@ public class WebSessionFilter implements Filter {
         HttpSession ses = httpReq.getSession(false);
 
         if (ses != null && ses instanceof WebSession) {
-            Collection<T2<String, Object>> updates = ((WebSession)ses).updates();
+            Collection<T2<String, Object>> updates = ((WebSession) ses).updates();
+
+            if (updates != null)
+                updateAttributes(transformSessionId(sesId), updates, ses.getMaxInactiveInterval());
+        }
+
+        return sesId;
+    }
+
+    /**
+     * @param httpReq Request.
+     * @param res Response.
+     * @param chain Filter chain.
+     * @return Session ID.
+     * @throws IOException In case of I/O error.
+     * @throws ServletException In case oif servlet error.
+     * @throws CacheException In case of other error.
+     */
+    private String doFilterV2(HttpServletRequest httpReq, ServletResponse res, FilterChain chain)
+        throws IOException, ServletException, CacheException {
+        WebSessionV2 cached = null;
+
+        String sesId = httpReq.getRequestedSessionId();
+
+        if (sesId != null) {
+            sesId = transformSessionId(sesId);
+
+            // Load from cache.
+            for (int i = 0; i < retries; i++) {
+                try {
+                    final WebSessionEntity entity = binaryCache.get(sesId);
+
+                    if (entity != null)
+                        cached = new WebSessionV2(sesId, null, false, ctx, entity, marshaller);
+
+                    break;
+                }
+                catch (CacheException | IgniteException | IllegalStateException e) {
+                    handleLoadSessionException(sesId, i, e);
+                }
+            }
+
+            if (cached != null) {
+                if (log.isDebugEnabled())
+                    log.debug("Using cached session for ID: " + sesId);
+            }
+            // If not found - invalidate session and create new one.
+            // Invalidate, because session might be removed from cache
+            // according to expiry policy.
+            else {
+                if (log.isDebugEnabled())
+                    log.debug("Cached session was invalidated and doesn't exist: " + sesId);
 
-            if (updates != null) {
-                lsnr.updateAttributes(sesIdTransformer != null ? sesIdTransformer.apply(ses.getId()) : ses.getId(),
-                    updates, ses.getMaxInactiveInterval());
+                final HttpSession ses = httpReq.getSession(false);
+
+                if (ses != null) {
+                    try {
+                        ses.invalidate();
+                    }
+                    catch (IllegalStateException ignore) {
+                        // Session was already invalidated.
+                    }
+                }
+
+                cached = createSessionV2(httpReq);
             }
         }
+        // No session was requested by the client, create new one and put in the request.
+        else
+            cached = createSessionV2(httpReq);
+
+        assert cached != null;
+
+        sesId = cached.getId();
+
+        httpReq = new RequestWrapperV2(httpReq, cached);
+
+        chain.doFilter(httpReq, res);
+
+        if (!cached.isValid())
+            binaryCache.remove(cached.id());
+        // Changed session ID.
+        else if (!cached.getId().equals(sesId)) {
+            final String oldId = cached.getId();
+
+            cached.invalidate();
+
+            binaryCache.remove(oldId);
+        }
+        else
+            updateAttributesV2(cached.getId(), cached);
+
+        return sesId;
+    }
+
+    /**
+     * Log and process exception happened on loading session from cache.
+     *
+     * @param sesId Session ID.
+     * @param tryCnt Try count.
+     * @param e Caught exception.
+     */
+    private void handleLoadSessionException(final String sesId, final int tryCnt, final RuntimeException e) {
+        if (log.isDebugEnabled())
+            log.debug(e.getMessage());
+
+        if (tryCnt == retries - 1)
+            throw new IgniteException("Failed to handle request [session= " + sesId + "]", e);
+        else {
+            if (log.isDebugEnabled())
+                log.debug("Failed to handle request (will retry): " + sesId);
+
+            handleCacheOperationException(e);
+        }
+    }
+
+    /**
+     * Transform session ID if ID transformer present.
+     *
+     * @param sesId Session ID to transform.
+     * @return Transformed session ID or the same if no session transformer available.
+     */
+    private String transformSessionId(final String sesId) {
+        if (sesIdTransformer != null)
+            return sesIdTransformer.apply(sesId);
 
         return sesId;
     }
@@ -477,7 +621,7 @@ public class WebSessionFilter implements Filter {
     private WebSession createSession(HttpServletRequest httpReq) {
         HttpSession ses = httpReq.getSession(true);
 
-        String sesId = sesIdTransformer != null ? sesIdTransformer.apply(ses.getId()) : ses.getId();
+        String sesId = transformSessionId(ses.getId());
 
         return createSession(ses, sesId);
     }
@@ -500,19 +644,10 @@ public class WebSessionFilter implements Filter {
 
         for (int i = 0; i < retries; i++) {
             try {
-                IgniteCache<String, WebSession> cache0;
-
-                if (cached.getMaxInactiveInterval() > 0) {
-                    long ttl = cached.getMaxInactiveInterval() * 1000;
-
-                    ExpiryPolicy plc = new ModifiedExpiryPolicy(new Duration(MILLISECONDS, ttl));
-
-                    cache0 = cache.withExpiryPolicy(plc);
-                }
-                else
-                    cache0 = cache;
+                final IgniteCache<String, WebSession> cache0 =
+                    cacheWithExpiryPolicy(cached.getMaxInactiveInterval(), cache);
 
-                WebSession old = cache0.getAndPutIfAbsent(sesId, cached);
+                final WebSession old = cache0.getAndPutIfAbsent(sesId, cached);
 
                 if (old != null) {
                     cached = old;
@@ -524,27 +659,210 @@ public class WebSessionFilter implements Filter {
                 break;
             }
             catch (CacheException | IgniteException | IllegalStateException e) {
-                if (log.isDebugEnabled())
-                    log.debug(e.getMessage());
+                handleCreateSessionException(sesId, i, e);
+            }
+        }
+
+        return cached;
+    }
+
+    /**
+     * Log error and delegate exception processing to {@link #handleCacheOperationException(Exception)}
+     *
+     * @param sesId Session ID.
+     * @param tryCnt Try count.
+     * @param e Exception to process.
+     */
+    private void handleCreateSessionException(final String sesId, final int tryCnt, final RuntimeException e) {
+        if (log.isDebugEnabled())
+            log.debug(e.getMessage());
+
+        if (tryCnt == retries - 1)
+            throw new IgniteException("Failed to save session: " + sesId, e);
+        else {
+            if (log.isDebugEnabled())
+                log.debug("Failed to save session (will retry): " + sesId);
+
+            handleCacheOperationException(e);
+        }
+    }
+
+    private WebSessionV2 createSessionV2(final HttpSession ses, final String sesId) throws IOException {
+        if (log.isDebugEnabled())
+            log.debug("Session created: " + sesId);
 
-                if (i == retries - 1)
-                    throw new IgniteException("Failed to save session: " + sesId, e);
+        WebSessionV2 cached = new WebSessionV2(sesId, ses, true, ctx, null, marshaller);
+
+        final WebSessionEntity marshaledEntity = cached.marshalAttributes();
+
+        for (int i = 0; i < retries; i++) {
+            try {
+                final IgniteCache<String, WebSessionEntity> cache0 = cacheWithExpiryPolicy(
+                    cached.getMaxInactiveInterval(), binaryCache);
+
+                final WebSessionEntity old = cache0.getAndPutIfAbsent(sesId, marshaledEntity);
+
+                if (old != null)
+                    cached = new WebSessionV2(sesId, null, false, ctx, old, marshaller);
+                else
+                    cached = new WebSessionV2(sesId, null, false, ctx, marshaledEntity, marshaller);
+
+                break;
+            }
+            catch (CacheException | IgniteException | IllegalStateException e) {
+                handleCreateSessionException(sesId, i, e);
+            }
+        }
+
+        return cached;
+    }
+
+    /**
+     * @param httpReq HTTP request.
+     * @return Cached session.
+     */
+    private WebSessionV2 createSessionV2(HttpServletRequest httpReq) throws IOException {
+        final HttpSession ses = httpReq.getSession(true);
+
+        final String sesId = transformSessionId(ses.getId());
+
+        return createSessionV2(ses, sesId);
+    }
+
+    /**
+     * @param maxInactiveInteval Interval to use in expiry policy.
+     * @param cache Cache.
+     * @param <T> Cached object type.
+     * @return Cache with expiry policy if {@code maxInactiveInteval} greater than zero.
+     */
+    private <T> IgniteCache<String, T> cacheWithExpiryPolicy(final int maxInactiveInteval,
+        final IgniteCache<String, T> cache) {
+        if (maxInactiveInteval > 0) {
+            long ttl = maxInactiveInteval * 1000;
+
+            ExpiryPolicy plc = new ModifiedExpiryPolicy(new Duration(MILLISECONDS, ttl));
+
+            return cache.withExpiryPolicy(plc);
+        }
+
+        return cache;
+    }
+
+    /**
+     * @param sesId Session ID.
+     */
+    public void destroySession(String sesId) {
+        assert sesId != null;
+        for (int i = 0; i < retries; i++) {
+            try {
+                if (cache.remove(sesId) && log.isDebugEnabled())
+                    log.debug("Session destroyed: " + sesId);
+            }
+            catch (CacheException | IgniteException | IllegalStateException e) {
+                if (i == retries - 1) {
+                    U.warn(log, "Failed to remove session [sesId=" +
+                        sesId + ", retries=" + retries + ']');
+                }
                 else {
-                    if (log.isDebugEnabled())
-                        log.debug("Failed to save session (will retry): " + sesId);
+                    U.warn(log, "Failed to remove session (will retry): " + sesId);
 
                     handleCacheOperationException(e);
                 }
             }
         }
+    }
 
-        return cached;
+    /**
+     * @param sesId Session ID.
+     * @param updates Updates list.
+     * @param maxInactiveInterval Max session inactive interval.
+     */
+    @SuppressWarnings("unchecked")
+    public void updateAttributes(String sesId, Collection<T2<String, Object>> updates, int maxInactiveInterval) {
+        assert sesId != null;
+        assert updates != null;
+
+        if (log.isDebugEnabled())
+            log.debug("Session attributes updated [id=" + sesId + ", updates=" + updates + ']');
+
+        try {
+            for (int i = 0; i < retries; i++) {
+                try {
+                    final IgniteCache<String, WebSession> cache0 = cacheWithExpiryPolicy(maxInactiveInterval, cache);
+
+                    cache0.invoke(sesId, WebSessionListener.newAttributeProcessor(updates));
+
+                    break;
+                }
+                catch (CacheException | IgniteException | IllegalStateException e) {
+                    handleAttributeUpdateException(sesId, i, e);
+                }
+            }
+        }
+        catch (Exception e) {
+            U.error(log, "Failed to update session attributes [id=" + sesId + ']', e);
+        }
+    }
+
+    /**
+     * @param sesId Session ID.
+     * @param ses Web session.
+     */
+    public void updateAttributesV2(final String sesId, final WebSessionV2 ses) throws IOException {
+        assert sesId != null;
+        assert ses != null;
+
+        final Map<String, byte[]> updatesMap = ses.binaryUpdatesMap();
+
+        if (log.isDebugEnabled())
+            log.debug("Session binary attributes updated [id=" + sesId + ", updates=" + updatesMap.keySet() + ']');
+
+        try {
+            for (int i = 0; i < retries; i++) {
+                try {
+                    final IgniteCache<String, WebSessionEntity> cache0 =
+                        cacheWithExpiryPolicy(ses.getMaxInactiveInterval(), binaryCache);
+
+                    cache0.invoke(sesId, new WebSessionAttributeProcessor(updatesMap.isEmpty() ? null : updatesMap,
+                        ses.getLastAccessedTime(), ses.getMaxInactiveInterval(), ses.isMaxInactiveIntervalChanged()));
+
+                    break;
+                }
+                catch (CacheException | IgniteException | IllegalStateException e) {
+                    handleAttributeUpdateException(sesId, i, e);
+                }
+            }
+        }
+        catch (Exception e) {
+            U.error(log, "Failed to update session V2 attributes [id=" + sesId + ']', e);
+        }
+    }
+
+    /**
+     * Log error and delegate processing to {@link #handleCacheOperationException(Exception)}.
+     *
+     * @param sesId Session ID.
+     * @param tryCnt Try count.
+     * @param e Exception to process.
+     */
+    private void handleAttributeUpdateException(final String sesId, final int tryCnt, final RuntimeException e) {
+        if (tryCnt == retries - 1) {
+            U.warn(log, "Failed to apply updates for session (maximum number of retries exceeded) [sesId=" +
+                sesId + ", retries=" + retries + ']');
+        }
+        else {
+            U.warn(log, "Failed to apply updates for session (will retry): " + sesId);
+
+            handleCacheOperationException(e);
+        }
     }
 
+
     /**
      * Handles cache operation exception.
      * @param e Exception
      */
+    @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
     void handleCacheOperationException(Exception e){
         IgniteFuture<?> retryFut = null;
 
@@ -608,7 +926,7 @@ public class WebSessionFilter implements Filter {
                 if (create) {
                     this.ses = createSession((HttpServletRequest)getRequest());
                     this.ses.servletContext(ctx);
-                    this.ses.listener(lsnr);
+                    this.ses.filter(WebSessionFilter.this);
                     this.ses.resetUpdates();
                 }
                 else
@@ -633,10 +951,73 @@ public class WebSessionFilter implements Filter {
 
             this.ses = createSession(ses, newId);
             this.ses.servletContext(ctx);
-            this.ses.listener(lsnr);
+            this.ses.filter(WebSessionFilter.this);
             this.ses.resetUpdates();
 
             return newId;
         }
     }
+
+    /**
+     * Request wrapper V2.
+     */
+    private class RequestWrapperV2 extends HttpServletRequestWrapper {
+        /** Session. */
+        private WebSessionV2 ses;
+
+        /**
+         * @param req Request.
+         * @param ses Session.
+         */
+        private RequestWrapperV2(HttpServletRequest req, WebSessionV2 ses) {
+            super(req);
+
+            assert ses != null;
+
+            this.ses = ses;
+        }
+
+        /** {@inheritDoc} */
+        @Override public HttpSession getSession(boolean create) {
+            if (!ses.isValid()) {
+                binaryCache.remove(ses.id());
+
+                if (create) {
+                    try {
+                        ses = createSessionV2((HttpServletRequest) getRequest());
+                    }
+                    catch (IOException e) {
+                        throw new IgniteException(e);
+                    }
+                }
+                else
+                    return null;
+            }
+
+            return ses;
+        }
+
+        /** {@inheritDoc} */
+        @Override public HttpSession getSession() {
+            return getSession(true);
+        }
+
+        /** {@inheritDoc} */
+        @Override public String changeSessionId() {
+            final HttpServletRequest req = (HttpServletRequest) getRequest();
+
+            final String newId = req.changeSessionId();
+
+            if (!F.eq(newId, ses.getId())) {
+                try {
+                    ses = createSessionV2(ses, newId);
+                }
+                catch (IOException e) {
+                    throw new IgniteException(e);
+                }
+            }
+
+            return newId;
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/b369d030/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionListener.java
----------------------------------------------------------------------
diff --git a/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionListener.java b/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionListener.java
index 0d8ffec..ab41879 100644
--- a/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionListener.java
+++ b/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionListener.java
@@ -22,127 +22,24 @@ import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.util.Collection;
-import javax.cache.CacheException;
-import javax.cache.expiry.Duration;
-import javax.cache.expiry.ExpiryPolicy;
-import javax.cache.expiry.ModifiedExpiryPolicy;
 import javax.cache.processor.EntryProcessor;
 import javax.cache.processor.MutableEntry;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.internal.util.typedef.T2;
-import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
 
-import static java.util.concurrent.TimeUnit.MILLISECONDS;
-
 /**
  * Session listener for web sessions caching.
  */
 class WebSessionListener {
-    /** Filter. */
-    private final WebSessionFilter filter;
-
-    /** Maximum retries. */
-    private final int retries;
-
-    /** Logger. */
-    private final IgniteLogger log;
-
-    /**
-     * @param ignite Grid.
-     * @param filter Filter.
-     * @param retries Maximum retries.
-     */
-    WebSessionListener(Ignite ignite, WebSessionFilter filter, int retries) {
-        assert ignite != null;
-        assert filter != null;
-
-        this.filter = filter;
-        this.retries = retries > 0 ? retries : 1;
-
-        log = ignite.log();
-    }
-
-    /**
-     * @param sesId Session ID.
-     */
-    public void destroySession(String sesId) {
-        assert sesId != null;
-        for (int i = 0; i < retries; i++) {
-            try {
-                if (filter.getCache().remove(sesId) && log.isDebugEnabled())
-                    log.debug("Session destroyed: " + sesId);
-            }
-            catch (CacheException | IgniteException | IllegalStateException e) {
-                if (i == retries - 1) {
-                    U.warn(log, "Failed to remove session [sesId=" +
-                        sesId + ", retries=" + retries + ']');
-                }
-                else {
-                    U.warn(log, "Failed to remove session (will retry): " + sesId);
-
-                    filter.handleCacheOperationException(e);
-                }
-            }
-        }
-    }
-
     /**
-     * @param sesId Session ID.
-     * @param updates Updates list.
-     * @param maxInactiveInterval Max session inactive interval.
+     * Creates new instance of attribute processor. Used for compatibility.
+     *
+     * @param updates Updates.
+     * @return New instance of attribute processor.
      */
-    @SuppressWarnings("unchecked")
-    public void updateAttributes(String sesId, Collection<T2<String, Object>> updates, int maxInactiveInterval) {
-        assert sesId != null;
-        assert updates != null;
-
-        if (log.isDebugEnabled())
-            log.debug("Session attributes updated [id=" + sesId + ", updates=" + updates + ']');
-
-        try {
-            for (int i = 0; i < retries; i++) {
-                try {
-                    IgniteCache<String, WebSession> cache0;
-
-                    if (maxInactiveInterval > 0) {
-                        long ttl = maxInactiveInterval * 1000;
-
-                        ExpiryPolicy plc = new ModifiedExpiryPolicy(new Duration(MILLISECONDS, ttl));
-
-                        cache0 = filter.getCache().withExpiryPolicy(plc);
-                    }
-                    else
-                        cache0 = filter.getCache();
-
-                    cache0.invoke(sesId, new AttributesProcessor(updates));
-
-                    break;
-                }
-                catch (CacheException | IgniteException | IllegalStateException e) {
-                    if (i == retries - 1) {
-                        U.warn(log, "Failed to apply updates for session (maximum number of retries exceeded) [sesId=" +
-                            sesId + ", retries=" + retries + ']');
-                    }
-                    else {
-                        U.warn(log, "Failed to apply updates for session (will retry): " + sesId);
-
-                        filter.handleCacheOperationException(e);
-                    }
-                }
-            }
-        }
-        catch (Exception e) {
-            U.error(log, "Failed to update session attributes [id=" + sesId + ']', e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return S.toString(WebSessionListener.class, this);
+    public static EntryProcessor<String, WebSession, Void> newAttributeProcessor(
+        final Collection<T2<String, Object>> updates) {
+        return new AttributesProcessor(updates);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/b369d030/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionV2.java
----------------------------------------------------------------------
diff --git a/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionV2.java b/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionV2.java
new file mode 100644
index 0000000..07a85db
--- /dev/null
+++ b/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionV2.java
@@ -0,0 +1,405 @@
+/*
+ * 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.cache.websession;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.internal.util.tostring.GridToStringExclude;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.websession.WebSessionEntity;
+import org.apache.ignite.marshaller.Marshaller;
+import org.jetbrains.annotations.Nullable;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpSession;
+import javax.servlet.http.HttpSessionContext;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Session implementation that uses internal entity, which stores binary attributes,
+ * for safe caching and processing on remote nodes.
+ */
+class WebSessionV2 implements HttpSession {
+    /** Empty session context. */
+    @SuppressWarnings("deprecation")
+    private static final HttpSessionContext EMPTY_SES_CTX = new HttpSessionContext() {
+        @Nullable @Override public HttpSession getSession(String id) {
+            return null;
+        }
+
+        @Override public Enumeration<String> getIds() {
+            return Collections.enumeration(Collections.<String>emptyList());
+        }
+    };
+
+    /** Placeholder for removed attribute. */
+    private static final Object REMOVED_ATTR = new Object();
+
+    /** Servlet context. */
+    @GridToStringExclude
+    private final ServletContext ctx;
+
+    /** Entity that holds binary attributes. */
+    private WebSessionEntity entity;
+
+    /** Attributes. */
+    protected Map<String, Object> attrs;
+
+    /** Timestamp that shows when this object was created. (Last access time from user request) */
+    private final long accessTime;
+
+    /** Cached session TTL since last query. */
+    private int maxInactiveInterval;
+
+    /** Flag indicates if {@link #maxInactiveInterval} waiting for update in cache. */
+    private boolean maxInactiveIntervalChanged;
+
+    /** New session flag. */
+    private boolean isNew;
+
+    /** Session invalidation flag. */
+    private boolean invalidated;
+
+    /** Grid marshaller. */
+    private final Marshaller marshaller;
+
+    /** Original session to delegate invalidation. */
+    private final HttpSession genuineSes;
+
+    /**
+     * @param id Session ID.
+     * @param ses Session.
+     * @param isNew Is new flag.
+     */
+    WebSessionV2(final String id, final @Nullable HttpSession ses, final boolean isNew, final ServletContext ctx,
+        @Nullable WebSessionEntity entity, final Marshaller marshaller) {
+        assert id != null;
+        assert marshaller != null;
+        assert ctx != null;
+        assert ses != null || entity != null;
+
+        this.marshaller = marshaller;
+        this.ctx = ctx;
+        this.isNew = isNew;
+        this.genuineSes = ses;
+
+        accessTime = System.currentTimeMillis();
+
+        if (entity == null) {
+            entity = new WebSessionEntity(id, ses.getCreationTime(), accessTime,
+                ses.getMaxInactiveInterval());
+        }
+
+        this.entity = entity;
+
+        maxInactiveInterval = entity.maxInactiveInterval();
+
+        if (ses != null) {
+            final Enumeration<String> names = ses.getAttributeNames();
+
+            while (names.hasMoreElements()) {
+                final String name = names.nextElement();
+
+                attributes().put(name, ses.getAttribute(name));
+            }
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getCreationTime() {
+        assertValid();
+
+        return entity.createTime();
+    }
+
+    /** {@inheritDoc} */
+    @Override public String getId() {
+        assertValid();
+
+        return entity.id();
+    }
+
+    /**
+     * @return Session ID without throwing exception.
+     */
+    public String id() {
+        return entity.id();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getLastAccessedTime() {
+        assertValid();
+
+        return accessTime;
+    }
+
+    /** {@inheritDoc} */
+    @Override public ServletContext getServletContext() {
+        return ctx;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void setMaxInactiveInterval(final int interval) {
+        maxInactiveInterval = interval;
+
+        maxInactiveIntervalChanged = true;
+    }
+
+    /**
+     * @return {@code True} if {@link #setMaxInactiveInterval(int)} was invoked.
+     */
+    public boolean isMaxInactiveIntervalChanged() {
+        return maxInactiveIntervalChanged;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getMaxInactiveInterval() {
+        return maxInactiveInterval;
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("deprecation")
+    @Override public HttpSessionContext getSessionContext() {
+        return EMPTY_SES_CTX;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Object getAttribute(final String name) {
+        assertValid();
+
+        Object attr = attributes().get(name);
+
+        if (attr == REMOVED_ATTR)
+            return null;
+
+        if (attr == null) {
+            final byte[] bytes = entity.attributes().get(name);
+
+            if (bytes != null) {
+                // deserialize
+                try {
+                    attr = unmarshal(bytes);
+                }
+                catch (IOException e) {
+                    throw new IgniteException(e);
+                }
+
+                attributes().put(name, attr);
+            }
+        }
+
+        return attr;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Object getValue(final String name) {
+        return getAttribute(name);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void setAttribute(final String name, final Object val) {
+        assertValid();
+
+        if (val == null)
+            removeAttribute(name);
+        else
+            attributes().put(name, val);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void putValue(final String name, final Object val) {
+        setAttribute(name, val);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Enumeration<String> getAttributeNames() {
+        assertValid();
+
+        return Collections.enumeration(attributeNames());
+    }
+
+    /**
+     * @return Set of attribute names.
+     */
+    private Set<String> attributeNames() {
+        if (!F.isEmpty(attrs)) {
+            final Set<String> names = new HashSet<>(entity.attributes().size() + attrs.size());
+
+            names.addAll(entity.attributes().keySet());
+
+            for (final Map.Entry<String, Object> entry : attrs.entrySet()) {
+                if (entry != REMOVED_ATTR)
+                    names.add(entry.getKey());
+            }
+
+            return names;
+        }
+
+        return entity.attributes().keySet();
+    }
+
+    /** {@inheritDoc} */
+    @Override public String[] getValueNames() {
+        assertValid();
+
+        final Set<String> names = attributeNames();
+
+        return names.toArray(new String[names.size()]);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void removeAttribute(final String name) {
+        assertValid();
+
+        attributes().put(name, REMOVED_ATTR);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void removeValue(final String name) {
+        removeAttribute(name);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void invalidate() {
+        assertValid();
+
+        if (genuineSes != null) {
+            try {
+                genuineSes.invalidate();
+            }
+            catch (IllegalStateException e) {
+                // Already invalidated, keep going.
+            }
+        }
+
+        invalidated = true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isNew() {
+        assertValid();
+
+        return isNew;
+    }
+
+    /**
+     * @return Marshaled updates or empty map if no params.
+     * @throws IOException
+     */
+    public Map<String, byte[]> binaryUpdatesMap() throws IOException {
+        final Map<String, Object> map = attributes();
+
+        if (F.isEmpty(map))
+            return Collections.emptyMap();
+
+        final Map<String, byte[]> res = new HashMap<>(map.size());
+
+        for (final Map.Entry<String, Object> entry : map.entrySet()) {
+            Object val = entry.getValue() == REMOVED_ATTR ? null : entry.getValue();
+
+            res.put(entry.getKey(), marshal(val));
+        }
+
+        return res;
+    }
+
+    /**
+     * Unmarshal object.
+     *
+     * @param bytes Data.
+     * @param <T> Expected type.
+     * @return Unmarshaled object.
+     * @throws IOException If unarshaling failed.
+     */
+    @Nullable private <T> T unmarshal(final byte[] bytes) throws IOException {
+        if (marshaller != null) {
+            try {
+                return marshaller.unmarshal(bytes, getClass().getClassLoader());
+            }
+            catch (IgniteCheckedException e) {
+                throw new IOException(e);
+            }
+        }
+
+        return null;
+    }
+
+    /**
+     * Marshal object.
+     *
+     * @param obj Object to marshal.
+     * @return Binary data.
+     * @throws IOException If marshaling failed.
+     */
+    @Nullable private byte[] marshal(final Object obj) throws IOException {
+        if (marshaller != null) {
+            try {
+                return marshaller.marshal(obj);
+            }
+            catch (IgniteCheckedException e) {
+                throw new IOException(e);
+            }
+        }
+
+        return null;
+    }
+
+    /**
+     * Marshal all attributes and save to serializable entity.
+     */
+    public WebSessionEntity marshalAttributes() throws IOException {
+        final WebSessionEntity marshaled = new WebSessionEntity(getId(), entity.createTime(), accessTime,
+            maxInactiveInterval);
+
+        for (final Map.Entry<String, Object> entry : attributes().entrySet())
+            marshaled.putAttribute(entry.getKey(), marshal(entry.getValue()));
+
+        return marshaled;
+    }
+
+    /**
+     * @return Session attributes.
+     */
+    private Map<String, Object> attributes() {
+        if (attrs == null)
+            attrs = new HashMap<>();
+
+        return attrs;
+    }
+
+    /**
+     * @return {@code True} if session wasn't invalidated.
+     */
+    public boolean isValid() {
+        return !invalidated;
+    }
+
+    /**
+     * Throw {@link IllegalStateException} if session was invalidated.
+     */
+    private void assertValid() {
+        if (invalidated)
+            throw new IllegalStateException("Session was invalidated.");
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/b369d030/modules/web/src/test/java/org/apache/ignite/internal/websession/IgniteWebSessionSelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/web/src/test/java/org/apache/ignite/internal/websession/IgniteWebSessionSelfTestSuite.java b/modules/web/src/test/java/org/apache/ignite/internal/websession/IgniteWebSessionSelfTestSuite.java
index 2e47262..1d15127 100644
--- a/modules/web/src/test/java/org/apache/ignite/internal/websession/IgniteWebSessionSelfTestSuite.java
+++ b/modules/web/src/test/java/org/apache/ignite/internal/websession/IgniteWebSessionSelfTestSuite.java
@@ -38,6 +38,11 @@ public class IgniteWebSessionSelfTestSuite extends TestSuite {
         suite.addTestSuite(WebSessionTransactionalSelfTest.class);
         suite.addTestSuite(WebSessionReplicatedSelfTest.class);
 
+        // Old implementation tests.
+        suite.addTestSuite(WebSessionV1SelfTest.class);
+        suite.addTestSuite(WebSessionTransactionalV1SelfTest.class);
+        suite.addTestSuite(WebSessionReplicatedV1SelfTest.class);
+
         System.setProperty(IGNITE_OVERRIDE_MCAST_GRP,
             GridTestUtils.getNextMulticastGroup(IgniteWebSessionSelfTestSuite.class));
 
@@ -78,4 +83,34 @@ public class IgniteWebSessionSelfTestSuite extends TestSuite {
             return "replicated";
         }
     }
+
+    /**
+     * Old version test.
+     */
+    public static class WebSessionV1SelfTest extends WebSessionSelfTest {
+        /** {@inheritDoc} */
+        @Override protected boolean keepBinary() {
+            return false;
+        }
+    }
+
+    /**
+     * Tests web sessions with TRANSACTIONAL cache in compatibility mode.
+     */
+    public static class WebSessionTransactionalV1SelfTest extends WebSessionTransactionalSelfTest {
+        /** {@inheritDoc} */
+        @Override protected boolean keepBinary() {
+            return false;
+        }
+    }
+
+    /**
+     * Tests web sessions with REPLICATED cache in compatibility mode.
+     */
+    public static class WebSessionReplicatedV1SelfTest extends WebSessionReplicatedSelfTest {
+        /** {@inheritDoc} */
+        @Override protected boolean keepBinary() {
+            return false;
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/b369d030/modules/web/src/test/java/org/apache/ignite/internal/websession/WebSessionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/web/src/test/java/org/apache/ignite/internal/websession/WebSessionSelfTest.java b/modules/web/src/test/java/org/apache/ignite/internal/websession/WebSessionSelfTest.java
index ccf0852..1e01d3c 100644
--- a/modules/web/src/test/java/org/apache/ignite/internal/websession/WebSessionSelfTest.java
+++ b/modules/web/src/test/java/org/apache/ignite/internal/websession/WebSessionSelfTest.java
@@ -18,9 +18,12 @@
 package org.apache.ignite.internal.websession;
 
 import java.io.BufferedReader;
+import java.io.Externalizable;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.Serializable;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 import java.net.URL;
 import java.net.URLConnection;
 import java.util.Random;
@@ -28,7 +31,6 @@ import java.util.concurrent.Callable;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.concurrent.atomic.AtomicReferenceArray;
 import javax.servlet.ServletException;
@@ -38,12 +40,14 @@ import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.events.Event;
 import org.apache.ignite.Ignition;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.util.typedef.G;
 import org.apache.ignite.internal.util.typedef.X;
 import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.marshaller.Marshaller;
 import org.apache.ignite.lang.IgnitePredicate;
 import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
@@ -72,6 +76,13 @@ public class WebSessionSelfTest extends GridCommonAbstractTest {
     }
 
     /**
+     * @return Keep binary flag.
+     */
+    protected boolean keepBinary() {
+        return true;
+    }
+
+    /**
      * @throws Exception If failed.
      */
     public void testSingleRequest() throws Exception {
@@ -114,7 +125,7 @@ public class WebSessionSelfTest extends GridCommonAbstractTest {
         Ignite ignite = Ignition.start(srvCfg);
 
         try {
-            srv = startServer(TEST_JETTY_PORT, clientCfg, "client", new SessionCreateServlet());
+            srv = startServer(TEST_JETTY_PORT, clientCfg, "client", new SessionCreateServlet(keepBinary()));
 
             URL url = new URL("http://localhost:" + TEST_JETTY_PORT + "/ignitetest/test");
 
@@ -173,7 +184,7 @@ public class WebSessionSelfTest extends GridCommonAbstractTest {
         Server srv = null;
 
         try {
-            srv = startServer(TEST_JETTY_PORT, cfg, null, new SessionCreateServlet());
+            srv = startServer(TEST_JETTY_PORT, cfg, null, new SessionCreateServlet(keepBinary()));
 
             String sesId = sendRequestAndCheckMarker("marker1", null);
             sendRequestAndCheckMarker("test_string", sesId);
@@ -184,7 +195,7 @@ public class WebSessionSelfTest extends GridCommonAbstractTest {
         }
     }
 
-    private String sendRequestAndCheckMarker(String reqMarker, String sesId) throws IOException {
+    private String sendRequestAndCheckMarker(String reqMarker, String sesId) throws IOException, IgniteCheckedException {
         URLConnection conn = new URL("http://localhost:" + TEST_JETTY_PORT +
             "/ignitetest/test?marker=" + reqMarker).openConnection();
         conn.addRequestProperty("Cookie", "JSESSIONID=" + sesId);
@@ -194,14 +205,33 @@ public class WebSessionSelfTest extends GridCommonAbstractTest {
         try (BufferedReader rdr = new BufferedReader(new InputStreamReader(conn.getInputStream()))) {
             sesId = rdr.readLine();
 
-            IgniteCache<String, HttpSession> cache = G.ignite().cache(getCacheName());
+            if (!keepBinary()) {
+                IgniteCache<String, HttpSession> cache = G.ignite().cache(getCacheName());
 
-            assertNotNull(cache);
+                assertNotNull(cache);
 
-            HttpSession ses = cache.get(sesId);
+                HttpSession ses = cache.get(sesId);
 
-            assertNotNull(ses);
-            assertEquals(reqMarker, ((Profile)ses.getAttribute("profile")).getMarker());
+                assertNotNull(ses);
+                assertEquals(reqMarker, ((Profile) ses.getAttribute("profile")).getMarker());
+            }
+            else {
+                IgniteCache<String, WebSessionEntity> cache = G.ignite().cache(getCacheName());
+
+                assertNotNull(cache);
+
+                WebSessionEntity ses = cache.get(sesId);
+
+                assertNotNull(ses);
+
+                final byte[] data = ses.attributes().get("profile");
+
+                assertNotNull(data);
+
+                final Marshaller marshaller = G.ignite().configuration().getMarshaller();
+
+                assertEquals(reqMarker, marshaller.<Profile>unmarshal(data, getClass().getClassLoader()).getMarker());
+            }
         }
         return sesId;
     }
@@ -216,7 +246,7 @@ public class WebSessionSelfTest extends GridCommonAbstractTest {
         Server srv = null;
 
         try {
-            srv = startServer(TEST_JETTY_PORT, cfg, null, new SessionCreateServlet());
+            srv = startServer(TEST_JETTY_PORT, cfg, null, new SessionCreateServlet(keepBinary()));
 
             URLConnection conn = new URL("http://localhost:" + TEST_JETTY_PORT + "/ignitetest/test").openConnection();
 
@@ -225,14 +255,36 @@ public class WebSessionSelfTest extends GridCommonAbstractTest {
             try (BufferedReader rdr = new BufferedReader(new InputStreamReader(conn.getInputStream()))) {
                 String sesId = rdr.readLine();
 
-                IgniteCache<String, HttpSession> cache = G.ignite().cache(getCacheName());
+                if (!keepBinary()) {
+                    IgniteCache<String, HttpSession> cache = G.ignite().cache(getCacheName());
 
-                assertNotNull(cache);
+                    assertNotNull(cache);
 
-                HttpSession ses = cache.get(sesId);
+                    HttpSession ses = cache.get(sesId);
 
-                assertNotNull(ses);
-                assertEquals("val1", ses.getAttribute("key1"));
+                    assertNotNull(ses);
+
+                    assertEquals("val1", ses.getAttribute("key1"));
+                }
+                else {
+                    final IgniteCache<String, WebSessionEntity> cache = G.ignite().cache(getCacheName());
+
+                    assertNotNull(cache);
+
+                    final WebSessionEntity entity = cache.get(sesId);
+
+                    assertNotNull(entity);
+
+                    final byte[] data = entity.attributes().get("key1");
+
+                    assertNotNull(data);
+
+                    final Marshaller marshaller = G.ignite().configuration().getMarshaller();
+
+                    final String val = marshaller.unmarshal(data, getClass().getClassLoader());
+
+                    assertEquals("val1", val);
+                }
             }
         }
         finally {
@@ -266,18 +318,34 @@ public class WebSessionSelfTest extends GridCommonAbstractTest {
 
                 assertNotNull(invalidatedSesId);
 
-                IgniteCache<String, HttpSession> cache = ignite.cache(getCacheName());
+                if (!keepBinary()) {
+                    IgniteCache<String, HttpSession> cache = ignite.cache(getCacheName());
 
-                assertNotNull(cache);
+                    assertNotNull(cache);
+
+                    HttpSession invalidatedSes = cache.get(invalidatedSesId);
+
+                    assertNull(invalidatedSes);
+
+                    // requests to subsequent getSession() returns null.
+                    String ses = rdr.readLine();
 
-                HttpSession invalidatedSes = cache.get(invalidatedSesId);
+                    assertEquals("null", ses);
+                }
+                else {
+                    IgniteCache<String, WebSessionEntity> cache = ignite.cache(getCacheName());
+
+                    assertNotNull(cache);
 
-                assertNull(invalidatedSes);
+                    WebSessionEntity invalidatedSes = cache.get(invalidatedSesId);
 
-                // requests to subsequent getSession() returns null.
-                String ses = rdr.readLine();
+                    assertNull(invalidatedSes);
 
-                assertEquals("null", ses);
+                    // requests to subsequent getSession() returns null.
+                    String ses = rdr.readLine();
+
+                    assertEquals("null", ses);
+                }
             }
 
             // put and update.
@@ -309,15 +377,31 @@ public class WebSessionSelfTest extends GridCommonAbstractTest {
 
                 assertTrue(latch.await(10, TimeUnit.SECONDS));
 
-                IgniteCache<String, HttpSession> cache = ignite.cache(getCacheName());
+                if (!keepBinary()) {
+                    IgniteCache<String, HttpSession> cache = ignite.cache(getCacheName());
 
-                assertNotNull(cache);
+                    assertNotNull(cache);
 
-                HttpSession ses = cache.get(sesId);
+                    HttpSession ses = cache.get(sesId);
 
-                assertNotNull(ses);
+                    assertNotNull(ses);
+
+                    assertEquals("val10", ses.getAttribute("key10"));
+                }
+                else {
+                    IgniteCache<String, WebSessionEntity> cache = ignite.cache(getCacheName());
+
+                    assertNotNull(cache);
+
+                    WebSessionEntity entity = cache.get(sesId);
+
+                    assertNotNull(entity);
+
+                    final Marshaller marshaller = ignite.configuration().getMarshaller();
 
-                assertEquals("val10", ses.getAttribute("key10"));
+                    assertEquals("val10",
+                        marshaller.unmarshal(entity.attributes().get("key10"), getClass().getClassLoader()));
+                }
             }
         }
         finally {
@@ -365,17 +449,35 @@ public class WebSessionSelfTest extends GridCommonAbstractTest {
 
                 assertTrue(newGenSesId.equals(newWebSesId));
 
-                IgniteCache<String, HttpSession> cache = ignite.cache(getCacheName());
+                if (!keepBinary()) {
+                    IgniteCache<String, HttpSession> cache = ignite.cache(getCacheName());
 
-                assertNotNull(cache);
+                    assertNotNull(cache);
 
-                Thread.sleep(1000);
+                    Thread.sleep(1000);
 
-                HttpSession ses = cache.get(newWebSesId);
+                    HttpSession ses = cache.get(newWebSesId);
 
-                assertNotNull(ses);
+                    assertNotNull(ses);
+
+                    assertEquals("val1", ses.getAttribute("key1"));
+                }
+                else {
+                    IgniteCache<String, WebSessionEntity> cache = ignite.cache(getCacheName());
+
+                    assertNotNull(cache);
+
+                    Thread.sleep(1000);
 
-                assertEquals("val1", ses.getAttribute("key1"));
+                    WebSessionEntity ses = cache.get(newWebSesId);
+
+                    assertNotNull(ses);
+
+                    final Marshaller marshaller = ignite.configuration().getMarshaller();
+
+                    assertEquals("val1",
+                        marshaller.<String>unmarshal(ses.attributes().get("key1"), getClass().getClassLoader()));
+                }
             }
 
             conn = new URL("http://localhost:" + TEST_JETTY_PORT + "/ignitetest/simple").openConnection();
@@ -524,14 +626,18 @@ public class WebSessionSelfTest extends GridCommonAbstractTest {
      * @param servlet Servlet.
      * @return Servlet container web context for this test.
      */
-    protected WebAppContext getWebContext(@Nullable String cfg, @Nullable String gridName, HttpServlet servlet) {
-        WebAppContext ctx = new WebAppContext(U.resolveIgnitePath("modules/core/src/test/webapp").getAbsolutePath(),
+    protected WebAppContext getWebContext(@Nullable String cfg, @Nullable String gridName,
+        boolean keepBinaryFlag, HttpServlet servlet) {
+        final String path = keepBinaryFlag ? "modules/core/src/test/webapp" : "modules/web/src/test/webapp2";
+
+        WebAppContext ctx = new WebAppContext(U.resolveIgnitePath(path).getAbsolutePath(),
             "/ignitetest");
 
         ctx.setInitParameter("IgniteConfigurationFilePath", cfg);
         ctx.setInitParameter("IgniteWebSessionsGridName", gridName);
         ctx.setInitParameter("IgniteWebSessionsCacheName", getCacheName());
         ctx.setInitParameter("IgniteWebSessionsMaximumRetriesOnFail", "100");
+        ctx.setInitParameter("IgniteWebSessionsKeepBinary", Boolean.toString(keepBinaryFlag));
 
         ctx.addServlet(new ServletHolder(servlet), "/*");
 
@@ -552,7 +658,7 @@ public class WebSessionSelfTest extends GridCommonAbstractTest {
         throws Exception {
         Server srv = new Server(port);
 
-        WebAppContext ctx = getWebContext(cfg, gridName, servlet);
+        WebAppContext ctx = getWebContext(cfg, gridName, keepBinary(), servlet);
 
         srv.setHandler(ctx);
 
@@ -576,6 +682,16 @@ public class WebSessionSelfTest extends GridCommonAbstractTest {
      * Test servlet.
      */
     private static class SessionCreateServlet extends HttpServlet {
+        /** Keep binary flag. */
+        private final boolean keepBinaryFlag;
+
+        /**
+         * @param keepBinaryFlag Keep binary flag.
+         */
+        private SessionCreateServlet(final boolean keepBinaryFlag) {
+            this.keepBinaryFlag = keepBinaryFlag;
+        }
+
         /** {@inheritDoc} */
         @Override protected void doGet(HttpServletRequest req, HttpServletResponse res)
             throws ServletException, IOException {
@@ -584,6 +700,7 @@ public class WebSessionSelfTest extends GridCommonAbstractTest {
             ses.setAttribute("checkCnt", 0);
             ses.setAttribute("key1", "val1");
             ses.setAttribute("key2", "val2");
+            ses.setAttribute("mkey", new TestObj("mval", keepBinaryFlag));
 
             Profile p = (Profile)ses.getAttribute("profile");
 
@@ -638,23 +755,25 @@ public class WebSessionSelfTest extends GridCommonAbstractTest {
 
             assert ses != null;
 
+            final String sesId = ses.getId();
+
             if (req.getPathInfo().equals("/invalidated")) {
-                X.println(">>>", "Session to invalidate with id: " + ses.getId(), ">>>");
+                X.println(">>>", "Session to invalidate with id: " + sesId, ">>>");
 
                 ses.invalidate();
 
-                res.getWriter().println(ses.getId());
+                res.getWriter().println(sesId);
 
                 // invalidates again.
                 req.getSession().invalidate();
             }
             else if (req.getPathInfo().equals("/valid")) {
-                X.println(">>>", "Created session: " + ses.getId(), ">>>");
+                X.println(">>>", "Created session: " + sesId, ">>>");
 
                 ses.setAttribute("key10", "val10");
             }
 
-            res.getWriter().println((req.getSession(false) == null) ? "null" : ses.getId());
+            res.getWriter().println((req.getSession(false) == null) ? "null" : sesId);
 
             res.getWriter().flush();
         }
@@ -746,4 +865,71 @@ public class WebSessionSelfTest extends GridCommonAbstractTest {
             res.getWriter().flush();
         }
     }
-}
+
+    /**
+     *
+     */
+    private static class TestObj implements Externalizable {
+        /** */
+        private static final long serialVersionUID = 0L;
+
+        /** */
+        private String val;
+
+        /** */
+        private boolean keepBinaryFlag;
+
+        /**
+         *
+         */
+        public TestObj() {
+        }
+
+        /**
+         * @param val Value.
+         * @param keepBinaryFlag Keep binary flag.
+         */
+        public TestObj(final String val, final boolean keepBinaryFlag) {
+            this.val = val;
+            this.keepBinaryFlag = keepBinaryFlag;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void writeExternal(final ObjectOutput out) throws IOException {
+            U.writeString(out, val);
+            out.writeBoolean(keepBinaryFlag);
+            System.out.println("TestObj marshalled");
+        }
+
+        /** {@inheritDoc} */
+        @Override public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
+            val = U.readString(in);
+            keepBinaryFlag = in.readBoolean();
+
+            // It must be unmarshalled only on client side.
+            if (keepBinaryFlag)
+                fail("Should not be unmarshalled");
+
+            System.out.println("TestObj unmarshalled");
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean equals(final Object o) {
+            if (this == o) return true;
+            if (o == null || getClass() != o.getClass()) return false;
+
+            final TestObj testObj = (TestObj) o;
+
+            if (keepBinaryFlag != testObj.keepBinaryFlag) return false;
+            return val != null ? val.equals(testObj.val) : testObj.val == null;
+
+        }
+
+        /** {@inheritDoc} */
+        @Override public int hashCode() {
+            int result = val != null ? val.hashCode() : 0;
+            result = 31 * result + (keepBinaryFlag ? 1 : 0);
+            return result;
+        }
+    }
+}
\ No newline at end of file


[14/14] ignite git commit: Merge remote-tracking branch 'remotes/origin/ignite-1.6'

Posted by av...@apache.org.
Merge remote-tracking branch 'remotes/origin/ignite-1.6'


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

Branch: refs/heads/master
Commit: 88d9fe6796948735bead36475f1953efcde90f4d
Parents: 608bd82 f07f988
Author: Anton Vinogradov <av...@apache.org>
Authored: Tue May 17 16:48:24 2016 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Tue May 17 16:48:24 2016 +0300

----------------------------------------------------------------------
 assembly/dependencies-schema-import.xml         |   1 +
 assembly/release-schema-import.xml              |   2 +-
 config/hadoop/default-config.xml                | 111 ++--
 .../apache/ignite/IgniteSystemProperties.java   |   8 +
 .../configuration/FileSystemConfiguration.java  |   4 +-
 .../configuration/HadoopConfiguration.java      |   2 +-
 .../igfs/IgfsGroupDataBlocksKeyMapper.java      |  43 +-
 .../apache/ignite/internal/IgniteKernal.java    |   7 +
 .../ignite/internal/IgniteNodeAttributes.java   |   4 +
 .../ignite/internal/binary/BinaryUtils.java     | 176 ++++++-
 .../internal/binary/BinaryWriterExImpl.java     |   7 +-
 .../discovery/GridDiscoveryManager.java         |  21 +
 .../processors/cache/GridCacheTtlManager.java   |   5 +-
 .../distributed/dht/GridDhtTxFinishFuture.java  |   2 +-
 .../continuous/GridContinuousProcessor.java     |   5 +-
 .../processors/igfs/IgfsDataManager.java        |   2 +-
 .../processors/igfs/IgfsDeleteWorker.java       |  10 +-
 .../internal/processors/igfs/IgfsProcessor.java |   2 +-
 .../internal/processors/igfs/IgfsUtils.java     |  14 +
 .../WebSessionAttributeProcessor.java           | 134 +++++
 .../internal/websession/WebSessionEntity.java   | 193 +++++++
 .../ignite/spi/discovery/tcp/ServerImpl.java    |  44 ++
 .../binary/BinaryMarshallerSelfTest.java        | 158 ++++--
 .../GridDiscoveryManagerAttributesSelfTest.java |  63 +++
 .../cache/CrossCacheTxRandomOperationsTest.java |  13 +-
 .../cache/jta/websphere/package-info.java       |  22 +
 .../stream/kafka/connect/IgniteSourceTask.java  | 122 +++--
 .../kafka/connect/IgniteSinkConnectorTest.java  |   8 +-
 .../connect/IgniteSourceConnectorMock.java      |   1 -
 .../connect/IgniteSourceConnectorTest.java      |  16 +-
 .../kafka/connect/IgniteSourceTaskMock.java     |   4 +-
 .../kafka/connect/TestCacheEventFilter.java     |   6 +-
 modules/schema-import-db/README.txt             |   4 +
 modules/schema-import-db/pom.xml                |  44 ++
 .../apache/ignite/schema/parser/DbColumn.java   |  76 +++
 .../ignite/schema/parser/DbMetadataReader.java  | 147 ++++++
 .../apache/ignite/schema/parser/DbTable.java    |  82 +++
 .../parser/dialect/DB2MetadataDialect.java      |  33 ++
 .../parser/dialect/DatabaseMetadataDialect.java |  75 +++
 .../parser/dialect/JdbcMetadataDialect.java     | 197 +++++++
 .../parser/dialect/MySQLMetadataDialect.java    |  62 +++
 .../parser/dialect/OracleMetadataDialect.java   | 364 +++++++++++++
 modules/schema-import/pom.xml                   |   6 +
 .../schema/parser/DatabaseMetadataParser.java   |  44 +-
 .../apache/ignite/schema/parser/DbColumn.java   |  76 ---
 .../apache/ignite/schema/parser/DbTable.java    |  82 ---
 .../parser/dialect/DB2MetadataDialect.java      |  33 --
 .../parser/dialect/DatabaseMetadataDialect.java |  75 ---
 .../parser/dialect/JdbcMetadataDialect.java     | 197 -------
 .../parser/dialect/MySQLMetadataDialect.java    |  61 ---
 .../parser/dialect/OracleMetadataDialect.java   | 364 -------------
 .../ignite/schema/ui/SchemaImportApp.java       | 526 ++++++++-----------
 .../ignite/cache/websession/WebSession.java     |  14 +-
 .../cache/websession/WebSessionFilter.java      | 499 +++++++++++++++---
 .../cache/websession/WebSessionListener.java    | 117 +----
 .../ignite/cache/websession/WebSessionV2.java   | 405 ++++++++++++++
 .../IgniteWebSessionSelfTestSuite.java          |  35 ++
 .../internal/websession/WebSessionSelfTest.java | 268 ++++++++--
 .../webapp2/META-INF/ignite-webapp-config.xml   | 279 ++++++++++
 modules/web/src/test/webapp2/WEB-INF/web.xml    |  45 ++
 .../cache/IgniteCacheAbstractBenchmark.java     |   5 +
 pom.xml                                         |   2 +
 62 files changed, 3760 insertions(+), 1667 deletions(-)
----------------------------------------------------------------------