auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public CommandContext resetExecutionContext() { START setExecutionContext(new ExecutionContext()); END return this; } return setExecution ...

Target:
public CommandContext resetExecutionContext() { return setExecutionContext(new ExecutionContext()); }
Source:
public VdcReturnValueBase endAction(VdcActionType actionType, VdcActionParametersBase parameters, CommandContext context) { CommandBase<?> command = START context != null ? CommandsFactory.createCommand(actionType, parameters, context.duplicate()) : END CommandsFactory.createCommand(actionType, parameters); return command.endAction(); } context must be non null

Target:
public VdcReturnValueBase endAction(VdcActionType actionType, VdcActionParametersBase parameters, CommandContext context) { return CommandsFactory.createCommand(actionType, parameters, context).endAction(); }
Source:
private void updateAvailabilitByDatacenter(StoragePool datacenter) { if (datacenter == null) { return; } START getModel().getActivateDomain().setIsAvailable(datacenter.getId() != StorageModel.UnassignedDataCenterId); END } Use .equals instead, it's two objects

Target:
private void updateAvailabilitByDatacenter(StoragePool datacenter) { if (datacenter == null) { return; } getModel().getActivateDomain().setIsAvailable(!StorageModel.UnassignedDataCenterId.equals(datacenter.getId())); }
Source:
public static Map<String, Object> jsonToMap(String jsonString) throws JsonParseException, JsonMappingException, IOException { final ObjectMapper mapper = new ObjectMapper(); final MapType type = mapper.getTypeFactory().constructMapType(Map.class, String.class, Object.class); final Map<String, Object> data = mapper.readValue(jsonString, type); START return data; END } Why's everything final?

Target:
public static Map<String, Object> jsonToMap(String jsonString) throws IOException { ObjectMapper mapper = new ObjectMapper(); MapType type = mapper.getTypeFactory().constructMapType(Map.class, String.class, Object.class); Map<String, Object> data = mapper.readValue(jsonString, type); return data; }
Source:
protected void updateDiskProfile(DiskImage diskImage) { if (isDiskImage()) { DiskImage oldDisk = (DiskImage) getOldDisk(); if (!Objects.equals(oldDisk.getDiskProfileId(), diskImage.getDiskProfileId())) { getImageStorageDomainMapDao().updateDiskProfileByImageGroupId(diskImage.getId(), diskImage.getStorageIds().get(0), START diskImage.getDiskProfileIds().get(0)); END } } } why not getDiskProfileId?

