brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From drigod...@apache.org
Subject [3/5] brooklyn-server git commit: ManagementContext.dataGrid not configurable
Date Mon, 08 May 2017 09:00:22 GMT
ManagementContext.dataGrid not configurable


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/236afd7a
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/236afd7a
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/236afd7a

Branch: refs/heads/master
Commit: 236afd7ab95a27e3a74fd28dc0337250c880ec32
Parents: 3c1a780
Author: Aled Sage <aled.sage@gmail.com>
Authored: Wed May 3 20:53:42 2017 +0100
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Fri May 5 11:23:51 2017 +0100

----------------------------------------------------------------------
 .../internal/AbstractManagementContext.java     | 48 ++------------------
 .../mgmt/internal/LocalManagementContext.java   | 28 +++---------
 2 files changed, 9 insertions(+), 67 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/236afd7a/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/AbstractManagementContext.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/AbstractManagementContext.java
b/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/AbstractManagementContext.java
index eed121d..193f328 100644
--- a/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/AbstractManagementContext.java
+++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/AbstractManagementContext.java
@@ -19,7 +19,6 @@
 package org.apache.brooklyn.core.mgmt.internal;
 
 import static com.google.common.base.Preconditions.checkNotNull;
-import static java.lang.String.format;
 import static org.apache.brooklyn.core.catalog.internal.CatalogUtils.newClassLoadingContextForCatalogItems;
 
 import java.net.URI;
@@ -61,8 +60,6 @@ import org.apache.brooklyn.core.entity.drivers.BasicEntityDriverManager;
 import org.apache.brooklyn.core.entity.drivers.downloads.BasicDownloadsManager;
 import org.apache.brooklyn.core.internal.BrooklynProperties;
 import org.apache.brooklyn.core.internal.storage.BrooklynStorage;
-import org.apache.brooklyn.core.internal.storage.DataGrid;
-import org.apache.brooklyn.core.internal.storage.DataGridFactory;
 import org.apache.brooklyn.core.internal.storage.impl.BrooklynStorageImpl;
 import org.apache.brooklyn.core.internal.storage.impl.inmemory.InMemoryDataGridFactory;
 import org.apache.brooklyn.core.location.BasicLocationRegistry;
@@ -75,7 +72,6 @@ import org.apache.brooklyn.core.mgmt.rebind.RebindManagerImpl;
 import org.apache.brooklyn.core.typereg.BasicBrooklynTypeRegistry;
 import org.apache.brooklyn.util.collections.MutableList;
 import org.apache.brooklyn.util.collections.MutableMap;
-import org.apache.brooklyn.util.core.ClassLoaderUtils;
 import org.apache.brooklyn.util.core.ResourceUtils;
 import org.apache.brooklyn.util.core.config.ConfigBag;
 import org.apache.brooklyn.util.core.task.BasicExecutionContext;
