auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public Object execute(final ExecutionEvent event) throws ExecutionException { final ISelection currentSelection = HandlerUtil.getCurrentSelection(event); final Resource resourceSelected = getSelectedResource(currentSelection); final TableConfiguration configuration = getEditedTableConfiguration(resourceSelected); <START> CreateNattableConfigurationWizard wizard = new CreateNattableConfigurationWizard(configuration, resourceSelected); <END> WizardDialog dialog = new WizardDialog(Display.getDefault().getActiveShell(), wizard); dialog.open(); return null; }</code><technical_language>final</technical_language>

Target:
public Object execute(final ExecutionEvent event) throws ExecutionException { final ISelection currentSelection = HandlerUtil.getCurrentSelection(event); final Resource resourceSelected = getSelectedResource(currentSelection); final TableConfiguration configuration = getEditedTableConfiguration(resourceSelected); final CreateNattableConfigurationWizard wizard = new CreateNattableConfigurationWizard(configuration, resourceSelected); final WizardDialog dialog = new WizardDialog(Display.getDefault().getActiveShell(), wizard); dialog.open(); return null; }
Source:
<code>private Integer getNumPartitions(String topic) { try { return this.kafka.partitionsFor(topic).size(); } catch(TimeoutException e) { LOGGER.error("Topic '" + topic + "' name does not exist. Exception: " + e.getLocalizedMessage()); <START> throw e; <END> } }</code><technical_language>wondering tested this; 0.9 producer do smarter a non-existent topic? stuck guessing timeouts</technical_language>

Target:
private Integer getNumPartitions(String topic) { try { return this.kafka.partitionsFor(topic).size(); } catch (KafkaException e) { LOGGER.error("Topic '" + topic + "' name does not exist. Exception: " + e.getLocalizedMessage()); throw e; } }
Source:
<code>public boolean removeReplica(ReplicaId replicaId) { if (!partitionToPartitionInfo.containsKey(replicaId.getPartitionId())) { logger.error("{} doesn't exist in replication manager, skipping removing replica request.", replicaId.getPartitionId()); return false; } PartitionInfo partitionInfo = partitionToPartitionInfo.get(replicaId.getPartitionId()); List<RemoteReplicaInfo> remoteReplicaInfos = partitionInfo.getRemoteReplicaInfos(); logger.info("Removing remote replicas of from replica threads", replicaId.getPartitionId()); removeRemoteReplicaInfoFromReplicaThread(remoteReplicaInfos); <START> mountPathToPartitionInfos.get(replicaId.getMountPath()).remove(partitionInfo); <END> partitionToPartitionInfo.remove(replicaId.getPartitionId()); return true; }</code><technical_language>computeIfPresent is atomic for concurrent map. This avoid heavy copyOnWriteArrayList</technical_language>

Target:
public boolean removeReplica(ReplicaId replicaId) { if (!partitionToPartitionInfo.containsKey(replicaId.getPartitionId())) { logger.error("{} doesn't exist in replication manager, skipping removing replica request.", replicaId.getPartitionId()); return false; } PartitionInfo partitionInfo = partitionToPartitionInfo.get(replicaId.getPartitionId()); List<RemoteReplicaInfo> remoteReplicaInfos = partitionInfo.getRemoteReplicaInfos(); logger.info("Removing remote replicas of from replica threads", replicaId.getPartitionId()); removeRemoteReplicaInfoFromReplicaThread(remoteReplicaInfos); mountPathToPartitionInfos.computeIfPresent(replicaId.getMountPath(), (k, v) -> { v.remove(partitionInfo); return v; }); partitionToPartitionInfo.remove(replicaId.getPartitionId()); logger.info("{} is successfully removed from replication manager", replicaId.getPartitionId()); return true; }
Source:
<code>private void annotateDataMutations(UngroupedAggregateRegionObserver.MutationList mutationsList, Scan scan) { <START> byte[] tenantId = null; <END> byte[] logicalTableName = null; byte[] schemaName = null; byte[] tableType = null; byte[] ddlTimestamp = null; tenantId = scan.getAttribute(MutationState.MutationMetadataType.TENANT_ID.toString()); schemaName = scan.getAttribute(MutationState.MutationMetadataType.SCHEMA_NAME.toString()); logicalTableName = scan.getAttribute(MutationState.MutationMetadataType.LOGICAL_TABLE_NAME.toString()); tableType = scan.getAttribute(MutationState.MutationMetadataType.TABLE_TYPE.toString()); ddlTimestamp = scan.getAttribute(MutationState.MutationMetadataType.TIMESTAMP.toString()); for (Mutation m : mutationsList) { if (tenantId != null) { m.setAttribute(MutationState.MutationMetadataType.TENANT_ID.toString(), tenantId); } m.setAttribute(MutationState.MutationMetadataType.SCHEMA_NAME.toString(), schemaName); m.setAttribute(MutationState.MutationMetadataType.LOGICAL_TABLE_NAME.toString(), logicalTableName); m.setAttribute(MutationState.MutationMetadataType.TABLE_TYPE.toString(), tableType); m.setAttribute(MutationState.MutationMetadataType.TIMESTAMP.toString(), ddlTimestamp); } }</code><technical_language>nit: assigning variables representing MutationMetadataType (null scan.getAttribute()), assign of removing null assignments</technical_language>

Target:
private void annotateDataMutations(UngroupedAggregateRegionObserver.MutationList mutationsList, Scan scan) { byte[] tenantId = scan.getAttribute(MutationState.MutationMetadataType.TENANT_ID.toString()); byte[] schemaName = scan.getAttribute(MutationState.MutationMetadataType.SCHEMA_NAME.toString()); byte[] logicalTableName = scan.getAttribute(MutationState.MutationMetadataType.LOGICAL_TABLE_NAME.toString()); byte[] tableType = scan.getAttribute(MutationState.MutationMetadataType.TABLE_TYPE.toString()); byte[] ddlTimestamp = scan.getAttribute(MutationState.MutationMetadataType.TIMESTAMP.toString()); for (Mutation m : mutationsList) { annotateMutation(m, tenantId, schemaName, logicalTableName, tableType, ddlTimestamp); } }
Source:
<code>protected void connectSensors() { super.connectSensors(); connectServiceUpIsRunning(); setBrokerUrl(); <START> setAttribute(MANAGEMENT_URL, format("http://%s:%s/", getAttribute(HOSTNAME), getAttribute(MANAGEMENT_PORT))); <END> }</code><technical_language>this set if ENABLE_MANAGEMENT_PLUGIN is false</technical_language>

