This is an automated email from the ASF dual-hosted git repository.
nreich pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push:
new f4433fc GEODE-4404: Move BackupWriter creation (#1521)
f4433fc is described below
commit f4433fcc6ce2d28568b7bf08b9b936ad08d3d1bf
Author: Nick Reich <[email protected]>
AuthorDate: Wed Feb 28 09:06:46 2018 -0800
GEODE-4404: Move BackupWriter creation (#1521)
* to facilitate future creation of backup plugins, the BackupWriter is
created
using generic information passed from gfsh
---
.../java/org/apache/geode/admin/BackupStatus.java | 20 ++++-
.../admin/internal/AdminDistributedSystemImpl.java | 66 +++++++++++++++--
.../org/apache/geode/internal/SystemAdmin.java | 5 +-
.../cache/backup/AbstractBackupWriterConfig.java | 51 +++++++++++++
.../cache/backup/BackupDataStoreHelper.java | 6 +-
.../geode/internal/cache/backup/BackupService.java | 9 +--
.../geode/internal/cache/backup/BackupTask.java | 37 +---------
.../geode/internal/cache/backup/BackupUtil.java | 38 ++++++++--
.../internal/cache/backup/BackupWriterFactory.java | 60 +++++++++++++++
.../backup/FileSystemBackupWriterConfig.java} | 35 ++++++---
.../geode/internal/cache/backup/PrepareBackup.java | 12 +--
.../cache/backup/PrepareBackupFactory.java | 20 +++--
.../cache/backup/PrepareBackupOperation.java | 14 ++--
.../cache/backup/PrepareBackupRequest.java | 19 ++---
.../org/apache/geode/management/BackupStatus.java | 21 +-----
.../internal/beans/DistributedSystemBridge.java | 71 ++++--------------
.../internal/beans/MemberMBeanBridge.java | 63 ----------------
.../cli/commands/BackupDiskStoreCommand.java | 5 +-
.../backup/AbstractBackupWriterConfigTest.java | 86 ++++++++++++++++++++++
.../cache/backup/BackupDistributedTest.java | 14 +++-
.../cache/backup/BackupIntegrationTest.java | 23 +++---
.../backup/BackupPrepareAndFinishMsgDUnitTest.java | 7 +-
.../internal/cache/backup/BackupServiceTest.java | 5 +-
.../cache/backup/BackupWriterFactoryTest.java | 63 ++++++++++++++++
.../backup/FileSystemBackupWriterConfigTest.java | 74 +++++++++++++++++++
.../backup/IncrementalBackupDistributedTest.java | 29 ++------
.../cache/backup/PrepareBackupFactoryTest.java | 10 +--
.../cache/backup/PrepareBackupOperationTest.java | 14 ++--
.../cache/backup/PrepareBackupRequestTest.java | 17 +++--
.../PersistentPartitionedRegionTestBase.java | 4 +-
.../beans/DistributedSystemBridgeJUnitTest.java | 2 +-
.../apache/geode/codeAnalysis/excludedClasses.txt | 3 +-
.../codeAnalysis/sanctionedDataSerializables.txt | 4 +-
33 files changed, 593 insertions(+), 314 deletions(-)
diff --git a/geode-core/src/main/java/org/apache/geode/admin/BackupStatus.java
b/geode-core/src/main/java/org/apache/geode/admin/BackupStatus.java
index 11740d9..8592ab6 100644
--- a/geode-core/src/main/java/org/apache/geode/admin/BackupStatus.java
+++ b/geode-core/src/main/java/org/apache/geode/admin/BackupStatus.java
@@ -14,6 +14,12 @@
*/
package org.apache.geode.admin;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.geode.cache.persistence.PersistentID;
+import org.apache.geode.distributed.DistributedMember;
+
/**
* The status of a backup operation, returned by
* {@link AdminDistributedSystem#backupAllMembers(java.io.File,java.io.File)}.
@@ -23,5 +29,17 @@ package org.apache.geode.admin;
*
"{@docRoot}/org/apache/geode/management/package-summary.html">management</a></code>
* package instead
*/
-public interface BackupStatus extends org.apache.geode.management.BackupStatus
{
+public interface BackupStatus {
+ /**
+ * Returns a map of disk stores that were successfully backed up. The key is
an online distributed
+ * member. The value is the set of disk stores on that distributed member.
+ */
+ Map<DistributedMember, Set<PersistentID>> getBackedUpDiskStores();
+
+ /**
+ * Returns the set of disk stores that were known to be offline at the time
of the backup. These
+ * members were not backed up. If this set is not empty the backup may not
contain a complete
+ * snapshot of any partitioned regions in the distributed system.
+ */
+ Set<PersistentID> getOfflineDiskStores();
}
diff --git
a/geode-core/src/main/java/org/apache/geode/admin/internal/AdminDistributedSystemImpl.java
b/geode-core/src/main/java/org/apache/geode/admin/internal/AdminDistributedSystemImpl.java
index 82bcc97..72719a9 100755
---
a/geode-core/src/main/java/org/apache/geode/admin/internal/AdminDistributedSystemImpl.java
+++
b/geode-core/src/main/java/org/apache/geode/admin/internal/AdminDistributedSystemImpl.java
@@ -14,30 +14,80 @@
*/
package org.apache.geode.admin.internal;
-import static org.apache.geode.distributed.ConfigurationProperties.*;
+import static org.apache.geode.distributed.ConfigurationProperties.DISABLE_TCP;
+import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
+import static
org.apache.geode.distributed.ConfigurationProperties.MCAST_ADDRESS;
+import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
import java.io.File;
import java.io.IOException;
import java.net.InetAddress;
-import java.util.*;
-import java.util.concurrent.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.UUID;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CancellationException;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.FutureTask;
import org.apache.logging.log4j.Logger;
import org.apache.geode.CancelException;
import org.apache.geode.SystemFailure;
-import org.apache.geode.admin.*;
+import org.apache.geode.admin.AdminException;
import org.apache.geode.admin.Alert;
+import org.apache.geode.admin.AlertLevel;
import org.apache.geode.admin.AlertListener;
+import org.apache.geode.admin.BackupStatus;
+import org.apache.geode.admin.CacheServer;
+import org.apache.geode.admin.CacheServerConfig;
+import org.apache.geode.admin.CacheVm;
+import org.apache.geode.admin.ConfigurationParameter;
+import org.apache.geode.admin.DistributedSystemConfig;
+import org.apache.geode.admin.DistributionLocator;
+import org.apache.geode.admin.DistributionLocatorConfig;
+import org.apache.geode.admin.GemFireHealth;
+import org.apache.geode.admin.ManagedEntity;
+import org.apache.geode.admin.ManagedEntityConfig;
+import org.apache.geode.admin.OperationCancelledException;
+import org.apache.geode.admin.RuntimeAdminException;
+import org.apache.geode.admin.SystemMember;
+import org.apache.geode.admin.SystemMemberCacheListener;
+import org.apache.geode.admin.SystemMembershipEvent;
+import org.apache.geode.admin.SystemMembershipListener;
import org.apache.geode.cache.persistence.PersistentID;
import org.apache.geode.distributed.DistributedMember;
import org.apache.geode.distributed.FutureCancelledException;
-import org.apache.geode.distributed.internal.*;
+import org.apache.geode.distributed.internal.ClusterDistributionManager;
+import org.apache.geode.distributed.internal.DistributionManager;
+import org.apache.geode.distributed.internal.InternalDistributedSystem;
+import org.apache.geode.distributed.internal.InternalLocator;
import
org.apache.geode.distributed.internal.membership.InternalDistributedMember;
import org.apache.geode.internal.Assert;
import org.apache.geode.internal.Banner;
-import org.apache.geode.internal.admin.*;
-import org.apache.geode.internal.admin.remote.*;
+import org.apache.geode.internal.admin.ApplicationVM;
+import org.apache.geode.internal.admin.GemFireVM;
+import org.apache.geode.internal.admin.GfManagerAgent;
+import org.apache.geode.internal.admin.GfManagerAgentConfig;
+import org.apache.geode.internal.admin.GfManagerAgentFactory;
+import org.apache.geode.internal.admin.SSLConfig;
+import org.apache.geode.internal.admin.remote.CompactRequest;
+import org.apache.geode.internal.admin.remote.DistributionLocatorId;
+import org.apache.geode.internal.admin.remote.MissingPersistentIDsRequest;
+import org.apache.geode.internal.admin.remote.PrepareRevokePersistentIDRequest;
+import org.apache.geode.internal.admin.remote.RemoteApplicationVM;
+import org.apache.geode.internal.admin.remote.RemoteTransportConfig;
+import org.apache.geode.internal.admin.remote.RevokePersistentIDRequest;
+import org.apache.geode.internal.admin.remote.ShutdownAllRequest;
import org.apache.geode.internal.cache.backup.BackupUtil;
import org.apache.geode.internal.cache.persistence.PersistentMemberPattern;
import org.apache.geode.internal.i18n.LocalizedStrings;
@@ -2313,7 +2363,7 @@ public class AdminDistributedSystemImpl implements
org.apache.geode.admin.AdminD
public static BackupStatus backupAllMembers(DistributionManager dm, File
targetDir,
File baselineDir) throws AdminException {
- return new BackupStatusImpl(BackupUtil.backupAllMembers(dm, targetDir,
baselineDir));
+ return BackupUtil.backupAllMembers(dm, targetDir.toString(),
baselineDir.toString());
}
public Map<DistributedMember, Set<PersistentID>> compactAllDiskStores()
throws AdminException {
diff --git
a/geode-core/src/main/java/org/apache/geode/internal/SystemAdmin.java
b/geode-core/src/main/java/org/apache/geode/internal/SystemAdmin.java
index d6660b2..336320e 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/SystemAdmin.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/SystemAdmin.java
@@ -619,9 +619,8 @@ public class SystemAdmin {
InternalDistributedSystem ads = getAdminCnx();
// Baseline directory should be null if it was not provided on the command
line
- BackupStatus status =
- BackupUtil.backupAllMembers(ads.getDistributionManager(), new
File(targetDir),
- (SystemAdmin.baselineDir == null ? null : new
File(SystemAdmin.baselineDir)));
+ BackupStatus status =
BackupUtil.backupAllMembers(ads.getDistributionManager(), targetDir,
+ SystemAdmin.baselineDir);
boolean incomplete = !status.getOfflineDiskStores().isEmpty();
diff --git
a/geode-core/src/main/java/org/apache/geode/internal/cache/backup/AbstractBackupWriterConfig.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/backup/AbstractBackupWriterConfig.java
new file mode 100644
index 0000000..f572bc7
--- /dev/null
+++
b/geode-core/src/main/java/org/apache/geode/internal/cache/backup/AbstractBackupWriterConfig.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional
information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache
License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express
+ * or implied. See the License for the specific language governing permissions
and limitations under
+ * the License.
+ */
+package org.apache.geode.internal.cache.backup;
+
+import java.util.Properties;
+
+import org.apache.commons.lang.StringUtils;
+
+abstract class AbstractBackupWriterConfig {
+
+ static final String TIMESTAMP = "TIMESTAMP";
+ static final String TYPE = "TYPE";
+
+ private final Properties properties;
+
+ AbstractBackupWriterConfig(Properties properties) {
+ this.properties = properties;
+ }
+
+ String getTimestamp() {
+ String value = properties.getProperty(TIMESTAMP);
+ if (StringUtils.isBlank(value)) {
+ throw new IllegalStateException("Timestamp is missing");
+ }
+ return value;
+ }
+
+ String getBackupType() {
+ String value = properties.getProperty(TYPE);
+ if (StringUtils.isBlank(value)) {
+ throw new IllegalStateException("Type is missing");
+ }
+ return value;
+ }
+
+ Properties getProperties() {
+ return properties;
+ }
+}
diff --git
a/geode-core/src/main/java/org/apache/geode/internal/cache/backup/BackupDataStoreHelper.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/backup/BackupDataStoreHelper.java
index 0d03047..89e1511 100644
---
a/geode-core/src/main/java/org/apache/geode/internal/cache/backup/BackupDataStoreHelper.java
+++
b/geode-core/src/main/java/org/apache/geode/internal/cache/backup/BackupDataStoreHelper.java
@@ -14,9 +14,9 @@
*/
package org.apache.geode.internal.cache.backup;
-import java.io.File;
import java.util.Collections;
import java.util.Map;
+import java.util.Properties;
import java.util.Set;
import org.apache.geode.cache.persistence.PersistentID;
@@ -37,7 +37,7 @@ public class BackupDataStoreHelper {
@SuppressWarnings("rawtypes")
public static BackupDataStoreResult backupAllMembers(DistributionManager dm,
Set recipients,
- File targetDir, File baselineDir) {
+ Properties properties) {
new FlushToDiskOperation(dm, dm.getId(), dm.getCache(), recipients,
flushToDiskFactory).send();
boolean abort = true;
@@ -45,7 +45,7 @@ public class BackupDataStoreHelper {
Map<DistributedMember, Set<PersistentID>> existingDataStores;
try {
existingDataStores = new PrepareBackupOperation(dm, dm.getId(),
dm.getCache(), recipients,
- prepareBackupFactory, targetDir, baselineDir).send();
+ prepareBackupFactory, properties).send();
abort = false;
} finally {
if (abort) {
diff --git
a/geode-core/src/main/java/org/apache/geode/internal/cache/backup/BackupService.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/backup/BackupService.java
index 6098f33..3857fd0 100644
---
a/geode-core/src/main/java/org/apache/geode/internal/cache/backup/BackupService.java
+++
b/geode-core/src/main/java/org/apache/geode/internal/cache/backup/BackupService.java
@@ -14,7 +14,6 @@
*/
package org.apache.geode.internal.cache.backup;
-import java.io.File;
import java.io.IOException;
import java.util.HashSet;
import java.util.List;
@@ -40,7 +39,7 @@ import org.apache.geode.internal.logging.LogService;
import org.apache.geode.internal.logging.LoggingThreadGroup;
public class BackupService {
- Logger logger = LogService.getLogger();
+ private static final Logger logger = LogService.getLogger();
public static final String DATA_STORES_TEMPORARY_DIRECTORY = "backupTemp_";
private final ExecutorService executor;
@@ -71,10 +70,10 @@ public class BackupService {
return Executors.newSingleThreadExecutor(threadFactory);
}
- public HashSet<PersistentID> prepareBackup(InternalDistributedMember sender,
File targetDir,
- File baselineDir) throws IOException, InterruptedException {
+ public HashSet<PersistentID> prepareBackup(InternalDistributedMember sender,
BackupWriter writer)
+ throws IOException, InterruptedException {
validateRequestingAdmin(sender);
- BackupTask backupTask = new BackupTask(cache, targetDir, baselineDir);
+ BackupTask backupTask = new BackupTask(cache, writer);
if (!currentTask.compareAndSet(null, backupTask)) {
throw new IOException("Another backup already in progress");
}
diff --git
a/geode-core/src/main/java/org/apache/geode/internal/cache/backup/BackupTask.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/backup/BackupTask.java
index 27ae581..781e76a 100644
---
a/geode-core/src/main/java/org/apache/geode/internal/cache/backup/BackupTask.java
+++
b/geode-core/src/main/java/org/apache/geode/internal/cache/backup/BackupTask.java
@@ -14,9 +14,7 @@
*/
package org.apache.geode.internal.cache.backup;
-import java.io.File;
import java.io.IOException;
-import java.nio.file.Path;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@@ -28,7 +26,6 @@ import org.apache.logging.log4j.Logger;
import org.apache.geode.InternalGemFireError;
import org.apache.geode.cache.DiskStore;
import org.apache.geode.cache.persistence.PersistentID;
-import
org.apache.geode.distributed.internal.membership.InternalDistributedMember;
import org.apache.geode.internal.cache.DiskStoreImpl;
import org.apache.geode.internal.cache.InternalCache;
import org.apache.geode.internal.cache.Oplog;
@@ -44,12 +41,9 @@ public class BackupTask {
private final RestoreScript restoreScript = new RestoreScript();
private final InternalCache cache;
private final CountDownLatch allowDestroys = new CountDownLatch(1);
- private final String memberId;
private final CountDownLatch locksAcquired = new CountDownLatch(1);
private final CountDownLatch otherMembersReady = new CountDownLatch(1);
private final HashSet<PersistentID> diskStoresWithData = new HashSet<>();
- private final File targetDir;
- private final File baselineDir;
private final BackupWriter backupWriter;
private volatile boolean isCancelled = false;
@@ -57,25 +51,9 @@ public class BackupTask {
private TemporaryBackupFiles temporaryFiles;
private BackupFileCopier fileCopier;
- BackupTask(InternalCache gemFireCache, File targetDir, File baselineDir) {
+ BackupTask(InternalCache gemFireCache, BackupWriter backupWriter) {
this.cache = gemFireCache;
- this.targetDir = targetDir;
- this.baselineDir = baselineDir;
- memberId = getCleanedMemberId();
- backupWriter = createBackupWriter();
- }
-
- private BackupWriter createBackupWriter() {
- BackupWriter writer;
- Path backupDirectory = targetDir.toPath().resolve(memberId);
- if (baselineDir == null) {
- writer = new FileSystemBackupWriter(backupDirectory);
- } else {
- FileSystemIncrementalBackupLocation incrementalBaselineLocation =
- new FileSystemIncrementalBackupLocation(baselineDir, memberId);
- writer = new FileSystemBackupWriter(backupDirectory,
incrementalBaselineLocation);
- }
- return writer;
+ this.backupWriter = backupWriter;
}
HashSet<PersistentID> getPreparedDiskStores() throws InterruptedException {
@@ -302,17 +280,6 @@ public class BackupTask {
return backup;
}
- private String getCleanedMemberId() {
- InternalDistributedMember memberId =
- cache.getInternalDistributedSystem().getDistributedMember();
- String vmId = memberId.toString();
- return cleanSpecialCharacters(vmId);
- }
-
- private String cleanSpecialCharacters(String string) {
- return string.replaceAll("[^\\w]+", "_");
- }
-
DiskStoreBackup getBackupForDiskStore(DiskStoreImpl diskStore) {
return backupByDiskStore.get(diskStore);
}
diff --git
a/geode-core/src/main/java/org/apache/geode/internal/cache/backup/BackupUtil.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/backup/BackupUtil.java
index 46e7d96..5ce481c 100644
---
a/geode-core/src/main/java/org/apache/geode/internal/cache/backup/BackupUtil.java
+++
b/geode-core/src/main/java/org/apache/geode/internal/cache/backup/BackupUtil.java
@@ -14,14 +14,20 @@
*/
package org.apache.geode.internal.cache.backup;
-import java.io.File;
+import static
org.apache.geode.internal.cache.backup.AbstractBackupWriterConfig.TIMESTAMP;
+import static
org.apache.geode.internal.cache.backup.AbstractBackupWriterConfig.TYPE;
+import static
org.apache.geode.internal.cache.backup.FileSystemBackupWriterConfig.BASELINE_DIR;
+import static
org.apache.geode.internal.cache.backup.FileSystemBackupWriterConfig.TARGET_DIR;
+
import java.text.SimpleDateFormat;
import java.util.Date;
+import java.util.Properties;
import java.util.Set;
import org.apache.geode.admin.internal.AdminDistributedSystemImpl;
import org.apache.geode.cache.persistence.PersistentID;
import org.apache.geode.distributed.internal.DistributionManager;
+import
org.apache.geode.distributed.internal.membership.InternalDistributedMember;
import org.apache.geode.internal.i18n.LocalizedStrings;
import org.apache.geode.management.BackupStatus;
import org.apache.geode.management.ManagementException;
@@ -33,19 +39,35 @@ public class BackupUtil {
// do not instantiate
}
- public static BackupStatus backupAllMembers(DistributionManager dm, File
targetDir,
- File baselineDir) throws ManagementException {
- BackupStatus status = null;
+ public static BackupStatus backupAllMembers(DistributionManager dm, String
targetDirPath,
+ String baselineDirPath) {
+ Properties properties = createBackupProperties(targetDirPath,
baselineDirPath);
+ return backupAllMembers(dm, properties);
+ }
+
+ static Properties createBackupProperties(String targetDirPath, String
baselineDirPath) {
+ Properties properties = new Properties();
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
+ properties.setProperty(TIMESTAMP, format.format(new Date()));
+ properties.setProperty(TYPE, "FileSystem");
+ properties.setProperty(TARGET_DIR, targetDirPath);
+ if (baselineDirPath != null) {
+ properties.setProperty(BASELINE_DIR, baselineDirPath);
+ }
+ return properties;
+ }
+
+ public static BackupStatus backupAllMembers(DistributionManager dm,
Properties properties)
+ throws ManagementException {
+ BackupStatus status;
if (BackupDataStoreHelper.obtainLock(dm)) {
try {
Set<PersistentID> missingMembers =
AdminDistributedSystemImpl.getMissingPersistentMembers(dm);
- Set recipients = dm.getOtherDistributionManagerIds();
+ Set<InternalDistributedMember> recipients =
dm.getOtherDistributionManagerIds();
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
- targetDir = new File(targetDir, format.format(new Date()));
BackupDataStoreResult result =
- BackupDataStoreHelper.backupAllMembers(dm, recipients, targetDir,
baselineDir);
+ BackupDataStoreHelper.backupAllMembers(dm, recipients, properties);
// It's possible that when calling getMissingPersistentMembers, some
members are
// still creating/recovering regions, and at FinishBackupRequest.send,
the
diff --git
a/geode-core/src/main/java/org/apache/geode/internal/cache/backup/BackupWriterFactory.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/backup/BackupWriterFactory.java
new file mode 100644
index 0000000..7111edc
--- /dev/null
+++
b/geode-core/src/main/java/org/apache/geode/internal/cache/backup/BackupWriterFactory.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional
information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache
License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express
+ * or implied. See the License for the specific language governing permissions
and limitations under
+ * the License.
+ */
+package org.apache.geode.internal.cache.backup;
+
+import static
org.apache.geode.internal.cache.backup.AbstractBackupWriterConfig.TIMESTAMP;
+
+import java.io.File;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Properties;
+
+public enum BackupWriterFactory {
+ FILE_SYSTEM("FileSystem") {
+ BackupWriter createWriter(Properties properties, String memberId) {
+ FileSystemBackupWriterConfig config = new
FileSystemBackupWriterConfig(properties);
+ Path targetDir = Paths.get(config.getTargetDirectory())
+ .resolve(properties.getProperty(TIMESTAMP)).resolve(memberId);
+ String baselineDir = config.getBaselineDirectory();
+ FileSystemIncrementalBackupLocation incrementalBackupLocation = null;
+ if (baselineDir != null) {
+ File baseline = new File(baselineDir);
+ incrementalBackupLocation = new
FileSystemIncrementalBackupLocation(baseline, memberId);
+ }
+ return new FileSystemBackupWriter(targetDir, incrementalBackupLocation);
+ }
+ };
+
+ private String type;
+
+ BackupWriterFactory(String type) {
+ this.type = type;
+ }
+
+ String getType() {
+ return type;
+ }
+
+ static BackupWriterFactory getFactoryForType(String type) {
+ for (BackupWriterFactory factory : BackupWriterFactory.values()) {
+ if (factory.type.equals(type)) {
+ return factory;
+ }
+ }
+ throw new IllegalArgumentException("No factory exists for type '" + type +
"'");
+ }
+
+ abstract BackupWriter createWriter(Properties properties, String memberId);
+}
diff --git a/geode-core/src/main/java/org/apache/geode/admin/BackupStatus.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/backup/FileSystemBackupWriterConfig.java
similarity index 52%
copy from geode-core/src/main/java/org/apache/geode/admin/BackupStatus.java
copy to
geode-core/src/main/java/org/apache/geode/internal/cache/backup/FileSystemBackupWriterConfig.java
index 11740d9..e54e21a 100644
--- a/geode-core/src/main/java/org/apache/geode/admin/BackupStatus.java
+++
b/geode-core/src/main/java/org/apache/geode/internal/cache/backup/FileSystemBackupWriterConfig.java
@@ -12,16 +12,29 @@
* or implied. See the License for the specific language governing permissions
and limitations under
* the License.
*/
-package org.apache.geode.admin;
+package org.apache.geode.internal.cache.backup;
-/**
- * The status of a backup operation, returned by
- * {@link AdminDistributedSystem#backupAllMembers(java.io.File,java.io.File)}.
- *
- * @since GemFire 6.5
- * @deprecated as of 7.0 use the <code><a href=
- *
"{@docRoot}/org/apache/geode/management/package-summary.html">management</a></code>
- * package instead
- */
-public interface BackupStatus extends org.apache.geode.management.BackupStatus
{
+import java.util.Properties;
+
+import org.apache.commons.lang.StringUtils;
+
+class FileSystemBackupWriterConfig extends AbstractBackupWriterConfig {
+ static final String TARGET_DIR = "TARGET_DIRECTORY";
+ static final String BASELINE_DIR = "BASELINE_DIRECTORY";
+
+ FileSystemBackupWriterConfig(Properties properties) {
+ super(properties);
+ }
+
+ public String getTargetDirectory() {
+ String value = getProperties().getProperty(TARGET_DIR);
+ if (StringUtils.isBlank(value)) {
+ throw new IllegalStateException("Target directory is missing");
+ }
+ return value;
+ }
+
+ public String getBaselineDirectory() {
+ return getProperties().getProperty(BASELINE_DIR);
+ }
}
diff --git
a/geode-core/src/main/java/org/apache/geode/internal/cache/backup/PrepareBackup.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/backup/PrepareBackup.java
index fc3f085..8460543 100644
---
a/geode-core/src/main/java/org/apache/geode/internal/cache/backup/PrepareBackup.java
+++
b/geode-core/src/main/java/org/apache/geode/internal/cache/backup/PrepareBackup.java
@@ -14,7 +14,6 @@
*/
package org.apache.geode.internal.cache.backup;
-import java.io.File;
import java.io.IOException;
import java.util.HashSet;
@@ -26,15 +25,12 @@ class PrepareBackup {
private final InternalDistributedMember member;
private final InternalCache cache;
- private final File targetDir;
- private final File baselineDir;
+ private final BackupWriter backupWriter;
- PrepareBackup(InternalDistributedMember member, InternalCache cache, File
targetDir,
- File baselineDir) {
+ PrepareBackup(InternalDistributedMember member, InternalCache cache,
BackupWriter backupWriter) {
this.member = member;
this.cache = cache;
- this.targetDir = targetDir;
- this.baselineDir = baselineDir;
+ this.backupWriter = backupWriter;
}
HashSet<PersistentID> run() throws IOException, InterruptedException {
@@ -42,7 +38,7 @@ class PrepareBackup {
if (cache == null) {
persistentIds = new HashSet<>();
} else {
- persistentIds = cache.getBackupService().prepareBackup(member,
targetDir, baselineDir);
+ persistentIds = cache.getBackupService().prepareBackup(member,
backupWriter);
}
return persistentIds;
}
diff --git
a/geode-core/src/main/java/org/apache/geode/internal/cache/backup/PrepareBackupFactory.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/backup/PrepareBackupFactory.java
index 8364d3a..4a85db1 100644
---
a/geode-core/src/main/java/org/apache/geode/internal/cache/backup/PrepareBackupFactory.java
+++
b/geode-core/src/main/java/org/apache/geode/internal/cache/backup/PrepareBackupFactory.java
@@ -14,8 +14,10 @@
*/
package org.apache.geode.internal.cache.backup;
-import java.io.File;
+import static
org.apache.geode.internal.cache.backup.AbstractBackupWriterConfig.TYPE;
+
import java.util.HashSet;
+import java.util.Properties;
import java.util.Set;
import org.apache.geode.cache.persistence.PersistentID;
@@ -31,18 +33,24 @@ class PrepareBackupFactory {
}
PrepareBackupRequest createRequest(InternalDistributedMember sender,
- Set<InternalDistributedMember> recipients, int processorId, File
targetDir,
- File baselineDir) {
- return new PrepareBackupRequest(sender, recipients, processorId, this,
targetDir, baselineDir);
+ Set<InternalDistributedMember> recipients, int processorId, Properties
properties) {
+ return new PrepareBackupRequest(sender, recipients, processorId, this,
properties);
}
PrepareBackup createPrepareBackup(InternalDistributedMember member,
InternalCache cache,
- File targetDir, File baselineDir) {
- return new PrepareBackup(member, cache, targetDir, baselineDir);
+ Properties properties) {
+ String memberId = cleanSpecialCharacters(member.toString());
+ BackupWriter backupWriter =
BackupWriterFactory.getFactoryForType(properties.getProperty(TYPE))
+ .createWriter(properties, memberId);
+ return new PrepareBackup(member, cache, backupWriter);
}
BackupResponse createBackupResponse(InternalDistributedMember sender,
HashSet<PersistentID> persistentIds) {
return new BackupResponse(sender, persistentIds);
}
+
+ private String cleanSpecialCharacters(String string) {
+ return string.replaceAll("[^\\w]+", "_");
+ }
}
diff --git
a/geode-core/src/main/java/org/apache/geode/internal/cache/backup/PrepareBackupOperation.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/backup/PrepareBackupOperation.java
index eb583c8..e7a899a 100644
---
a/geode-core/src/main/java/org/apache/geode/internal/cache/backup/PrepareBackupOperation.java
+++
b/geode-core/src/main/java/org/apache/geode/internal/cache/backup/PrepareBackupOperation.java
@@ -14,8 +14,8 @@
*/
package org.apache.geode.internal.cache.backup;
-import java.io.File;
import java.io.IOException;
+import java.util.Properties;
import java.util.Set;
import org.apache.logging.log4j.Logger;
@@ -34,19 +34,17 @@ class PrepareBackupOperation extends BackupOperation {
private final InternalCache cache;
private final Set<InternalDistributedMember> recipients;
private final PrepareBackupFactory prepareBackupFactory;
- private final File targetDir;
- private final File baselineDir;
+ private final Properties properties;
PrepareBackupOperation(DistributionManager dm, InternalDistributedMember
member,
InternalCache cache, Set<InternalDistributedMember> recipients,
- PrepareBackupFactory prepareBackupFactory, File targetDir, File
baselineDir) {
+ PrepareBackupFactory prepareBackupFactory, Properties properties) {
super(dm);
this.member = member;
this.cache = cache;
this.recipients = recipients;
this.prepareBackupFactory = prepareBackupFactory;
- this.targetDir = targetDir;
- this.baselineDir = baselineDir;
+ this.properties = properties;
}
@Override
@@ -57,14 +55,14 @@ class PrepareBackupOperation extends BackupOperation {
@Override
DistributionMessage createDistributionMessage(ReplyProcessor21
replyProcessor) {
return prepareBackupFactory.createRequest(member, recipients,
replyProcessor.getProcessorId(),
- targetDir, baselineDir);
+ properties);
}
@Override
void processLocally() {
try {
addToResults(member,
- prepareBackupFactory.createPrepareBackup(member, cache, targetDir,
baselineDir).run());
+ prepareBackupFactory.createPrepareBackup(member, cache,
properties).run());
} catch (IOException | InterruptedException e) {
logger.fatal("Failed to PrepareBackup in " + member, e);
}
diff --git
a/geode-core/src/main/java/org/apache/geode/internal/cache/backup/PrepareBackupRequest.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/backup/PrepareBackupRequest.java
index 8d6a66e..fc42c24 100644
---
a/geode-core/src/main/java/org/apache/geode/internal/cache/backup/PrepareBackupRequest.java
+++
b/geode-core/src/main/java/org/apache/geode/internal/cache/backup/PrepareBackupRequest.java
@@ -16,9 +16,9 @@ package org.apache.geode.internal.cache.backup;
import java.io.DataInput;
import java.io.DataOutput;
-import java.io.File;
import java.io.IOException;
import java.util.HashSet;
+import java.util.Properties;
import java.util.Set;
import org.apache.logging.log4j.Logger;
@@ -43,21 +43,19 @@ public class PrepareBackupRequest extends CliLegacyMessage {
private static final Logger logger = LogService.getLogger();
private final transient PrepareBackupFactory prepareBackupFactory;
- private File targetDir;
- private File baselineDir;
+ private Properties properties;
public PrepareBackupRequest() {
this.prepareBackupFactory = new PrepareBackupFactory();
}
PrepareBackupRequest(InternalDistributedMember sender,
Set<InternalDistributedMember> recipients,
- int msgId, PrepareBackupFactory prepareBackupFactory, File targetDir,
File baselineDir) {
+ int msgId, PrepareBackupFactory prepareBackupFactory, Properties
properties) {
setSender(sender);
setRecipients(recipients);
this.msgId = msgId;
this.prepareBackupFactory = prepareBackupFactory;
- this.targetDir = targetDir;
- this.baselineDir = baselineDir;
+ this.properties = properties;
}
@Override
@@ -65,8 +63,7 @@ public class PrepareBackupRequest extends CliLegacyMessage {
HashSet<PersistentID> persistentIds;
try {
persistentIds = prepareBackupFactory
- .createPrepareBackup(dm.getDistributionManagerId(), dm.getCache(),
targetDir, baselineDir)
- .run();
+ .createPrepareBackup(dm.getDistributionManagerId(), dm.getCache(),
properties).run();
} catch (IOException | InterruptedException e) {
logger.error(LocalizedMessage.create(LocalizedStrings.CliLegacyMessage_ERROR,
getClass()), e);
return AdminFailureResponse.create(getSender(), e);
@@ -82,14 +79,12 @@ public class PrepareBackupRequest extends CliLegacyMessage {
@Override
public void fromData(DataInput in) throws IOException,
ClassNotFoundException {
super.fromData(in);
- targetDir = DataSerializer.readFile(in);
- baselineDir = DataSerializer.readFile(in);
+ properties = DataSerializer.readProperties(in);
}
@Override
public void toData(DataOutput out) throws IOException {
super.toData(out);
- DataSerializer.writeFile(targetDir, out);
- DataSerializer.writeFile(baselineDir, out);
+ DataSerializer.writeProperties(properties, out);
}
}
diff --git
a/geode-core/src/main/java/org/apache/geode/management/BackupStatus.java
b/geode-core/src/main/java/org/apache/geode/management/BackupStatus.java
index fb78607..92448e7 100644
--- a/geode-core/src/main/java/org/apache/geode/management/BackupStatus.java
+++ b/geode-core/src/main/java/org/apache/geode/management/BackupStatus.java
@@ -14,29 +14,10 @@
*/
package org.apache.geode.management;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.geode.cache.persistence.PersistentID;
-import org.apache.geode.distributed.DistributedMember;
-
/**
* The status of a backup operation.
*
* @since Geode 1.4
*/
-public interface BackupStatus {
-
- /**
- * Returns a map of disk stores that were successfully backed up. The key is
an online distributed
- * member. The value is the set of disk stores on that distributed member.
- */
- Map<DistributedMember, Set<PersistentID>> getBackedUpDiskStores();
-
- /**
- * Returns the set of disk stores that were known to be offline at the time
of the backup. These
- * members were not backed up. If this set is not empty the backup may not
contain a complete
- * snapshot of any partitioned regions in the distributed system.
- */
- Set<PersistentID> getOfflineDiskStores();
+public interface BackupStatus extends org.apache.geode.admin.BackupStatus {
}
diff --git
a/geode-core/src/main/java/org/apache/geode/management/internal/beans/DistributedSystemBridge.java
b/geode-core/src/main/java/org/apache/geode/management/internal/beans/DistributedSystemBridge.java
index bfb8d68..a0618f3 100644
---
a/geode-core/src/main/java/org/apache/geode/management/internal/beans/DistributedSystemBridge.java
+++
b/geode-core/src/main/java/org/apache/geode/management/internal/beans/DistributedSystemBridge.java
@@ -14,7 +14,6 @@
*/
package org.apache.geode.management.internal.beans;
-import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
@@ -26,12 +25,12 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
-import java.util.stream.Collectors;
import javax.management.InstanceNotFoundException;
import javax.management.ListenerNotFoundException;
@@ -55,12 +54,11 @@ import
org.apache.geode.internal.admin.remote.PrepareRevokePersistentIDRequest;
import org.apache.geode.internal.admin.remote.RevokePersistentIDRequest;
import org.apache.geode.internal.admin.remote.ShutdownAllRequest;
import org.apache.geode.internal.cache.InternalCache;
-import org.apache.geode.internal.cache.backup.BackupDataStoreHelper;
-import org.apache.geode.internal.cache.backup.BackupDataStoreResult;
+import org.apache.geode.internal.cache.backup.BackupUtil;
import org.apache.geode.internal.cache.persistence.PersistentMemberPattern;
-import org.apache.geode.internal.i18n.LocalizedStrings;
import org.apache.geode.internal.logging.LogService;
import org.apache.geode.internal.logging.log4j.LocalizedMessage;
+import org.apache.geode.management.BackupStatus;
import org.apache.geode.management.CacheServerMXBean;
import org.apache.geode.management.DiskBackupStatus;
import org.apache.geode.management.DiskMetrics;
@@ -480,57 +478,20 @@ public class DistributedSystemBridge {
* @param baselineDirPath path of the directory for baseline backup.
* @return open type DiskBackupStatus containing each member wise disk back
up status
*/
- public DiskBackupStatus backupAllMembers(String targetDirPath, String
baselineDirPath)
- throws Exception {
- if (BackupDataStoreHelper.obtainLock(dm)) {
- try {
-
- if (targetDirPath == null || targetDirPath.isEmpty()) {
- throw new Exception(
-
ManagementStrings.TARGET_DIR_CANT_BE_NULL_OR_EMPTY.toLocalizedString());
- }
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
- File targetDir = new File(targetDirPath);
- targetDir = new File(targetDir, format.format(new Date()));
-
- File baselineDir = null;
- if (baselineDirPath != null) {
- baselineDir = new File(baselineDirPath);
- }
-
- DistributionManager dm = cache.getDistributionManager();
- Set recipients = dm.getOtherDistributionManagerIds();
-
- BackupDataStoreResult result =
- BackupDataStoreHelper.backupAllMembers(dm, recipients, targetDir,
baselineDir);
-
-
- DiskBackupStatusImpl diskBackupStatus = new DiskBackupStatusImpl();
- Map<DistributedMember, Set<PersistentID>> successfulMembers =
result.getSuccessfulMembers();
- diskBackupStatus.generateBackedUpDiskStores(successfulMembers);
-
- // It's possible that when calling getMissingPersistentMembers, some
- // members
- // are
- // still creating/recovering regions, and at FinishBackupRequest.send,
the
- // regions at the members are ready. Logically, since the members in
- // successfulMembers
- // should override the previous missingMembers
- Set<PersistentID> successfulIds =
result.getSuccessfulMembers().values().stream()
- .flatMap(Set::stream).collect(Collectors.toSet());
- Set<PersistentID> missingIds =
-
result.getExistingDataStores().values().stream().flatMap(Set::stream)
- .filter((v) ->
!successfulIds.contains(v)).collect(Collectors.toSet());
-
- diskBackupStatus.generateOfflineDiskStores(missingIds);
- return diskBackupStatus;
- } finally {
- BackupDataStoreHelper.releaseLock(dm);
- }
- } else {
- throw new Exception(
-
LocalizedStrings.DistributedSystem_BACKUP_ALREADY_IN_PROGRESS.toLocalizedString());
+ public DiskBackupStatus backupAllMembers(String targetDirPath, String
baselineDirPath) {
+ Properties properties = new Properties();
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
+ properties.setProperty("TIMESTAMP", format.format(new Date()));
+ properties.setProperty("TYPE", "FileSystem");
+ properties.setProperty("TARGET_DIRECTORY", targetDirPath);
+ if (baselineDirPath != null) {
+ properties.setProperty("BASELINE_DIRECTORY", baselineDirPath);
}
+ BackupStatus result = BackupUtil.backupAllMembers(dm, properties);
+ DiskBackupStatusImpl diskBackupStatus = new DiskBackupStatusImpl();
+
diskBackupStatus.generateBackedUpDiskStores(result.getBackedUpDiskStores());
+ diskBackupStatus.generateOfflineDiskStores(result.getOfflineDiskStores());
+ return diskBackupStatus;
}
/**
diff --git
a/geode-core/src/main/java/org/apache/geode/management/internal/beans/MemberMBeanBridge.java
b/geode-core/src/main/java/org/apache/geode/management/internal/beans/MemberMBeanBridge.java
index a7fc574..38d5a87 100644
---
a/geode-core/src/main/java/org/apache/geode/management/internal/beans/MemberMBeanBridge.java
+++
b/geode-core/src/main/java/org/apache/geode/management/internal/beans/MemberMBeanBridge.java
@@ -16,7 +16,6 @@ package org.apache.geode.management.internal.beans;
import static org.apache.geode.internal.lang.SystemUtils.getLineSeparator;
-import java.io.File;
import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryMXBean;
@@ -29,7 +28,6 @@ import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -48,7 +46,6 @@ import org.apache.geode.StatisticsType;
import org.apache.geode.cache.DiskStore;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.execute.FunctionService;
-import org.apache.geode.cache.persistence.PersistentID;
import org.apache.geode.cache.wan.GatewayReceiver;
import org.apache.geode.cache.wan.GatewaySender;
import org.apache.geode.distributed.Locator;
@@ -98,10 +95,8 @@ import
org.apache.geode.internal.statistics.platform.SolarisSystemStats;
import org.apache.geode.internal.statistics.platform.WindowsSystemStats;
import org.apache.geode.internal.stats50.VMStats50;
import org.apache.geode.internal.tcp.ConnectionTable;
-import org.apache.geode.management.DiskBackupResult;
import org.apache.geode.management.GemFireProperties;
import org.apache.geode.management.JVMMetrics;
-import org.apache.geode.management.ManagementException;
import org.apache.geode.management.OSMetrics;
import org.apache.geode.management.cli.Result;
import org.apache.geode.management.internal.ManagementConstants;
@@ -987,64 +982,6 @@ public class MemberMBeanBridge {
}
/**
- * backs up all the disk to the targeted directory
- *
- * @param targetDirPath path of the directory where back up is to be taken
- * @return array of DiskBackup results which might get aggregated at
Managing node Check the
- * validity of this mbean call. When does it make sense to backup a
single member of a
- * gemfire system in isolation of the other members?
- */
- public DiskBackupResult[] backupMember(String targetDirPath) {
- if (cache != null) {
- Collection<DiskStore> diskStores =
cache.listDiskStoresIncludingRegionOwned();
- for (DiskStore store : diskStores) {
- store.flush();
- }
- }
-
- DiskBackupResult[] diskBackUpResult = null;
- File targetDir = new File(targetDirPath);
-
- if (cache == null) {
- return null;
-
- } else {
- try {
- boolean abort = true;
- Set<PersistentID> existingDataStores;
- Set<PersistentID> successfulDataStores;
- try {
- existingDataStores = cache.getBackupService().prepareBackup(
- cache.getInternalDistributedSystem().getDistributedMember(),
targetDir, null);
- abort = false;
- } finally {
- if (abort) {
- cache.getBackupService().abortBackup();
- successfulDataStores = Collections.emptySet();
- } else {
- successfulDataStores = cache.getBackupService().doBackup();
- }
- }
- diskBackUpResult = new DiskBackupResult[existingDataStores.size()];
- int j = 0;
-
- for (PersistentID id : existingDataStores) {
- if (successfulDataStores.contains(id)) {
- diskBackUpResult[j] = new DiskBackupResult(id.getDirectory(),
false);
- } else {
- diskBackUpResult[j] = new DiskBackupResult(id.getDirectory(),
true);
- }
- j++;
- }
-
- } catch (IOException | InterruptedException e) {
- throw new ManagementException(e);
- }
- }
- return diskBackUpResult;
- }
-
- /**
* @return The name for this member.
*/
public String getName() {
diff --git
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/BackupDiskStoreCommand.java
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/BackupDiskStoreCommand.java
index 7415395..b8894e4 100644
---
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/BackupDiskStoreCommand.java
+++
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/BackupDiskStoreCommand.java
@@ -15,7 +15,6 @@
package org.apache.geode.management.internal.cli.commands;
-import java.io.File;
import java.util.Map;
import java.util.Set;
@@ -61,9 +60,9 @@ public class BackupDiskStoreCommand implements GfshCommand {
BackupStatus backupStatus;
if (baselineDir != null && !baselineDir.isEmpty()) {
- backupStatus = BackupUtil.backupAllMembers(dm, new File(targetDir),
new File(baselineDir));
+ backupStatus = BackupUtil.backupAllMembers(dm, targetDir, baselineDir);
} else {
- backupStatus = BackupUtil.backupAllMembers(dm, new File(targetDir),
null);
+ backupStatus = BackupUtil.backupAllMembers(dm, targetDir, null);
}
Map<DistributedMember, Set<PersistentID>> backedupMemberDiskstoreMap =
diff --git
a/geode-core/src/test/java/org/apache/geode/internal/cache/backup/AbstractBackupWriterConfigTest.java
b/geode-core/src/test/java/org/apache/geode/internal/cache/backup/AbstractBackupWriterConfigTest.java
new file mode 100644
index 0000000..4809870
--- /dev/null
+++
b/geode-core/src/test/java/org/apache/geode/internal/cache/backup/AbstractBackupWriterConfigTest.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional
information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache
License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express
+ * or implied. See the License for the specific language governing permissions
and limitations under
+ * the License.
+ */
+package org.apache.geode.internal.cache.backup;
+
+import static
org.apache.geode.internal.cache.backup.AbstractBackupWriterConfig.TIMESTAMP;
+import static
org.apache.geode.internal.cache.backup.AbstractBackupWriterConfig.TYPE;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Properties;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.test.junit.categories.UnitTest;
+
+@Category(UnitTest.class)
+public class AbstractBackupWriterConfigTest {
+
+ private Properties properties;
+ private String timestamp;
+ private String type;
+ private AbstractBackupWriterConfig config;
+
+ @Before
+ public void setUp() {
+ properties = new Properties();
+ timestamp = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date());
+ type = "FileSystem";
+ config = new AbstractBackupWriterConfig(properties) {};
+ }
+
+ @Test
+ public void getTimestampThrowsIfMissing() {
+ assertThatThrownBy(() ->
config.getTimestamp()).isInstanceOf(IllegalStateException.class);
+ }
+
+ @Test
+ public void getTimestampThrowsIfBlank() {
+ properties.setProperty(TIMESTAMP, "");
+ assertThatThrownBy(() ->
config.getTimestamp()).isInstanceOf(IllegalStateException.class);
+ }
+
+ @Test
+ public void getTimestampReturnsCorrectString() {
+ properties.setProperty(TIMESTAMP, timestamp);
+ assertThat(config.getTimestamp()).isEqualTo(timestamp);
+ }
+
+ @Test
+ public void getBackupTypeThrowsIfMissing() {
+ assertThatThrownBy(() ->
config.getBackupType()).isInstanceOf(IllegalStateException.class);
+ }
+
+ @Test
+ public void getBackupTypeThrowsIfBlank() {
+ properties.setProperty(TYPE, "");
+ assertThatThrownBy(() ->
config.getBackupType()).isInstanceOf(IllegalStateException.class);
+ }
+
+ @Test
+ public void getBackupTypeReturnsCorrectString() {
+ properties.setProperty(TYPE, type);
+ assertThat(config.getBackupType()).isEqualTo(type);
+ }
+
+ @Test
+ public void getProperties() {
+ assertThat(config.getProperties()).isSameAs(properties);
+ }
+}
diff --git
a/geode-core/src/test/java/org/apache/geode/internal/cache/backup/BackupDistributedTest.java
b/geode-core/src/test/java/org/apache/geode/internal/cache/backup/BackupDistributedTest.java
index 014425f..9fb8cd9 100755
---
a/geode-core/src/test/java/org/apache/geode/internal/cache/backup/BackupDistributedTest.java
+++
b/geode-core/src/test/java/org/apache/geode/internal/cache/backup/BackupDistributedTest.java
@@ -123,7 +123,6 @@ public class BackupDistributedTest extends
PersistentPartitionedRegionTestBase {
workingDirByVm.put(vm3, tempDir.newFolder());
backupBaseDir = tempDir.newFolder("backupDir");
-
}
@Override
@@ -143,6 +142,15 @@ public class BackupDistributedTest extends
PersistentPartitionedRegionTestBase {
createData();
+ vm0.invoke(() -> {
+
assertThat(getCache().getDistributionManager().getNormalDistributionManagerIds()).hasSize(2);
+ });
+
+ vm2.invoke(() -> {
+ getCache();
+
assertThat(getCache().getDistributionManager().getNormalDistributionManagerIds()).hasSize(3);
+ });
+
BackupStatus status = backupMember(vm2);
assertThat(status.getBackedUpDiskStores()).hasSize(2);
assertThat(status.getOfflineDiskStores()).isEmpty();
@@ -692,8 +700,8 @@ public class BackupDistributedTest extends
PersistentPartitionedRegionTestBase {
private BackupStatus backupMember(final VM vm) {
return vm.invoke("backup", () -> {
try {
- return
BackupUtil.backupAllMembers(getSystem().getDistributionManager(), backupBaseDir,
- null);
+ return BackupUtil.backupAllMembers(getCache().getDistributionManager(),
+ backupBaseDir.toString(), null);
} catch (ManagementException e) {
throw new RuntimeException(e);
}
diff --git
a/geode-core/src/test/java/org/apache/geode/internal/cache/backup/BackupIntegrationTest.java
b/geode-core/src/test/java/org/apache/geode/internal/cache/backup/BackupIntegrationTest.java
index 36bf6b3..ac2f7e6 100644
---
a/geode-core/src/test/java/org/apache/geode/internal/cache/backup/BackupIntegrationTest.java
+++
b/geode-core/src/test/java/org/apache/geode/internal/cache/backup/BackupIntegrationTest.java
@@ -192,8 +192,8 @@ public class BackupIntegrationTest {
}
BackupService backup = cache.getBackupService();
-
backup.prepareBackup(cache.getInternalDistributedSystem().getDistributedMember(),
backupDir,
- null);
+ BackupWriter writer = getBackupWriter();
+ backup.prepareBackup(cache.getMyId(), writer);
backup.doBackup();
// Put another key to make sure we restore
@@ -241,13 +241,19 @@ public class BackupIntegrationTest {
createDiskStore();
BackupService backup = cache.getBackupService();
-
backup.prepareBackup(cache.getInternalDistributedSystem().getDistributedMember(),
backupDir,
- null);
+ BackupWriter writer = getBackupWriter();
+ backup.prepareBackup(cache.getMyId(), writer);
backup.doBackup();
assertEquals("No backup files should have been created",
Collections.emptyList(),
Arrays.asList(backupDir.list()));
}
+ private BackupWriter getBackupWriter() {
+ Properties backupProperties =
BackupUtil.createBackupProperties(backupDir.toString(), null);
+ return BackupWriterFactory.FILE_SYSTEM.createWriter(backupProperties,
+ cache.getMyId().toString());
+ }
+
@Test
public void testBackupOverflowOnlyDiskStore() throws Exception {
createDiskStore();
@@ -257,8 +263,7 @@ public class BackupIntegrationTest {
region.put("A", "A");
BackupService backup = cache.getBackupService();
-
backup.prepareBackup(cache.getInternalDistributedSystem().getDistributedMember(),
backupDir,
- null);
+ backup.prepareBackup(cache.getMyId(), getBackupWriter());
backup.doBackup();
@@ -285,8 +290,7 @@ public class BackupIntegrationTest {
}
BackupService backupService = cache.getBackupService();
-
backupService.prepareBackup(cache.getInternalDistributedSystem().getDistributedMember(),
- backupDir, null);
+ backupService.prepareBackup(cache.getMyId(), getBackupWriter());
final Region theRegion = region;
final DiskStore theDiskStore = ds;
CompletableFuture.runAsync(() -> destroyAndCompact(theRegion,
theDiskStore));
@@ -319,8 +323,7 @@ public class BackupIntegrationTest {
createRegion();
BackupService backupService = cache.getBackupService();
-
backupService.prepareBackup(cache.getInternalDistributedSystem().getDistributedMember(),
- backupDir, null);
+ backupService.prepareBackup(cache.getMyId(), getBackupWriter());
backupService.doBackup();
Collection<File> fileCollection = FileUtils.listFiles(backupDir,
new RegexFileFilter("BackupIntegrationTest.cache.xml"),
DirectoryFileFilter.DIRECTORY);
diff --git
a/geode-core/src/test/java/org/apache/geode/internal/cache/backup/BackupPrepareAndFinishMsgDUnitTest.java
b/geode-core/src/test/java/org/apache/geode/internal/cache/backup/BackupPrepareAndFinishMsgDUnitTest.java
index 3001db1..8d22f07 100644
---
a/geode-core/src/test/java/org/apache/geode/internal/cache/backup/BackupPrepareAndFinishMsgDUnitTest.java
+++
b/geode-core/src/test/java/org/apache/geode/internal/cache/backup/BackupPrepareAndFinishMsgDUnitTest.java
@@ -26,6 +26,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
@@ -143,9 +144,10 @@ public abstract class BackupPrepareAndFinishMsgDUnitTest
extends CacheTestCase {
throws InterruptedException, TimeoutException, ExecutionException {
DistributionManager dm =
GemFireCacheImpl.getInstance().getDistributionManager();
Set recipients = dm.getOtherDistributionManagerIds();
+ Properties backupProperties =
BackupUtil.createBackupProperties(diskDirs[0].toString(), null);
Future<Void> future = null;
new PrepareBackupOperation(dm, dm.getId(), dm.getCache(), recipients,
- new PrepareBackupFactory(), diskDirs[0], null).send();
+ new PrepareBackupFactory(), backupProperties).send();
ReentrantLock backupLock = ((LocalRegion)
region).getDiskStore().getBackupLock();
future = CompletableFuture.runAsync(function);
Awaitility.await().atMost(5, TimeUnit.SECONDS)
@@ -158,8 +160,9 @@ public abstract class BackupPrepareAndFinishMsgDUnitTest
extends CacheTestCase {
private void doReadActionsAndVerifyCompletion() {
DistributionManager dm =
GemFireCacheImpl.getInstance().getDistributionManager();
Set recipients = dm.getOtherDistributionManagerIds();
+ Properties backupProperties =
BackupUtil.createBackupProperties(diskDirs[0].toString(), null);
new PrepareBackupOperation(dm, dm.getId(), dm.getCache(), recipients,
- new PrepareBackupFactory(), diskDirs[0], null).send();
+ new PrepareBackupFactory(), backupProperties).send();
ReentrantLock backupLock = ((LocalRegion)
region).getDiskStore().getBackupLock();
List<CompletableFuture<?>> futureList = doReadActions();
CompletableFuture.allOf(futureList.toArray(new
CompletableFuture<?>[futureList.size()]));
diff --git
a/geode-core/src/test/java/org/apache/geode/internal/cache/backup/BackupServiceTest.java
b/geode-core/src/test/java/org/apache/geode/internal/cache/backup/BackupServiceTest.java
index 5fa10f9..daa2037 100644
---
a/geode-core/src/test/java/org/apache/geode/internal/cache/backup/BackupServiceTest.java
+++
b/geode-core/src/test/java/org/apache/geode/internal/cache/backup/BackupServiceTest.java
@@ -20,7 +20,6 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
@@ -74,7 +73,7 @@ public class BackupServiceTest {
public void startBackupThrowsExceptionWhenAnotherBackupInProgress() throws
Exception {
BackupTask backupTask = mock(BackupTask.class);
backupService.currentTask.set(backupTask);
- assertThatThrownBy(() -> backupService.prepareBackup(sender, new File(""),
null))
+ assertThatThrownBy(() -> backupService.prepareBackup(sender, null))
.isInstanceOf(IOException.class);
}
@@ -85,7 +84,7 @@ public class BackupServiceTest {
@Test
public void prepareBackupReturnsEmptyPersistentIdsWhenBackupNotInProgress()
throws Exception {
- assertThat(backupService.prepareBackup(sender, new File(""),
null).size()).isEqualTo(0);
+ assertThat(backupService.prepareBackup(sender, null).size()).isEqualTo(0);
}
}
diff --git
a/geode-core/src/test/java/org/apache/geode/internal/cache/backup/BackupWriterFactoryTest.java
b/geode-core/src/test/java/org/apache/geode/internal/cache/backup/BackupWriterFactoryTest.java
new file mode 100644
index 0000000..884104e
--- /dev/null
+++
b/geode-core/src/test/java/org/apache/geode/internal/cache/backup/BackupWriterFactoryTest.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional
information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache
License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express
+ * or implied. See the License for the specific language governing permissions
and limitations under
+ * the License.
+ */
+package org.apache.geode.internal.cache.backup;
+
+import static
org.apache.geode.internal.cache.backup.AbstractBackupWriterConfig.TIMESTAMP;
+import static
org.apache.geode.internal.cache.backup.AbstractBackupWriterConfig.TYPE;
+import static
org.apache.geode.internal.cache.backup.BackupWriterFactory.FILE_SYSTEM;
+import static
org.apache.geode.internal.cache.backup.FileSystemBackupWriterConfig.BASELINE_DIR;
+import static
org.apache.geode.internal.cache.backup.FileSystemBackupWriterConfig.TARGET_DIR;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import java.util.Properties;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.test.junit.categories.UnitTest;
+
+@Category(UnitTest.class)
+public class BackupWriterFactoryTest {
+
+ @Test
+ public void returnsCorrectFactoryForName() {
+
assertThat(BackupWriterFactory.getFactoryForType("FileSystem")).isEqualTo(FILE_SYSTEM);
+ }
+
+ @Test
+ public void throwsExceptionWhenFactoryForInvalidNameGiven() {
+ assertThatThrownBy(() -> BackupWriterFactory.getFactoryForType("badName"))
+ .isInstanceOf(IllegalArgumentException.class);
+ }
+
+ @Test
+ public void getType() {
+ assertThat(FILE_SYSTEM.getType()).isEqualTo("FileSystem");
+ }
+
+ @Test
+ public void returnsCorrectWriterType() {
+ Properties properties = new Properties();
+ properties.setProperty(TYPE, FILE_SYSTEM.getType());
+ properties.setProperty(TIMESTAMP, "yyyy-MM-dd-HH-mm-ss");
+ properties.setProperty(TARGET_DIR, "targetDir");
+ properties.setProperty(BASELINE_DIR, "baselineDir");
+
+ assertThat(FILE_SYSTEM.createWriter(properties, "memberId"))
+ .isInstanceOf(FileSystemBackupWriter.class);
+ }
+
+}
diff --git
a/geode-core/src/test/java/org/apache/geode/internal/cache/backup/FileSystemBackupWriterConfigTest.java
b/geode-core/src/test/java/org/apache/geode/internal/cache/backup/FileSystemBackupWriterConfigTest.java
new file mode 100644
index 0000000..d159125
--- /dev/null
+++
b/geode-core/src/test/java/org/apache/geode/internal/cache/backup/FileSystemBackupWriterConfigTest.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional
information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache
License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express
+ * or implied. See the License for the specific language governing permissions
and limitations under
+ * the License.
+ */
+package org.apache.geode.internal.cache.backup;
+
+import static
org.apache.geode.internal.cache.backup.FileSystemBackupWriterConfig.BASELINE_DIR;
+import static
org.apache.geode.internal.cache.backup.FileSystemBackupWriterConfig.TARGET_DIR;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatCode;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import java.util.Properties;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.test.junit.categories.UnitTest;
+
+@Category(UnitTest.class)
+public class FileSystemBackupWriterConfigTest {
+
+ private Properties properties;
+ private String targetDir;
+ private String baselineDir;
+ private FileSystemBackupWriterConfig config;
+
+ @Before
+ public void setUp() {
+ properties = new Properties();
+ config = new FileSystemBackupWriterConfig(properties);
+ targetDir = "relative/path";
+ baselineDir = "baseline/directory";
+ }
+
+ @Test
+ public void getTargetDirectoryThrowsIfMissing() {
+ assertThatThrownBy(() ->
config.getTargetDirectory()).isInstanceOf(IllegalStateException.class);
+ }
+
+ @Test
+ public void getTargetDirectoryThrowsIfBlank() {
+ properties.setProperty(TARGET_DIR, "");
+ assertThatThrownBy(() ->
config.getTargetDirectory()).isInstanceOf(IllegalStateException.class);
+ }
+
+ @Test
+ public void getTargetDirectoryReturnsCorrectString() {
+ properties.setProperty(TARGET_DIR, targetDir);
+ assertThat(config.getTargetDirectory()).isEqualTo(targetDir);
+ }
+
+ @Test
+ public void getBaselineDirectoryReturnsCorrectString() {
+ properties.setProperty(BASELINE_DIR, baselineDir);
+ assertThat(config.getBaselineDirectory()).isEqualTo(baselineDir);
+ }
+
+ @Test
+ public void getBaselineDirectoryIsOptional() {
+ assertThatCode(() ->
config.getBaselineDirectory()).doesNotThrowAnyException();
+ }
+}
diff --git
a/geode-core/src/test/java/org/apache/geode/internal/cache/backup/IncrementalBackupDistributedTest.java
b/geode-core/src/test/java/org/apache/geode/internal/cache/backup/IncrementalBackupDistributedTest.java
index a5a5e9e..be74312 100644
---
a/geode-core/src/test/java/org/apache/geode/internal/cache/backup/IncrementalBackupDistributedTest.java
+++
b/geode-core/src/test/java/org/apache/geode/internal/cache/backup/IncrementalBackupDistributedTest.java
@@ -60,7 +60,6 @@ import org.apache.geode.cache.RegionShortcut;
import org.apache.geode.cache.persistence.PersistentID;
import org.apache.geode.distributed.DistributedMember;
import org.apache.geode.distributed.DistributedSystem;
-import org.apache.geode.distributed.internal.DistributionManager;
import org.apache.geode.internal.ClassPathLoader;
import org.apache.geode.internal.DeployedJar;
import org.apache.geode.internal.cache.DiskStoreImpl;
@@ -207,51 +206,33 @@ public class IncrementalBackupDistributedTest extends
JUnit4CacheTestCase {
});
}
- /**
- * Invokes {@link BackupUtil#backupAllMembers(DistributionManager, File,
File)} on a member.
- *
- * @param vm a member of the distributed system
- * @return the status of the backup.
- */
private BackupStatus baseline(VM vm) {
return vm.invoke(() -> {
try {
- return
BackupUtil.backupAllMembers(getSystem().getDistributionManager(),
getBaselineDir(),
- null);
+ return
BackupUtil.backupAllMembers(getSystem().getDistributionManager(),
+ getBaselineDir().toString(), null);
} catch (ManagementException e) {
throw new RuntimeException(e);
}
});
}
- /**
- * Invokes {@link BackupUtil#backupAllMembers(DistributionManager, File,
File)} on a member.
- *
- * @param vm a member of the distributed system.
- * @return a status of the backup operation.
- */
private BackupStatus incremental(VM vm) {
return vm.invoke(() -> {
try {
return
BackupUtil.backupAllMembers(getSystem().getDistributionManager(),
- getIncrementalDir(), getBaselineBackupDir());
+ getIncrementalDir().toString(), getBaselineBackupDir().toString());
} catch (ManagementException e) {
throw new RuntimeException(e);
}
});
}
- /**
- * Invokes {@link BackupUtil#backupAllMembers(DistributionManager, File,
File)} on a member.
- *
- * @param vm a member of the distributed system.
- * @return a status of the backup operation.
- */
private BackupStatus incremental2(VM vm) {
return vm.invoke(() -> {
try {
return
BackupUtil.backupAllMembers(getSystem().getDistributionManager(),
- getIncremental2Dir(), getIncrementalBackupDir());
+ getIncremental2Dir().toString(),
getIncrementalBackupDir().toString());
} catch (ManagementException e) {
throw new RuntimeException(e);
}
@@ -960,7 +941,7 @@ public class IncrementalBackupDistributedTest extends
JUnit4CacheTestCase {
public Object call() {
try {
return
BackupUtil.backupAllMembers(getSystem().getDistributionManager(),
- getIncrementalDir(), this.baselineDir);
+ getIncrementalDir().toString(), this.baselineDir.toString());
} catch (ManagementException e) {
throw new RuntimeException(e);
diff --git
a/geode-core/src/test/java/org/apache/geode/internal/cache/backup/PrepareBackupFactoryTest.java
b/geode-core/src/test/java/org/apache/geode/internal/cache/backup/PrepareBackupFactoryTest.java
index 7f2f95b..731dead 100644
---
a/geode-core/src/test/java/org/apache/geode/internal/cache/backup/PrepareBackupFactoryTest.java
+++
b/geode-core/src/test/java/org/apache/geode/internal/cache/backup/PrepareBackupFactoryTest.java
@@ -18,8 +18,8 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import java.io.File;
import java.util.HashSet;
+import java.util.Properties;
import java.util.Set;
import org.junit.Before;
@@ -44,7 +44,6 @@ public class PrepareBackupFactoryTest {
private Set<InternalDistributedMember> recipients;
private InternalDistributedMember member;
private InternalCache cache;
- private File targetDir;
@Before
public void setUp() throws Exception {
@@ -53,8 +52,6 @@ public class PrepareBackupFactoryTest {
sender = mock(InternalDistributedMember.class);
member = mock(InternalDistributedMember.class);
cache = mock(InternalCache.class);
- targetDir = mock(File.class);
-
recipients = new HashSet<>();
when(dm.getSystem()).thenReturn(mock(InternalDistributedSystem.class));
@@ -71,13 +68,14 @@ public class PrepareBackupFactoryTest {
@Test
public void createRequestReturnsPrepareBackupRequest() throws Exception {
- assertThat(prepareBackupFactory.createRequest(sender, recipients, 1,
targetDir, null))
+ assertThat(prepareBackupFactory.createRequest(sender, recipients, 1, null))
.isInstanceOf(PrepareBackupRequest.class);
}
@Test
public void createPrepareBackupReturnsPrepareBackup() throws Exception {
- assertThat(prepareBackupFactory.createPrepareBackup(member, cache,
targetDir, null))
+ Properties properties = BackupUtil.createBackupProperties("targetDir",
null);
+ assertThat(prepareBackupFactory.createPrepareBackup(member, cache,
properties))
.isInstanceOf(PrepareBackup.class);
}
diff --git
a/geode-core/src/test/java/org/apache/geode/internal/cache/backup/PrepareBackupOperationTest.java
b/geode-core/src/test/java/org/apache/geode/internal/cache/backup/PrepareBackupOperationTest.java
index a132e76..3e24178 100644
---
a/geode-core/src/test/java/org/apache/geode/internal/cache/backup/PrepareBackupOperationTest.java
+++
b/geode-core/src/test/java/org/apache/geode/internal/cache/backup/PrepareBackupOperationTest.java
@@ -27,6 +27,7 @@ import static org.mockito.Mockito.when;
import java.io.File;
import java.io.IOException;
import java.util.HashSet;
+import java.util.Properties;
import java.util.Set;
import org.junit.Before;
@@ -80,17 +81,20 @@ public class PrepareBackupOperationTest {
member2 = mock(InternalDistributedMember.class, "member2");
recipients = new HashSet<>();
+ Properties backupProperties =
+ BackupUtil.createBackupProperties(targetDir.toString(),
baselineDir.toString());
+
prepareBackupOperation = new PrepareBackupOperation(dm, sender, cache,
recipients,
- prepareBackupFactory, targetDir, baselineDir);
+ prepareBackupFactory, backupProperties);
when(prepareBackupReplyProcessor.getProcessorId()).thenReturn(42);
when(prepareBackupFactory.createReplyProcessor(eq(prepareBackupOperation),
eq(dm),
eq(recipients))).thenReturn(prepareBackupReplyProcessor);
- when(prepareBackupFactory.createRequest(eq(sender), eq(recipients),
eq(42), eq(targetDir),
- eq(baselineDir))).thenReturn(prepareBackupRequest);
- when(prepareBackupFactory.createPrepareBackup(eq(sender), eq(cache),
eq(targetDir),
- eq(baselineDir))).thenReturn(prepareBackup);
+ when(prepareBackupFactory.createRequest(eq(sender), eq(recipients), eq(42),
+ eq(backupProperties))).thenReturn(prepareBackupRequest);
+ when(prepareBackupFactory.createPrepareBackup(eq(sender), eq(cache),
eq(backupProperties)))
+ .thenReturn(prepareBackup);
}
@Test
diff --git
a/geode-core/src/test/java/org/apache/geode/internal/cache/backup/PrepareBackupRequestTest.java
b/geode-core/src/test/java/org/apache/geode/internal/cache/backup/PrepareBackupRequestTest.java
index b8cbcc0..cb26a8c 100644
---
a/geode-core/src/test/java/org/apache/geode/internal/cache/backup/PrepareBackupRequestTest.java
+++
b/geode-core/src/test/java/org/apache/geode/internal/cache/backup/PrepareBackupRequestTest.java
@@ -24,6 +24,7 @@ import static org.mockito.Mockito.when;
import java.io.File;
import java.io.IOException;
import java.util.HashSet;
+import java.util.Properties;
import java.util.Set;
import org.junit.Before;
@@ -52,6 +53,7 @@ public class PrepareBackupRequestTest {
private PrepareBackup prepareBackup;
private File targetDir;
private File baselineDir;
+ private Properties backupProperties;
@Before
public void setUp() throws Exception {
@@ -67,24 +69,27 @@ public class PrepareBackupRequestTest {
recipients = new HashSet<>();
persistentIds = new HashSet<>();
+ backupProperties =
+ BackupUtil.createBackupProperties(targetDir.toString(),
baselineDir.toString());
+
when(dm.getCache()).thenReturn(cache);
when(dm.getDistributionManagerId()).thenReturn(sender);
- when(prepareBackupFactory.createPrepareBackup(eq(sender), eq(cache),
eq(targetDir),
- eq(baselineDir))).thenReturn(prepareBackup);
+ when(prepareBackupFactory.createPrepareBackup(eq(sender), eq(cache),
eq(backupProperties)))
+ .thenReturn(prepareBackup);
when(prepareBackupFactory.createBackupResponse(eq(sender),
eq(persistentIds)))
.thenReturn(mock(BackupResponse.class));
when(prepareBackup.run()).thenReturn(persistentIds);
- prepareBackupRequest = new PrepareBackupRequest(sender, recipients, msgId,
prepareBackupFactory,
- targetDir, baselineDir);
+ prepareBackupRequest =
+ new PrepareBackupRequest(sender, recipients, msgId,
prepareBackupFactory, backupProperties);
}
@Test
public void usesFactoryToCreatePrepareBackup() throws Exception {
prepareBackupRequest.createResponse(dm);
- verify(prepareBackupFactory, times(1)).createPrepareBackup(eq(sender),
eq(cache), eq(targetDir),
- eq(baselineDir));
+ verify(prepareBackupFactory, times(1)).createPrepareBackup(eq(sender),
eq(cache),
+ eq(backupProperties));
}
@Test
diff --git
a/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/PersistentPartitionedRegionTestBase.java
b/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/PersistentPartitionedRegionTestBase.java
index 1b2732e..6a3ea80 100644
---
a/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/PersistentPartitionedRegionTestBase.java
+++
b/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/PersistentPartitionedRegionTestBase.java
@@ -615,8 +615,8 @@ public abstract class PersistentPartitionedRegionTestBase
extends JUnit4CacheTes
protected BackupStatus backup(final VM vm) {
return vm.invoke("backup", () -> {
try {
- return
BackupUtil.backupAllMembers(getSystem().getDistributionManager(),
getBackupDir(),
- null);
+ return
BackupUtil.backupAllMembers(getSystem().getDistributionManager(),
+ getBackupDir().toString(), null);
} catch (ManagementException e) {
throw new RuntimeException(e);
}
diff --git
a/geode-core/src/test/java/org/apache/geode/management/internal/beans/DistributedSystemBridgeJUnitTest.java
b/geode-core/src/test/java/org/apache/geode/management/internal/beans/DistributedSystemBridgeJUnitTest.java
index 2b5e2ce..c6e90dc 100644
---
a/geode-core/src/test/java/org/apache/geode/management/internal/beans/DistributedSystemBridgeJUnitTest.java
+++
b/geode-core/src/test/java/org/apache/geode/management/internal/beans/DistributedSystemBridgeJUnitTest.java
@@ -73,7 +73,7 @@ public class DistributedSystemBridgeJUnitTest {
InOrder inOrder = inOrder(dm, backupService);
inOrder.verify(dm).putOutgoing(isA(PrepareBackupRequest.class));
- inOrder.verify(backupService).prepareBackup(any(), any(), any());
+ inOrder.verify(backupService).prepareBackup(any(), any());
inOrder.verify(dm).putOutgoing(isA(FinishBackupRequest.class));
inOrder.verify(backupService).doBackup();
}
diff --git
a/geode-core/src/test/resources/org/apache/geode/codeAnalysis/excludedClasses.txt
b/geode-core/src/test/resources/org/apache/geode/codeAnalysis/excludedClasses.txt
index 895758c..c00f72b 100644
---
a/geode-core/src/test/resources/org/apache/geode/codeAnalysis/excludedClasses.txt
+++
b/geode-core/src/test/resources/org/apache/geode/codeAnalysis/excludedClasses.txt
@@ -20,9 +20,10 @@ org/apache/geode/internal/cache/DiskStoreMonitor$DiskState
org/apache/geode/internal/cache/InitialImageOperation$GIITestHook
org/apache/geode/internal/cache/Oplog$OPLOG_TYPE
org/apache/geode/internal/cache/UserSpecifiedDiskStoreAttributes
+org/apache/geode/internal/cache/backup/BackupWriterFactory
+org/apache/geode/internal/cache/backup/BackupWriterFactory$1
org/apache/geode/internal/cache/client/protocol/exception/ServiceLoadingFailureException
org/apache/geode/internal/cache/client/protocol/exception/ServiceVersionNotFoundException
-org/apache/geode/internal/cache/UserSpecifiedDiskStoreAttributes
org/apache/geode/internal/cache/client/protocol/exception/ServiceLoadingFailureException
org/apache/geode/internal/cache/client/protocol/exception/ServiceVersionNotFoundException
org/apache/geode/internal/cache/tier/CommunicationMode
diff --git
a/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedDataSerializables.txt
b/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedDataSerializables.txt
index c17eecb..5abf7ae 100644
---
a/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedDataSerializables.txt
+++
b/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedDataSerializables.txt
@@ -1426,8 +1426,8 @@ fromData,14,2a2bb700042a2bb80005b50003b1
toData,14,2a2bb700062ab400032bb80007b1
org/apache/geode/internal/cache/backup/PrepareBackupRequest,2
-fromData,22,2a2bb700192a2bb8001ab500082a2bb8001ab50009b1
-toData,22,2a2bb7001b2ab400082bb8001c2ab400092bb8001cb1
+fromData,14,2a2bb700182a2bb80019b50008b1
+toData,14,2a2bb7001a2ab400082bb8001bb1
org/apache/geode/internal/cache/compression/CompressedCachedDeserializable,2
fromData,18,2a2ab600082bb8000fb900090200b50003b1
--
To stop receiving notification emails like this one, please contact
[email protected].