ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vkuliche...@apache.org
Subject [5/7] incubator-ignite git commit: IGNITE-141 - Marshallers refactoring
Date Sat, 07 Mar 2015 00:44:30 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/9d63a88d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/9d63a88d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/9d63a88d

Branch: refs/heads/ignite-141
Commit: 9d63a88d8c052b7abdcf14f9c05ba36d9b25f992
Parents: cc32cce
Author: Valentin Kulichenko <vkulichenko@gridgain.com>
Authored: Fri Mar 6 15:10:31 2015 -0800
Committer: Valentin Kulichenko <vkulichenko@gridgain.com>
Committed: Fri Mar 6 15:10:31 2015 -0800

----------------------------------------------------------------------
 .../ignite/internal/ClassesGenerator.java       |   60 +-
 .../internal/MarshallerContextAdapter.java      |   47 +-
 .../ignite/internal/MarshallerContextImpl.java  |    4 +-
 .../ignite/internal/classnames-jdk.properties   |  325 ----
 .../ignite/internal/classnames.properties       | 1547 ------------------
 .../GridClientOptimizedMarshaller.java          |    3 +-
 .../ignite/internal/util/IgniteUtils.java       |   30 -
 .../optimized/OptimizedClassDescriptor.java     |    2 +-
 .../META-INF/classnames-jdk.properties          |  325 ++++
 .../resources/META-INF/classnames.properties    | 1547 ++++++++++++++++++
 .../marshaller/MarshallerContextTestImpl.java   |   41 +-
 .../config/benchmark-multicast.properties       |   24 +-
 12 files changed, 1955 insertions(+), 2000 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9d63a88d/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 4d06dea..6a03f0a 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,10 +30,10 @@ import java.util.jar.*;
  */
 public class ClassesGenerator {
     /** */
-    private static final String DFLT_BASE_PATH = U.getIgniteHome() + "/modules/core/src/main/java";
+    private static final String FILE_PATH = "META-INF/classnames.properties";
 
     /** */
-    private static final String FILE_PATH = "org/apache/ignite/internal/classnames.properties";
+    private static final String DFLT_BASE_PATH = U.getIgniteHome() + "/modules/core/src/main/resources";
 
     /** */
     private static final String HEADER =
@@ -55,7 +55,7 @@ public class ClassesGenerator {
         "#";
 
     /** */
-    private static final String[] INCLUDED_PACKAGES = {
+    private static final String[] PACKAGES = {
         "org.apache.ignite",
         "org.jdk8.backport",
         "org.pcollections",
@@ -69,26 +69,9 @@ public class ClassesGenerator {
     public static void main(String[] args) throws Exception {
         String basePath = args.length > 0 ? args[0] : DFLT_BASE_PATH;
 
-        File file = new File(basePath, FILE_PATH);
+        ClassesGenerator gen = new ClassesGenerator(basePath, HEADER, PACKAGES);
 
-        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)
-            out.println(cls.getName());
+        gen.generate();
     }
 
     /** */
@@ -104,11 +87,30 @@ public class ClassesGenerator {
     /** */
     private final Collection<String> errs = new ArrayList<>();
 
+    /** */
+    private final String basePath;
+
+    /** */
+    private final String header;
+
+    /** */
+    private final String[] packages;
+
+    /**
+     * @param basePath Base file path.
+     * @param header Header.
+     * @param packages Included packages.
+     */
+    public ClassesGenerator(String basePath, String header, String[] packages) {
+        this.basePath = basePath;
+        this.header = header;
+        this.packages = packages;
+    }
+
     /**
      * @throws Exception In case of error.
-     * @return Classes.
      */
-    private Collection<Class> generate() throws Exception {
+    public void generate() throws Exception {
         System.out.println("Generating classnames.properties...");
 
         for (URL url : ldr.getURLs())
@@ -123,7 +125,13 @@ public class ClassesGenerator {
             throw new Exception(sb.toString().trim());
         }
 
-        return classes;
+        PrintStream out = new PrintStream(new File(basePath, FILE_PATH));
+
+        out.println(header);
+        out.println();
+
+        for (Class cls : classes)
+            out.println(cls.getName());
     }
 
     /**
@@ -183,7 +191,7 @@ public class ClassesGenerator {
 
         boolean included = false;
 
-        for (String pkg : INCLUDED_PACKAGES) {
+        for (String pkg : packages) {
             if (clsName.startsWith(pkg)) {
                 included = true;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9d63a88d/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextAdapter.java
index 1fc6c5a..5e71a17 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextAdapter.java
@@ -21,6 +21,8 @@ import org.apache.ignite.marshaller.*;
 import org.jdk8.backport.*;
 
 import java.io.*;
+import java.net.*;
+import java.util.*;
 import java.util.concurrent.*;
 
 /**
@@ -28,10 +30,10 @@ import java.util.concurrent.*;
  */
 public abstract class MarshallerContextAdapter implements MarshallerContext {
     /** */
-    private static final String[] CLS_NAMES_FILES = {
-        "org/apache/ignite/internal/classnames.properties",
-        "org/apache/ignite/internal/classnames-jdk.properties"
-    };
+    private static final String CLS_NAMES_FILE = "META-INF/classnames.properties";
+
+    /** */
+    private static final String JDK_CLS_NAMES_FILE = "META-INF/classnames-jdk.properties";
 
     /** */
     protected final ConcurrentMap<Integer, String> clsNameById = new ConcurrentHashMap8<>();
@@ -43,23 +45,36 @@ public abstract class MarshallerContextAdapter implements MarshallerContext
{
         try {
             ClassLoader ldr = getClass().getClassLoader();
 
-            for (String file : CLS_NAMES_FILES) {
-                BufferedReader rdr = new BufferedReader(new InputStreamReader(ldr.getResourceAsStream(file)));
-
-                String line;
-
-                while ((line = rdr.readLine()) != null) {
-                    if (line.isEmpty() || line.startsWith("#"))
-                        continue;
+            Enumeration<URL> urls = ldr.getResources(CLS_NAMES_FILE);
 
-                    String clsName = line.trim();
+            while (urls.hasMoreElements())
+                processResource(urls.nextElement());
 
-                    clsNameById.put(clsName.hashCode(), clsName);
-                }
-            }
+            processResource(ldr.getResource(JDK_CLS_NAMES_FILE));
         }
         catch (IOException e) {
             throw new IllegalStateException("Failed to initialize marshaller context.", e);
         }
     }
+
+    /**
+     * @param url Resource URL.
+     * @throws IOException In case of error.
+     */
+    private void processResource(URL url) throws IOException {
+        try (InputStream in = url.openStream()) {
+            BufferedReader rdr = new BufferedReader(new InputStreamReader(in));
+
+            String line;
+
+            while ((line = rdr.readLine()) != null) {
+                if (line.isEmpty() || line.startsWith("#"))
+                    continue;
+
+                String clsName = line.trim();
+
+                clsNameById.put(clsName.hashCode(), clsName);
+            }
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9d63a88d/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java
index 4a254fb..5c47235 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java
@@ -47,6 +47,8 @@ public class MarshallerContextImpl extends MarshallerContextAdapter {
     /** {@inheritDoc} */
     @Override public void registerClass(int id, Class cls) {
         if (!clsNameById.containsKey(id)) {
+            U.debug("REG: " + cls.getName());
+
             try {
                 if (cache == null)
                     U.awaitQuiet(latch);
@@ -89,6 +91,6 @@ public class MarshallerContextImpl extends MarshallerContextAdapter {
             }
         }
 
-        return U.forName(clsName, ldr);
+        return Class.forName(clsName, false, ldr);
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9d63a88d/modules/core/src/main/java/org/apache/ignite/internal/classnames-jdk.properties
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/classnames-jdk.properties
b/modules/core/src/main/java/org/apache/ignite/internal/classnames-jdk.properties
deleted file mode 100644
index 0cae0f7..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/classnames-jdk.properties
+++ /dev/null
@@ -1,325 +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.
-#
-
-[B
-[C
-[D
-[F
-[I
-[J
-[S
-[Z
-[Ljava.lang.Object;
-java.lang.AbstractMethodError
-java.lang.ArithmeticException
-java.lang.ArrayIndexOutOfBoundsException
-java.lang.ArrayStoreException
-java.lang.AssertionError
-java.lang.Boolean
-java.lang.BootstrapMethodError
-java.lang.Byte
-java.lang.Character
-java.lang.Character$UnicodeScript
-java.lang.Class
-java.lang.ClassCastException
-java.lang.ClassCircularityError
-java.lang.ClassFormatError
-java.lang.ClassNotFoundException
-java.lang.CloneNotSupportedException
-java.lang.Double
-java.lang.EnumConstantNotPresentException
-java.lang.Error
-java.lang.Exception
-java.lang.ExceptionInInitializerError
-java.lang.Float
-java.lang.IllegalAccessError
-java.lang.IllegalAccessException
-java.lang.IllegalArgumentException
-java.lang.IllegalMonitorStateException
-java.lang.IllegalStateException
-java.lang.IllegalThreadStateException
-java.lang.IncompatibleClassChangeError
-java.lang.IndexOutOfBoundsException
-java.lang.InstantiationError
-java.lang.InstantiationException
-java.lang.Integer
-java.lang.InternalError
-java.lang.InterruptedException
-java.lang.LinkageError
-java.lang.Long
-java.lang.NegativeArraySizeException
-java.lang.NoClassDefFoundError
-java.lang.NoSuchFieldError
-java.lang.NoSuchFieldException
-java.lang.NoSuchMethodError
-java.lang.NoSuchMethodException
-java.lang.NullPointerException
-java.lang.NumberFormatException
-java.lang.OutOfMemoryError
-java.lang.ProcessBuilder$Redirect$Type
-java.lang.ReflectiveOperationException
-java.lang.RuntimeException
-java.lang.RuntimePermission
-java.lang.SecurityException
-java.lang.Short
-java.lang.StackOverflowError
-java.lang.StackTraceElement
-java.lang.String
-java.lang.String$CaseInsensitiveComparator
-java.lang.StringBuffer
-java.lang.StringBuilder
-java.lang.StringIndexOutOfBoundsException
-java.lang.Thread$State
-java.lang.ThreadDeath
-java.lang.Throwable
-java.lang.TypeNotPresentException
-java.lang.UNIXProcess$LaunchMechanism
-java.lang.UnknownError
-java.lang.UnsatisfiedLinkError
-java.lang.UnsupportedClassVersionError
-java.lang.UnsupportedOperationException
-java.lang.VerifyError
-java.lang.annotation.AnnotationFormatError
-java.lang.annotation.AnnotationTypeMismatchException
-java.lang.annotation.ElementType
-java.lang.annotation.IncompleteAnnotationException
-java.lang.annotation.RetentionPolicy
-java.lang.instrument.IllegalClassFormatException
-java.lang.instrument.UnmodifiableClassException
-java.lang.invoke.MethodType
-java.lang.invoke.WrongMethodTypeException
-java.lang.management.ManagementPermission
-java.lang.management.MemoryType
-java.lang.management.PlatformComponent
-java.lang.reflect.GenericSignatureFormatError
-java.lang.reflect.InvocationTargetException
-java.lang.reflect.MalformedParameterizedTypeException
-java.lang.reflect.Proxy
-java.lang.reflect.ReflectPermission
-java.lang.reflect.UndeclaredThrowableException
-java.net.Authenticator$RequestorType
-java.net.BindException
-java.net.ConnectException
-java.net.HttpRetryException
-java.net.Inet4Address
-java.net.Inet6Address
-java.net.InetAddress
-java.net.InetAddress$Cache$Type
-java.net.InetSocketAddress
-java.net.MalformedURLException
-java.net.NetPermission
-java.net.NoRouteToHostException
-java.net.PortUnreachableException
-java.net.ProtocolException
-java.net.Proxy$Type
-java.net.SocketException
-java.net.SocketPermission
-java.net.SocketPermissionCollection
-java.net.SocketTimeoutException
-java.net.StandardProtocolFamily
-java.net.URI
-java.net.URISyntaxException
-java.net.URL
-java.net.UnknownHostException
-java.net.UnknownServiceException
-java.util.AbstractMap$SimpleEntry
-java.util.AbstractMap$SimpleImmutableEntry
-java.util.ArrayDeque
-java.util.ArrayList
-java.util.Arrays$ArrayList
-java.util.BitSet
-java.util.Collections$AsLIFOQueue
-java.util.Collections$CheckedCollection
-java.util.Collections$CheckedList
-java.util.Collections$CheckedMap
-java.util.Collections$CheckedRandomAccessList
-java.util.Collections$CheckedSet
-java.util.Collections$CheckedSortedMap
-java.util.Collections$CheckedSortedSet
-java.util.Collections$CopiesList
-java.util.Collections$EmptyList
-java.util.Collections$EmptyMap
-java.util.Collections$EmptySet
-java.util.Collections$ReverseComparator
-java.util.Collections$ReverseComparator2
-java.util.Collections$SetFromMap
-java.util.Collections$SingletonList
-java.util.Collections$SingletonMap
-java.util.Collections$SingletonSet
-java.util.Collections$SynchronizedCollection
-java.util.Collections$SynchronizedList
-java.util.Collections$SynchronizedMap
-java.util.Collections$SynchronizedRandomAccessList
-java.util.Collections$SynchronizedSet
-java.util.Collections$SynchronizedSortedMap
-java.util.Collections$SynchronizedSortedSet
-java.util.Collections$UnmodifiableCollection
-java.util.Collections$UnmodifiableList
-java.util.Collections$UnmodifiableMap
-java.util.Collections$UnmodifiableMap$UnmodifiableEntrySet
-java.util.Collections$UnmodifiableRandomAccessList
-java.util.Collections$UnmodifiableSet
-java.util.Collections$UnmodifiableSortedMap
-java.util.Collections$UnmodifiableSortedSet
-java.util.ConcurrentModificationException
-java.util.Currency
-java.util.Date
-java.util.DuplicateFormatFlagsException
-java.util.EmptyStackException
-java.util.EnumMap
-java.util.EnumSet$SerializationProxy
-java.util.EventObject
-java.util.FormatFlagsConversionMismatchException
-java.util.Formatter$BigDecimalLayoutForm
-java.util.FormatterClosedException
-java.util.GregorianCalendar
-java.util.HashMap
-java.util.HashSet
-java.util.Hashtable
-java.util.IdentityHashMap
-java.util.IllegalFormatCodePointException
-java.util.IllegalFormatConversionException
-java.util.IllegalFormatException
-java.util.IllegalFormatFlagsException
-java.util.IllegalFormatPrecisionException
-java.util.IllegalFormatWidthException
-java.util.IllformedLocaleException
-java.util.InputMismatchException
-java.util.InvalidPropertiesFormatException
-java.util.JapaneseImperialCalendar
-java.util.JumboEnumSet
-java.util.LinkedHashMap
-java.util.LinkedHashSet
-java.util.LinkedList
-java.util.Locale
-java.util.Locale$Category
-java.util.MissingFormatArgumentException
-java.util.MissingFormatWidthException
-java.util.MissingResourceException
-java.util.NoSuchElementException
-java.util.PriorityQueue
-java.util.Properties
-java.util.PropertyPermission
-java.util.PropertyPermissionCollection
-java.util.Random
-java.util.RegularEnumSet
-java.util.ServiceConfigurationError
-java.util.SimpleTimeZone
-java.util.Stack
-java.util.TooManyListenersException
-java.util.TreeMap
-java.util.TreeMap$AscendingSubMap
-java.util.TreeMap$DescendingSubMap
-java.util.TreeMap$SubMap
-java.util.TreeSet
-java.util.UUID
-java.util.UnknownFormatConversionException
-java.util.UnknownFormatFlagsException
-java.util.Vector
-java.util.concurrent.ArrayBlockingQueue
-java.util.concurrent.BrokenBarrierException
-java.util.concurrent.CancellationException
-java.util.concurrent.ConcurrentHashMap
-java.util.concurrent.ConcurrentHashMap$Segment
-java.util.concurrent.ConcurrentHashMap$WriteThroughEntry
-java.util.concurrent.ConcurrentLinkedDeque
-java.util.concurrent.ConcurrentLinkedQueue
-java.util.concurrent.ConcurrentSkipListMap
-java.util.concurrent.ConcurrentSkipListMap$SubMap
-java.util.concurrent.ConcurrentSkipListSet
-java.util.concurrent.CopyOnWriteArrayList
-java.util.concurrent.CopyOnWriteArraySet
-java.util.concurrent.CountDownLatch$Sync
-java.util.concurrent.Exchanger$Node
-java.util.concurrent.Exchanger$Slot
-java.util.concurrent.ExecutionException
-java.util.concurrent.ForkJoinPool$InvokeAll
-java.util.concurrent.ForkJoinTask$AdaptedCallable
-java.util.concurrent.ForkJoinTask$AdaptedRunnable
-java.util.concurrent.LinkedBlockingDeque
-java.util.concurrent.LinkedBlockingQueue
-java.util.concurrent.LinkedTransferQueue
-java.util.concurrent.PriorityBlockingQueue
-java.util.concurrent.RejectedExecutionException
-java.util.concurrent.Semaphore
-java.util.concurrent.Semaphore$FairSync
-java.util.concurrent.Semaphore$NonfairSync
-java.util.concurrent.SynchronousQueue
-java.util.concurrent.SynchronousQueue$FifoWaitQueue
-java.util.concurrent.SynchronousQueue$LifoWaitQueue
-java.util.concurrent.SynchronousQueue$WaitQueue
-java.util.concurrent.ThreadLocalRandom
-java.util.concurrent.ThreadPoolExecutor$Worker
-java.util.concurrent.TimeUnit$1
-java.util.concurrent.TimeUnit$2
-java.util.concurrent.TimeUnit$3
-java.util.concurrent.TimeUnit$4
-java.util.concurrent.TimeUnit$5
-java.util.concurrent.TimeUnit$6
-java.util.concurrent.TimeUnit$7
-java.util.concurrent.TimeoutException
-java.util.concurrent.atomic.AtomicBoolean
-java.util.concurrent.atomic.AtomicInteger
-java.util.concurrent.atomic.AtomicIntegerArray
-java.util.concurrent.atomic.AtomicLong
-java.util.concurrent.atomic.AtomicLongArray
-java.util.concurrent.atomic.AtomicReference
-java.util.concurrent.atomic.AtomicReferenceArray
-java.util.concurrent.locks.AbstractQueuedLongSynchronizer$ConditionObject
-java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject
-java.util.concurrent.locks.ReentrantLock
-java.util.concurrent.locks.ReentrantLock$FairSync
-java.util.concurrent.locks.ReentrantLock$NonfairSync
-java.util.concurrent.locks.ReentrantReadWriteLock
-java.util.concurrent.locks.ReentrantReadWriteLock$FairSync
-java.util.concurrent.locks.ReentrantReadWriteLock$NonfairSync
-java.util.concurrent.locks.ReentrantReadWriteLock$ReadLock
-java.util.concurrent.locks.ReentrantReadWriteLock$WriteLock
-java.util.jar.JarException
-java.util.jar.JarVerifier$VerifierCodeSource
-java.util.logging.Level
-java.util.logging.LogRecord
-java.util.logging.LoggingPermission
-java.util.prefs.AbstractPreferences$NodeAddedEvent
-java.util.prefs.AbstractPreferences$NodeRemovedEvent
-java.util.prefs.BackingStoreException
-java.util.prefs.InvalidPreferencesFormatException
-java.util.prefs.NodeChangeEvent
-java.util.prefs.PreferenceChangeEvent
-java.util.regex.Pattern
-java.util.regex.PatternSyntaxException
-java.util.regex.UnicodeProp$1
-java.util.regex.UnicodeProp$10
-java.util.regex.UnicodeProp$11
-java.util.regex.UnicodeProp$12
-java.util.regex.UnicodeProp$13
-java.util.regex.UnicodeProp$14
-java.util.regex.UnicodeProp$15
-java.util.regex.UnicodeProp$16
-java.util.regex.UnicodeProp$17
-java.util.regex.UnicodeProp$18
-java.util.regex.UnicodeProp$2
-java.util.regex.UnicodeProp$3
-java.util.regex.UnicodeProp$4
-java.util.regex.UnicodeProp$5
-java.util.regex.UnicodeProp$6
-java.util.regex.UnicodeProp$7
-java.util.regex.UnicodeProp$8
-java.util.regex.UnicodeProp$9
-java.util.zip.DataFormatException
-java.util.zip.ZipError
-java.util.zip.ZipException


Mime
View raw message