MondrianCatalogHelper implements IAclAwareMondrianCatalogService { public synchronized void setDataSourcesConfig( final String dataSourcesConfig ) { this.dataSourcesConfig = dataSourcesConfig; } @VisibleForTesting @Deprecated  MondrianCatalogHelper( IAclNodeHelper aclHelper );  MondrianCatalogHelper();  MondrianCatalogHelper( boolean useLegacyDbName ); @Deprecated static MondrianCatalogHelper getInstance(); @Override synchronized void reInit( final IPentahoSession pentahoSession ); String generateInMemoryDatasourcesXml( IUnifiedRepository unifiedRepository ); synchronized String getDataSourcesConfig(); synchronized void setDataSourcesConfig( final String dataSourcesConfig ); @Override List<MondrianCatalog> listCatalogs( final IPentahoSession pentahoSession, final boolean jndiOnly ); @Override synchronized void addCatalog( final MondrianCatalog catalog, final boolean overwrite,
                                       final IPentahoSession pentahoSession ); @Override void addCatalog( InputStream inputStream, MondrianCatalog catalog, boolean overwriteInRepossitory,
                          IPentahoSession session ); @Override synchronized void addCatalog( InputStream schemaInputStream, final MondrianCatalog catalog,
                                       final boolean overwrite, RepositoryFileAcl acl,
                                       final IPentahoSession pentahoSession ); synchronized void setAclHelper( IAclNodeHelper helper ); @Override void setAclFor( String catalogName, RepositoryFileAcl acl ); @Override RepositoryFileAcl getAclFor( String catalogName ); void importSchema( File mondrianFile, String databaseConnection, String parameters ); @Override MondrianCatalog getCatalog( final String context, final IPentahoSession pentahoSession ); MondrianCatalogComplementInfo getCatalogComplementInfoMap( String name ); @Override MondrianSchema loadMondrianSchema( final String solutionLocation, final IPentahoSession pentahoSession ); boolean isUseSchemaNameAsCatalogName(); void setUseSchemaNameAsCatalogName( final boolean useSchemaNameAsCatalogName ); static int addToCatalog( String baseUrl, boolean enableXmla, String schemaSolutionPath,
                                  IPentahoSession session, String jndiName, boolean overwrite ); @Override void removeCatalog( final String catalogName, final IPentahoSession pentahoSession ); static final String MONDRIAN_DATASOURCE_FOLDER; static String MONDRIAN_CATALOG_CACHE_REGION; }
@Test public void testInconsistentSynchronizationOfDataSourcesConfig() throws Exception { MondrianCatalogHelperTestable mondrianCatalogHelper = new MondrianCatalogHelperTestable(); AtomicReference<Boolean> failed = new AtomicReference<>(); failed.set( Boolean.FALSE ); ExecutorService executorService = Executors.newFixedThreadPool( 2 ); executorService.execute( () -> { System.out.println( "validateSynchronizedDataSourcesConfig()" ); try { mondrianCatalogHelper.validateSynchronizedDataSourcesConfig(); } catch ( InterruptedException e ) { e.printStackTrace(); failed.set( Boolean.TRUE ); } catch ( Exception e ) { e.printStackTrace(); failed.set( Boolean.TRUE ); } }); executorService.execute( () -> { for( int i = 0 ; i < 25 ; i++ ) { try { Thread.sleep( 10 ); } catch ( InterruptedException e ) { e.printStackTrace(); failed.set( Boolean.TRUE ); } mondrianCatalogHelper.setDataSourcesConfig( "b" ); } System.out.println( "setDataSourcesConfig() - Finished" ); }); executorService.shutdown(); if( executorService.awaitTermination( 5000, TimeUnit.MILLISECONDS) ) { if( failed.get() ) { System.out.println( "Failed multi-thread execution" ); Assert.fail(); } return; } System.out.println( "Failed by timeout"); Assert.fail(); }