Target:
protected void connectSensors() { super.connectSensors(); connectServiceUpIsRunning(); setBrokerUrl(); if (getEnableManagementPlugin()) { setAttribute(MANAGEMENT_URL, format("http://%s:%s/", getAttribute(HOSTNAME), getAttribute(MANAGEMENT_PORT))); } }
Source:
<code>public void loadGroupByCenter(int centerId) { checkViewAttached(); getMvpView().showProgressbar(true); mSubscription.add(collectionDataManager.fetchGroupsAssociatedWithCenter(centerId) .observeOn(AndroidSchedulers.mainThread()) .subscribeOn(Schedulers.io()) .subscribe(new Subscriber<CenterWithAssociations>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { getMvpView().showProgressbar(false); <START> try { <END> if (e instanceof HttpException) { String errorMessage = ((HttpException) e).response().errorBody() .string(); getMvpView().showError(MFErrorParser.parseError(errorMessage) .getErrors().get(0).getDefaultUserMessage()); } } catch (Throwable throwable) { RxJavaPlugins.getInstance().getErrorHandler().handleError(e); } } @Override public void onNext(CenterWithAssociations centerWithAssociations) { getMvpView().showProgressbar(false); getMvpView().showGroupByCenter(centerWithAssociations); } })); }</code><technical_language>this utils method show error <LINK_0></technical_language>

Target:
public void loadGroupByCenter(int centerId) { checkViewAttached(); getMvpView().showProgressbar(true); mSubscription.add(collectionDataManager.fetchGroupsAssociatedWithCenter(centerId) .observeOn(AndroidSchedulers.mainThread()) .subscribeOn(Schedulers.io()) .subscribe(new Subscriber<CenterWithAssociations>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { getMvpView().showProgressbar(false); getMvpView().showError(MFErrorParser.errorMessage(e)); } @Override public void onNext(CenterWithAssociations centerWithAssociations) { getMvpView().showProgressbar(false); getMvpView().showGroupByCenter(centerWithAssociations); } })); }
Source:
<code>public Transferable getTransferable() { if (!myStatusIsSpecified && !isDataFlavorSupported(ItemTransferable.DESIGNER_FLAVOR) <START> && <END> isDataFlavorSupported(DataFlavor.stringFlavor)) { accept(DnDConstants.ACTION_COPY); } if (myDragEvent != null) { return myDragEvent.getTransferable(); } else { return myDropEvent.getTransferable(); } }</code><technical_language>Please wrap operators. <LINK_0></technical_language>

Target:
public Transferable getTransferable() { if (!myStatusSpecified && !isDataFlavorSupported(ItemTransferable.DESIGNER_FLAVOR) && isDataFlavorSupported(DataFlavor.stringFlavor)) { accept(DnDConstants.ACTION_COPY); } if (myDragEvent != null) { return myDragEvent.getTransferable(); } else { return myDropEvent.getTransferable(); } }
Source:
<code>public void process(Exchange exchange) throws Exception { final HazelcastOperation operation = lookupOperation(exchange); <START> switch ((operation != null) ? operation : HazelcastOperation.PUBLISH) { <END> case PUBLISH: this.publish(exchange); break; default: throw new IllegalArgumentException(String.format("The value '%s' is not allowed for parameter '%s' on the TOPIC cache.", operation, HazelcastConstants.OPERATION)); } HazelcastComponentHelper.copyHeaders(exchange); }</code><technical_language>nice if default operation is set endpoint configured lookupOperation return a null</technical_language>

Target:
public void process(Exchange exchange) throws Exception { final HazelcastOperation operation = lookupOperation(exchange); switch (operation) { case PUBLISH: this.publish(exchange); break; default: throw new IllegalArgumentException(String.format("The value '%s' is not allowed for parameter '%s' on the TOPIC cache.", operation, HazelcastConstants.OPERATION)); } HazelcastComponentHelper.copyHeaders(exchange); }
Source:
<code>public List<String> getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos targetPos) { if (args.length == 1) { <START> List<String> list = new ArrayList<>(Arrays.asList(server.getOnlinePlayerNames())); <END> list.addAll(defaultSelectors); return list; } else { return Collections.emptyList(); } }</code><technical_language>Personally I if bothering implement tab complete Tab complete instead of tab overwrite lots of mods implement of lazy. For implementation people online, bob alice. If I start typing "ali" hit tab show bob, alice, @p, @a, @r, @e, @s instead of completing finishing option of "alice". for other command's tab complete. In addition if arguments is displaying this full list. This is I in mods for tab complete of player names: java if (args.length == 0) { return Arrays.asList(server.getPlayerList().getOnlinePlayerNames()); } if (args.length == 1) { String partialName = args[0]; return Arrays.stream(server.getPlayerList().getOnlinePlayerNames()).filter(name -> name.startsWith(partialName)).collect(Collectors.toList()); } I recommend similar (given this "defaultSelectors" in it)</technical_language>

Target:
public List<String> getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos targetPos) { if (args.length == 1) { List<String> list = new ArrayList<>(Arrays.asList(server.getOnlinePlayerNames())); list.addAll(DEFAULT_SELECTORS); return getListOfStringsMatchingLastWord(args, list); } else { return Collections.emptyList(); } }
Source:
<code>public void testFailedRegionMove() throws Exception { MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster(); Admin admin = TEST_UTIL.getAdmin(); Table table = TEST_UTIL.getConnection().getTable(TABLE_NAME); List<Put> puts = new ArrayList<>(); for (int i = 0; i < 1000; i++) { puts.add(new Put(Bytes.toBytes("rowkey_" + i)) .addColumn(Bytes.toBytes("fam1"), Bytes.toBytes("q1"), Bytes.toBytes("val_" + i))); } table.put(puts); admin.flush(TABLE_NAME); HRegionServer regionServer = cluster.getRegionServer(0); String rsName = regionServer.getServerName().getAddress().toString(); int numRegions = regionServer.getNumberOfOnlineRegions(); List<HRegion> hRegions = regionServer.getRegions().stream() .filter(hRegion -> hRegion.getRegionInfo().getTable().equals(TABLE_NAME)) .collect(Collectors.toList()); RegionMover.RegionMoverBuilder rmBuilder = new RegionMover.RegionMoverBuilder(rsName, TEST_UTIL.getConfiguration()).ack(true) .maxthreads(8); try (RegionMover rm = rmBuilder.build()) { <START> LOG.debug("Unloading " + regionServer.getServerName()); <END> rm.unload(); Assert.assertEquals(0, regionServer.getNumberOfOnlineRegions()); LOG.debug("Successfully Unloaded\nNow Loading"); admin.offline(hRegions.get(0).getRegionInfo().getRegionName()); Assert.assertFalse(rm.load()); } }</code><technical_language>nit: parameter substitution</technical_language>

