protected void restoreBackup(int expectedNumScripts) throws IOException, InterruptedException { List<File> restoreScripts = FileUtil.findAll(getBackupDir(), ".*restore.*"); assertEquals("Restore scripts " + restoreScripts, expectedNumScripts, restoreScripts.size()); for(File script : restoreScripts) { execute(script); } }
protected void checkData(VM vm0, final int startKey, final int endKey, final String value) { checkData(vm0, startKey, endKey, value, PR_REGION_NAME); }
protected void createData(VM vm, final int startKey, final int endKey, final String value) { getLogWriter().info("createData invoked. PR_REGION_NAME is " + PR_REGION_NAME); createData(vm, startKey, endKey,value, PR_REGION_NAME); }
private void execute(File script) throws IOException, InterruptedException { ProcessBuilder pb = new ProcessBuilder(script.getAbsolutePath()); pb.redirectErrorStream(true); Process process = pb.start(); InputStream is = process.getInputStream(); byte[] buffer = new byte[1024]; BufferedReader br = new BufferedReader(new InputStreamReader(is)); String line; while((line = br.readLine()) != null) { getLogWriter().fine("OUTPUT:" + line); //TODO validate output }; assertEquals(0, process.waitFor()); }
public void run() { Cache cache = getCache(); cache.close(); } };
private SerializableRunnable getCreatePRRunnable(final int redundancy, final int recoveryDelay) { return getCreatePRRunnable(redundancy, recoveryDelay, 113); }
public void run() { GemFireCacheImpl cache = (GemFireCacheImpl) getCache(); DistributedSystemConfig config; AdminDistributedSystem adminDS = null; try { config = AdminDistributedSystemFactory.defineDistributedSystem(getSystem(), ""); adminDS = AdminDistributedSystemFactory.getDistributedSystem(config); adminDS.connect(); adminDS.waitToBeConnected(MAX_WAIT); adminDS.revokePersistentMember(SocketCreator.getLocalHost(), directory.getCanonicalPath()); } catch (Exception e) { throw new RuntimeException(e); } finally { if(adminDS != null) { adminDS.disconnect(); } } } });
public void run() { final CountDownLatch recoveryDone; if(redundancy > 0) { recoveryDone = new CountDownLatch(1); ResourceObserver observer = new InternalResourceManager.ResourceObserverAdapter() { @Override public void recoveryFinished(Region region) { recoveryDone.countDown(); } }; InternalResourceManager.setResourceObserver(observer ); } else { recoveryDone = null; } Cache cache = getCache(); RegionAttributes attr = getPersistentPRAttributes(redundancy, recoveryDelay, cache, numBuckets, synchronous); cache.createRegion(PR_REGION_NAME, attr); if(recoveryDone != null) { try { recoveryDone.await(); } catch (InterruptedException e) { fail("Interrupted", e); } } } };
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(); } } } });
protected Set<Integer> getBucketList(VM vm0) { return getBucketList(vm0, PR_REGION_NAME); }
protected RegionAttributes getPersistentPRAttributes(final int redundancy, final int recoveryDelay, Cache cache, int numBuckets, boolean synchronous) { DiskStore ds = cache.findDiskStore("disk"); if(ds == null) { ds = cache.createDiskStoreFactory() .setDiskDirs(getDiskDirs()).create("disk"); } AttributesFactory af = new AttributesFactory(); PartitionAttributesFactory paf = new PartitionAttributesFactory(); paf.setRedundantCopies(redundancy); paf.setRecoveryDelay(recoveryDelay); paf.setTotalNumBuckets(numBuckets); //Make sure all vms end up with the same local max memory paf.setLocalMaxMemory(500); af.setPartitionAttributes(paf.create()); af.setDataPolicy(DataPolicy.PERSISTENT_PARTITION); af.setDiskStoreName("disk"); af.setDiskSynchronous(synchronous); RegionAttributes attr = af.create(); return attr; }
public void run() { Cache cache = getCache(); cache.close(); } };
private SerializableRunnable getCreatePRRunnable(final int redundancy, final int recoveryDelay, final int numBuckets) { return getCreatePRRunnable(redundancy, recoveryDelay, numBuckets, true); }
public void run() { getCache(); DistributedSystemConfig config; AdminDistributedSystem adminDS = null; try { config = AdminDistributedSystemFactory.defineDistributedSystem(getSystem(), ""); adminDS = AdminDistributedSystemFactory.getDistributedSystem(config); adminDS.connect(); adminDS.waitToBeConnected(MAX_WAIT); adminDS.revokePersistentMember(SocketCreator.getLocalHost(), null); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException(e); } finally { if(adminDS != null) { adminDS.disconnect(); } } } });
public void run() { Cache cache = getCache(); Region region = cache.getRegion(regionName); for(int i =startKey; i < endKey; i++) { assertEquals("For key " + i, value, region.get(i)); } } };
protected void createPR(VM vm0, final int redundancy, final int recoveryDelay, int numBuckets) { SerializableRunnable createPR = getCreatePRRunnable(redundancy, recoveryDelay, numBuckets); vm0.invoke(createPR); }
public Object call() throws Exception { Cache cache = getCache(); return cache.getDistributedSystem().getDistributedMember(); } };
protected AsyncInvocation createPRAsync(VM vm0, final int redundancy) { SerializableRunnable createPR = getCreatePRRunnable(redundancy, -1); return vm0.invokeAsync(createPR); }
public void run() { Cache cache = getCache(); Region region = cache.getRegion(PR_REGION_NAME); region.close(); } };
protected void createPR(VM vm0, final int redundancy, final int recoveryDelay, int numBuckets, boolean synchronous) { SerializableRunnable createPR = getCreatePRRunnable(redundancy, recoveryDelay, numBuckets, synchronous); vm0.invoke(createPR); }