This is an automated email from the ASF dual-hosted git repository.

madhan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/atlas.git


The following commit(s) were added to refs/heads/master by this push:
     new 4e3b9a66f ATLAS-4966: atlas-server-api module: update for code 
readability improvements - #2
4e3b9a66f is described below

commit 4e3b9a66f33519b66ee79f85c5fb4d769fc723a5
Author: Madhan Neethiraj <mad...@apache.org>
AuthorDate: Mon Feb 17 01:12:01 2025 -0800

    ATLAS-4966: atlas-server-api module: update for code readability 
improvements - #2
---
 .../src/main/java/org/apache/atlas/RequestContext.java   | 10 +++++-----
 .../apache/atlas/exception/EntityNotFoundException.java  |  9 ++++-----
 .../org/apache/atlas/exception/NotFoundException.java    |  9 ++++-----
 .../org/apache/atlas/ha/AtlasServerIdSelectorTest.java   | 16 ++++++++++------
 4 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/server-api/src/main/java/org/apache/atlas/RequestContext.java 
b/server-api/src/main/java/org/apache/atlas/RequestContext.java
index ab921bec3..b3acdb627 100644
--- a/server-api/src/main/java/org/apache/atlas/RequestContext.java
+++ b/server-api/src/main/java/org/apache/atlas/RequestContext.java
@@ -44,9 +44,9 @@ import static 
org.apache.atlas.model.instance.AtlasObjectId.KEY_GUID;
 public class RequestContext {
     private static final Logger METRICS = LoggerFactory.getLogger("METRICS");
 
-    private static final ThreadLocal<RequestContext> CURRENT_CONTEXT  = new 
ThreadLocal<>();
-    private static final Set<RequestContext>         ACTIVE_REQUESTS  = new 
HashSet<>();
-    private static final boolean                     isMetricsEnabled = 
METRICS.isDebugEnabled();
+    private static final ThreadLocal<RequestContext> CURRENT_CONTEXT    = new 
ThreadLocal<>();
+    private static final Set<RequestContext>         ACTIVE_REQUESTS    = new 
HashSet<>();
+    private static final boolean                     IS_METRICS_ENABLED = 
METRICS.isDebugEnabled();
 
     private final long                                   requestTime          
= System.currentTimeMillis();
     private final Map<String, AtlasEntityHeader>         updatedEntities      
= new HashMap<>();
@@ -56,7 +56,7 @@ public class RequestContext {
     private final Map<String, AtlasEntity>               diffEntityCache      
= new HashMap<>();
     private final Map<String, List<AtlasClassification>> addedPropagations    
= new HashMap<>();
     private final Map<String, List<AtlasClassification>> removedPropagations  
= new HashMap<>();
-    private final AtlasPerfMetrics                       metrics              
= isMetricsEnabled ? new AtlasPerfMetrics() : null;
+    private final AtlasPerfMetrics                       metrics              
= IS_METRICS_ENABLED ? new AtlasPerfMetrics() : null;
     private       List<EntityGuidPair>                   entityGuidInRequest;
     private final Set<String>                            entitiesToSkipUpdate 
= new HashSet<>();
     private final Set<String>                            onlyCAUpdateEntities 
= new HashSet<>();
@@ -482,7 +482,7 @@ public class RequestContext {
         return this.queuedTasks;
     }
 
-    public class EntityGuidPair {
+    public static class EntityGuidPair {
         private final Object entity;
         private final String guid;
 
diff --git 
a/server-api/src/main/java/org/apache/atlas/exception/EntityNotFoundException.java
 
b/server-api/src/main/java/org/apache/atlas/exception/EntityNotFoundException.java
index 14be3ed62..7584761f0 100644
--- 
a/server-api/src/main/java/org/apache/atlas/exception/EntityNotFoundException.java
+++ 
b/server-api/src/main/java/org/apache/atlas/exception/EntityNotFoundException.java
@@ -6,9 +6,9 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -37,8 +37,7 @@ public class EntityNotFoundException extends 
NotFoundException {
         super(cause);
     }
 
-    public EntityNotFoundException(String message, Throwable cause, boolean 
enableSuppression,
-            boolean writableStackTrace) {
+    public EntityNotFoundException(String message, Throwable cause, boolean 
enableSuppression, boolean writableStackTrace) {
         super(message, cause, enableSuppression, writableStackTrace);
     }
 }
diff --git 
a/server-api/src/main/java/org/apache/atlas/exception/NotFoundException.java 
b/server-api/src/main/java/org/apache/atlas/exception/NotFoundException.java
index c24789ddf..a0dc7660d 100644
--- a/server-api/src/main/java/org/apache/atlas/exception/NotFoundException.java
+++ b/server-api/src/main/java/org/apache/atlas/exception/NotFoundException.java
@@ -6,9 +6,9 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -39,8 +39,7 @@ public class NotFoundException extends AtlasException {
         super(cause);
     }
 
-    public NotFoundException(String message, Throwable cause, boolean 
enableSuppression,
-                             boolean writableStackTrace) {
+    public NotFoundException(String message, Throwable cause, boolean 
enableSuppression, boolean writableStackTrace) {
         super(message, cause, enableSuppression, writableStackTrace);
     }
 }
diff --git 
a/server-api/src/main/test/org/apache/atlas/ha/AtlasServerIdSelectorTest.java 
b/server-api/src/test/java/org/apache/atlas/ha/AtlasServerIdSelectorTest.java
similarity index 92%
rename from 
server-api/src/main/test/org/apache/atlas/ha/AtlasServerIdSelectorTest.java
rename to 
server-api/src/test/java/org/apache/atlas/ha/AtlasServerIdSelectorTest.java
index 3321ce48f..c99e0eeb3 100644
--- 
a/server-api/src/main/test/org/apache/atlas/ha/AtlasServerIdSelectorTest.java
+++ 
b/server-api/src/test/java/org/apache/atlas/ha/AtlasServerIdSelectorTest.java
@@ -6,9 +6,9 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -43,26 +43,30 @@ public class AtlasServerIdSelectorTest {
     @Test
     public void testShouldSelectRightServerAddress() throws AtlasException {
         
when(configuration.getStringArray(HAConfiguration.ATLAS_SERVER_IDS)).thenReturn(new
 String[] {"id1", "id2"});
-        
when(configuration.getString(HAConfiguration.ATLAS_SERVER_ADDRESS_PREFIX 
+"id1")).thenReturn("127.0.0.1:31000");
-        
when(configuration.getString(HAConfiguration.ATLAS_SERVER_ADDRESS_PREFIX 
+"id2")).thenReturn("127.0.0.1:21000");
+        
when(configuration.getString(HAConfiguration.ATLAS_SERVER_ADDRESS_PREFIX + 
"id1")).thenReturn("127.0.0.1:31000");
+        
when(configuration.getString(HAConfiguration.ATLAS_SERVER_ADDRESS_PREFIX + 
"id2")).thenReturn("127.0.0.1:21000");
 
         String atlasServerId = 
AtlasServerIdSelector.selectServerId(configuration);
+
         assertEquals(atlasServerId, "id2");
     }
 
     @Test(expectedExceptions = AtlasException.class)
     public void testShouldFailIfNoIDsConfiguration() throws AtlasException {
         
when(configuration.getStringArray(HAConfiguration.ATLAS_SERVER_IDS)).thenReturn(new
 String[] {});
+
         AtlasServerIdSelector.selectServerId(configuration);
+
         fail("Should not return any server id if IDs not found in 
configuration");
     }
 
     @Test(expectedExceptions = AtlasException.class)
     public void testShouldFailIfNoMatchingAddressForID() throws AtlasException 
{
         
when(configuration.getStringArray(HAConfiguration.ATLAS_SERVER_IDS)).thenReturn(new
 String[] {"id1", "id2"});
-        
when(configuration.getString(HAConfiguration.ATLAS_SERVER_ADDRESS_PREFIX 
+"id1")).thenReturn("127.0.0.1:31000");
+        
when(configuration.getString(HAConfiguration.ATLAS_SERVER_ADDRESS_PREFIX + 
"id1")).thenReturn("127.0.0.1:31000");
 
         AtlasServerIdSelector.selectServerId(configuration);
+
         fail("Should not return any server id if no matching address found for 
any ID");
     }
 }

Reply via email to