Target:
public void testFailedRegionMove() throws Exception { final TableName tableName = TableName.valueOf(name.getMethodName()); MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster(); Admin admin = TEST_UTIL.getAdmin(); Table table = TEST_UTIL.getConnection().getTable(tableName); List<Put> puts = new ArrayList<>(); for (int i = 0; i < 1000; i++) { puts.add(new Put(Bytes.toBytes("rowkey_" + i)) .addColumn(Bytes.toBytes("fam1"), Bytes.toBytes("q1"), Bytes.toBytes("val_" + i))); } table.put(puts); admin.flush(tableName); HRegionServer regionServer = cluster.getRegionServer(0); String rsName = regionServer.getServerName().getAddress().toString(); int numRegions = regionServer.getNumberOfOnlineRegions(); List<HRegion> hRegions = regionServer.getRegions().stream() .filter(hRegion -> hRegion.getRegionInfo().getTable().equals(tableName)) .collect(Collectors.toList()); RegionMover.RegionMoverBuilder rmBuilder = new RegionMover.RegionMoverBuilder(rsName, TEST_UTIL.getConfiguration()).ack(true) .maxthreads(8); try (RegionMover rm = rmBuilder.build()) { LOG.debug("Unloading {}", regionServer.getServerName()); rm.unload(); Assert.assertEquals(0, regionServer.getNumberOfOnlineRegions()); LOG.debug("Successfully Unloaded, now Loading"); admin.offline(hRegions.get(0).getRegionInfo().getRegionName()); Assert.assertFalse(rm.load()); } }
Source:
<code>public OffsetDateTime getScheduledEnqueueTime() { OffsetDateTime scheduledEnqueueTime = null; <START> Map<String, Object> messageAnnotationMap = amqpAnnotatedMessage.getMessageAnnotations(); <END> if (messageAnnotationMap.containsKey(SCHEDULED_ENQUEUE_UTC_TIME_NAME.getValue())) { scheduledEnqueueTime = ((Date) messageAnnotationMap.get(SCHEDULED_ENQUEUE_UTC_TIME_NAME.getValue())) .toInstant().atOffset(ZoneOffset.UTC); } return scheduledEnqueueTime; }</code><technical_language>suggestion var = amqpAnnotatedMessage.getMessageAnnotations().get(SCHEDULED_ENQUEUE_UTC_TIME_NAME.getValue()); return != null ? ((Date) value).toInstant().atOffset(ZoneOffset.UTC) : null;</technical_language>

Target:
public OffsetDateTime getScheduledEnqueueTime() { Object value = amqpAnnotatedMessage.getMessageAnnotations().get(SCHEDULED_ENQUEUE_UTC_TIME_NAME.getValue()); return value != null ? ((Date) value).toInstant().atOffset(ZoneOffset.UTC) : null; }
Source:
<code><START> public static void input(MethodHandle methodHandle, NullableDoubleState state, double value) <END> { if (state.isNull()) { state.setNull(false); state.setDouble(value); return; } try { if ((boolean) methodHandle.invokeExact(value, state.getDouble())) { state.setDouble(value); } } catch (Throwable t) { throw internalError(t); } }</code><technical_language>adding a helper function: java private static void updateDoubleState(MethodHandle methodHandle, NullableDoubleState state, double other) { if (state.isNull()) { state.setNull(false); state.setDouble(other); return; } try { if ((boolean) methodHandle.invokeExact(other, state.getDouble())) { state.setDouble(other); } } catch (Throwable t) { throw internalError(t); } } in this case, input combine shortened java public static void input(MethodHandle methodHandle, NullableDoubleState state, double value) { updateDoubleState(methodHandle, state, other); } java public static void combine(MethodHandle methodHandle, NullableDoubleState state, NullableDoubleState otherState) { updateDoubleState(methodHandle, state, otherState.getDouble()); }</technical_language>

Target:
public static void input(MethodHandle methodHandle, NullableDoubleState state, double value) { compareAndUpdateState(methodHandle, state, value); }
Source:
<code>public void thingUpdated(final Thing thing, ThingTrackerEvent thingTrackerEvent) { ThingUID thingUID = thing.getUID(); Thing oldThing = getThing(thingUID); if (oldThing != thing) { this.things.remove(oldThing); this.things.add(thing); } final ThingHandler thingHandler = thingHandlers.get(thingUID); if (thingHandler != null) { if (oldThing != thing) { thing.setHandler(thingHandler); } if (ThingHandlerHelper.isHandlerInitialized(thing)) { try { if (!thingUpdatedLock.contains(thingUID)) { SafeMethodCaller.call(new SafeMethodCaller.ActionWithException<Void>() { @Override public Void call() throws Exception { thingHandler.thingUpdated(thing); return null; } }); } } catch (Exception ex) { logger.error("Exception occured while calling thing updated at ThingHandler '{}': {}", thingHandler, ex.getMessage(), ex); } } else { logger.debug( <START> "Cannot notify handler about updated thing '{}', because thing is not initialized (must be in status ONLINE or OFFLINE). Start handler initialization instead.", <END> thing.getThingTypeUID()); initializeHandler(thing); } } else { registerAndInitializeHandler(thing, getThingHandlerFactory(thing)); } if (oldThing != thing) { oldThing.setHandler(null); } }</code><technical_language>I told some time is is (or is not) initialized, is handler only. is currently derived status, abstracted isHandlerInitialized function above</technical_language>

Target:
public void thingUpdated(final Thing thing, ThingTrackerEvent thingTrackerEvent) { ThingUID thingUID = thing.getUID(); Thing oldThing = getThing(thingUID); if (oldThing != thing) { this.things.remove(oldThing); this.things.add(thing); } final ThingHandler thingHandler = thingHandlers.get(thingUID); if (thingHandler != null) { if (oldThing != thing) { thing.setHandler(thingHandler); } if (ThingHandlerHelper.isHandlerInitialized(thing)) { try { if (!thingUpdatedLock.contains(thingUID)) { SafeMethodCaller.call(new SafeMethodCaller.ActionWithException<Void>() { @Override public Void call() throws Exception { thingHandler.thingUpdated(thing); return null; } }); } } catch (Exception ex) { logger.error("Exception occured while calling thing updated at ThingHandler '{}': {}", thingHandler, ex.getMessage(), ex); } } else { logger.debug( "Cannot notify handler about updated thing '{}', because handler is not initialized (must be in status ONLINE or OFFLINE). Start handler initialization instead.", thing.getThingTypeUID()); initializeHandler(thing); } } else { registerAndInitializeHandler(thing, getThingHandlerFactory(thing)); } if (oldThing != thing) { oldThing.setHandler(null); } }
Source:
<code>private void findNextElement() { if (metricFamilySamples != null && metricFamilySamples.hasNext()) { next = filter(metricFamilySamples.next()); } else { while (collectorIter.hasNext()) { metricFamilySamples = collectorIter.next().collect().iterator(); if (metricFamilySamples.hasNext()) { next = filter(metricFamilySamples.next()); if(next == null) { <START> continue; <END> } return; } } next = null; } }</code><technical_language>This skip rest of collector time a non-matching sample</technical_language>

