ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vkuliche...@apache.org
Subject [12/50] [abbrv] incubator-ignite git commit: IGNITE-141 - Marshallers refactoring
Date Wed, 11 Mar 2015 00:56:40 GMT
IGNITE-141 - Marshallers refactoring


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

Branch: refs/heads/sprint-2
Commit: 20284adac13871df0c0a0e9797a629f24a6ce199
Parents: 1e83a26
Author: Valentin Kulichenko <vkulichenko@gridgain.com>
Authored: Thu Mar 5 12:42:54 2015 -0800
Committer: Valentin Kulichenko <vkulichenko@gridgain.com>
Committed: Thu Mar 5 12:42:54 2015 -0800

----------------------------------------------------------------------
 modules/core/pom.xml                            |  26 ++++
 .../cache/CachePartialUpdateException.java      |   3 +
 .../configuration/CacheConfiguration.java       |   3 +
 .../ignite/internal/ClassesGenerator.java       | 145 ++++++++++++++-----
 .../ignite/internal/classnames.properties       |  15 +-
 .../continuous/CacheContinuousQueryEvent.java   |   3 +
 .../continuous/CacheContinuousQueryManager.java |   3 +
 .../datastructures/DataStructuresProcessor.java |   6 +
 .../visor/cache/VisorCacheClearTask.java        |   6 +
 9 files changed, 163 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/20284ada/modules/core/pom.xml
----------------------------------------------------------------------
diff --git a/modules/core/pom.xml b/modules/core/pom.xml
index 316b1ae..b5c3de0 100644
--- a/modules/core/pom.xml
+++ b/modules/core/pom.xml
@@ -163,7 +163,33 @@
                         </goals>
                     </execution>
                 </executions>
+                <configuration>
+                    <excludes>
+                        <exclude>**/ClassesGenerator*</exclude>
+                    </excludes>
+                </configuration>
             </plugin>
