@Test public void testLoad_ExistingInstallation() throws Exception { try (ODatabaseDocumentTx db = database.getInstance().connect()) { ClusteredModelVersions versions = new ClusteredModelVersions(); versions.put("clustered", "1.2"); versions.put("local", "99"); entityAdapter.set(db, versions); } PropertiesFile modelProperties = new PropertiesFile(new File(dbFolder, ModelVersionStore.MODEL_PROPERTIES)); modelProperties.put("clustered", "99"); modelProperties.put("local", "2.1"); modelProperties.store(); store.start(); Map<String, String> versions = store.load(); assertThat(versions, hasEntry("clustered", "1.2")); assertThat(versions, hasEntry("local", "2.1")); assertThat(versions.entrySet(), hasSize(2)); }
@Guarded(by = STARTED) public synchronized Map<String, String> load() { Map<String, String> modelVersions = new HashMap<>(); load(modelVersions, upgradeManager.getLocalModels(), localModelVersions::getProperty); load(modelVersions, upgradeManager.getClusteredModels(), clusteredModelVersions::get); return modelVersions; }
ModelVersionStore extends StateGuardLifecycleSupport { @Guarded(by = STARTED) public synchronized Map<String, String> load() { Map<String, String> modelVersions = new HashMap<>(); load(modelVersions, upgradeManager.getLocalModels(), localModelVersions::getProperty); load(modelVersions, upgradeManager.getClusteredModels(), clusteredModelVersions::get); return modelVersions; } }
ModelVersionStore extends StateGuardLifecycleSupport { @Guarded(by = STARTED) public synchronized Map<String, String> load() { Map<String, String> modelVersions = new HashMap<>(); load(modelVersions, upgradeManager.getLocalModels(), localModelVersions::getProperty); load(modelVersions, upgradeManager.getClusteredModels(), clusteredModelVersions::get); return modelVersions; } @Inject  ModelVersionStore(final UpgradeManager upgradeManager,
                           @Named(DatabaseInstanceNames.CONFIG) final Provider<DatabaseInstance> databaseInstance,
                           final ClusteredModelVersionsEntityAdapter entityAdapter,
                           final ApplicationDirectories applicationDirectories); }
ModelVersionStore extends StateGuardLifecycleSupport { @Guarded(by = STARTED) public synchronized Map<String, String> load() { Map<String, String> modelVersions = new HashMap<>(); load(modelVersions, upgradeManager.getLocalModels(), localModelVersions::getProperty); load(modelVersions, upgradeManager.getClusteredModels(), clusteredModelVersions::get); return modelVersions; } @Inject  ModelVersionStore(final UpgradeManager upgradeManager,
                           @Named(DatabaseInstanceNames.CONFIG) final Provider<DatabaseInstance> databaseInstance,
                           final ClusteredModelVersionsEntityAdapter entityAdapter,
                           final ApplicationDirectories applicationDirectories); @Guarded(by = STARTED) boolean isNewInstance(); @Guarded(by = STARTED) synchronized Map<String, String> load(); @Guarded(by = STARTED) synchronized void save(Map<String, String> modelVersions); }
ModelVersionStore extends StateGuardLifecycleSupport { @Guarded(by = STARTED) public synchronized Map<String, String> load() { Map<String, String> modelVersions = new HashMap<>(); load(modelVersions, upgradeManager.getLocalModels(), localModelVersions::getProperty); load(modelVersions, upgradeManager.getClusteredModels(), clusteredModelVersions::get); return modelVersions; } @Inject  ModelVersionStore(final UpgradeManager upgradeManager,
                           @Named(DatabaseInstanceNames.CONFIG) final Provider<DatabaseInstance> databaseInstance,
                           final ClusteredModelVersionsEntityAdapter entityAdapter,
                           final ApplicationDirectories applicationDirectories); @Guarded(by = STARTED) boolean isNewInstance(); @Guarded(by = STARTED) synchronized Map<String, String> load(); @Guarded(by = STARTED) synchronized void save(Map<String, String> modelVersions);  }