Target:
private void findNextElement() { next = null; while (metricFamilySamples != null && metricFamilySamples.hasNext()) { next = filter(metricFamilySamples.next()); if (next != null) { return; } } if (next == null) { while (collectorIter.hasNext()) { metricFamilySamples = collectorIter.next().collect().iterator(); while (metricFamilySamples.hasNext()) { next = filter(metricFamilySamples.next()); if (next != null) { return; } } } } }
Source:
<code>public static Map<Integer, RegionProjection> projectionsOfRegions(int featureIdx, int maxDepth, IntStream regionIndexes, int blockSize, IgniteFunction<Integer, Object> affinity, UUID trainingUUID, Ignite ignite) { HashMap<Integer, RegionProjection> regsForSearch = new HashMap<>(); IgniteCache<RegionKey, List<RegionProjection>> cache = getOrCreate(ignite); PrimitiveIterator.OfInt itr = regionIndexes.iterator(); int curBlockIdx = -1; List<RegionProjection> block = null; <START> Object affKey = affinity.apply(featureIdx); <END> while (itr.hasNext()) { int i = itr.nextInt(); int blockIdx = i / blockSize; if (blockIdx != curBlockIdx) { block = cache.localPeek(key(featureIdx, blockIdx, affKey, trainingUUID)); curBlockIdx = blockIdx; } if (block == null) throw new IllegalStateException("Unexpected null block at index " + i); RegionProjection reg = block.get(i % blockSize); if (reg.depth() <= maxDepth) regsForSearch.put(i, reg); } return regsForSearch; }</code><technical_language>Rename affinityKey. reason cut</technical_language>

Target:
public static Map<Integer, RegionProjection> projectionsOfRegions(int featureIdx, int maxDepth, IntStream regionIndexes, int blockSize, IgniteFunction<Integer, Object> affinity, UUID trainingUUID, Ignite ignite) { HashMap<Integer, RegionProjection> regsForSearch = new HashMap<>(); IgniteCache<RegionKey, List<RegionProjection>> cache = getOrCreate(ignite); PrimitiveIterator.OfInt itr = regionIndexes.iterator(); int curBlockIdx = -1; List<RegionProjection> block = null; Object affinityKey = affinity.apply(featureIdx); while (itr.hasNext()) { int i = itr.nextInt(); int blockIdx = i / blockSize; if (blockIdx != curBlockIdx) { block = cache.localPeek(key(featureIdx, blockIdx, affinityKey, trainingUUID)); curBlockIdx = blockIdx; } if (block == null) throw new IllegalStateException("Unexpected null block at index " + i); RegionProjection reg = block.get(i % blockSize); if (reg.depth() < maxDepth) regsForSearch.put(i, reg); } return regsForSearch; }
Source:
<code>private boolean isOrphan(File file) { String fileName = file.getName(); return fileName.startsWith("pack") && (fileName.endsWith(PackExt.BITMAP_INDEX.getExtension()) || fileName.endsWith(PackExt.INDEX.getExtension())) && !new File(file.getParentFile(), <START> fileName.substring(0, fileName.lastIndexOf(".") + 1) END> + PackExt.PACK.getExtension()).exists(); }</code><technical_language>a file named "pack-1234idx" in directory. '.' in a extension. files deleted, or</technical_language>

Target:
private boolean isOrphan(File file) { String fileName = file.getName(); return fileName.startsWith("pack") && (fileName.endsWith("." + PackExt.BITMAP_INDEX.getExtension()) || fileName .endsWith("." + PackExt.INDEX.getExtension())) && !new File(file.getParentFile(), fileName.substring(0, fileName.lastIndexOf(".") + 1) + PackExt.PACK.getExtension()).exists(); }
Source:
<code>public boolean isMirrored() { <START> Object property = getProperty("MIRRORED"); END> return property instanceof Boolean && ((Boolean)property).booleanValue(); }</code><technical_language>remark constant</technical_language>

Target:
public boolean isMirrored() { Object property = getProperty(EMFCompareConfiguration.MIRRORED); return property instanceof Boolean && ((Boolean)property).booleanValue(); }
Source:
<code>public synchronized void registerListener(DruidNodeDiscovery.Listener listener) { for (DiscoveryDruidNode node : nodes.values()) { listenerExecutor.submit(() -> { try { listener.nodeAdded(node); } catch (Exception ex) { log.error(ex, "Exception occured in DiscoveryDruidNode.nodeAdded(node=[%s]) in listener [%s].", node, listener); } }); } <START> nodeListeners.add(listener); <END> }</code><technical_language>I add list register added stuff</technical_language>

Target:
public void registerListener(DruidNodeDiscovery.Listener listener) { synchronized (lock) { for (DiscoveryDruidNode node : nodes.values()) { listenerExecutor.submit(() -> { try { listener.nodeAdded(node); } catch (Exception ex) { log.error( ex, "Exception occured in DiscoveryDruidNode.nodeAdded(node=[%s]) in listener [%s].", node, listener ); } }); } nodeListeners.add(listener); } }
Source:
<code>catch (ClassNotFoundException e) { <START> throw new IllegalStateException(e); <END> }</code><technical_language>add some context in exception message</technical_language>

Target:
catch (ClassNotFoundException e) { log.warn("Spring Data Hadoop is required on the classpath to register modules to HDFS. This feature is disabled."); }
Source:
<code><START> public Builder withLimits(List<JLimit> limits) { <END> this.limits = limits; return this; }</code><technical_language>add please vararg version of this method public Builder withLimits(JLimit limit, JLimit... limits)</technical_language>

Target:
public Builder withLimits(List<JLimit> limits) { Objects.requireNonNull(limits); this.limits = limits; return this; }
Source:
<code>public ServerTest() throws InterruptedException, IOException, StoreException, InstantiationException { notificationSystem = new MockNotificationSystem(9); <START> nonSSLCluster = new MockCluster(notificationSystem, false, "", "", ""); <END> sslCluster = new MockCluster(notificationSystem, true, "DC2,DC3", "DC1,DC3", "DC1,DC2"); }</code><technical_language>suggestion for MockCluster constructor</technical_language>