+
+            <!--<plugin>-->
+                <!--<groupId>org.codehaus.mojo</groupId>-->
+                <!--<artifactId>exec-maven-plugin</artifactId>-->
+                <!--<version>1.3.2</version>-->
+                <!--<executions>-->
+                    <!--<execution>-->
+                        <!--<phase>process-classes</phase>-->
+                        <!--<goals>-->
+                            <!--<goal>java</goal>-->
+                        <!--</goals>-->
+                        <!--<configuration>-->
+                            <!--<mainClass>org.apache.ignite.internal.ClassesGenerator</mainClass>-->
+                            <!--<arguments>-->
+                                <!--<argument>${project.basedir}/target/classes</argument>-->
+                            <!--</arguments>-->
+                            <!--<classpathScope>compile</classpathScope>-->
+                        <!--</configuration>-->
+                    <!--</execution>-->
+                <!--</executions>-->
+            <!--</plugin>-->
         </plugins>
     </build>
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/20284ada/modules/core/src/main/java/org/apache/ignite/cache/CachePartialUpdateException.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CachePartialUpdateException.java
b/modules/core/src/main/java/org/apache/ignite/cache/CachePartialUpdateException.java
index cab473f..50b26a8 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/CachePartialUpdateException.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/CachePartialUpdateException.java
@@ -27,6 +27,9 @@ import java.util.*;
  * One can get list of keys for which update failed with method {@link #failedKeys()}.
  */
 public class CachePartialUpdateException extends CacheException {
+    /** */
+    private static final long serialVersionUID = 0L;
+
     /**
      * @param e Cause.
      */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/20284ada/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
index 224176f..d7e38a7 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
@@ -43,6 +43,9 @@ import java.util.*;
  */
 @SuppressWarnings("RedundantFieldInitialization")
 public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
+    /** */
+    private static final long serialVersionUID = 0L;
+
     /** Default size of preload thread pool. */
     public static final int DFLT_PRELOAD_THREAD_POOL_SIZE = 2;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/20284ada/modules/core/src/main/java/org/apache/ignite/internal/ClassesGenerator.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/ClassesGenerator.java b/modules/core/src/main/java/org/apache/ignite/internal/ClassesGenerator.java
index eec4076..641a10f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/ClassesGenerator.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/ClassesGenerator.java
@@ -30,7 +30,10 @@ import java.util.jar.*;
  */
 public class ClassesGenerator {
     /** */
-    private static final String PATH = "modules/core/src/main/java/org/apache/ignite/internal/classnames.properties";
+    private static final String DFLT_BASE_PATH = U.getIgniteHome() + "/modules/core/src/main/java";
+
+    /** */
+    private static final String FILE_PATH = "org/apache/ignite/internal/classnames.properties";
 
     /** */
     private static final String HEADER =
@@ -67,63 +70,106 @@ public class ClassesGenerator {
      * @throws Exception In case of error.
      */
     public static void main(String[] args) throws Exception {
-        PrintStream out = new PrintStream(new File(U.getIgniteHome(), PATH));
+        String basePath = args.length > 0 ? args[0] : DFLT_BASE_PATH;
+
+        File file = new File(basePath, FILE_PATH);
+
+        ClassesGenerator gen = new ClassesGenerator();
+
+        write(file, gen.generate());
+    }
+
+    /**
+     * @param file File.
+     * @param classes Classes.
+     * @throws Exception In case of error.
+     */
+    private static void write(File file, Collection<Class> classes) throws Exception
{
+        PrintStream out = new PrintStream(file);
 
         out.println(HEADER);
         out.println();
 
-        for (Class cls : classes())
+        for (Class cls : classes)
             out.println(cls.getName());
     }
 
+    /** */
+    private final URLClassLoader ldr = (URLClassLoader)getClass().getClassLoader();
+
+    /** */
+    private final Collection<Class> classes = new TreeSet<>(new Comparator<Class>()
{
+        @Override public int compare(Class c1, Class c2) {
+            return c1.getName().compareTo(c2.getName());
+        }
+    });
+
+    /** */
+    private final Collection<String> errs = new ArrayList<>();
+
     /**
-     * @return Classes.
      * @throws Exception In case of error.
+     * @return Classes.
      */
-    private static Collection<Class> classes() throws Exception {
-        Collection<Class> col = new TreeSet<>(new Comparator<Class>() {
-            @Override public int compare(Class c1, Class c2) {
-                return c1.getName().compareTo(c2.getName());
-            }
-        });
+    private Collection<Class> generate() throws Exception {
+        System.out.println("Generating classnames.properties...");
 
-        URLClassLoader ldr = (URLClassLoader)ClassesGenerator.class.getClassLoader();
+        URLClassLoader ldr0 = ldr;
 
-        for (URL url : ldr.getURLs()) {
-            File file = new File(url.toURI());
+        while (ldr0 != null) {
+            for (URL url : ldr0.getURLs())
+                processUrl(url);
 
-            int prefixLen = file.getPath().length() + 1;
+            ldr0 = (URLClassLoader)ldr0.getParent();
+        }
 
-            processFile(file, ldr, prefixLen, col);
+        if (!errs.isEmpty()) {
+            StringBuilder sb = new StringBuilder("Failed to generate classnames.properties
due to errors:\n");
+
+            for (String err : errs)
+                sb.append("    ").append(err).append('\n');
+
+            throw new Exception(sb.toString().trim());
         }
 
-        col.add(byte[].class);
-        col.add(short[].class);
-        col.add(int[].class);
-        col.add(long[].class);
-        col.add(float[].class);
-        col.add(double[].class);
-        col.add(char[].class);
-        col.add(boolean[].class);
-        col.add(Object[].class);
-
-        return col;
+        classes.add(byte[].class);
+        classes.add(short[].class);
+        classes.add(int[].class);
+        classes.add(long[].class);
+        classes.add(float[].class);
+        classes.add(double[].class);
+        classes.add(char[].class);
+        classes.add(boolean[].class);
+        classes.add(Object[].class);
+
+        return classes;
+    }
+
+    /**
+     * @param url URL.
+     * @throws Exception In case of error.
+     */
+    private void processUrl(URL url) throws Exception {
+        System.out.println("    Processing URL: " + url);
+
+        File file = new File(url.toURI());
+
+        int prefixLen = file.getPath().length() + 1;
+
+        processFile(file, prefixLen);
     }
 
     /**
      * @param file File.
-     * @param ldr Class loader.
-     * @param prefixLen Prefix length.
-     * @param col Classes.
      * @throws Exception In case of error.
      */
-    private static void processFile(File file, ClassLoader ldr, int prefixLen, Collection<Class>
col) throws Exception {
+    private void processFile(File file, int prefixLen) throws Exception {
         if (!file.exists())
             throw new FileNotFoundException("File doesn't exist: " + file);
 
         if (file.isDirectory()) {
             for (File f : file.listFiles())
-                processFile(f, ldr, prefixLen, col);
+                processFile(f, prefixLen);
         }
         else {
             assert file.isFile();
@@ -136,23 +182,21 @@ public class ClassesGenerator {
 
                     while ((entry = jin.getNextJarEntry()) != null) {
                         if (!entry.isDirectory() && entry.getName().toLowerCase().endsWith(".class"))
-                            processClassFile(entry.getName(), ldr, 0, col);
+                            processClassFile(entry.getName(), 0);
                     }
                 }
             }
             else if (path.toLowerCase().endsWith(".class"))
-                processClassFile(path, ldr, prefixLen, col);
+                processClassFile(path, prefixLen);
         }
     }
 
     /**
      * @param path File path.
-     * @param ldr Class loader.
      * @param prefixLen Prefix length.
-     * @param col Classes.
      * @throws Exception In case of error.
      */
-    private static void processClassFile(String path, ClassLoader ldr, int prefixLen, Collection<Class>
col)
+    private void processClassFile(String path, int prefixLen)
         throws Exception {
         String clsName = path.substring(prefixLen, path.length() - 6).replace(File.separatorChar,
'.');
 
@@ -169,9 +213,32 @@ public class ClassesGenerator {
         if (included) {
             Class<?> cls = Class.forName(clsName, false, ldr);
 
-            if (!cls.isInterface() && !Modifier.isAbstract(cls.getModifiers()) &&
-                Serializable.class.isAssignableFrom(cls))
-                col.add((Class)cls);
+            boolean isSerializable = !cls.isInterface() && !Modifier.isAbstract(cls.getModifiers())
&&
+                Serializable.class.isAssignableFrom(cls);
+
+            if (isSerializable) {
+                if (!cls.isEnum() && !cls.getSimpleName().isEmpty() && cls.getName().startsWith("org.apache.ignite"))
{
+                    try {
+                        Field field = cls.getDeclaredField("serialVersionUID");
+
+                        if (!field.getType().equals(long.class))
+                            errs.add("serialVersionUID field is not long in class: " + cls.getName());
+
+                        int mod = field.getModifiers();
+
+                        if (!Modifier.isStatic(mod))
+                            errs.add("serialVersionUID field is not static in class: " +
cls.getName());
+
+                        if (!Modifier.isFinal(mod))
+                            errs.add("serialVersionUID field is not final in class: " + cls.getName());
+                    }
+                    catch (NoSuchFieldException ignored) {
+                        errs.add("No serialVersionUID field in class: " + cls.getName());
+                    }
+                }
+
+                classes.add((Class)cls);
+            }
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/20284ada/modules/core/src/main/java/org/apache/ignite/internal/classnames.properties
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/classnames.properties b/modules/core/src/main/java/org/apache/ignite/internal/classnames.properties
index 4849e53..64b93ad 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/classnames.properties
+++ b/modules/core/src/main/java/org/apache/ignite/internal/classnames.properties
@@ -460,7 +460,6 @@ org.apache.ignite.internal.IgniteInterruptedCheckedException
 org.apache.ignite.internal.IgniteKernal
 org.apache.ignite.internal.IgniteKernal$1
 org.apache.ignite.internal.IgniteKernal$5
-org.apache.ignite.internal.IgniteKernal$6
 org.apache.ignite.internal.IgniteMessagingImpl
 org.apache.ignite.internal.IgniteSchedulerImpl
 org.apache.ignite.internal.IgniteServicesImpl
@@ -1152,13 +1151,13 @@ org.apache.ignite.internal.processors.datastructures.GridCacheSetProxy
 org.apache.ignite.internal.processors.datastructures.GridSetQueryPredicate
 org.apache.ignite.internal.processors.dr.GridDrDataLoadCacheUpdater
 org.apache.ignite.internal.processors.dr.GridDrType
-org.apache.ignite.internal.processors.hadoop.GridHadoopFileBlock
-org.apache.ignite.internal.processors.hadoop.GridHadoopJobId
-org.apache.ignite.internal.processors.hadoop.GridHadoopJobPhase
-org.apache.ignite.internal.processors.hadoop.GridHadoopJobProperty
-org.apache.ignite.internal.processors.hadoop.GridHadoopJobStatus
-org.apache.ignite.internal.processors.hadoop.GridHadoopTaskInfo
-org.apache.ignite.internal.processors.hadoop.GridHadoopTaskType
+org.apache.ignite.internal.processors.hadoop.HadoopFileBlock
+org.apache.ignite.internal.processors.hadoop.HadoopJobId
+org.apache.ignite.internal.processors.hadoop.HadoopJobPhase
+org.apache.ignite.internal.processors.hadoop.HadoopJobProperty
+org.apache.ignite.internal.processors.hadoop.HadoopJobStatus
+org.apache.ignite.internal.processors.hadoop.HadoopTaskInfo
+org.apache.ignite.internal.processors.hadoop.HadoopTaskType
 org.apache.ignite.internal.processors.igfs.IgfsAckMessage
 org.apache.ignite.internal.processors.igfs.IgfsAttributes
 org.apache.ignite.internal.processors.igfs.IgfsBlockKey

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/20284ada/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEvent.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEvent.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEvent.java
index c90ae34..2e284cc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEvent.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEvent.java
@@ -27,6 +27,9 @@ import javax.cache.event.*;
  * Continuous query event.
  */
 class CacheContinuousQueryEvent<K, V> extends CacheEntryEvent<K, V> {
+    /** */
+    private static final long serialVersionUID = 0L;
+
     /** Entry. */
     @GridToStringExclude
     private final CacheContinuousQueryEntry<K, V> e;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/20284ada/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
index 0643c0e..7f3d8ff 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
@@ -679,6 +679,9 @@ public class CacheContinuousQueryManager<K, V> extends GridCacheManagerAdapter<K
      */
     private static class JCacheQueryRemoteFilter<K, V> implements CacheEntryEventFilter<K,
V>, Externalizable {
         /** */
+        private static final long serialVersionUID = 0L;
+
+        /** */
         private CacheEntryEventFilter<K, V> impl;
 
         /** */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/20284ada/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
index 6ae7188..a81928f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
@@ -1262,6 +1262,9 @@ public final class DataStructuresProcessor extends GridProcessorAdapter
{
      */
     static class CollectionInfo implements Externalizable {
         /** */
+        private static final long serialVersionUID = 0L;
+
+        /** */
         private boolean collocated;
 
         /** */
@@ -1306,6 +1309,9 @@ public final class DataStructuresProcessor extends GridProcessorAdapter
{
      */
     static class QueueInfo extends CollectionInfo {
         /** */
+        private static final long serialVersionUID = 0L;
+
+        /** */
         private int cap;
 
         /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/20284ada/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTask.java
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTask.java
index f341a04..0b4c82c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTask.java
@@ -137,6 +137,9 @@ public class VisorCacheClearTask extends VisorOneNodeTask<String, IgniteBiTuple<
     @GridInternal
     private static class VisorCacheSizeCallable implements IgniteCallable<Integer>
{
         /** */
+        private static final long serialVersionUID = 0L;
+
+        /** */
         private final IgniteCache cache;
 
         /**
@@ -158,6 +161,9 @@ public class VisorCacheClearTask extends VisorOneNodeTask<String, IgniteBiTuple<
     @GridInternal
     private static class VisorCacheClearCallable implements IgniteCallable<Integer>
{
         /** */
+        private static final long serialVersionUID = 0L;
+
+        /** */
         private final IgniteCache cache;
 
         /**


Mime
View raw message