@@ -95,36 +91,6 @@ import com.google.common.collect.ImmutableSet;
 public abstract class AbstractManagementContext implements ManagementContextInternal {
     private static final Logger log = LoggerFactory.getLogger(AbstractManagementContext.class);
 
-    private static DataGridFactory loadDataGridFactory(BrooklynProperties properties) {
-        String clazzName = properties.getFirst(DataGridFactory.class.getName());
-        if(clazzName == null){
-            clazzName = InMemoryDataGridFactory.class.getName();
-        }
-
-        Class<?> clazz;
-        try{
-            //todo: which classloader should we use?
-            clazz = new ClassLoaderUtils(AbstractManagementContext.class).loadClass(clazzName);
-        }catch(ClassNotFoundException e){
-            throw new IllegalStateException(format("Could not load class [%s]",clazzName),e);
-        }
-
-        Object instance;
-        try {
-            instance = clazz.newInstance();
-        } catch (InstantiationException e) {
-            throw new IllegalStateException(format("Could not instantiate class [%s]",clazzName),e);
-        } catch (IllegalAccessException e) {
-            throw new IllegalStateException(format("Could not instantiate class [%s]",clazzName),e);
-        }
-
-        if(!(instance instanceof DataGridFactory)){
-            throw new IllegalStateException(format("Class [%s] not an instantiate of class
[%s]",clazzName, DataGridFactory.class.getName()));
-        }
-
-        return (DataGridFactory)instance;
-    }
-
     static {
         ResourceUtils.addClassLoaderProvider(new Function<Object, BrooklynClassLoadingContext>()
{
             @Override
@@ -194,24 +160,16 @@ public abstract class AbstractManagementContext implements ManagementContextInte
     protected Maybe<URI> uri = Maybe.absent();
     protected CatalogInitialization catalogInitialization;
 
-    public AbstractManagementContext(BrooklynProperties brooklynProperties){
-        this(brooklynProperties, null);
-    }
-
-    public AbstractManagementContext(BrooklynProperties brooklynProperties, DataGridFactory
datagridFactory) {
+    public AbstractManagementContext(BrooklynProperties brooklynProperties) {
         this.configMap = new DeferredBrooklynProperties(brooklynProperties, this);
         this.scratchpad = new BasicScratchpad();
         this.entityDriverManager = new BasicEntityDriverManager();
         this.downloadsManager = BasicDownloadsManager.newDefault(configMap);
-        if (datagridFactory == null) {
-            datagridFactory = loadDataGridFactory(brooklynProperties);
-        }
-        DataGrid datagrid = datagridFactory.newDataGrid(this);
-
+        
         this.catalog = new BasicBrooklynCatalog(this);
         this.typeRegistry = new BasicBrooklynTypeRegistry(this);
         
-        this.storage = new BrooklynStorageImpl(datagrid);
+        this.storage = new BrooklynStorageImpl(new InMemoryDataGridFactory().newDataGrid(this));
         this.rebindManager = new RebindManagerImpl(this); // TODO leaking "this" reference;
yuck
         this.highAvailabilityManager = new HighAvailabilityManagerImpl(this); // TODO leaking
"this" reference; yuck
         

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/236afd7a/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/LocalManagementContext.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/LocalManagementContext.java
b/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/LocalManagementContext.java
index bdb6302..3e3b776 100644
--- a/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/LocalManagementContext.java
+++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/LocalManagementContext.java
@@ -49,7 +49,6 @@ import org.apache.brooklyn.core.entity.drivers.downloads.BasicDownloadsManager;
 import org.apache.brooklyn.core.internal.BrooklynInitialization;
 import org.apache.brooklyn.core.internal.BrooklynProperties;
 import org.apache.brooklyn.core.internal.BrooklynProperties.Factory.Builder;
-import org.apache.brooklyn.core.internal.storage.DataGridFactory;
 import org.apache.brooklyn.core.mgmt.entitlement.Entitlements;
 import org.apache.brooklyn.core.mgmt.ha.OsgiManager;
 import org.apache.brooklyn.core.objs.proxy.InternalEntityFactory;
@@ -150,41 +149,26 @@ public class LocalManagementContext extends AbstractManagementContext
{
         this(BrooklynProperties.Factory.builderDefault());
     }
 
-    public LocalManagementContext(BrooklynProperties brooklynProperties) {
-        this(brooklynProperties, (DataGridFactory)null);
-    }
-
     /**
      * Creates a new LocalManagementContext.
      *
      * @param brooklynProperties the BrooklynProperties.
-     * @param datagridFactory the DataGridFactory to use. If this instance is null, it means
that the system
-     *                        is going to use BrooklynProperties to figure out which instance
to load or otherwise
-     *                        use a default instance.
      */
     @VisibleForTesting
-    public LocalManagementContext(BrooklynProperties brooklynProperties, DataGridFactory
datagridFactory) {
-        this(Builder.fromProperties(brooklynProperties), datagridFactory);
+    public LocalManagementContext(BrooklynProperties brooklynProperties) {
+        this(Builder.fromProperties(brooklynProperties));
     }
     
     public LocalManagementContext(Builder builder) {
-        this(builder, null, null);
-    }
-    
-    public LocalManagementContext(Builder builder, DataGridFactory datagridFactory) {
-        this(builder, null, datagridFactory);
-    }
-
-    public LocalManagementContext(Builder builder, Map<String, Object> brooklynAdditionalProperties)
{
-        this(builder, brooklynAdditionalProperties, null);
+        this(builder, null);
     }
     
     public LocalManagementContext(BrooklynProperties brooklynProperties, Map<String, Object>
brooklynAdditionalProperties) {
-        this(Builder.fromProperties(brooklynProperties), brooklynAdditionalProperties, null);
+        this(Builder.fromProperties(brooklynProperties), brooklynAdditionalProperties);
     }
     
-    public LocalManagementContext(Builder builder, Map<String, Object> brooklynAdditionalProperties,
DataGridFactory datagridFactory) {
-        super(builder.build(), datagridFactory);
+    public LocalManagementContext(Builder builder, Map<String, Object> brooklynAdditionalProperties)
{
+        super(builder.build());
         
         checkNotNull(configMap, "brooklynProperties");
         


Mime
View raw message