Target:
public ServerTest() throws InterruptedException, IOException, StoreException, InstantiationException { notificationSystem = new MockNotificationSystem(9); }
Source:
<code>public void broadcast(BroadcastMessage message, @Nullable NodeAddress sender, @Nullable BroadcastHandler.Listener listener) { broadcastRequests.add(new BroadcastRequest(message, sender, listener)); <START> log.info("Broadcast requested for {}. We queue it up for next bundled broadcast.", <END> message.getClass().getSimpleName()); if (timer == null) { timer = UserThread.runAfter(this::maybeBroadcastBundle, BROADCAST_INTERVAL_MS, TimeUnit.MILLISECONDS); } }</code><technical_language>This is verbose, a good idea level info. running a mainnet client for a while this log is 40% of total log lines</technical_language>

Target:
public void broadcast(BroadcastMessage message, @Nullable NodeAddress sender, @Nullable BroadcastHandler.Listener listener) { broadcastRequests.add(new BroadcastRequest(message, sender, listener)); log.debug("Broadcast requested for {}. We queue it up for next bundled broadcast.", message.getClass().getSimpleName()); if (timer == null) { timer = UserThread.runAfter(this::maybeBroadcastBundle, BROADCAST_INTERVAL_MS, TimeUnit.MILLISECONDS); } }
Source:
<code>public static List<Object[]> data() { return Arrays.asList( <START> new Object[][]{{MessageFormatRecord.Message_Header_Version_V1}, {MessageFormatRecord.Message_Header_Version_V1}}); <END> }</code><technical_language>typo. 2nd V2</technical_language>

Target:
public static List<Object[]> data() { return Arrays.asList( new Object[][]{{MessageFormatRecord.Message_Header_Version_V1}, {MessageFormatRecord.Message_Header_Version_V2}}); }
Source:
<code>public void tryMouseDoubleclickZoom() throws InterruptedException { final boolean[] dirty = { true }; final TmfTimeRange[] timeRange = new TmfTimeRange[1]; super.treeTest(); loadFlameGraph(); <START> ITimeGraphEntry entry = selectRoot(); <END> assertEquals(3, entry.getChildren().size()); ITimeGraphEntry actualEntry = entry.getChildren().get(1); ITimeEvent actualEvent = getFirstEvent(actualEntry); assertNotNull(actualEvent); TimeGraphControl timeGraphControl = fTimeGraphViewer.getTimeGraphControl(); fTimeGraphViewer.addRangeListener((TimeGraphRangeUpdateEvent event) -> { dirty[0] = false; timeRange[0] = new TmfTimeRange(TmfTimestamp.fromNanos(event.getStartTime()), TmfTimestamp.fromNanos(event.getEndTime())); }); int x = UIThreadRunnable.syncExec(() -> timeGraphControl.getXForTime((long) ((actualEvent.getDuration() + actualEvent.getTime()) * 0.5))); fBot.waitUntil(new SWTBotTestCondition() { @Override public boolean test() throws Exception { return !dirty[0]; } }); SWTBotCanvas canvasBot = new SWTBotCanvas(timeGraphControl); canvasBot.doubleClick(x, 45); fFg.waitForUpdate(); UIThreadRunnable.syncExec(() -> fTimeGraphViewer.refresh()); assertEquals(new TmfTimeRange(TmfTimestamp.fromNanos(0), TmfTimestamp.fromNanos(100)), timeRange[0]); }</code><technical_language>SWTBotTimeGraph.getEntry(String)</technical_language>

Target:
public void tryMouseDoubleclickZoom() throws InterruptedException { super.treeTest(); loadFlameGraph(); ITimeGraphEntry entry = selectRoot(); assertEquals(3, entry.getChildren().size()); ITimeGraphEntry actualEntry = entry.getChildren().get(1); ITimeEvent actualEvent = getFirstEvent(actualEntry); assertNotNull(actualEvent); TimeGraphControl timeGraphControl = fTimeGraphViewer.getTimeGraphControl(); int x = UIThreadRunnable.syncExec(() -> timeGraphControl.getXForTime((long) ((actualEvent.getDuration() + actualEvent.getTime()) * 0.5))); SWTBotCanvas canvasBot = new SWTBotCanvas(timeGraphControl); canvasBot.doubleClick(x, 45); fFg.waitForUpdate(); UIThreadRunnable.syncExec(() -> fTimeGraphViewer.refresh()); assertEquals(new TmfTimeRange(TmfTimestamp.fromNanos(0), TmfTimestamp.fromNanos(80)), new TmfTimeRange(TmfTimestamp.fromNanos(fTimeGraphViewer.getTime0()), TmfTimestamp.fromNanos(fTimeGraphViewer.getTime1()))); }
Source:
<code>private void assertSuccess() throws Exception { for (RequestAndResult requestAndResult : requestAndResultsList) { String blobId = requestAndResult.result.result(); Exception exception = requestAndResult.result.error(); Assert.assertNotNull("blobId should not be null", blobId); Assert.assertNull("exception should be null", exception); HashMap<String, ByteBuffer> allChunks = new HashMap<String, ByteBuffer>(); <START> for (MockServer mockServer : mockServerLayout.getMockServers()) { <END> for (Map.Entry<String, ByteBuffer> blobEntry : mockServer.getBlobs().entrySet()) { ByteBuffer chunk = allChunks.get(blobEntry.getKey()); if (chunk == null) { allChunks.put(blobEntry.getKey(), blobEntry.getValue()); } else { if (checkContentEquality) { Assert.assertTrue("All requests for the same blob id must be identical except for correlation id", areIdenticalPutRequests(chunk.array(), blobEntry.getValue().array())); } } } } verifyBlob(blobId, requestAndResult.putContent, allChunks); } }</code><technical_language>583 595. this of for loop for loop</technical_language>

