ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject [37/50] [abbrv] incubator-ignite git commit: ignite-classname Marshaller load classname properties by plugin name.
Date Fri, 12 Jun 2015 14:25:27 GMT
ignite-classname Marshaller load classname properties by plugin name.


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

Branch: refs/heads/ignite-484-1
Commit: a515ec91d23910b3a4d686f5d53f279cdb6e4cb0
Parents: b087aca
Author: nikolay_tikhonov <ntikhonov@gridgain.com>
Authored: Fri Jun 12 12:49:53 2015 +0300
Committer: nikolay_tikhonov <ntikhonov@gridgain.com>
Committed: Fri Jun 12 12:49:53 2015 +0300

----------------------------------------------------------------------
 .../ignite/internal/GridKernalContextImpl.java   |  5 +++--
 .../org/apache/ignite/internal/IgniteKernal.java | 19 +++++++++++++++++--
 .../internal/MarshallerContextAdapter.java       | 18 ++++++++++++++++--
 .../ignite/internal/MarshallerContextImpl.java   |  7 ++++++-
 .../optimized/GridClientOptimizedMarshaller.java |  5 +++++
 .../processors/plugin/IgnitePluginProcessor.java | 16 ++--------------
 .../marshaller/MarshallerContextTestImpl.java    | 18 ++++++++++++++++++
 .../junits/GridTestKernalContext.java            |  1 +
 8 files changed, 68 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a515ec91/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
index f921d49..7b07593 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
@@ -340,7 +340,8 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
         ExecutorService p2pExecSvc,
         ExecutorService mgmtExecSvc,
         ExecutorService igfsExecSvc,
