Skip to content

Commit

Permalink
IGNITE-14823 Argument abbrevation (#11088)
Browse files Browse the repository at this point in the history
  • Loading branch information
nizhikov authored Dec 12, 2023
1 parent b3fe55e commit b7c36c9
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 50 deletions.
4 changes: 2 additions & 2 deletions modules/checkstyle/src/main/resources/abbrevations.csv
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ affinity,aff
argument,arg
arguments,args
array,arr
#attribute,attr
#attributes,attrs
attribute,attr
attributes,attrs
#buffer,buf
#class,cls
#command,cmd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ public class ClusterNodeAttributeAffinityBackupFilter implements IgniteBiPredica
private static final long serialVersionUID = 1L;

/** Attribute names. */
private final String[] attributeNames;
private final String[] attrNames;

/**
* @param attributeNames The list of attribute names for the set of attributes to compare. Must be at least one.
* @param attrNames The list of attribute names for the set of attributes to compare. Must be at least one.
*/
public ClusterNodeAttributeAffinityBackupFilter(String... attributeNames) {
A.ensure(attributeNames.length > 0, "attributeNames.length > 0");
public ClusterNodeAttributeAffinityBackupFilter(String... attrNames) {
A.ensure(attrNames.length > 0, "attributeNames.length > 0");

this.attributeNames = attributeNames.clone();
this.attrNames = attrNames.clone();
}

/**
Expand All @@ -113,8 +113,8 @@ public ClusterNodeAttributeAffinityBackupFilter(String... attributeNames) {
for (ClusterNode node : previouslySelected) {
boolean match = true;

for (String attribute : attributeNames) {
if (!Objects.equals(candidate.attribute(attribute), node.attribute(attribute))) {
for (String attr : attrNames) {
if (!Objects.equals(candidate.attribute(attr), node.attribute(attr))) {
match = false;

break;
Expand All @@ -134,6 +134,6 @@ public ClusterNodeAttributeAffinityBackupFilter(String... attributeNames) {
* @return Attribute names.
*/
public String[] getAttributeNames() {
return attributeNames.clone();
return attrNames.clone();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ public CacheDistributionJob(@Nullable CacheDistributionCommandArg arg, boolean d
if (arg.userAttributes() != null) {
info.setUserAttributes(new TreeMap<>());

for (String userAttribute : arg.userAttributes())
info.getUserAttributes().put(userAttribute, (String)node.attributes().get(userAttribute));
for (String userAttr : arg.userAttributes())
info.getUserAttributes().put(userAttr, (String)node.attributes().get(userAttr));
}

info.setGroups(new ArrayList<>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ public void print(Consumer<String> printer) {

StringBuilder userAttrsName = new StringBuilder();
if (!rows.isEmpty() && rows.get(0).userAttrs != null) {
for (String userAttribute : rows.get(0).userAttrs.keySet()) {
for (String userAttr : rows.get(0).userAttrs.keySet()) {
userAttrsName.append(',');

if (userAttribute != null)
userAttrsName.append(userAttribute);
if (userAttr != null)
userAttrsName.append(userAttr);
}
}
printer.accept("[groupId,partition,nodeId,primary,state,updateCounter,partitionSize,nodeAddresses" + userAttrsName + "]");
Expand Down Expand Up @@ -333,10 +333,10 @@ public void print(Consumer<String> printer) {
out.a(addrs);

if (userAttrs != null) {
for (String userAttribute : userAttrs.values()) {
for (String userAttr : userAttrs.values()) {
out.a(',');
if (userAttribute != null)
out.a(userAttribute);
if (userAttr != null)
out.a(userAttr);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ public MetricRegistryMBean(ReadOnlyMetricRegistry mreg) {
}

/** {@inheritDoc} */
@Override public Object getAttribute(String attribute) {
if (attribute.equals("MBeanInfo"))
@Override public Object getAttribute(String attr) {
if (attr.equals("MBeanInfo"))
return getMBeanInfo();

Metric metric = mreg.findMetric(attribute);
Metric metric = mreg.findMetric(attr);

if (metric == null)
return searchHistogram(attribute, mreg);
return searchHistogram(attr, mreg);

if (metric instanceof BooleanMetric)
return ((BooleanMetric)metric).value();
Expand All @@ -80,7 +80,7 @@ else if (metric instanceof ObjectMetric)
@Override public MBeanInfo getMBeanInfo() {
Iterator<Metric> iter = mreg.iterator();

List<MBeanAttributeInfo> attributes = new ArrayList<>();
List<MBeanAttributeInfo> attrs = new ArrayList<>();

iter.forEachRemaining(metric -> {
if (metric instanceof HistogramMetric) {
Expand All @@ -91,7 +91,7 @@ else if (metric instanceof ObjectMetric)
for (String name : names) {
String n = name.substring(mreg.name().length() + 1);

attributes.add(new MBeanAttributeInfo(
attrs.add(new MBeanAttributeInfo(
n,
Long.class.getName(),
metric.description() != null ? metric.description() : n,
Expand All @@ -101,7 +101,7 @@ else if (metric instanceof ObjectMetric)
}
}
else {
attributes.add(new MBeanAttributeInfo(
attrs.add(new MBeanAttributeInfo(
metric.name().substring(mreg.name().length() + 1),
metricClass(metric),
metric.description() != null ? metric.description() : metric.name(),
Expand All @@ -115,7 +115,7 @@ else if (metric instanceof ObjectMetric)
return new MBeanInfo(
ReadOnlyMetricManager.class.getName(),
mreg.name(),
attributes.toArray(new MBeanAttributeInfo[attributes.size()]),
attrs.toArray(new MBeanAttributeInfo[attrs.size()]),
null,
null,
null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
*/
public abstract class ReadOnlyDynamicMBean implements DynamicMBean {
/** {@inheritDoc} */
@Override public void setAttribute(Attribute attribute) {
@Override public void setAttribute(Attribute attr) {
throw new UnsupportedOperationException("setAttribute is not supported.");
}

/** {@inheritDoc} */
@Override public AttributeList setAttributes(AttributeList attributes) {
@Override public AttributeList setAttributes(AttributeList attrs) {
throw new UnsupportedOperationException("setAttributes is not supported.");
}

Expand All @@ -60,8 +60,8 @@ else if ("invoke".equals(actionName))
AttributeList list = new AttributeList();

try {
for (String attribute : attributes) {
Object val = getAttribute(attribute);
for (String attr : attributes) {
Object val = getAttribute(attr);

list.add(val);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ public abstract class AffinityFunctionBackupFilterAbstractSelfTest extends GridC
assert node != null : "primary is null";
assert assigned != null : "backup is null";

Map<String, Integer> backupAssignedAttribute = getAttributeStatistic(assigned);
Map<String, Integer> backupAssignedAttr = getAttributeStatistic(assigned);

String nodeAttributeVal = node.attribute(SPLIT_ATTRIBUTE_NAME);
String nodeAttrVal = node.attribute(SPLIT_ATTRIBUTE_NAME);

if (FIRST_NODE_GROUP.equals(nodeAttributeVal)
&& backupAssignedAttribute.get(FIRST_NODE_GROUP) < 2)
if (FIRST_NODE_GROUP.equals(nodeAttrVal)
&& backupAssignedAttr.get(FIRST_NODE_GROUP) < 2)
return true;

return backupAssignedAttribute.get(nodeAttributeVal).equals(0);
return backupAssignedAttr.get(nodeAttrVal).equals(0);
}
};

Expand All @@ -89,26 +89,26 @@ public abstract class AffinityFunctionBackupFilterAbstractSelfTest extends GridC
* @return Statistic.
*/
@NotNull protected static Map<String, Integer> getAttributeStatistic(Collection<ClusterNode> nodes) {
Map<String, Integer> backupAssignedAttribute = new HashMap<>();
Map<String, Integer> backupAssignedAttr = new HashMap<>();

backupAssignedAttribute.put(FIRST_NODE_GROUP, 0);
backupAssignedAttr.put(FIRST_NODE_GROUP, 0);

backupAssignedAttribute.put("B", 0);
backupAssignedAttr.put("B", 0);

backupAssignedAttribute.put("C", 0);
backupAssignedAttr.put("C", 0);

for (ClusterNode assignedNode: nodes) {
if (assignedNode == null)
continue;

String val = assignedNode.attribute(SPLIT_ATTRIBUTE_NAME);

Integer cnt = backupAssignedAttribute.get(val);
Integer cnt = backupAssignedAttr.get(val);

backupAssignedAttribute.put(val, cnt + 1);
backupAssignedAttr.put(val, cnt + 1);
}

return backupAssignedAttribute;
return backupAssignedAttr;
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ public void testExecutorBeans() throws Exception {
/** Checks that a bean with the specified group and name is available and has the expected attribute */
private void checkBean(String grp, String name, String attributeName, Object expAttributeVal) throws Exception {
ObjectName mBeanName = IgniteUtils.makeMBeanName(grid().name(), grp, name);
Object attributeVal = grid().configuration().getMBeanServer().getAttribute(mBeanName, attributeName);
Object attrVal = grid().configuration().getMBeanServer().getAttribute(mBeanName, attributeName);

assertEquals(expAttributeVal, attributeVal);
assertEquals(expAttributeVal, attrVal);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,18 @@ public class LogExporterSpiTest extends AbstractExporterSpiTest {
public void testLogSpi() throws Exception {
cleanPersistenceDir();

Set<String> expectedAttributes = new GridConcurrentHashSet<>(EXPECTED_ATTRIBUTES);
Set<String> expectedAttrs = new GridConcurrentHashSet<>(EXPECTED_ATTRIBUTES);

log.registerListener(s -> {
for (String attr : expectedAttributes) {
for (String attr : expectedAttrs) {
if (s.contains(attr))
expectedAttributes.remove(attr);
expectedAttrs.remove(attr);
}
});

ignite = startGrid(0);

boolean res = waitForCondition(expectedAttributes::isEmpty, EXPORT_TIMEOUT * 10);
boolean res = waitForCondition(expectedAttrs::isEmpty, EXPORT_TIMEOUT * 10);

assertTrue(res);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ public void testEvictionPolicyBeans() throws Exception {
/** Checks that a bean with the specified group and name is available and has the expected attribute */
private void checkBean(String grp, String name, String attributeName, Object expAttributeVal) throws Exception {
ObjectName mBeanName = IgniteUtils.makeMBeanName(grid().name(), grp, name);
Object attributeVal = grid().configuration().getMBeanServer().getAttribute(mBeanName, attributeName);
Object attrVal = grid().configuration().getMBeanServer().getAttribute(mBeanName, attributeName);

assertEquals(expAttributeVal, attributeVal);
assertEquals(expAttributeVal, attrVal);
}
}

0 comments on commit b7c36c9

Please sign in to comment.