Target:
private void assertSuccess() throws Exception { HashMap<String, ByteBuffer> allChunks = new HashMap<String, ByteBuffer>(); for (MockServer mockServer : mockServerLayout.getMockServers()) { for (Map.Entry<String, ByteBuffer> blobEntry : mockServer.getBlobs().entrySet()) { ByteBuffer chunk = allChunks.get(blobEntry.getKey()); if (chunk == null) { allChunks.put(blobEntry.getKey(), blobEntry.getValue()); } else { if (checkContentEquality) { Assert.assertTrue("All requests for the same blob id must be identical except for correlation id", areIdenticalPutRequests(chunk.array(), blobEntry.getValue().array())); } } } } for (RequestAndResult requestAndResult : requestAndResultsList) { String blobId = requestAndResult.result.result(); Exception exception = requestAndResult.result.error(); Assert.assertNotNull("blobId should not be null", blobId); Assert.assertNull("exception should be null", exception); verifyBlob(blobId, requestAndResult.putContent, allChunks); } }
Source:
<code>public void onLoad(ItemGroup<? extends Item> parent, String name) throws IOException { super.onLoad(parent, name); init2(); ArrayList<P> items = new ArrayList<>(getItems()); for (P item : items) { String itemName = item.getName(); <START> String mangledName = NameMangler.apply(itemName); <END> if (!itemName.equals(mangledName)) { if (getItem(mangledName) == null) { item.renameTo(mangledName); if (item.getDisplayNameOrNull() == null) { item.setDisplayName(itemName); item.save(); } } } } try { srcDigest = Util.getDigestOf(Items.XSTREAM2.toXML(sources)); } catch (XStreamException e) { srcDigest = null; } try { facDigest = Util.getDigestOf(Items.XSTREAM2.toXML(getProjectFactory())); } catch (XStreamException e) { facDigest = null; } if (state == null) { state = new State(this); } try { state.load(); } catch (XStreamException | IOException e) { LOGGER.log(Level.WARNING, "Could not read persisted state, will be recovered on next index.", e); state.reset(); } }</code><technical_language>this applying NameMangler original branch name? applying encoded name, produce a result</technical_language>

Target:
public void onLoad(ItemGroup<? extends Item> parent, String name) throws IOException { super.onLoad(parent, name); init2(); ArrayList<P> items = new ArrayList<>(getItems()); BranchProjectFactory<P, R> projectFactory = getProjectFactory(); for (P item : items) { if (projectFactory.isProject(item)) { String itemName = item.getName(); Branch branch = projectFactory.getBranch(item); String mangledName = branch.getEncodedName(); if (!itemName.equals(mangledName)) { if (super.getItem(mangledName) == null) { LOGGER.log(Level.INFO, "Non-mangled name detected for branch {0}. Renaming {1}/{2} to {1}/{3}", new Object[]{branch.getName(), getFullName(), itemName, mangledName}); item.renameTo(mangledName); if (item.getDisplayNameOrNull() == null) { item.setDisplayName(branch.getName()); item.save(); } } } } } try { srcDigest = Util.getDigestOf(Items.XSTREAM2.toXML(sources)); } catch (XStreamException e) { srcDigest = null; } try { facDigest = Util.getDigestOf(Items.XSTREAM2.toXML(projectFactory)); } catch (XStreamException e) { facDigest = null; } if (state == null) { state = new State(this); } try { state.load(); } catch (XStreamException | IOException e) { LOGGER.log(Level.WARNING, "Could not read persisted state, will be recovered on next index.", e); state.reset(); } }
Source:
<code>public void setup() { random = new Random().nextInt(); <START> random = random ^ random; END> }</code><technical_language>.. ..</technical_language>

Target:
public void setup() { random = new Random(0).nextInt(MATCH_CASES); }
Source:
<code>public synchronized void playSoundFileWithStartTime(String pathToSoundfile, <START> int startTimeInMilSeconds) { <END> playSound(pathToSoundfile, startTimeInMilSeconds); }</code><technical_language>name is ok, is difference playSound. Please remove and/or rename Play Sound)</technical_language>

Target:
public synchronized void playSoundFileWithStartTime(String pathToSoundfile, int startTimeInMilSeconds) { MediaPlayer mediaPlayer = getAvailableMediaPlayer(); if (mediaPlayer != null) { try { soundFiles.add(pathToSoundfile); mediaPlayer.setDataSource(pathToSoundfile); mediaPlayer.prepare(); mediaPlayer.seekTo(startTimeInMilSeconds); mediaPlayer.start(); } catch (Exception exception) { Log.e(TAG, "Couldn't play sound file '" + pathToSoundfile + "'", exception); } } }
Source:
<code><START> private Widget editCondition( final Pattern52 origPattern, <END> final ConditionCol52 origCol ) { Image edit = GuidedDecisionTableImageResources508.INSTANCE.Edit(); edit.setAltText( GuidedDecisionTableConstants.INSTANCE.EditThisColumnsConfiguration() ); return new ImageButton( edit, GuidedDecisionTableConstants.INSTANCE.EditThisColumnsConfiguration(), new ClickHandler() { public void onClick( ClickEvent w ) { presenter.getActiveDecisionTable().editCondition( origPattern, origCol ); } } ); }</code><technical_language>another spot for a bit of 'DRY'ing-up..? (for overloaded editCondition(..))</technical_language>

Target:
private Widget editCondition( final Pattern52 origPattern, final ConditionCol52 origCol ) { return makeEditColumnWidget( GuidedDecisionTableConstants.INSTANCE.EditThisColumnsConfiguration(), () -> presenter.getActiveDecisionTable().editCondition( origPattern, origCol ) ); }
Source:
<code>protected void tearDown() { boolean removed = api().deleteRole(roleName); <START> assertTrue(removed); <END> }</code><technical_language>This fail if testCreateRole test fails. leave assertions for tests, tearDown methods</technical_language>

Target:
protected void tearDown() { api().deleteRole(roleName); }
Source:
<code>public void init(final GlusterVolumeSnapshotModel model) { super.init(model); model.getInterval().getSelectedItemChangedEvent().addListener(new IEventListener<EventArgs>() { @Override public void eventRaised(Event<? extends EventArgs> ev, Object sender, EventArgs args) { getView().setCriticalIntervalLabelVisibility(model, Integer.parseInt(((ListModel<String>) sender).getSelectedItem())); } }); model.getRecurrence().getSelectedItemChangedEvent().addListener(new IEventListener<EventArgs>() { @Override public void eventRaised(Event<? extends EventArgs> ev, Object sender, EventArgs args) { getView().updateVisibilities(model); getView().setCriticalIntervalLabelVisibility(model, Integer.parseInt(model.getInterval().getSelectedItem())); getView().setMessage(null); } }); model.getEndByOptions().getSelectedItemChangedEvent().addListener(new IEventListener<EventArgs>() { @Override public void eventRaised(Event<? extends EventArgs> ev, Object sender, EventArgs args) { getView().setEndDateVisibility(model); } }); model.getPropertyChangedEvent().addListener(new IEventListener<PropertyChangedEventArgs>() { @Override public void eventRaised(Event<? extends PropertyChangedEventArgs> ev, Object sender, PropertyChangedEventArgs args) { if(args.propertyName.equalsIgnoreCase("validateAndSwitchAppropriateTab")) { getView().handleValidationErrors(model); <START> getView().editorInvalidityBasedTabControl(); <END> } else if(args.propertyName.equalsIgnoreCase("modelPropertiesChanged")) { getView().handleValidationErrors(model); } } }); }</code><technical_language>name Verb</technical_language>

