@Test public void testGetMetaStoreFactoryEmbeddedMetaStoreSuccess() throws MetaStoreException { NamedClusterManager namedClusterManager = new NamedClusterManager(); MetaStoreFactory<NamedClusterImpl> metaStoreFactoryFirst = null; MetaStoreFactory<NamedClusterImpl> metaStoreFactorySecond = null; EmbeddedMetaStore embeddedMetaStore = mock( EmbeddedMetaStore.class ); metaStoreFactoryFirst = namedClusterManager.getMetaStoreFactory( embeddedMetaStore ); metaStoreFactorySecond = namedClusterManager.getMetaStoreFactory( embeddedMetaStore ); assertNotNull( "metaStoreFactoryFirst is expected to NOT be null", metaStoreFactoryFirst ); assertNotNull( "metaStoreFactorySecond is expected to NOT be null", metaStoreFactoryFirst ); assertEquals( "Called NamedClusterManager.getMetaStoreFactory twice, passing in the same EmbeddedMetaStore. " + "Both calls should return the same instance of MetaStoreFactory", metaStoreFactoryFirst, metaStoreFactorySecond ); }
@VisibleForTesting MetaStoreFactory<NamedClusterImpl> getMetaStoreFactory( IMetaStore metastore ) { MetaStoreFactory<NamedClusterImpl> namedClusterMetaStoreFactory = null; if ( !( metastore instanceof EmbeddedMetaStore ) ) { return new MetaStoreFactory<>( NamedClusterImpl.class, metastore, PentahoDefaults.NAMESPACE ); } namedClusterMetaStoreFactory = factoryMap.computeIfAbsent( metastore, m -> ( new MetaStoreFactory<>( NamedClusterImpl.class, m, NamedClusterEmbedManager.NAMESPACE ) ) ); return namedClusterMetaStoreFactory; }
NamedClusterManager implements NamedClusterService { @VisibleForTesting MetaStoreFactory<NamedClusterImpl> getMetaStoreFactory( IMetaStore metastore ) { MetaStoreFactory<NamedClusterImpl> namedClusterMetaStoreFactory = null; if ( !( metastore instanceof EmbeddedMetaStore ) ) { return new MetaStoreFactory<>( NamedClusterImpl.class, metastore, PentahoDefaults.NAMESPACE ); } namedClusterMetaStoreFactory = factoryMap.computeIfAbsent( metastore, m -> ( new MetaStoreFactory<>( NamedClusterImpl.class, m, NamedClusterEmbedManager.NAMESPACE ) ) ); return namedClusterMetaStoreFactory; } }
NamedClusterManager implements NamedClusterService { @VisibleForTesting MetaStoreFactory<NamedClusterImpl> getMetaStoreFactory( IMetaStore metastore ) { MetaStoreFactory<NamedClusterImpl> namedClusterMetaStoreFactory = null; if ( !( metastore instanceof EmbeddedMetaStore ) ) { return new MetaStoreFactory<>( NamedClusterImpl.class, metastore, PentahoDefaults.NAMESPACE ); } namedClusterMetaStoreFactory = factoryMap.computeIfAbsent( metastore, m -> ( new MetaStoreFactory<>( NamedClusterImpl.class, m, NamedClusterEmbedManager.NAMESPACE ) ) ); return namedClusterMetaStoreFactory; }  }
NamedClusterManager implements NamedClusterService { @VisibleForTesting MetaStoreFactory<NamedClusterImpl> getMetaStoreFactory( IMetaStore metastore ) { MetaStoreFactory<NamedClusterImpl> namedClusterMetaStoreFactory = null; if ( !( metastore instanceof EmbeddedMetaStore ) ) { return new MetaStoreFactory<>( NamedClusterImpl.class, metastore, PentahoDefaults.NAMESPACE ); } namedClusterMetaStoreFactory = factoryMap.computeIfAbsent( metastore, m -> ( new MetaStoreFactory<>( NamedClusterImpl.class, m, NamedClusterEmbedManager.NAMESPACE ) ) ); return namedClusterMetaStoreFactory; }  BundleContext getBundleContext(); void setBundleContext( BundleContext bundleContext ); @Override void close( IMetaStore metastore ); @Override NamedCluster getClusterTemplate(); @Override void setClusterTemplate( NamedCluster clusterTemplate ); @Override void create( NamedCluster namedCluster, IMetaStore metastore ); @Override NamedCluster read( String clusterName, IMetaStore metastore ); @Override void update( NamedCluster namedCluster, IMetaStore metastore ); @Override void delete( String clusterName, IMetaStore metastore ); @Override List<NamedCluster> list( IMetaStore metastore ); @Override List<NamedCluster> list( IMetaStore metastore, List<MetaStoreException> exceptionList ); @Override List<String> listNames( IMetaStore metastore ); @Override boolean contains( String clusterName, IMetaStore metastore ); @Override NamedCluster getNamedClusterByName( String namedClusterName, IMetaStore metastore ); Map<String, Object> getProperties(); @Override NamedCluster getNamedClusterByHost( String hostName, IMetaStore metastore ); @Override void updateNamedClusterTemplate( String hostName, int port, boolean isMapr ); }
NamedClusterManager implements NamedClusterService { @VisibleForTesting MetaStoreFactory<NamedClusterImpl> getMetaStoreFactory( IMetaStore metastore ) { MetaStoreFactory<NamedClusterImpl> namedClusterMetaStoreFactory = null; if ( !( metastore instanceof EmbeddedMetaStore ) ) { return new MetaStoreFactory<>( NamedClusterImpl.class, metastore, PentahoDefaults.NAMESPACE ); } namedClusterMetaStoreFactory = factoryMap.computeIfAbsent( metastore, m -> ( new MetaStoreFactory<>( NamedClusterImpl.class, m, NamedClusterEmbedManager.NAMESPACE ) ) ); return namedClusterMetaStoreFactory; }  BundleContext getBundleContext(); void setBundleContext( BundleContext bundleContext ); @Override void close( IMetaStore metastore ); @Override NamedCluster getClusterTemplate(); @Override void setClusterTemplate( NamedCluster clusterTemplate ); @Override void create( NamedCluster namedCluster, IMetaStore metastore ); @Override NamedCluster read( String clusterName, IMetaStore metastore ); @Override void update( NamedCluster namedCluster, IMetaStore metastore ); @Override void delete( String clusterName, IMetaStore metastore ); @Override List<NamedCluster> list( IMetaStore metastore ); @Override List<NamedCluster> list( IMetaStore metastore, List<MetaStoreException> exceptionList ); @Override List<String> listNames( IMetaStore metastore ); @Override boolean contains( String clusterName, IMetaStore metastore ); @Override NamedCluster getNamedClusterByName( String namedClusterName, IMetaStore metastore ); Map<String, Object> getProperties(); @Override NamedCluster getNamedClusterByHost( String hostName, IMetaStore metastore ); @Override void updateNamedClusterTemplate( String hostName, int port, boolean isMapr ); static final String BIG_DATA_SLAVE_METASTORE_DIR; }