use of org.apache.geode.admin.DistributedSystemConfig in project geode by apache.
the class ShutdownAllDUnitTest method shutDownAllMembers.
// TODO prpersist
// test move bucket
// test async put
// test create a new bucket by put async
private void shutDownAllMembers(VM vm, final int expnum) {
vm.invoke(new SerializableRunnable("Shutdown all the members") {
public void run() {
DistributedSystemConfig config;
AdminDistributedSystemImpl adminDS = null;
try {
config = AdminDistributedSystemFactory.defineDistributedSystem(getSystem(), "");
adminDS = (AdminDistributedSystemImpl) AdminDistributedSystemFactory.getDistributedSystem(config);
adminDS.connect();
Set members = adminDS.shutDownAllMembers();
int num = members == null ? 0 : members.size();
assertEquals(expnum, num);
} catch (AdminException e) {
throw new RuntimeException(e);
} finally {
if (adminDS != null) {
adminDS.disconnect();
}
}
}
});
// clean up for this vm
System.setProperty("TestInternalGemFireError", "false");
}
use of org.apache.geode.admin.DistributedSystemConfig in project geode by apache.
the class PersistentPartitionedRegionTestBase method backup.
// used for above test
protected BackupStatus backup(VM vm) {
return (BackupStatus) vm.invoke(new SerializableCallable("Backup all members") {
public Object call() {
DistributedSystemConfig config;
AdminDistributedSystem adminDS = null;
try {
config = AdminDistributedSystemFactory.defineDistributedSystem(getSystem(), "");
adminDS = AdminDistributedSystemFactory.getDistributedSystem(config);
adminDS.connect();
adminDS.waitToBeConnected(MAX_WAIT);
return adminDS.backupAllMembers(getBackupDir());
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
if (adminDS != null) {
adminDS.disconnect();
}
}
}
});
}
use of org.apache.geode.admin.DistributedSystemConfig in project geode by apache.
the class DistributionManagerDUnitTest method createAlertListener.
static void createAlertListener() throws Exception {
DistributedSystemConfig config = AdminDistributedSystemFactory.defineDistributedSystem(getSystemStatic(), null);
adminSystem = AdminDistributedSystemFactory.getDistributedSystem(config);
adminSystem.setAlertLevel(AlertLevel.SEVERE);
adminSystem.addAlertListener(new AlertListener() {
public void alert(Alert alert) {
try {
logger.info("alert listener invoked for alert originating in " + alert.getConnectionName());
logger.info(" alert text = " + alert.getMessage());
logger.info(" systemMember = " + alert.getSystemMember());
} catch (Exception e) {
logger.fatal("exception trying to use alert object", e);
}
synchronized (alertGuard) {
alertReceived = true;
}
}
});
adminSystem.connect();
assertTrue(adminSystem.waitToBeConnected(5 * 1000));
}
use of org.apache.geode.admin.DistributedSystemConfig in project geode by apache.
the class PersistentRecoveryOrderDUnitTest method testCompactFromAdmin.
/**
* Tests to make sure that we stop waiting for a member that we revoke.
*
* @throws Exception
*/
@Test
public void testCompactFromAdmin() throws Exception {
Host host = Host.getHost(0);
final VM vm0 = host.getVM(0);
VM vm1 = host.getVM(1);
VM vm2 = host.getVM(2);
createPersistentRegionWithoutCompaction(vm0);
createPersistentRegionWithoutCompaction(vm1);
vm1.invoke(new SerializableRunnable("Create some data") {
public void run() {
GemFireCacheImpl cache = (GemFireCacheImpl) getCache();
Region region = cache.getRegion(REGION_NAME);
for (int i = 0; i < 1024; i++) {
region.put(i, new byte[1024]);
}
for (int i = 2; i < 1024; i++) {
assertTrue(region.destroy(i) != null);
}
DiskStore store = cache.findDiskStore(REGION_NAME);
store.forceRoll();
}
});
// vm1.invoke(new SerializableRunnable("compact") {
// public void run() {
// Cache cache = getCache();
// DiskStore ds = cache.findDiskStore(REGION_NAME);
// assertTrue(ds.forceCompaction());
// }
// });
//
// vm0.invoke(new SerializableRunnable("compact") {
// public void run() {
// Cache cache = getCache();
// DiskStore ds = cache.findDiskStore(REGION_NAME);
// assertTrue(ds.forceCompaction());
// }
// });
vm2.invoke(new SerializableRunnable("Compact") {
public void run() {
GemFireCacheImpl cache = (GemFireCacheImpl) getCache();
DistributedSystemConfig config;
AdminDistributedSystem adminDS = null;
try {
config = AdminDistributedSystemFactory.defineDistributedSystem(getSystem(), "");
adminDS = AdminDistributedSystemFactory.getDistributedSystem(config);
adminDS.connect();
Map<DistributedMember, Set<PersistentID>> missingIds = adminDS.compactAllDiskStores();
assertEquals(2, missingIds.size());
for (Set<PersistentID> value : missingIds.values()) {
assertEquals(1, value.size());
}
} catch (AdminException e) {
throw new RuntimeException(e);
} finally {
if (adminDS != null) {
adminDS.disconnect();
}
}
}
});
SerializableRunnable compactVM = new SerializableRunnable("compact") {
public void run() {
Cache cache = getCache();
DiskStore ds = cache.findDiskStore(REGION_NAME);
assertFalse(ds.forceCompaction());
}
};
vm0.invoke(compactVM);
vm1.invoke(compactVM);
}
use of org.apache.geode.admin.DistributedSystemConfig in project geode by apache.
the class IncrementalBackupDUnitTest method testMissingBaseline.
/**
* Successful if all members perform a full backup when they share the baseline directory and it
* is missing.
*/
@Test
public void testMissingBaseline() throws Exception {
/*
* Get the member ID for VM 1 and perform a baseline.
*/
String memberId = getMemberId(Host.getHost(0).getVM(1));
assertBackupStatus(performBaseline());
/*
* Find all of the member's oplogs in the baseline (*.crf,*.krf,*.drf)
*/
Collection<File> memberBaselineOplogs = FileUtils.listFiles(getBackupDirForMember(getBaselineDir(), memberId), new RegexFileFilter(OPLOG_REGEX), DirectoryFileFilter.DIRECTORY);
assertFalse(memberBaselineOplogs.isEmpty());
List<String> memberBaselineOplogNames = new LinkedList<>();
TransformUtils.transform(memberBaselineOplogs, memberBaselineOplogNames, TransformUtils.fileNameTransformer);
/*
* Custom incremental backup callable that retrieves the current baseline before deletion.
*/
SerializableCallable callable = new SerializableCallable("Backup all members.") {
private final File baselineDir = getBaselineBackupDir();
@Override
public Object call() {
AdminDistributedSystem adminDS = null;
try {
DistributedSystemConfig config = AdminDistributedSystemFactory.defineDistributedSystem(getSystem(), "");
adminDS = AdminDistributedSystemFactory.getDistributedSystem(config);
adminDS.connect();
return adminDS.backupAllMembers(getIncrementalDir(), this.baselineDir);
} catch (AdminException e) {
throw new RuntimeException(e);
} finally {
if (adminDS != null) {
adminDS.disconnect();
}
}
}
};
/*
* Do an incremental after deleting the baseline. It should discover that the baseline is gone
* and backup all of the operation logs that are in the baseline.
*/
FileUtils.deleteDirectory(getBaselineDir());
Host.getHost(0).getVM(1).invoke(callable);
/*
* Find all of the member's oplogs in the incremental (*.crf,*.krf,*.drf)
*/
Collection<File> memberIncrementalOplogs = FileUtils.listFiles(getBackupDirForMember(getIncrementalDir(), memberId), new RegexFileFilter(OPLOG_REGEX), DirectoryFileFilter.DIRECTORY);
assertFalse(memberIncrementalOplogs.isEmpty());
List<String> memberIncrementalOplogNames = new LinkedList<>();
TransformUtils.transform(memberIncrementalOplogs, memberIncrementalOplogNames, TransformUtils.fileNameTransformer);
/*
* Assert that all of the baseline operation logs are in the incremental backup. If so, then the
* missing baseline was discovered by the incremental backup process.
*/
for (String oplog : memberBaselineOplogNames) {
assertTrue(memberIncrementalOplogNames.contains(oplog));
}
}
Aggregations