@Test public void testRefreshCache() { zoneRepository.operateGroupOperations(operationContext, zoneOperations, false); int allZoneOperationsSize = zoneRepository.getAllZoneOperations(DeploymentConfig.regionId()).size(); zoneRepository.refreshCache(); Assert.assertEquals(allZoneOperationsSize + zoneOperations.size(), zoneRepository.getAllZoneOperations(DeploymentConfig.regionId()).size()); for (ZoneOperationModel model : zoneOperations) { ZoneKey zoneKey = new ZoneKey(model.getRegionId(), model.getServiceId(), model.getZoneId()); ZoneOperations zoneOperations = zoneRepository.getZoneOperations(zoneKey); Assert.assertEquals(zoneKey, zoneOperations.getZoneKey()); Assert.assertEquals(1, zoneOperations.getOperations().size()); Assert.assertEquals(model.getOperation(), zoneOperations.getOperations().get(0)); Assert.assertEquals(1, zoneRepository.getServiceZoneOperations(model.getServiceId()).size()); zoneOperations = zoneRepository.getServiceZoneOperations(model.getServiceId()).get(0); Assert.assertEquals(zoneKey, zoneOperations.getZoneKey()); Assert.assertEquals(1, zoneOperations.getOperations().size()); Assert.assertEquals(model.getOperation(), zoneOperations.getOperations().get(0)); } zoneRepository.operateGroupOperations(operationContext, zoneOperations, true); zoneRepository.refreshCache(); Assert.assertEquals(allZoneOperationsSize, zoneRepository.getAllZoneOperations(DeploymentConfig.regionId()).size()); for (ZoneOperationModel model : zoneOperations) { ZoneKey zoneKey = new ZoneKey(model.getRegionId(), model.getServiceId(), model.getZoneId()); Assert.assertNull(zoneRepository.getZoneOperations(zoneKey)); Assert.assertEquals(0, zoneRepository.getServiceZoneOperations(model.getServiceId()).size()); } }
protected boolean refreshCache() { Set<String> changedServices; try { changedServices = refreshZoneOperations(); } catch (Throwable ex) { logger.error("zone operation cache refresh failed", ex); return false; } for (String serviceKey : changedServices) { registryRepository.addInstanceChange(InstanceChanges.newReloadInstanceChange(serviceKey)); } return true; }
ZoneRepository { protected boolean refreshCache() { Set<String> changedServices; try { changedServices = refreshZoneOperations(); } catch (Throwable ex) { logger.error("zone operation cache refresh failed", ex); return false; } for (String serviceKey : changedServices) { registryRepository.addInstanceChange(InstanceChanges.newReloadInstanceChange(serviceKey)); } return true; } }
ZoneRepository { protected boolean refreshCache() { Set<String> changedServices; try { changedServices = refreshZoneOperations(); } catch (Throwable ex) { logger.error("zone operation cache refresh failed", ex); return false; } for (String serviceKey : changedServices) { registryRepository.addInstanceChange(InstanceChanges.newReloadInstanceChange(serviceKey)); } return true; } private  ZoneRepository(); }
ZoneRepository { protected boolean refreshCache() { Set<String> changedServices; try { changedServices = refreshZoneOperations(); } catch (Throwable ex) { logger.error("zone operation cache refresh failed", ex); return false; } for (String serviceKey : changedServices) { registryRepository.addInstanceChange(InstanceChanges.newReloadInstanceChange(serviceKey)); } return true; } private  ZoneRepository(); static ZoneRepository getInstance(); boolean isZoneDown(ZoneKey zoneKey); List<ZoneOperations> getAllZoneOperations(String regionId); ZoneOperations getZoneOperations(ZoneKey zoneKey); List<ZoneOperations> getServiceZoneOperations(String serviceId); List<ZoneOperations> getZoneOperationsList(ZoneOperationModel filter); void operateGroupOperations(OperationContext operationContext, List<ZoneOperationModel> zoneOperations, boolean isOperationComplete); boolean isLastRefreshSuccess(); long getLastRefreshTime(); }
ZoneRepository { protected boolean refreshCache() { Set<String> changedServices; try { changedServices = refreshZoneOperations(); } catch (Throwable ex) { logger.error("zone operation cache refresh failed", ex); return false; } for (String serviceKey : changedServices) { registryRepository.addInstanceChange(InstanceChanges.newReloadInstanceChange(serviceKey)); } return true; } private  ZoneRepository(); static ZoneRepository getInstance(); boolean isZoneDown(ZoneKey zoneKey); List<ZoneOperations> getAllZoneOperations(String regionId); ZoneOperations getZoneOperations(ZoneKey zoneKey); List<ZoneOperations> getServiceZoneOperations(String serviceId); List<ZoneOperations> getZoneOperationsList(ZoneOperationModel filter); void operateGroupOperations(OperationContext operationContext, List<ZoneOperationModel> zoneOperations, boolean isOperationComplete); boolean isLastRefreshSuccess(); long getLastRefreshTime();  }