@Override protected String getDefaultContainerForAnyNonFilesystem() { return backupContainerFor(super.getDefaultContainerForAnyNonFilesystem()); } }
/** @see PersistencePathResolver */ public static PersistencePathResolver newMainPersistencePathResolver(StringConfigMap brooklynProperties) { return new PersistencePathResolver(brooklynProperties); } /** @see PersistencePathResolver */
@Override public PersistenceBackupPathResolver dir(String dirOrContainer) { super.dir(dirOrContainer); return this; } @Override
/** * @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(); }
/** @see BrooklynServerPaths#getMgmtBaseDir(ManagementContext) */ public static String getMgmtBaseDir(ManagementContext mgmt) { return BrooklynServerPaths.getMgmtBaseDir(mgmt); } /** @see BrooklynServerPaths#getMgmtBaseDir(ManagementContext) */
public String resolve() { String path = dirOrContainer; if (path==null) path = getDefaultPathFromConfig(); if (Strings.isBlank(locationSpec) || "localhost".equals(locationSpec)) { // file system if (Strings.isBlank(path)) path=getDefaultDirForAnyFilesystem(); return resolveAgainstBaseDir(brooklynProperties, path); } else { // obj store if (path==null) path=getDefaultContainerForAnyNonFilesystem(); return path; } }
@Override public PersistenceBackupPathResolver location(String backupLocationSpec) { super.location(backupLocationSpec); return this; } protected boolean isBackupSameLocation() {
/** 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()}.
@Override protected String getDefaultDirForAnyFilesystem() { return backupContainerFor(DEFAULT_PERSISTENCE_CONTAINER_NAME); } @Override
/** @deprecated since 0.7.0 use {@link BrooklynServerPaths#newMainPersistencePathResolver(ManagementContext)} */ @Deprecated public static String getPersistenceDir(StringConfigMap brooklynProperties) { return resolvePersistencePath(null, brooklynProperties, null); }
/** @deprecated since 0.7.0 use {@link BrooklynServerPaths#getBrooklynWebTmpDir(ManagementContext)} */ @Deprecated public static File getBrooklynWebTmpDir(ManagementContext mgmt) { return BrooklynServerPaths.getBrooklynWebTmpDir(mgmt); }
/** @see PersistenceBackupPathResolver */ public static PersistenceBackupPathResolver newBackupPersistencePathResolver(ManagementContext mgmt) { return new PersistenceBackupPathResolver(mgmt.getConfig()); }
/** @deprecated since 0.7.0 use {@link BrooklynServerPaths#newMainPersistencePathResolver(ManagementContext)} */ @Deprecated public static String getPersistenceDir(ManagementContext mgmt) { return getPersistenceDir(mgmt.getConfig()); } /** @deprecated since 0.7.0 use {@link BrooklynServerPaths#newMainPersistencePathResolver(ManagementContext)} */
/** Appends a standard format subpath sub-path to the path returned by {@link #resolve()}. * <p> * For example, this might write to: * <code>~/.brooklyn/brooklyn-persisted-state/backups/2014-11-13-1201-n0deId-promotion-sA1t */ public String resolveWithSubpathFor(ManagementContext managementContext, String label) { return resolveWithSubpath(Time.makeDateSimpleStampString()+"-"+managementContext.getManagementNodeId()+"-"+label+"-"+Identifiers.makeRandomId(4)); } @Override
@Override protected void checkPersistenceContainerNameIsDefault() { String expected = BrooklynServerPaths.newMainPersistencePathResolver(BrooklynProperties.Factory.newEmpty()).location(null).dir(null).resolve(); checkPersistenceContainerNameIs(expected); }
/** @see BrooklynServerPaths#getMgmtBaseDir(ManagementContext) */ public static String getMgmtBaseDir(StringConfigMap brooklynProperties) { return BrooklynServerPaths.getMgmtBaseDir(brooklynProperties); } /** @see BrooklynServerPaths#getMgmtBaseDir(ManagementContext) */
/** @see PersistencePathResolver */ public static PersistencePathResolver newMainPersistencePathResolver(ManagementContext mgmt) { return new PersistencePathResolver(mgmt.getConfig()); }
/** @see BrooklynServerPaths#getMgmtBaseDir(ManagementContext) */ public static String getMgmtBaseDir(Map<String,?> brooklynProperties) { return BrooklynServerPaths.getMgmtBaseDir(brooklynProperties); }
/** Computes the base dir where brooklyn should read and write configuration. * Defaults to <code>~/.brooklyn/</code>. * <p> * Also see other variants of this method if a {@link ManagementContext} is not yet available. */ public static String getMgmtBaseDir(ManagementContext mgmt) { return getMgmtBaseDir(mgmt.getConfig()); }
protected static String resolveAgainstBaseDir(StringConfigMap brooklynProperties, String path) { if (!Os.isAbsolutish(path)) path = Os.mergePaths(getMgmtBaseDir(brooklynProperties), path); return Os.tidyPath(path); }