Make HwvtepTableReader.alltables a constant 41/86141/3
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 3 Dec 2019 11:11:29 +0000 (12:11 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 3 Dec 2019 11:43:55 +0000 (12:43 +0100)
This array is treated as a constant source of a stream, turn it
into a proper constant, sharing it among all instances.

Change-Id: Iab1416086deb923fa65d805c075b7acffebb999e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepTableReader.java

index 41c53bcb2802e76c29496d6cc985f13bd9dc34df..cbc0e845cb99061e3bccd9cb5b0e494783dc9ffd 100644 (file)
@@ -67,8 +67,7 @@ import org.slf4j.LoggerFactory;
 public class HwvtepTableReader {
 
     private static final Logger LOG = LoggerFactory.getLogger(HwvtepTableReader.class);
-
-    private final Class[] alltables = new Class[] {
+    private static final Class<?>[] ALL_TABLES = new Class[] {
         ACLEntry.class,
         ACL.class,
         ArpSourcesLocal.class,
@@ -334,9 +333,9 @@ public class HwvtepTableReader {
 
     public TableUpdates readAllTables() throws ExecutionException, InterruptedException {
         TypedDatabaseSchema dbSchema = connectionInstance.getSchema(HwvtepSchemaConstants.HARDWARE_VTEP).get();
-        List<Operation> operations = Arrays.asList(alltables).stream()
+        List<Operation> operations = Arrays.stream(ALL_TABLES)
                 .map(tableClass -> dbSchema.getTableSchema(tableClass))
-                .map(tableSchema -> buildSelectOperationFor(tableSchema))
+                .map(HwvtepTableReader::buildSelectOperationFor)
                 .collect(Collectors.toList());
         List<OperationResult> results = connectionInstance.transact(dbSchema, operations).get();
 
@@ -356,9 +355,9 @@ public class HwvtepTableReader {
     }
 
     private static Select<GenericTableSchema> buildSelectOperationFor(final GenericTableSchema tableSchema) {
-        Select<GenericTableSchema> selectOpearation = op.select(tableSchema);
-        selectOpearation.setColumns(tableSchema.getColumnList());
-        return selectOpearation;
+        Select<GenericTableSchema> selectOperation = op.select(tableSchema);
+        selectOperation.setColumns(tableSchema.getColumnList());
+        return selectOperation;
     }
 
     private static UUID getRowUuid(final Row<GenericTableSchema> row) {