Target:
protected void updateDiskProfile(DiskImage diskImage) { if (isDiskImage()) { DiskImage oldDisk = (DiskImage) getOldDisk(); if (!Objects.equals(oldDisk.getDiskProfileId(), diskImage.getDiskProfileId())) { getImageStorageDomainMapDao().updateDiskProfileByImageGroupId(diskImage.getId(), diskImage.getStorageIds().get(0), diskImage.getDiskProfileId()); } } }
Source:
public void testChangeDiskProfileForDisk() { // fetch image image_storage_domain_map image_storage_domain_map = dao.getAllByImageId(EXISTING_IMAGE_ID).get(0); // test that the current disk profile doesn't equal with the new disk profile assertThat("Same source and dest disk profile id, cannot perform test", START image_storage_domain_map.getDiskProfileId(), not(equalTo(Guid.newGuid()))); END // change to newDiskProfileId dao.updateDiskProfileByImageGroupId(EXISTING_DISK_ID, EXISTING_DOMAIN_ID, FixturesTool.DISK_PROFILE_2); // fetch the image again image_storage_domain_map = dao.getAllByImageId(EXISTING_IMAGE_ID).get(0); // check that the new disk profile is the inserted one assertEquals("disk profile wasn't changed", image_storage_domain_map.getDiskProfileId(), FixturesTool.DISK_PROFILE_2); } you use different guid here and on the update statement.

Target:
public void testChangeDiskProfileForDisk() { // fetch image image_storage_domain_map image_storage_domain_map = dao.getAllByImageId(EXISTING_IMAGE_ID).get(0); // test that the current disk profile doesn't equal with the new disk profile assertThat("Same source and dest disk profile id, cannot perform test", image_storage_domain_map.getDiskProfileId(), not(equalTo(FixturesTool.DISK_PROFILE_2))); // change to newDiskProfileId dao.updateDiskProfileByImageGroupId(EXISTING_DISK_ID, EXISTING_DOMAIN_ID, FixturesTool.DISK_PROFILE_2); // fetch the image again image_storage_domain_map = dao.getAllByImageId(EXISTING_IMAGE_ID).get(0); // check that the new disk profile is the inserted one assertEquals("disk profile wasn't changed", image_storage_domain_map.getDiskProfileId(), FixturesTool.DISK_PROFILE_2); }
Source:
protected boolean setAndValidateDiskProfiles() { START if (diskInfoDestinationMap != null) { END Map<DiskImage, Guid> map = new HashMap<>(); for (DiskImage diskImage : diskInfoDestinationMap.values()) { map.put(diskImage, diskImage.getStorageIds().get(0)); } return validate(DiskProfileHelper.setAndValidateDiskProfiles(map)); } return true; } iirc it's initialized in the ctor, check that it's not empty .

Target:
protected boolean setAndValidateDiskProfiles() { if (diskInfoDestinationMap != null && !diskInfoDestinationMap.isEmpty()) { Map<DiskImage, Guid> map = new HashMap<>(); for (DiskImage diskImage : diskInfoDestinationMap.values()) { map.put(diskImage, diskImage.getStorageIds().get(0)); } return validate(DiskProfileHelper.setAndValidateDiskProfiles(map)); } return true; }
Source:
protected boolean setAndValidateDiskProfiles() { Map<DiskImage, Guid> map = new HashMap<>(); START if (diskInfoDestinationMap != null) { END for (DiskImage diskImage : diskInfoDestinationMap.values()) { map.put(diskImage, diskImage.getStorageIds().get(0)); } } return validate(DiskProfileHelper.setAndValidateDiskProfiles(map)); } create the map here only when needed

Target:
protected boolean setAndValidateDiskProfiles() { if (diskInfoDestinationMap != null) { Map<DiskImage, Guid> map = new HashMap<>(); for (DiskImage diskImage : diskInfoDestinationMap.values()) { map.put(diskImage, diskImage.getStorageIds().get(0)); } return validate(DiskProfileHelper.setAndValidateDiskProfiles(map)); } return true; }
Source:
public DiskProfileValidator(DiskProfile diskProfile) { START this(diskProfile.getId()); END this.diskProfile = diskProfile; } NPE in case that diskProfile is null

Target:
public DiskProfileValidator(DiskProfile diskProfile) { this(diskProfile != null ? diskProfile.getId() : null); this.diskProfile = diskProfile; }
Source:
START public void close() throws IOException { END tarArchiveOutputStream.close(); } please remove from this patch

Target:
public void close() throws Exception { tarArchiveOutputStream.close(); }
Source:
protected VDSReturnValue runVdsCommand(VDSCommandType commandType, VDSParametersBase parameters) throws VdcBLLException { START parameters.setCorrelationId(getCorrelationId()); END return getBackend().getResourceManager().RunVdsCommand(commandType, parameters); } we still have this in thread local... why is it needed in this patch?

Target:
protected VDSReturnValue runVdsCommand(VDSCommandType commandType, VDSParametersBase parameters) throws VdcBLLException { return getBackend().getResourceManager().RunVdsCommand(commandType, parameters); }
Source:
private void initCommandExecutor() { if (!cmdExecutorInitialized) { START synchronized(LOCK) { END if (!cmdExecutorInitialized) { for (CommandEntity cmdEntity : coco.getCommandsWithCallBackEnabled()) { switch(cmdEntity.getCommandStatus()) { case ACTIVE_SYNC: case NOT_STARTED: coco.retrieveCommand(cmdEntity.getId()).setCommandStatus(CommandStatus.FAILED_RESTARTED); break; default: if (!cmdEntity.isCallBackNotified()) { addToCallBackMap(cmdEntity); } break; } } cmdExecutorInitialized = true; } } } } please rebase, arik removed the lock in a different patch.

Target:
private void initCommandExecutor() { if (!cmdExecutorInitialized) { for (CommandEntity cmdEntity : coco.getCommandsWithCallBackEnabled()) { switch(cmdEntity.getCommandStatus()) { case ACTIVE_SYNC: case NOT_STARTED: coco.retrieveCommand(cmdEntity.getId()).setCommandStatus(CommandStatus.FAILED_RESTARTED); break; default: if (!cmdEntity.isCallBackNotified()) { addToCallBackMap(cmdEntity); } break; } } cmdExecutorInitialized = true; } }
Source:
public void initSelectedMacPool() { Collection<MacPool> allMacPools = getMacPoolListModel().getItems(); StoragePool dc = getEntity(); if (allMacPools != null && dc != null) { Guid macPoolId = dc.getMacPoolId(); START if (macPoolId != null) { END for (MacPool macPool : allMacPools) { if (macPoolId.equals(macPool.getId())) { getMacPoolListModel().setSelectedItem(macPool); break; } } } } } 1. And what if it it is null? Shouldn't you choose the default pool? 2. Should be part of the previous patch.

Target:
public void initSelectedMacPool() { Collection<MacPool> allMacPools = getMacPoolListModel().getItems(); StoragePool dc = getEntity(); if (allMacPools != null && dc != null) { Guid macPoolId = dc.getMacPoolId(); for (MacPool macPool : allMacPools) { if (macPool.getId().equals(macPoolId)) { getMacPoolListModel().setSelectedItem(macPool); break; } } } }
Source:
public TextBoxLabel() { super(new EmptyValueRenderer<String>() { @Override public String render(String value) { START String renderedText = super.render(value); END return renderedText; } }); } in case you are removing the SafeHtmlUtils.htmlEscape(renderedText); you do not need to override the render() method. Please use only: super(new EmptyValueRenderer<String>());

Target:
public TextBoxLabel() { super(new EmptyValueRenderer<String>()); }
Source:
public void remove() { if (getConfirmWindow() != null) { return; } START ConfirmationModel model = getRemoveQosModel(); END setConfirmWindow(model); } variable can be removed

Target:
public void remove() { if (getConfirmWindow() != null) { return; } setConfirmWindow(getRemoveQosModel()); }
Source:
public void newQos() { if (getWindow() != null) { return; } final NewQosModel<T, P> newQosModel = getNewQosModel(); setWindow(newQosModel); START newQosModel.getDataCenters().setItems(Arrays.asList(getEntity())); END newQosModel.getDataCenters().setSelectedItem(getEntity()); } use this signature: 'setItems(Collection<T> value, T selectedItem)'

Target:
public void newQos() { if (getWindow() != null) { return; } final NewQosModel<T, P> newQosModel = getNewQosModel(); setWindow(newQosModel); newQosModel.getDataCenters().setItems(Arrays.asList(getEntity()), getEntity()); }
Source:
protected void addCommands() { START UICommand tempVar2 = new UICommand("OnSave", this); //$NON-NLS-1$ END tempVar2.setTitle(ConstantsManager.getInstance().getConstants().ok()); tempVar2.setIsDefault(true); getCommands().add(tempVar2); UICommand tempVar3 = new UICommand("Cancel", this); //$NON-NLS-1$ tempVar3.setTitle(ConstantsManager.getInstance().getConstants().cancel()); tempVar3.setIsCancel(true); getCommands().add(tempVar3); } rename tempvar

Target:
protected void addCommands() { getCommands().add(new UICommand("OnSave", this).setTitle(ConstantsManager.getInstance().getConstants().ok()) //$NON-NLS-1$ .setIsDefault(true)); getCommands().add(new UICommand("Cancel", this).setTitle(ConstantsManager.getInstance().getConstants().cancel()) //$NON-NLS-1$ .setIsCancel(true)); }
Source:
public void edit(QosModel<StorageQos, StorageQosParametersModel> object) { qosWidget.edit(object.getQosParametersModel()); START driver.edit(object); END } call driver's edit first

Target:
public void edit(QosModel<StorageQos, StorageQosParametersModel> object) { driver.edit(object); qosWidget.edit(object.getQosParametersModel()); }
Source:
START static String getResourceBundleName() { END return "bundles/AuditLogMessages"; } package private.

Target:
private static String getResourceBundleName() { return "bundles/AuditLogMessages"; }
Source:
private void scheduleCheckStatus() { START if (scheduledStatusCheckInProgress || reportsWebappDeployed) { END return; } scheduledStatusCheckInProgress = true; Scheduler.get().scheduleFixedDelay( new Scheduler.RepeatingCommand() { @Override public boolean execute() { if (retryCount > MAX_RETRY_COUNTS || reportsWebappDeployed) { scheduledStatusCheckInProgress = false; return false; } retryCount++; checkReportsWebAppStatus(); return true; } }, RETRY_INTERVAL); } I see you"ve moved 'reportsWebappDeployed' but what about 'retryCount > MAX_RETRY_COUNTS'?

Target:
private void scheduleCheckStatus() { scheduledStatusCheckInProgress = true; Scheduler.get().scheduleFixedDelay( new Scheduler.RepeatingCommand() { @Override public boolean execute() { if (retryCount > MAX_RETRY_COUNTS || reportsWebappDeployed) { scheduledStatusCheckInProgress = false; return false; } retryCount++; checkReportsWebAppStatus(); return true; } }, RETRY_INTERVAL); }
Source:
private void scheduleCheckStatus() { START if (urlInitialized && reportBaseUrl.trim().isEmpty()) { END return; } if (scheduledStatusCheckInProgress) { return; } scheduledStatusCheckInProgress = true; Scheduler.get().scheduleFixedDelay( new Scheduler.RepeatingCommand() { @Override public boolean execute() { if (retryCount > MAX_RETRY_COUNTS || reportsWebappDeployed) { scheduledStatusCheckInProgress = false; return false; } retryCount++; checkReportsWebAppStatus(); return true; } }, RETRY_INTERVAL); } IMO, urlInitialized check here is redundant. I"m not sure how can you get to this point with urlInitialized=false. (And if it is false- don't you want to return?)

Target:
private void scheduleCheckStatus() { if (scheduledStatusCheckInProgress || reportsWebappDeployed) { return; } scheduledStatusCheckInProgress = true; Scheduler.get().scheduleFixedDelay( new Scheduler.RepeatingCommand() { @Override public boolean execute() { if (retryCount > MAX_RETRY_COUNTS || reportsWebappDeployed) { scheduledStatusCheckInProgress = false; return false; } retryCount++; checkReportsWebAppStatus(); return true; } }, RETRY_INTERVAL); }
Source:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String queryString = request.getQueryString(); if (StringUtils.isNotEmpty(queryString)) { if (url.indexOf("?") == -1) { url += "?"; } else { url += "&"; } url += queryString; } START response.sendRedirect(response.encodeRedirectURL(url)); END } I am almost sure you cannot encode the query string, as result is double encode.

Target:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String queryString = request.getQueryString(); if (StringUtils.isNotEmpty(queryString)) { if (url.indexOf("?") == -1) { url += "?"; } else { url += "&"; } url += queryString; } response.sendRedirect(url); }
Source:
START private void scheduleCheckStatus() { END scheduledStatusCheckInProgress = true; Scheduler.get().scheduleFixedDelay( new Scheduler.RepeatingCommand() { @Override public boolean execute() { if (retryCount > MAX_RETRY_COUNTS || reportsWebappDeployed) { scheduledStatusCheckInProgress = false; return false; } retryCount++; checkReportsWebAppStatus(); return true; } }, RETRY_INTERVAL); } Why did you move the if from here? Should be- if (scheduledStatusCheckInProgress || retryCount > MAX_RETRY_COUNTS || reportsWebappDeployed) { return; } It is better to keep the if here over duplicating it to 'onError' and 'Response.SC_NOT_FOUND'

Target:
private void scheduleCheckStatus() { if (scheduledStatusCheckInProgress || retryCount > MAX_RETRY_COUNTS || reportsWebappDeployed) { return; } scheduledStatusCheckInProgress = true; Scheduler.get().scheduleFixedDelay( new Scheduler.RepeatingCommand() { @Override public boolean execute() { if (retryCount > MAX_RETRY_COUNTS || reportsWebappDeployed) { scheduledStatusCheckInProgress = false; return false; } retryCount++; checkReportsWebAppStatus(); return true; } }, RETRY_INTERVAL); }
Source:
protected List<Guid> executeHSMGetStorageDomainsList(HSMGetStorageDomainsListVDSCommandParameters parameters) { START return (ArrayList<Guid>) runVdsCommand(VDSCommandType.HSMGetStorageDomainsList, parameters).getReturnValue(); END } can it be cast to List?

Target:
protected List<Guid> executeHSMGetStorageDomainsList(HSMGetStorageDomainsListVDSCommandParameters parameters) { return (List<Guid>) runVdsCommand(VDSCommandType.HSMGetStorageDomainsList, parameters).getReturnValue(); }
Source:
public void testImportVMFromConfigurationWhenVMDoesNotExists() { initCommand(null); assertFalse(cmd.canDoAction()); START Assert.assertTrue(cmd.getReturnValue() END .getCanDoActionMessages() .contains(VdcBllMessages.ACTION_TYPE_FAILED_UNSUPPORTED_OVF.toString())); } remove 'Assert.' (there's already a static import)

Target:
public void testImportVMFromConfigurationWhenVMDoesNotExists() { initCommand(null); assertFalse(cmd.canDoAction()); assertTrue(cmd.getReturnValue() .getCanDoActionMessages() .contains(VdcBllMessages.ACTION_TYPE_FAILED_UNSUPPORTED_OVF.toString())); }
Source:
public void testImportVMFromConfigurationXMLCouldNotGetParsed() { OvfEntityData ovfEntity = getOvfEntityData(); ovfEntity.setOvfData("This is not a valid XML"); initCommand(ovfEntity); when(unregisteredOVFDataDao.getByEntityIdAndStorageDomain(vmId, storageDomainId)).thenReturn(ovfEntity); assertFalse(cmd.canDoAction()); START Assert.assertTrue(cmd.getReturnValue() END .getCanDoActionMessages() .contains(VdcBllMessages.ACTION_TYPE_FAILED_OVF_CONFIGURATION_NOT_SUPPORTED.toString())); } remove 'Assert.' (there's already a static import)

Target:
public void testImportVMFromConfigurationXMLCouldNotGetParsed() { OvfEntityData ovfEntity = getOvfEntityData(); ovfEntity.setOvfData("This is not a valid XML"); initCommand(ovfEntity); when(unregisteredOVFDataDao.getByEntityIdAndStorageDomain(vmId, storageDomainId)).thenReturn(ovfEntity); assertFalse(cmd.canDoAction()); assertTrue(cmd.getReturnValue() .getCanDoActionMessages() .contains(VdcBllMessages.ACTION_TYPE_FAILED_OVF_CONFIGURATION_NOT_SUPPORTED.toString())); }
Source:
private void setXmlOvfData() { try { xmlOvfData = new String(Files.readAllBytes(Paths.get(VM_OVF_XML_DATA))); START } catch (IOException e) { END e.printStackTrace(); } } Just throw it upwards.

Target:
private void setXmlOvfData() throws IOException { xmlOvfData = new String(Files.readAllBytes(Paths.get(VM_OVF_XML_DATA))); }
Source:
START protected ImportVmParameters createParametersWhenImagesExistOnTargetStorageDomain() { END ImportVmParameters params = new ImportVmParameters(); params.setContainerId(vmId); params.setStorageDomainId(storageDomainId); params.setVdsGroupId(clusterId); params.setImagesExistOnTargetStorageDomain(true); return params; } should be private static

Target:
private static ImportVmParameters createParametersWhenImagesExistOnTargetStorageDomain() { ImportVmParameters params = new ImportVmParameters(); params.setContainerId(vmId); params.setStorageDomainId(storageDomainId); params.setVdsGroupId(clusterId); params.setImagesExistOnTargetStorageDomain(true); return params; }
Source:
protected boolean canDoAction() { parameter = getParameters(); if (parameter == null || parameter.getVolumeId() == null || parameter.getSlaveNodeIp() == null || parameter.getSlaveVolumeName() == null) { return false; } masterVolume = getGlusterVolumeDao().getById(parameter.getVolumeId()); START if (masterVolume.getStatus() == GlusterStatus.DOWN) { END return false; } return true; } Do we need a null check here for masterVolume ??

Target:
protected boolean canDoAction() { parameter = getParameters(); if (parameter == null || parameter.getVolumeId() == null || parameter.getSlaveNodeIp() == null || parameter.getSlaveVolumeName() == null) { return false; } if(masterVolume == null) { return false; } masterVolume = getGlusterVolumeDao().getById(parameter.getVolumeId()); if (masterVolume.getStatus() == GlusterStatus.DOWN) { return false; } return true; }
Source:
public UpdateGlusterHostPubKeyToSlaveParameters(Guid vdsId, List<String> pubKeys) { START this(vdsId, pubKeys, "root"); END } may want to externalise to constants..in a separate patch maybe? call it GEOREP_ROOT_USER or similar

Target:
public UpdateGlusterHostPubKeyToSlaveParameters(Guid vdsId, List<String> pubKeys) { this(vdsId, pubKeys, null); }
Source:
public void updataMaxVmsInPool() { AsyncDataProvider.getInstance().getInstance().getMaxVmsInPool(new AsyncQuery(this, START new INewAsyncCallback() { END @Override public void onSuccess(Object target, Object returnValue) { VmModelBehaviorBase behavior = (VmModelBehaviorBase) target; behavior.setMaxVmsInPool((Integer) returnValue); behavior.updateMaxNumOfVmCpus(); } } )); } getInstance().getInstance() ?

Target:
public void updataMaxVmsInPool() { AsyncDataProvider.getInstance().getMaxVmsInPool(new AsyncQuery(this, new INewAsyncCallback() { @Override public void onSuccess(Object target, Object returnValue) { VmModelBehaviorBase behavior = (VmModelBehaviorBase) target; behavior.setMaxVmsInPool((Integer) returnValue); behavior.updateMaxNumOfVmCpus(); } } )); }
Source:
protected void executeQueryCommand() { // Get the list of authentication profile names: List<ExtensionProxy> extensions = getExtensionsManager().getExtensionsByService(Authz.class.getName()); List<String> names = new ArrayList<>(extensions.size()); for (ExtensionProxy extension : extensions) { names.add(AuthzUtils.getName(extension)); } if (getParameters().getFilterInternalDomain()) { START names.remove(INTERNAL); END } sort(names); // Return the sorted list: getQueryReturnValue().setReturnValue(names); } why do we remove internal? internal should be as any other.

Target:
protected void executeQueryCommand() { // Get the list of authentication profile names: List<ExtensionProxy> extensions = getExtensionsManager().getExtensionsByService(Authz.class.getName()); List<String> names = new ArrayList<>(extensions.size()); for (ExtensionProxy extension : extensions) { names.add(AuthzUtils.getName(extension)); } sort(names); // Return the sorted list: getQueryReturnValue().setReturnValue(names); }
Source:
START private List<DiskImage> getAllDisks(List<DiskImage> newDisksList, List<DiskImage> cloneDisksList) { END List<DiskImage> disksList = new ArrayList<>(); disksList.addAll(newDisksList); disksList.addAll(cloneDisksList); return disksList; } should be static.

Target:
private static List<DiskImage> getAllDisks(List<DiskImage> newDisksList, List<DiskImage> cloneDisksList) { List<DiskImage> disksList = new ArrayList<>(); disksList.addAll(newDisksList); disksList.addAll(cloneDisksList); return disksList; }
Source:
protected MemoryImageBuilder getMemoryImageBuilder() { START if (null == memoryBuilder) { END memoryBuilder = createMemoryImageBuilder(); } return memoryBuilder; } I'd flip the comparison - if (memoryBuilder == null) - seems more readable.

Target:
protected MemoryImageBuilder getMemoryImageBuilder() { if (memoryBuilder == null) { memoryBuilder = createMemoryImageBuilder(); } return memoryBuilder; }
Source:
private VolumeType getVolumeTypeForDomain() { START if (null == volumeTypeForDomain) { END StorageDomainStatic sdStatic = DbFacade.getInstance().getStorageDomainStaticDao().get(storageDomainId); volumeTypeForDomain = HibernateVmCommand.getMemoryVolumeTypeForStorageDomain(sdStatic.getStorageType()); } return volumeTypeForDomain; } here too - why is the null on the left side?

Target:
private VolumeType getVolumeTypeForDomain() { if (volumeTypeForDomain == null) { StorageDomainStatic sdStatic = DbFacade.getInstance().getStorageDomainStaticDao().get(storageDomainId); volumeTypeForDomain = HibernateVmCommand.getMemoryVolumeTypeForStorageDomain(sdStatic.getStorageType()); } return volumeTypeForDomain; }
Source:
public void setCommandExecuted() { START Transaction transaction = TransactionSupport.suspend(); END try { TaskManagerUtil.updateCommandExecuted(getCommandId()); } finally { TransactionSupport.resume(transaction); } } Ravi, if the thread is not in transaction, suspend() returns null. Is it safe to pass null to resume?

Target:
public void setCommandExecuted() { Transaction transaction = TransactionSupport.suspend(); try { TaskManagerUtil.updateCommandExecuted(getCommandId()); } finally { if (transaction != null) { TransactionSupport.resume(transaction); } } }
Source:
public Fails(VdcBllMessages expected, String... variableReplacements) { START matcher = CoreMatchers.allOf( END not(isValid()), new WithMessage(expected), hasVariableReplacements(variableReplacements)); } you should also replace the access to CoreMatchers.allOf with a static import of allOf to be consistent.

Target:
public Fails(VdcBllMessages expected, String... variableReplacements) { matcher = allOf( not(isValid()), new WithMessage(expected), hasVariableReplacements(variableReplacements)); }
Source:
public ValidationResult(VdcBllMessages message, String... variableReplacements) { if (message == null) { throw new IllegalArgumentException("message must not be null"); } this.message = message; START this.variableReplacements = variableReplacements == null END ? null : Collections.unmodifiableList(Arrays.asList(variableReplacements)); } I think it would be more readable if written as: if (variableReplacements != null) { this.variableReplacements = Collections.unmodifiableList(Arrays.asList(variableReplacements)); }

Target:
public ValidationResult(VdcBllMessages message, String... variableReplacements) { if (message == null) { throw new IllegalArgumentException("message must not be null"); } this.message = message; if (variableReplacements != null) { this.variableReplacements = Collections.unmodifiableList(Arrays.asList(variableReplacements)); } }
Source:
protected void findGroups(String searchString, AsyncQuery query) { Frontend.getInstance() .runQuery(VdcQueryType.Search, START new DirectorySearchParameters("ADGROUP@" + ((ProfileEntry) getProfile().getSelectedItem()).getAuthz() + ": " + searchString, SearchType.DirectoryGroup, (String) getNamespace().getSelectedItem()), query); //$NON-NLS-1$ //$NON-NLS-2$ END } If you"ll use generics you won't need this cast.

Target:
protected void findGroups(String searchString, AsyncQuery query) { Frontend.getInstance() .runQuery(VdcQueryType.Search, new DirectorySearchParameters("ADGROUP@" + ((ProfileEntry) getProfile().getSelectedItem()).getAuthz() + ": " + searchString, SearchType.DirectoryGroup, getNamespace().getSelectedItem()), query); //$NON-NLS-1$ //$NON-NLS-2$ }
Source:
public List getEmulatedMachinesList() { // List resultList = lst(); List resultList = lst(); resultList.add("vdsmfake"); START resultList.add("host25-rack06.scale.openstack.engineering.redhat.com"); END resultList.add("pc-0.12"); resultList.add("pc-0.13"); resultList.add("pc-0.14"); resultList.add("pc-0.15"); resultList.add("pc-1.0"); resultList.add("pc-1.0"); resultList.add("rhel6.4.0"); resultList.add("pc"); resultList.add("isapc"); return resultList; } please remove this one

Target:
public List getEmulatedMachinesList() { // List resultList = lst(); List resultList = lst(); resultList.add("vdsmfake"); resultList.add("pc-0.12"); resultList.add("pc-0.13"); resultList.add("pc-0.14"); resultList.add("pc-0.15"); resultList.add("pc-1.0"); resultList.add("pc-1.0"); resultList.add("rhel6.4.0"); resultList.add("pc"); resultList.add("isapc"); return resultList; }
Source:
START protected static END void removeNetworkFromHosts(Network network, CommandContext context, List<VdsNetworkInterface> nics) { RemoveNetworkParametersBuilder builder = new RemoveNetworkParametersBuilder(network, context); ArrayList<VdcActionParametersBase> parameters = builder.buildParameters(nics); if (!parameters.isEmpty()) { NetworkParametersBuilder.updateParametersSequencing(parameters); Backend.getInstance().runInternalMultipleActions(VdcActionType.PersistentSetupNetworks, parameters, context); } } Why protected and not private?

Target:
private static void removeNetworkFromHosts(Network network, CommandContext context, List<VdsNetworkInterface> nics) { RemoveNetworkParametersBuilder builder = new RemoveNetworkParametersBuilder(network, context); ArrayList<VdcActionParametersBase> parameters = builder.buildParameters(nics); if (!parameters.isEmpty()) { NetworkParametersBuilder.updateParametersSequencing(parameters); Backend.getInstance().runInternalMultipleActions(VdcActionType.PersistentSetupNetworks, parameters, context); } }
Source:
public void onLogout() { AsyncQuery query = new AsyncQuery(); query.setHandleFailure(true); START query.setModel(this); END query.asyncCallback = new INewAsyncCallback() { @Override public void onSuccess(Object model, Object ReturnValue) { Window.Location.reload(); } }; frontend.logoffAsync(frontend.getLoggedInUser(), query); } "this" is not a model, rather than a UI infra object (BaseApplicationInit). Original code (in UserPortal ApplicationInit) was presumably copy-pasted from CommonModel#signOut method, where "this" refers to CommonModel. I suggest to remove this line, I don't think it has any effect here.

Target:
public void onLogout() { AsyncQuery query = new AsyncQuery(); query.setHandleFailure(true); query.asyncCallback = new INewAsyncCallback() { @Override public void onSuccess(Object model, Object ReturnValue) { // Reload entire application after the user has logged out successfully on backend. Window.Location.reload(); } }; frontend.logoffAsync(frontend.getLoggedInUser(), query); }
Source:
private boolean isOptionEnabledOnVolume(GlusterVolumeEntity volume, List<PredicateFilter<GlusterVolumeOptionEntity>> predicates) { List<GlusterVolumeOptionEntity> volumeOptionsEnabled = new ArrayList<GlusterVolumeOptionEntity>(volume.getOptions()); List<GlusterVolumeOptionEntity> filteredOptions = volumeOptionsEnabled; for(PredicateFilter<GlusterVolumeOptionEntity> predicate : predicates) { START filteredOptions = ListUtils.filter(volumeOptionsEnabled, predicate); END } if(filteredOptions.size() > 0) { return true; } return false; } shouldn't this be filteredOptions = ListUtils.filter(filteredOptions, predicate);

Target:
private boolean isOptionEnabledOnVolume(GlusterVolumeEntity volume, List<PredicateFilter<GlusterVolumeOptionEntity>> predicates) { List<GlusterVolumeOptionEntity> volumeOptionsEnabled = new ArrayList<GlusterVolumeOptionEntity>(volume.getOptions()); List<GlusterVolumeOptionEntity> filteredOptions = volumeOptionsEnabled; for(PredicateFilter<GlusterVolumeOptionEntity> predicate : predicates) { filteredOptions = ListUtils.filter(filteredOptions, predicate); } if(filteredOptions.size() > 0) { return true; } return false; }
Source:
private String generateTokenValueResponse() { byte[] tokenBytes; HttpSession session = getThreadLocalRequest().getSession(); synchronized (session) { if (session.getAttribute(XSRF_TOKEN) == null) { tokenBytes = new byte[TOKEN_SIZE]; //nextBytes is thread safe. random.nextBytes(tokenBytes); session.setAttribute(XSRF_TOKEN, tokenBytes); } else { tokenBytes = (byte[]) session.getAttribute(XSRF_TOKEN); START } END } return StringUtils.toHexString(tokenBytes); } either get this once or get it always... two patterns: sync { tokenBytes = (byte[]) session.getAttribute(XSRF_TOKEN); if (tokenBytes == null) { ... session.setAttribute(XSRF_TOKEN, tokenBytes); } } or: sync { if (session.getAttribute(XSRF_TOKEN) == null) { ... session.setAttribute(XSRF_TOKEN, tokenBytes); } } tokenBytes = (byte[]) session.getAttribute(XSRF_TOKEN);

Target:
private String generateTokenValueResponse() { byte[] tokenBytes; HttpSession session = getThreadLocalRequest().getSession(); synchronized (session) { tokenBytes = (byte[]) session.getAttribute(XSRF_TOKEN); if (session.getAttribute(XSRF_TOKEN) == null) { tokenBytes = new byte[TOKEN_SIZE]; //nextBytes is thread safe. random.nextBytes(tokenBytes); session.setAttribute(XSRF_TOKEN, tokenBytes); } } return StringUtils.toHexString(tokenBytes); }
Source:
public AuditLogType getAuditLogTypeValue() { if (getSucceeded()) { return AuditLogType.USER_VDS_STOP; START } else { END return skippedDueToFencingPolicy ? AuditLogType.VDS_NOT_STOPPED_DUE_TO_POLICY : AuditLogType.USER_FAILED_VDS_STOP; } } From the user point of view the action that failed was restarting the Host. That's true that we are implementing Restart as stop-wait-start-wait but this should be transparent to the user IMO and the log should say that the restart operation had failed I see that the log of the NonRespondingTreatmentCommand does exactly that so IMO this block should remain without any change : @Override public AuditLogType getAuditLogTypeValue() { return getSucceeded() ? AuditLogType.USER_VDS_STOP : AuditLogType.USER_FAILED_VDS_STOP;

Target:
public AuditLogType getAuditLogTypeValue() { return getSucceeded() ? AuditLogType.USER_VDS_STOP : AuditLogType.USER_FAILED_VDS_STOP; }
Source:
public void discoverNetworks() { START ArrayList<Provider<?>> END items = new ArrayList<Provider<?>>(); items.add(provider); getProviders().setItems(items); getProviders().setSelectedItem(provider); } Please change the left side to Collection.

Target:
public void discoverNetworks() { Collection<Provider<?>> items = new ArrayList<Provider<?>>(); items.add(provider); getProviders().setItems(items); getProviders().setSelectedItem(provider); }
Source:
public void testGetEntityNameByIdAndTypeForCpuProfile() { CpuProfile cpuProfile = dbFacade.getCpuProfileDao().get(FixturesTool.CPU_PROFILE_1); assertNotNull(cpuProfile); String name = cpuProfile.getName(); START assertTrue(name.equals(dbFacade.getEntityNameByIdAndType(FixturesTool.CPU_PROFILE_1, VdcObjectType.CpuProfile))); END } can you replace with assertEquals?

Target:
public void testGetEntityNameByIdAndTypeForCpuProfile() { CpuProfile cpuProfile = dbFacade.getCpuProfileDao().get(FixturesTool.CPU_PROFILE_1); assertNotNull(cpuProfile); String name = cpuProfile.getName(); assertEquals(name, dbFacade.getEntityNameByIdAndType(FixturesTool.CPU_PROFILE_1, VdcObjectType.CpuProfile)); }
Source:
protected void updateMemoryBalloon() { if (getModel().getSelectedCluster() != null) { VDSGroup cluster = getModel().getSelectedCluster(); boolean hasMemoryBalloon = (cluster.getcompatibility_version() .compareTo(VmListModel.BALLOON_DEVICE_MIN_VERSION) >= 0 && cluster.getArchitecture() START .compareTo(VmListModel.BALLOON_DEVICE_BLACKLISTED_ARCH) != 0); END getModel().getMemoryBalloonDeviceEnabled().setIsAvailable(hasMemoryBalloon); } } please change to equals()

Target:
protected void updateMemoryBalloon() { if (getModel().getSelectedCluster() != null) { VDSGroup cluster = getModel().getSelectedCluster(); boolean hasMemoryBalloon = (cluster.getcompatibility_version() .compareTo(VmListModel.BALLOON_DEVICE_MIN_VERSION) >= 0 && cluster.getArchitecture() .equals(VmListModel.BALLOON_DEVICE_BLACKLISTED_ARCH)); getModel().getMemoryBalloonDeviceEnabled().setIsAvailable(hasMemoryBalloon); } }
Source:
private CommandEntity getParentCommandEntity(Guid cmdId, VdcActionType actionType, VdcActionParametersBase parameters) { START CommandEntity cmdEntity = Guid.isNullOrEmpty(cmdId) ? null : coco.getCommandEntity(cmdId); END if (cmdEntity == null) { cmdEntity = coco.createCommandEntity(cmdId, actionType, parameters); if (!Guid.isNullOrEmpty(cmdId)) { cmdEntity.setCommandStatus(CommandStatus.ACTIVE); coco.persistCommand(cmdEntity); } } return cmdEntity; } I think this already appeared before - maybe move the trenary if logic inside coco.getCommandEntity(guid) ?

Target:
private CommandEntity getParentCommandEntity(Guid cmdId, VdcActionType actionType, VdcActionParametersBase parameters) { CommandEntity cmdEntity = coco.getCommandEntity(cmdId); if (cmdEntity == null) { cmdEntity = coco.createCommandEntity(cmdId, actionType, parameters); if (!Guid.isNullOrEmpty(cmdId)) { cmdEntity.setCommandStatus(CommandStatus.ACTIVE); coco.persistCommand(cmdEntity); } } return cmdEntity; }
Source:
private boolean eventExists(String eventName) { START for (AuditLogType alt : AuditLogType.values()) { END if (alt.name().equals(eventName)) { return true; } } return false; } Wouldn't this solution be better rather than traverse through all values and do string comparisons? private boolean eventExists(String eventName) { boolean exists = false; try { AuditLogType.valueOf(eventName); exists = true; } catch (Exception ex) { } return exists; }

Target:
private boolean eventExists(String eventName) { boolean exists = false; try { AuditLogType.valueOf(eventName); exists = true; } catch (Exception ex) { } return exists; }
Source:
START public List<GlusterGeoRepSessionDetails> getSessionDetails() { END return sessionDetails; } HI, Is this being used by frontend? If so, shouldn't it be a concrete class, and not List? (See many other place in code), as GWT has issues with dynamic types/inheritance?

Target:
public ArrayList<GlusterGeoRepSessionDetails> getSessionDetails() { return sessionDetails; }
Source:
START public void executeQueryCommand() { END IscsiBond iscsiBond = getDbFacade().getIscsiBondDao().get(getParameters().getId()); if (iscsiBond != null) { iscsiBond.getNetworkIds().addAll(getDbFacade().getIscsiBondDao() .getNetworkIdsByIscsiBondId(iscsiBond.getId())); iscsiBond.getStorageConnectionIds().addAll(getDbFacade().getIscsiBondDao() .getStorageConnectionIdsByIscsiBondId(iscsiBond.getId())); getQueryReturnValue().setReturnValue(iscsiBond); } } Why make it public?

Target:
protected void executeQueryCommand() { IscsiBond iscsiBond = getDbFacade().getIscsiBondDao().get(getParameters().getId()); if (iscsiBond != null) { iscsiBond.getNetworkIds().addAll(getDbFacade().getIscsiBondDao() .getNetworkIdsByIscsiBondId(iscsiBond.getId())); iscsiBond.getStorageConnectionIds().addAll(getDbFacade().getIscsiBondDao() .getStorageConnectionIdsByIscsiBondId(iscsiBond.getId())); getQueryReturnValue().setReturnValue(iscsiBond); } }
Source:
START boolean isBalloonEnabled() { END Boolean balloonEnabled = getParameters().isBalloonEnabled(); return balloonEnabled != null ? balloonEnabled : VmDeviceUtils.isBalloonEnabled(getVmId()); } please make method protected

Target:
protected boolean isBalloonEnabled() { Boolean balloonEnabled = getParameters().isBalloonEnabled(); return balloonEnabled != null ? balloonEnabled : VmDeviceUtils.isBalloonEnabled(getVmId()); }
Source:
public void search() { START if (getEntity() != null) END super.search(); } why the braces removed?

Target:
public void search() { if (getEntity() != null) { super.search(); } }
Source:
private void closeConfirmationWindow() { if(getConfirmWindow() == null) { return; } else { setConfirmWindow(null); START } END } you could just do setConfirmWindow(null); like above method

Target:
private void closeConfirmationWindow() { setConfirmWindow(null); }
Source:
public boolean isCidrFormatValid(String cidr) { START return (cidr != null && cidr.matches(ValidationUtils.CIDR_FORMAT_PATTERN)); END } no need for surrounding brackets

Target:
public boolean isCidrFormatValid(String cidr) { return cidr != null && cidr.matches(ValidationUtils.CIDR_FORMAT_PATTERN); }
Source:
public boolean isCidrFormatValid(String cidr) { START return (cidr == null || !cidr.matches(ValidationUtils.CIDR_FORMAT_PATTERN)) ? END false : true; } it could be replaced only by: return cidr != null && cidr.matches(ValidationUtils.CIDR_FORMAT_PATTERN);

Target:
public boolean isCidrFormatValid(String cidr) { return (cidr != null && cidr.matches(ValidationUtils.CIDR_FORMAT_PATTERN)); }
Source:
START public static boolean isCidrFormatValid(String cidr) { END return (cidr == null || !cidr.matches(ValidationUtils.CIDR_FORMAT_PATTERN)) ? false : true; } can the methods be non-static?

Target:
public boolean isCidrFormatValid(String cidr) { return (cidr == null || !cidr.matches(ValidationUtils.CIDR_FORMAT_PATTERN)) ? false : true; }
Source:
private static int covnertIpToInt(String ipAdd) { String[] subAdd = ipAdd.split("\\."); int output = 0; int temp; START for (int index = 3; index > -1; index--) { END temp = Integer.parseInt(subAdd[3 - index]); temp <<= (index * 8); output |= temp; } return output; } 1. OutOfBoundaries prone. 2. Why do you start from the less significant part?

Target:
private static long covnertIpToInt(String ipAdd) { String[] subAdd = ipAdd.split("\\."); long output = 0; long temp; for (int index = 3; index > -1; index--) { temp = Integer.parseInt(subAdd[3 - index]); temp <<= (index * 8); output |= temp; } return output; }
Source:
public CidrContainer(String cidr) { START super(); END this.cidr = cidr; } the call for the empty c'tor is redundant.

Target:
public CidrContainer(String cidr) { this.cidr = cidr; }
Source:
public ValidationResult validate(Object value) { START assert value instanceof String; END String cidr = (String) value; ValidationResult result = new ValidationResult(); if (!CidrValidator.isCidrFormatValid(cidr)) { return failWith(result, getThisFieldMustContainCidrInFormatMsg()); } else if (!CidrValidator.isCidrNetworkAddressValid(cidr)) { return failWith(result, getCidrNotNetworkAddress()); } else { result.setSuccess(true); return result; } } 1. Shouldn't you check assert (value == null || value instanceof String)? 2. Please add some text explaining why this assertion was made in case it fails (e.g. "This validation must be applied to a String").

Target:
public ValidationResult validate(Object value) { //This validation must be applied to a String assert value==null ||value instanceof String; String cidr = (String) value; ValidationResult result = new ValidationResult(); result.setSuccess(true); if (!CidrValidator.isCidrFormatValid(cidr)) { failWith(result, getThisFieldMustContainCidrInFormatMsg()); } else if (!CidrValidator.isCidrNetworkAddressValid(cidr)) { failWith(result, getCidrNotNetworkAddress()); } return result; }
Source:
public void setCustomEmulatedMachine(String customEmulatedMachine) { START this.customEmulatedMachine = ((customEmulatedMachine == null || customEmulatedMachine.length() == 0) ? null : customEmulatedMachine); END } please use trim().isEmpty() instead of length check

Target:
public void setCustomEmulatedMachine(String customEmulatedMachine) { this.customEmulatedMachine = ((customEmulatedMachine == null || customEmulatedMachine.trim().isEmpty()) ? null : customEmulatedMachine); }
Source:
public void succededToHibernate() { TransactionSupport.executeInNewTransaction( new TransactionMethod<Object>() { @Override public Object runInTransaction() { START VmDynamic vmDynamic = db().getVmDynamicDao().get(id); END vmDynamic.setStatus(VMStatus.SavingState); update(vmDynamic); return null; } } ); } you can just use getVmDynamicDao()

Target:
public void succededToHibernate() { TransactionSupport.executeInNewTransaction( new TransactionMethod<Object>() { @Override public Object runInTransaction() { VmDynamic vmDynamic = getVmDynamicDao().get(id); vmDynamic.setStatus(VMStatus.SavingState); update(vmDynamic); return null; } } ); }
Source:
START protected void setActionMessageParameters() { END addCanDoActionMessage(VdcBllMessages.VAR__ACTION__PAUSE); } call super.setActionMessageParameters();

Target:
protected void setActionMessageParameters() { super.setActionMessageParameters(); addCanDoActionMessage(VdcBllMessages.VAR__ACTION__PAUSE); }
Source:
protected boolean canDoAction() { START setGlusterVolumeId(getGeoRepSession().getMasterVolumeId()); END if (!super.canDoAction()) { return false; } if (getGeoRepSession().getStatus() == GeoRepSessionStatus.PASSIVE) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_GEOREP_SESSION_ALREADY_PAUSED); } return false; } Will the volumeId not be set in the constructor from parameters?

Target:
protected boolean canDoAction() { if (!super.canDoAction()) { return false; } if (getGeoRepSession().getStatus() == GeoRepSessionStatus.PASSIVE) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_GEOREP_SESSION_ALREADY_PAUSED); } return false; }
Source:
START public synchronized ArrayList getStorageDelay() { END return storageDelay; } Why you synchronized all the getters to Lists?

Target:
public ArrayList getStorageDelay() { return storageDelay; }
Source:
public Map getVmStats(String uuid) { final Host host = getActiveHost(); //about to add some changes Map resultMap = getDoneStatus(); List statusList = new ArrayList(); START VM vm = host.getRunningVMs().get(uuid); END statusList.add(fillVmStatsMap(vm)); resultMap.put("statsList", statusList); Utils.getLatency(); return resultMap; } Can vm be null here?

Target:
public Map getVmStats(String uuid) { final Host host = getActiveHost(); Map resultMap = getDoneStatus(); List statusList = new ArrayList(); VM vm = host.getRunningVMs().get(uuid); if (vm != null){ statusList.add(fillVmStatsMap(vm)); } resultMap.put("statsList", statusList); Utils.getLatency(); return resultMap; }
Source:
START public static Map getStatusMap(String message, int code) { END Map resultMap = new HashMap(); Map statusMap = new HashMap(); statusMap.put("message", message); statusMap.put("code", Integer.valueOf(code)); resultMap.put("status", statusMap); return resultMap; } It would be good to use Map<String, Object> to remove suppressed warnings.

Target:
public static Map getStatusMap(String message, int code) { Map<String, Object> resultMap = new HashMap(); Map<String, Object> statusMap = new HashMap(); statusMap.put("message", message); statusMap.put("code", Integer.valueOf(code)); resultMap.put("status", statusMap); return resultMap; }
Source:
public void testGetAllEntitiesForStorageDomain() { List<OvfEntityData> ovfEntityDataList = dao.getAllForStorageDomainByEntityType(FixturesTool.STORAGE_DOAMIN_NFS2_1, null); START assertTrue("There should be entities fetched for the specified storage domain", !ovfEntityDataList.isEmpty()); END assertEquals("A Template and a VM should be fetched for the specified storage domain", 2, ovfEntityDataList.size()); } There's no point in asserting the list isn't empty - you check its size on the next line. What you should do is assert it's not null

Target:
public void testGetAllEntitiesForStorageDomain() { List<OvfEntityData> ovfEntityDataList = dao.getAllForStorageDomainByEntityType(FixturesTool.STORAGE_DOAMIN_NFS2_1, null); assertEquals("A Template and a VM should be fetched for the specified storage domain", 2, ovfEntityDataList.size()); }
Source:
public void dispose() { log.info("vdsManager::disposing"); SchedulerUtilQuartzImpl.getInstance().deleteJob(onTimerJobId); XmlRpcUtils.shutDownConnection(_vdsProxy.getHttpClient()); START if (JsonRpcVdsServer.class.isInstance(_vdsProxy)) { END ((JsonRpcVdsServer) _vdsProxy).close(); } } do you think its a good idea to perform these steps in the client code? and for both implementations regardless of the instance in hand?

Target:
public void dispose() { log.info("vdsManager::disposing"); SchedulerUtilQuartzImpl.getInstance().deleteJob(onTimerJobId); _vdsProxy.close(); }
Source:
START private void updateCpus(VmNumaNode vmNumaNode, int coresPerNode, Integer cpuCount) { END List<Integer> coreList = new ArrayList<Integer>(); for (int j = 0; j < coresPerNode; j++, cpuCount++) { coreList.add(cpuCount); } vmNumaNode.setCpuIds(coreList); } I'd say you will not achieve here what you intended - the Integer is immutable so by cpuCount++ you just replace the value which has been passed here and will have no effect on the value outside of this function where it will still be always 0.

Target:
private Integer updateCpus(VmNumaNode vmNumaNode, int coresPerNode, Integer cpuCount) { List<Integer> coreList = new ArrayList<Integer>(); for (int j = 0; j < coresPerNode; j++, cpuCount++) { coreList.add(cpuCount); } vmNumaNode.setCpuIds(coreList); return cpuCount; }
Source:
public StatusOnlyReturnForXmlRpc glusterVolumeGeoRepSessionDelete(String volumeName, String remoteHost, String remoteVolumeName) { try { START return new StatusOnlyReturnForXmlRpc(vdsServer.glusterVolumeGeoRepSessionDelete(volumeName, remoteVolumeName, remoteVolumeName)); END } catch (UndeclaredThrowableException ute) { throw new XmlRpcRunTimeException(ute); } } remoteVolumeName passed twice. I feel remoteHost to be passed as second arg

Target:
public StatusOnlyReturnForXmlRpc glusterVolumeGeoRepSessionDelete(String volumeName, String remoteHost, String remoteVolumeName) { try { return new StatusOnlyReturnForXmlRpc(vdsServer.glusterVolumeGeoRepSessionDelete(volumeName, remoteHost, remoteVolumeName)); } catch (UndeclaredThrowableException ute) { throw new XmlRpcRunTimeException(ute); } }
Source:
START protected Map<String, Pair<String, String>> getExclusiveLocks() { END if (!isInternalExecution()) { return Collections.singletonMap(getGeoRepSession().getId().toString(), LockMessagesMatchUtil.makeLockingPair(LockingGroup.GLUSTER_GEOREP, VdcBllMessages.ACTION_TYPE_FAILED_GEOREP_SESSION_LOCKED)); } return super.getExclusiveLocks(); } It get lock on the georep session in one case. But in else case, it will get the lock on the cluster level. Is it the expected behavior?

Target:
protected Map<String, Pair<String, String>> getExclusiveLocks() { if (!isInternalExecution()) { return Collections.singletonMap(getGeoRepSession().getId().toString(), LockMessagesMatchUtil.makeLockingPair(LockingGroup.GLUSTER_GEOREP, VdcBllMessages.ACTION_TYPE_FAILED_GEOREP_SESSION_LOCKED)); } return null; }