From b7c36c9252c5219b59082cb36c4d4fa1e8f9285c Mon Sep 17 00:00:00 2001 From: Nikolay Date: Tue, 12 Dec 2023 13:31:37 +0300 Subject: [PATCH] IGNITE-14823 Argument abbrevation (#11088) --- .../src/main/resources/abbrevations.csv | 4 ++-- ...sterNodeAttributeAffinityBackupFilter.java | 16 ++++++------- .../distribution/CacheDistributionTask.java | 4 ++-- .../CacheDistributionTaskResult.java | 12 +++++----- .../spi/metric/jmx/MetricRegistryMBean.java | 16 ++++++------- .../spi/metric/jmx/ReadOnlyDynamicMBean.java | 8 +++---- ...yFunctionBackupFilterAbstractSelfTest.java | 24 +++++++++---------- .../ignite/internal/GridMBeansTest.java | 4 ++-- .../internal/metric/LogExporterSpiTest.java | 8 +++---- .../cache/GridEvictionPolicyMBeansTest.java | 4 ++-- 10 files changed, 50 insertions(+), 50 deletions(-) diff --git a/modules/checkstyle/src/main/resources/abbrevations.csv b/modules/checkstyle/src/main/resources/abbrevations.csv index 2e21e16a960ea..aa696a7d166eb 100644 --- a/modules/checkstyle/src/main/resources/abbrevations.csv +++ b/modules/checkstyle/src/main/resources/abbrevations.csv @@ -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 diff --git a/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/ClusterNodeAttributeAffinityBackupFilter.java b/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/ClusterNodeAttributeAffinityBackupFilter.java index 7a94d7a579be0..07103f35958f3 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/ClusterNodeAttributeAffinityBackupFilter.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/ClusterNodeAttributeAffinityBackupFilter.java @@ -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(); } /** @@ -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; @@ -134,6 +134,6 @@ public ClusterNodeAttributeAffinityBackupFilter(String... attributeNames) { * @return Attribute names. */ public String[] getAttributeNames() { - return attributeNames.clone(); + return attrNames.clone(); } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/commandline/cache/distribution/CacheDistributionTask.java b/modules/core/src/main/java/org/apache/ignite/internal/commandline/cache/distribution/CacheDistributionTask.java index 21041faeb2520..d98ad2a83d9cc 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/commandline/cache/distribution/CacheDistributionTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/commandline/cache/distribution/CacheDistributionTask.java @@ -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<>()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/commandline/cache/distribution/CacheDistributionTaskResult.java b/modules/core/src/main/java/org/apache/ignite/internal/commandline/cache/distribution/CacheDistributionTaskResult.java index 184a7e95acb48..99b016836cc0e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/commandline/cache/distribution/CacheDistributionTaskResult.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/commandline/cache/distribution/CacheDistributionTaskResult.java @@ -129,11 +129,11 @@ public void print(Consumer 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 + "]"); @@ -333,10 +333,10 @@ public void print(Consumer 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); } } diff --git a/modules/core/src/main/java/org/apache/ignite/spi/metric/jmx/MetricRegistryMBean.java b/modules/core/src/main/java/org/apache/ignite/spi/metric/jmx/MetricRegistryMBean.java index cd8fb5e374849..7d97b41f08ab8 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/metric/jmx/MetricRegistryMBean.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/metric/jmx/MetricRegistryMBean.java @@ -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(); @@ -80,7 +80,7 @@ else if (metric instanceof ObjectMetric) @Override public MBeanInfo getMBeanInfo() { Iterator iter = mreg.iterator(); - List attributes = new ArrayList<>(); + List attrs = new ArrayList<>(); iter.forEachRemaining(metric -> { if (metric instanceof HistogramMetric) { @@ -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, @@ -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(), @@ -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); diff --git a/modules/core/src/main/java/org/apache/ignite/spi/metric/jmx/ReadOnlyDynamicMBean.java b/modules/core/src/main/java/org/apache/ignite/spi/metric/jmx/ReadOnlyDynamicMBean.java index 75da1e5df2995..e59763064abc4 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/metric/jmx/ReadOnlyDynamicMBean.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/metric/jmx/ReadOnlyDynamicMBean.java @@ -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."); } @@ -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); } diff --git a/modules/core/src/test/java/org/apache/ignite/cache/affinity/AffinityFunctionBackupFilterAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/affinity/AffinityFunctionBackupFilterAbstractSelfTest.java index b95f97de72760..eaeff3767b675 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/affinity/AffinityFunctionBackupFilterAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/affinity/AffinityFunctionBackupFilterAbstractSelfTest.java @@ -72,15 +72,15 @@ public abstract class AffinityFunctionBackupFilterAbstractSelfTest extends GridC assert node != null : "primary is null"; assert assigned != null : "backup is null"; - Map backupAssignedAttribute = getAttributeStatistic(assigned); + Map 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); } }; @@ -89,13 +89,13 @@ public abstract class AffinityFunctionBackupFilterAbstractSelfTest extends GridC * @return Statistic. */ @NotNull protected static Map getAttributeStatistic(Collection nodes) { - Map backupAssignedAttribute = new HashMap<>(); + Map 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) @@ -103,12 +103,12 @@ public abstract class AffinityFunctionBackupFilterAbstractSelfTest extends GridC 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} */ diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridMBeansTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridMBeansTest.java index c35c130f2a4b1..a1c64c054e683 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridMBeansTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridMBeansTest.java @@ -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); } /** diff --git a/modules/core/src/test/java/org/apache/ignite/internal/metric/LogExporterSpiTest.java b/modules/core/src/test/java/org/apache/ignite/internal/metric/LogExporterSpiTest.java index 28dbb5f1a2e2e..493d778f86941 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/metric/LogExporterSpiTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/metric/LogExporterSpiTest.java @@ -71,18 +71,18 @@ public class LogExporterSpiTest extends AbstractExporterSpiTest { public void testLogSpi() throws Exception { cleanPersistenceDir(); - Set expectedAttributes = new GridConcurrentHashSet<>(EXPECTED_ATTRIBUTES); + Set 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); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridEvictionPolicyMBeansTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridEvictionPolicyMBeansTest.java index 149451697294e..3ad7df06ed3b8 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridEvictionPolicyMBeansTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridEvictionPolicyMBeansTest.java @@ -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); } }