Skip to content

Commit

Permalink
Revert "[BACKLOG-17014] Provide key driven Mulit-provider MetastoreLo…
Browse files Browse the repository at this point in the history
…cator"
  • Loading branch information
rmansoor authored Jun 23, 2017
1 parent 6ced942 commit 856a201
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@

package org.pentaho.di.engine.configuration.impl;

import java.util.ArrayList;
import java.util.List;

import org.pentaho.di.core.attributes.metastore.EmbeddedMetaStore;
import org.pentaho.di.engine.configuration.api.RunConfigurationProvider;
import org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfigurationProvider;
import org.pentaho.di.engine.configuration.impl.spark.SparkRunConfigurationProvider;

import java.util.ArrayList;
import java.util.List;

/**
* Created by bmorrise on 5/4/17.
*/
public class EmbeddedRunConfigurationManager {
public static RunConfigurationManager build( EmbeddedMetaStore embeddedMetaStore ) {
DefaultRunConfigurationProvider defaultRunConfigurationProvider =
new DefaultRunConfigurationProvider( ( String s ) -> embeddedMetaStore, null );
new DefaultRunConfigurationProvider( () -> embeddedMetaStore, null );
SparkRunConfigurationProvider sparkRunConfigurationProvider =
new SparkRunConfigurationProvider( ( String s ) -> embeddedMetaStore, null );
new SparkRunConfigurationProvider( () -> embeddedMetaStore, null );

List<RunConfigurationProvider> runConfigurationProviders = new ArrayList<>();
runConfigurationProviders.add( defaultRunConfigurationProvider );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@

package org.pentaho.di.engine.configuration.impl;

import java.util.Collections;
import java.util.List;

import org.pentaho.di.engine.configuration.api.RunConfiguration;
import org.pentaho.di.engine.configuration.api.RunConfigurationFactory;
import org.pentaho.di.metastore.MetaStoreConst;
Expand All @@ -35,6 +32,9 @@
import org.pentaho.metastore.persist.MetaStoreFactory;
import org.pentaho.osgi.metastore.locator.api.MetastoreLocator;

import java.util.Collections;
import java.util.List;

import static org.pentaho.metastore.util.PentahoDefaults.NAMESPACE;

/**
Expand All @@ -55,16 +55,12 @@ private <T extends RunConfiguration> MetaStoreFactory<T> getMetastoreFactory( Cl

protected <T extends RunConfiguration> MetaStoreFactory<T> getMetastoreFactory( Class<T> clazz )
throws MetaStoreException {
IMetaStore metaStore = metastoreLocator.getMetastore( MetastoreLocator.REPOSITORY_PROVIDER_KEY );
if ( metaStore == null ) {
metaStore = metastoreLocator.getMetastore( MetastoreLocator.LOCAL_PROVIDER_KEY );
}
IMetaStore metaStore = metastoreLocator.getMetastore();
return getMetastoreFactory( clazz, metaStore != null ? metaStore : MetaStoreConst.openLocalPentahoMetaStore() );
}

protected abstract <T extends RunConfiguration> MetaStoreFactory<T> getMetaStoreFactory() throws MetaStoreException;

@Override
public boolean delete( String name ) {
try {
getMetaStoreFactory().deleteElement( name );
Expand All @@ -75,7 +71,6 @@ public boolean delete( String name ) {
return true;
}

@Override
public void deleteAll() {
try {
List<String> elementNames = getMetaStoreFactory().getElementNames();
Expand All @@ -88,7 +83,6 @@ public void deleteAll() {

}

@Override
public List<RunConfiguration> load() {
try {
return getMetaStoreFactory().getElements();
Expand All @@ -98,7 +92,6 @@ public List<RunConfiguration> load() {
}


@Override
public RunConfiguration load( String name ) {
try {
return getMetaStoreFactory().loadElement( name );
Expand All @@ -107,7 +100,6 @@ public RunConfiguration load( String name ) {
}
}

@Override
public boolean save( RunConfiguration runConfiguration ) {
try {
getMetaStoreFactory().saveElement( runConfiguration );
Expand All @@ -118,7 +110,6 @@ public boolean save( RunConfiguration runConfiguration ) {
return true;
}

@Override
public List<String> getNames() {
try {
return getMetaStoreFactory().getElementNames();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@

package org.pentaho.di.engine.configuration.impl;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -43,12 +39,14 @@
import org.pentaho.di.engine.configuration.impl.spark.SparkRunConfigurationExecutor;
import org.pentaho.di.engine.configuration.impl.spark.SparkRunConfigurationProvider;
import org.pentaho.metastore.stores.memory.MemoryMetaStore;
import org.pentaho.metastore.stores.xml.XmlMetaStore;
import org.pentaho.osgi.metastore.locator.api.MetastoreLocator;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import static org.junit.Assert.*;

/**
* Created by bmorrise on 3/15/17.
Expand All @@ -65,7 +63,7 @@ public class RunConfigurationManagerTest {
public void setup() throws Exception {

MemoryMetaStore memoryMetaStore = new MemoryMetaStore();
MetastoreLocator metastoreLocator = ( String s ) -> memoryMetaStore;
MetastoreLocator metastoreLocator = () -> memoryMetaStore;

DefaultRunConfigurationProvider defaultRunConfigurationProvider =
new DefaultRunConfigurationProvider( metastoreLocator, defaultRunConfigurationExecutor );
Expand Down Expand Up @@ -176,7 +174,7 @@ public void testGetExecutor() {
@Test
public void testOrdering() {
MemoryMetaStore memoryMetaStore = new MemoryMetaStore();
MetastoreLocator metastoreLocator = ( String s ) -> memoryMetaStore;
MetastoreLocator metastoreLocator = () -> memoryMetaStore;

DefaultRunConfigurationProvider defaultRunConfigurationProvider =
new DefaultRunConfigurationProvider( metastoreLocator, defaultRunConfigurationExecutor );
Expand Down

0 comments on commit 856a201

Please sign in to comment.