/** * @param optionalSuppliedValue * An optional value which has been supplied explicitly * @param brooklynProperties * The properties map where the persistence path should be looked up if not supplied, * along with finding the brooklyn.base.dir if needed (using file system persistence * with a relative path) * @param optionalObjectStoreLocationSpec * If a location spec is supplied, this will return a container name suitable for use * with the given object store based on brooklyn.persistence.dir; if null this method * will return a full file system path, relative to the brooklyn.base.dir if the * configured brooklyn.persistence.dir is not absolute * @return The container name or full path for where persist state should be kept * @deprecated since 0.7.0 use {@link BrooklynServerPaths#newMainPersistencePathResolver(ManagementContext)} */ @Deprecated public static String resolvePersistencePath(String optionalSuppliedValue, StringConfigMap brooklynProperties, String optionalObjectStoreLocationSpec) { return BrooklynServerPaths.newMainPersistencePathResolver(brooklynProperties).location(optionalObjectStoreLocationSpec).dir(optionalSuppliedValue).resolve(); }
persistenceLocation = brooklynProperties.getConfig(BrooklynServerConfig.PERSISTENCE_LOCATION_SPEC); persistenceDir = BrooklynServerPaths.newMainPersistencePathResolver(brooklynProperties).location(persistenceLocation).dir(persistenceDir).resolve(); objectStore = BrooklynPersistenceUtils.newPersistenceObjectStore(managementContext, persistenceLocation, persistenceDir, persistMode, highAvailabilityMode);
/** Creates a {@link PersistenceObjectStore} for use with a specified set of modes. */ public static PersistenceObjectStore newPersistenceObjectStore(ManagementContext managementContext, String locationSpecString, String locationContainer, PersistMode persistMode, HighAvailabilityMode highAvailabilityMode) { PersistenceObjectStore destinationObjectStore; locationContainer = BrooklynServerPaths.newMainPersistencePathResolver(managementContext).location(locationSpecString).dir(locationContainer).resolve(); LocationSpec<?> locationSpec = Strings.isBlank(locationSpecString) ? LocationSpec.create(LocalhostMachineProvisioningLocation.class) : managementContext.getLocationRegistry().getLocationSpec(locationSpecString).get(); Location location = managementContext.getLocationManager().createLocation(locationSpec .configure(LocalLocationManager.CREATE_UNMANAGED, true)); if (!(location instanceof LocationWithObjectStore)) { throw new IllegalArgumentException("Destination location "+location+" does not offer a persistent store"); } destinationObjectStore = ((LocationWithObjectStore)location).newPersistenceObjectStore(locationContainer); destinationObjectStore.injectManagementContext(managementContext); destinationObjectStore.prepareForSharedUse(persistMode, highAvailabilityMode); return destinationObjectStore; }
private void initManagementContextAndPersistence(String persistenceDir) { BrooklynProperties brooklynProperties = BrooklynProperties.Factory.builderDefault().build(); brooklynProperties.put(BrooklynServerConfig.MGMT_BASE_DIR.getName(), ""); brooklynProperties.put(BrooklynServerConfig.OSGI_CACHE_DIR, "target/" + BrooklynServerConfig.OSGI_CACHE_DIR.getDefaultValue()); mgmt = LocalManagementContextForTests.newInstance(brooklynProperties); mgmts.add(mgmt); persistenceDir = BrooklynServerPaths.newMainPersistencePathResolver(brooklynProperties).dir(persistenceDir).resolve(); PersistenceObjectStore objectStore = BrooklynPersistenceUtils.newPersistenceObjectStore(mgmt, null, persistenceDir, PersistMode.AUTO, HighAvailabilityMode.HOT_STANDBY); BrooklynMementoPersisterToObjectStore persister = new BrooklynMementoPersisterToObjectStore( objectStore, mgmt); RebindManager rebindManager = mgmt.getRebindManager(); PersistenceExceptionHandler persistenceExceptionHandler = PersistenceExceptionHandlerImpl.builder().build(); ((RebindManagerImpl) rebindManager).setPeriodicPersistPeriod(Duration.ONE_SECOND); rebindManager.setPersister(persister, persistenceExceptionHandler); ((RebindManagerImpl) rebindManager).forcePersistNow(); }
@Override protected void checkPersistenceContainerNameIsDefault() { String expected = BrooklynServerPaths.newMainPersistencePathResolver(BrooklynProperties.Factory.newEmpty()).location(null).dir(null).resolve(); checkPersistenceContainerNameIs(expected); }
/** Appends a sub-path to the path returned by {@link #resolve()} */ public String resolveWithSubpath(String subpath) { return Urls.mergePaths(super.resolve(), subpath); } /** Appends a standard format subpath sub-path to the path returned by {@link #resolve()}.