-        ExecutorService restExecSvc) throws IgniteCheckedException {
+        ExecutorService restExecSvc,
+        List<PluginProvider> plugins) throws IgniteCheckedException {
         assert grid != null;
         assert cfg != null;
         assert gw != null;
@@ -357,7 +358,7 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
         this.igfsExecSvc = igfsExecSvc;
         this.restExecSvc = restExecSvc;
 
-        marshCtx = new MarshallerContextImpl();
+        marshCtx = new MarshallerContextImpl(plugins);
 
         try {
             spring = SPRING.create(false);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a515ec91/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 db238c8..9b2ae27 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
@@ -77,6 +77,7 @@ import javax.management.*;
 import java.io.*;
 import java.lang.management.*;
 import java.lang.reflect.*;
+import java.security.*;
 import java.text.*;
 import java.util.*;
 import java.util.concurrent.*;
@@ -629,6 +630,19 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable
{
         // Ack configuration.
         ackSpis();
 
+        List<PluginProvider> plugins = AccessController.doPrivileged(new PrivilegedAction<List<PluginProvider>>()
{
+            @Override public List<PluginProvider> run() {
+                List<PluginProvider> providers = new ArrayList<>();
+
+                ServiceLoader<PluginProvider> ldr = ServiceLoader.load(PluginProvider.class);
+
+                for (PluginProvider provider : ldr)
+                    providers.add(provider);
+
+                return providers;
+            }
+        });
+
         // Spin out SPIs & managers.
         try {
             ctx = new GridKernalContextImpl(log,
@@ -642,7 +656,8 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable
{
                 p2pExecSvc,
                 mgmtExecSvc,
                 igfsExecSvc,
-                restExecSvc);
+                restExecSvc,
+                plugins);
 
             cfg.getMarshaller().setContext(ctx.marshallerContext());
 
@@ -678,7 +693,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable
{
 
             addHelper(IGFS_HELPER.create(F.isEmpty(cfg.getFileSystemConfiguration())));
 
-            startProcessor(new IgnitePluginProcessor(ctx, cfg));
+            startProcessor(new IgnitePluginProcessor(ctx, cfg, plugins));
 
             verChecker = null;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a515ec91/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 2ec9825..6ef7713 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.*;
 import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.marshaller.*;
+import org.apache.ignite.plugin.*;
+import org.jetbrains.annotations.*;
 import org.jsr166.*;
 
 import java.io.*;
@@ -46,8 +48,10 @@ public abstract class MarshallerContextAdapter implements MarshallerContext
{
 
     /**
      * Initializes context.
+     *
+     * @param plugins Plugins.
      */
-    public MarshallerContextAdapter() {
+    public MarshallerContextAdapter(@Nullable List<PluginProvider> plugins) {
         try {
             ClassLoader ldr = U.gridClassLoader();
 
@@ -76,6 +80,16 @@ public abstract class MarshallerContextAdapter implements MarshallerContext
{
             checkHasClassName(GridDhtPartitionFullMap.class.getName(), ldr, CLS_NAMES_FILE);
             checkHasClassName(GridDhtPartitionMap.class.getName(), ldr, CLS_NAMES_FILE);
             checkHasClassName(HashMap.class.getName(), ldr, JDK_CLS_NAMES_FILE);
+
+            if (plugins != null && !plugins.isEmpty()) {
+                for (PluginProvider plugin : plugins) {
+                    URL pluginClsNames = ldr.getResource("META-INF/" + plugin.name().toLowerCase()
+                        + ".classnames.properties");
+
+                    if (pluginClsNames != null)
+                        processResource(pluginClsNames);
+                }
+            }
         }
         catch (IOException e) {
             throw new IllegalStateException("Failed to initialize marshaller context.", e);
@@ -87,7 +101,7 @@ public abstract class MarshallerContextAdapter implements MarshallerContext
{
      * @param ldr Class loader used to get properties file.
      * @param fileName File name.
      */
-    private void checkHasClassName(String clsName, ClassLoader ldr, String fileName) {
+    public void checkHasClassName(String clsName, ClassLoader ldr, String fileName) {
         if (!map.containsKey(clsName.hashCode()))
             throw new IgniteException("Failed to read class name from class names properties
file. " +
                 "Make sure class names properties file packaged with ignite binaries is not
corrupted " +

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a515ec91/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 4b0251d..7940e95 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
@@ -20,9 +20,11 @@ package org.apache.ignite.internal;
 import org.apache.ignite.*;
 import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.plugin.*;
 
 import javax.cache.event.*;
 import java.io.*;
+import java.util.*;
 import java.util.concurrent.*;
 
 /**
@@ -45,9 +47,12 @@ public class MarshallerContextImpl extends MarshallerContextAdapter {
     private int failedCnt;
 
     /**
+     * @param plugins Plugins.
      * @throws IgniteCheckedException In case of error.
      */
-    public MarshallerContextImpl() throws IgniteCheckedException {
+    public MarshallerContextImpl(List<PluginProvider> plugins) throws IgniteCheckedException
{
+        super(plugins);
+
         workDir = U.resolveWorkDirectory("marshaller", false);
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a515ec91/modules/core/src/main/java/org/apache/ignite/internal/client/marshaller/optimized/GridClientOptimizedMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/marshaller/optimized/GridClientOptimizedMarshaller.java
b/modules/core/src/main/java/org/apache/ignite/internal/client/marshaller/optimized/GridClientOptimizedMarshaller.java
index 254962a..7c2bd2f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/marshaller/optimized/GridClientOptimizedMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/client/marshaller/optimized/GridClientOptimizedMarshaller.java
@@ -100,6 +100,11 @@ public class GridClientOptimizedMarshaller implements GridClientMarshaller
{
     /**
      */
     private static class ClientMarshallerContext extends MarshallerContextAdapter {
+        /** */
+        public ClientMarshallerContext() {
+            super(null);
+        }
+
         /** {@inheritDoc} */
         @Override protected boolean registerClassName(int id, String clsName) {
             throw new UnsupportedOperationException(clsName);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a515ec91/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/IgnitePluginProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/IgnitePluginProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/IgnitePluginProcessor.java
index 8f2cc51..ecc6924 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/IgnitePluginProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/IgnitePluginProcessor.java
@@ -48,26 +48,14 @@ public class IgnitePluginProcessor extends GridProcessorAdapter {
      *
      * @param ctx Kernal context.
      * @param cfg Ignite configuration.
+     * @param providers Plugin providers.
      */
     @SuppressWarnings("TypeMayBeWeakened")
-    public IgnitePluginProcessor(GridKernalContext ctx, IgniteConfiguration cfg) {
+    public IgnitePluginProcessor(GridKernalContext ctx, IgniteConfiguration cfg, List<PluginProvider>
providers) {
         super(ctx);
 
         ExtensionRegistryImpl registry = new ExtensionRegistryImpl();
 
-        List<PluginProvider> providers = AccessController.doPrivileged(new PrivilegedAction<List<PluginProvider>>()
{
-            @Override public List<PluginProvider> run() {
-                List<PluginProvider> providers = new ArrayList<>();
-
-                ServiceLoader<PluginProvider> ldr = ServiceLoader.load(PluginProvider.class);
-
-                for (PluginProvider provider : ldr)
-                    providers.add(provider);
-
-                return providers;
-            }
-        });
-
         for (PluginProvider provider : providers) {
             GridPluginContext pluginCtx = new GridPluginContext(ctx, cfg);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a515ec91/modules/core/src/test/java/org/apache/ignite/marshaller/MarshallerContextTestImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/marshaller/MarshallerContextTestImpl.java
b/modules/core/src/test/java/org/apache/ignite/marshaller/MarshallerContextTestImpl.java
index 4164fda..00d1f43 100644
--- a/modules/core/src/test/java/org/apache/ignite/marshaller/MarshallerContextTestImpl.java
+++ b/modules/core/src/test/java/org/apache/ignite/marshaller/MarshallerContextTestImpl.java
@@ -19,8 +19,10 @@ package org.apache.ignite.marshaller;
 
 import org.apache.ignite.*;
 import org.apache.ignite.internal.*;
+import org.apache.ignite.plugin.*;
 import org.jsr166.*;
 
+import java.util.*;
 import java.util.concurrent.*;
 
 /**
@@ -30,6 +32,22 @@ public class MarshallerContextTestImpl extends MarshallerContextAdapter
{
     /** */
     private final static ConcurrentMap<Integer, String> map = new ConcurrentHashMap8<>();
 
+    /**
+     * Initializes context.
+     *
+     * @param plugins Plugins.
+     */
+    public MarshallerContextTestImpl(List<PluginProvider> plugins) {
+        super(plugins);
+    }
+
+    /**
+     * Initializes context.
+     */
+    public MarshallerContextTestImpl() {
+        super(null);
+    }
+
     /** {@inheritDoc} */
     @Override protected boolean registerClassName(int id, String clsName) throws IgniteCheckedException
{
         String oldClsName = map.putIfAbsent(id, clsName);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a515ec91/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java
b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java
index 6b7a7f9..37948d9 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java
@@ -45,6 +45,7 @@ public class GridTestKernalContext extends GridKernalContextImpl {
             null,
             null,
             null,
+            null,
             null);
 
         GridTestUtils.setFieldValue(grid(), "cfg", config());


Mime
View raw message