Target:
public void init(final GlusterVolumeSnapshotModel model) { super.init(model); model.getInterval().getSelectedItemChangedEvent().addListener(new IEventListener<EventArgs>() { @Override public void eventRaised(Event<? extends EventArgs> ev, Object sender, EventArgs args) { getView().setCriticalIntervalLabelVisibility(model, Integer.parseInt(((ListModel<String>) sender).getSelectedItem())); } }); model.getRecurrence().getSelectedItemChangedEvent().addListener(new IEventListener<EventArgs>() { @Override public void eventRaised(Event<? extends EventArgs> ev, Object sender, EventArgs args) { getView().updateVisibilities(model); getView().setCriticalIntervalLabelVisibility(model, Integer.parseInt(model.getInterval().getSelectedItem())); getView().setMessage(null); } }); model.getEndByOptions().getSelectedItemChangedEvent().addListener(new IEventListener<EventArgs>() { @Override public void eventRaised(Event<? extends EventArgs> ev, Object sender, EventArgs args) { getView().setEndDateVisibility(model); } }); model.getPropertyChangedEvent().addListener(new IEventListener<PropertyChangedEventArgs>() { @Override public void eventRaised(Event<? extends PropertyChangedEventArgs> ev, Object sender, PropertyChangedEventArgs args) { if(args.propertyName.equalsIgnoreCase("validateAndSwitchAppropriateTab")) { getView().handleValidationErrors(model); getView().switchTabBasedOnEditorInvalidity(); } else if(args.propertyName.equalsIgnoreCase("modelPropertiesChanged")) { getView().handleValidationErrors(model); } } }); }
Source:
<code>public void testSanity() { List<ConnectorTableLayoutResult> layouts = metadata.getTableLayouts(SESSION, tableHandle, Constraint.alwaysTrue(), Optional.empty()); assertEquals(layouts.size(), 1); ConnectorTableLayoutResult layout = getOnlyElement(layouts); assertInstanceOf(layout.getTableLayout().getHandle(), RaptorTableLayoutHandle.class); ConnectorSplitSource splitSource = getSplits(raptorSplitManager, layout); int splitCount = 0; while (!splitSource.isFinished()) { List<ConnectorSplit> splits = getSplits(splitSource, 1000); splitCount += splits.size(); RaptorSplit split = (RaptorSplit) (splits.get(0)); <START> assertEquals(split.isTableSupportsDeltaDelete(), false); <END> assertEquals(split.getColumnTypes(), Optional.empty()); } assertEquals(splitCount, 4); }</code><technical_language>assertFalse</technical_language>

Target:
public void testSanity() { List<ConnectorTableLayoutResult> layouts = metadata.getTableLayouts(SESSION, tableHandle, Constraint.alwaysTrue(), Optional.empty()); assertEquals(layouts.size(), 1); ConnectorTableLayoutResult layout = getOnlyElement(layouts); assertInstanceOf(layout.getTableLayout().getHandle(), RaptorTableLayoutHandle.class); ConnectorSplitSource splitSource = getSplits(raptorSplitManager, layout); int splitCount = 0; while (!splitSource.isFinished()) { List<ConnectorSplit> splits = getSplits(splitSource, 1000); splitCount += splits.size(); RaptorSplit split = (RaptorSplit) (splits.get(0)); assertFalse(split.isTableSupportsDeltaDelete()); assertEquals(split.getColumnTypes(), Optional.empty()); } assertEquals(splitCount, 4); }
Source:
<code>@Override public void start() throws IgniteCheckedException { for (MetricExporterSpi spi : getSpis()) spi.setMetricRegistry(this); startSpi(); ctx.internalSubscriptionProcessor().registerDistributedMetastorageListener( new DistributedMetastorageLifecycleListener() { @Override public void onReadyForRead(ReadableDistributedMetaStorage metastorage) { try { metastorage.iterate(HITRATE_CFG_PREFIX, (name, val) -> onHitRateConfigChanged( name.substring(HITRATE_CFG_PREFIX.length() + 1), (Long) val)); metastorage.iterate(HISTOGRAM_CFG_PREFIX, (name, val) -> onHistgoramConfigChanged( name.substring(HISTOGRAM_CFG_PREFIX.length() + 1), (long[]) val)); metastorage.listen(n -> n.startsWith(HITRATE_CFG_PREFIX), (name, oldVal, newVal) -> onHitRateConfigChanged( name.substring(HITRATE_CFG_PREFIX.length() + 1), (Long) newVal)); metastorage.listen(n -> n.startsWith(HISTOGRAM_CFG_PREFIX), (name, oldVal, newVal) -> onHistgoramConfigChanged( name.substring(HISTOGRAM_CFG_PREFIX.length() + 1), (long[]) newVal)); } catch (IgniteCheckedException e) { throw new IgniteException(e); } } @Override public void onReadyForWrite(DistributedMetaStorage metastorage) { <START> metaLock.writeLock().lock(); <END> try { GridMetricManager.this.metastorage = metastorage; } finally { metaLock.writeLock().unlock(); } } }); }</code><technical_language>need this RWLock? volatile visibility for meatLock field. Is races onReadyForWrite readFromMetastorage</technical_language>

Target:
@Override public void start() throws IgniteCheckedException { for (MetricExporterSpi spi : getSpis()) spi.setMetricRegistry(this); startSpi(); ctx.internalSubscriptionProcessor().registerDistributedMetastorageListener( new DistributedMetastorageLifecycleListener() { @Override public void onReadyForRead(ReadableDistributedMetaStorage metastorage) { roMetastorage = metastorage; try { metastorage.iterate(HITRATE_CFG_PREFIX, (name, val) -> onHitRateConfigChanged( name.substring(HITRATE_CFG_PREFIX.length() + 1), (Long) val)); metastorage.iterate(HISTOGRAM_CFG_PREFIX, (name, val) -> onHistogramConfigChanged( name.substring(HISTOGRAM_CFG_PREFIX.length() + 1), (long[]) val)); } catch (IgniteCheckedException e) { throw new IgniteException(e); } metastorage.listen(n -> n.startsWith(HITRATE_CFG_PREFIX), (name, oldVal, newVal) -> onHitRateConfigChanged( name.substring(HITRATE_CFG_PREFIX.length() + 1), (Long) newVal)); metastorage.listen(n -> n.startsWith(HISTOGRAM_CFG_PREFIX), (name, oldVal, newVal) -> onHistogramConfigChanged( name.substring(HISTOGRAM_CFG_PREFIX.length() + 1), (long[]) newVal)); } @Override public void onReadyForWrite(DistributedMetaStorage metastorage) { GridMetricManager.this.metastorage = metastorage; } }); }
Source:
<code>public void onUserRestrictionsChanged() { final Bundle restrictions = mUserManager.getUserRestrictions(); final boolean newlyDisallowed = restrictions.getBoolean(UserManager.DISALLOW_CONFIG_TETHERING); final boolean prevDisallowed = mDisallowTethering; mDisallowTethering = newlyDisallowed; final boolean tetheringDisallowedChanged = (newlyDisallowed != prevDisallowed); if (!tetheringDisallowedChanged) { return; } final boolean isTetheringActiveOnDevice = (mWrapper.getTetheredIfaces().length != 0); final boolean disallowedTethering = newlyDisallowed && isTetheringActiveOnDevice; if (disallowedTethering) { mWrapper.untetherAll(); } <START> mNotificationUpdater.onUserRestrictionsChanged(disallowedTethering); <END> }</code><technical_language>This false if newlyDisallowed && prevDisallowed && !tetheringActive "status" represent in this parameter ? If represents tethering is disallowed, newlyDisallowed</technical_language>

Target:
public void onUserRestrictionsChanged() { final Bundle restrictions = mUserManager.getUserRestrictions(); final boolean newlyDisallowed = restrictions.getBoolean(UserManager.DISALLOW_CONFIG_TETHERING); final boolean prevDisallowed = mDisallowTethering; mDisallowTethering = newlyDisallowed; final boolean tetheringDisallowedChanged = (newlyDisallowed != prevDisallowed); if (!tetheringDisallowedChanged) { return; } final boolean isTetheringActiveOnDevice = (mWrapper.getTetheredIfaces().length != 0); final boolean tetheringRestricted = newlyDisallowed && isTetheringActiveOnDevice; if (tetheringRestricted) { mWrapper.untetherAll(); } mNotificationUpdater.onTetheringRestrictionsChanged(tetheringRestricted); }
Source:
<code>private GlusterBrickEntity getBrickEntity(GlusterVolumeEntity volume, Map<String, Object> brick) { String brickName = (String) brick.get(BRICK); String glusterHostUuid = (String) brick.get(HOST_UUID); if (!StringUtils.isEmpty(glusterHostUuid)) { GlusterServer glusterServer = GlusterDBUtils.getInstance().getServerByUuid(Guid.createGuidFromString(glusterHostUuid)); if (glusterServer == null) { log.warnFormat("Could not update brick {0} to volume {1} - server uuid {2} not found", brickName, volume.getName(), glusterHostUuid); return null; } String[] brickParts = brickName.split(":", -1); if (brickParts.length != 2) { log.warnFormat("Invalid brick representation [" + brickName + "]"); return null; } <START> String brickDir = brickParts[1]; <END> VdsStatic server = DbFacade.getInstance().getVdsStaticDao().get(glusterServer.getId()); return DbFacade.getInstance().getGlusterBrickDao().getBrickByServerIdAndDirectory(server.getId(), brickDir); } return GlusterCoreUtil.getBrickByQualifiedName(volume.getBricks(), brickName); }</code><technical_language>do need this server. glusterServer.getId() suffice</technical_language>

Target:
private GlusterBrickEntity getBrickEntity(GlusterVolumeEntity volume, Map<String, Object> brick) { String brickName = (String) brick.get(BRICK); String glusterHostUuid = (String) brick.get(HOST_UUID); if (!StringUtils.isEmpty(glusterHostUuid)) { GlusterServer glusterServer = GlusterDBUtils.getInstance().getServerByUuid(Guid.createGuidFromString(glusterHostUuid)); if (glusterServer == null) { log.warnFormat("Could not update brick {0} to volume {1} - server uuid {2} not found", brickName, volume.getName(), glusterHostUuid); return null; } String[] brickParts = brickName.split(":", -1); if (brickParts.length != 2) { log.warnFormat("Invalid brick representation [" + brickName + "]"); return null; } String brickDir = brickParts[1]; return DbFacade.getInstance().getGlusterBrickDao().getBrickByServerIdAndDirectory(glusterServer.getId(), brickDir); } return GlusterCoreUtil.getBrickByQualifiedName(volume.getBricks(), brickName); }
Source:
<code>private void updateVmStatistics(VM vmToUpdate) { if (_vdsManager.getRefreshStatistics()) { VmStatistics vmStatistics = _runningVms.get(vmToUpdate.getId()).getVmStatistics(); vmToUpdate.updateRunTimeStatisticsData(vmStatistics, vmToUpdate); addVmStatisticsToList(vmToUpdate.getStatisticsData()); updateInterfaceStatistics(vmToUpdate, vmStatistics); for (DiskImageDynamic imageDynamic : _runningVms.get(vmToUpdate.getId()).getVmDynamic().getDisks()) { <START> Disk disk = getDbFacade().getDiskDao().get(imageDynamic.getId()); <END> if (disk instanceof DiskImage) { DiskImage diskImage = (DiskImage) disk; Guid ActiveImageId = diskImage.getImageId(); imageDynamic.setId(ActiveImageId); _vmDiskImageDynamicToSave.put(ActiveImageId, imageDynamic); } } } }</code><technical_language>this adds a lot of db loads - prefer avoid it.</technical_language>

Target:
private void updateVmStatistics(VM vmToUpdate) { if (_vdsManager.getRefreshStatistics()) { VmStatistics vmStatistics = _runningVms.get(vmToUpdate.getId()).getVmStatistics(); vmToUpdate.updateRunTimeStatisticsData(vmStatistics, vmToUpdate); addVmStatisticsToList(vmToUpdate.getStatisticsData()); updateInterfaceStatistics(vmToUpdate, vmStatistics); for (DiskImageDynamic imageDynamic : _runningVms.get(vmToUpdate.getId()).getVmDynamic().getDisks()) { Disk disk = getDbFacade().getDiskDao().get(imageDynamic.getId()); if (disk instanceof DiskImage) { DiskImage diskImage = (DiskImage) disk; Guid activeImageId = diskImage.getImageId(); imageDynamic.setId(activeImageId); _vmDiskImageDynamicToSave.put(activeImageId, imageDynamic); } } } }