From 10119331189066c009db4f0000a39ae586cc164c Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Mon, 28 Oct 2019 08:25:36 +0100 Subject: [PATCH] Do not use Foo.toString() when logging This was spotted in a JFR run, where JsonRpcEndpoint would consume a lot of CPU formatting a logging object. Eliminate calls to toString() in logging arguments, as the framework will call these when really needed. Change-Id: Id077c285074c1fd8012539ab7c144ddc4b286376 Signed-off-by: Robert Varga --- .../ovsdb/hwvtepsouthbound/it/HwvtepSouthboundIT.java | 2 +- .../opendaylight/ovsdb/lib/impl/OvsdbConnectionService.java | 2 +- .../org/opendaylight/ovsdb/lib/jsonrpc/JsonRpcEndpoint.java | 6 +++--- .../integrationtest/ovsdbclient/OvsdbClientTestIT.java | 2 +- .../integrationtest/ovsdbclient/OvsdbClientTestTypedIT.java | 2 +- .../transactions/md/OvsdbAutoAttachRemovedCommand.java | 4 ++-- .../southbound/transactions/md/OvsdbQosRemovedCommand.java | 4 ++-- .../transactions/md/OvsdbQueueRemovedCommand.java | 4 ++-- .../org/opendaylight/ovsdb/southbound/it/SouthboundIT.java | 4 ++-- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/hwvtepsouthbound/hwvtepsouthbound-it/src/test/java/org/opendaylight/ovsdb/hwvtepsouthbound/it/HwvtepSouthboundIT.java b/hwvtepsouthbound/hwvtepsouthbound-it/src/test/java/org/opendaylight/ovsdb/hwvtepsouthbound/it/HwvtepSouthboundIT.java index 96b1bb6e8..2513237e0 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-it/src/test/java/org/opendaylight/ovsdb/hwvtepsouthbound/it/HwvtepSouthboundIT.java +++ b/hwvtepsouthbound/hwvtepsouthbound-it/src/test/java/org/opendaylight/ovsdb/hwvtepsouthbound/it/HwvtepSouthboundIT.java @@ -425,7 +425,7 @@ public class HwvtepSouthboundIT extends AbstractMdsalTestBase { psAugBuilder.setTunnelIps(tunnelIps); psAugBuilder.setTunnels(tunnels); psNodeBuilder.addAugmentation(PhysicalSwitchAugmentation.class, psAugBuilder.build()); - LOG.debug("Built with intent to store PhysicalSwitch data {}", psAugBuilder.toString()); + LOG.debug("Built with intent to store PhysicalSwitch data {}", psAugBuilder); Assert.assertTrue( mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, psIid, psNodeBuilder.build())); try { diff --git a/library/impl/src/main/java/org/opendaylight/ovsdb/lib/impl/OvsdbConnectionService.java b/library/impl/src/main/java/org/opendaylight/ovsdb/lib/impl/OvsdbConnectionService.java index 3be844912..0edbd65a6 100644 --- a/library/impl/src/main/java/org/opendaylight/ovsdb/lib/impl/OvsdbConnectionService.java +++ b/library/impl/src/main/java/org/opendaylight/ovsdb/lib/impl/OvsdbConnectionService.java @@ -509,7 +509,7 @@ public class OvsdbConnectionService implements AutoCloseable, OvsdbConnection { } public static void channelClosed(final OvsdbClient client) { - LOG.info("Connection closed {}", client.getConnectionInfo().toString()); + LOG.info("Connection closed {}", client.getConnectionInfo()); CONNECTIONS.remove(client); if (client.isConnectionPublished()) { for (OvsdbConnectionListener listener : CONNECTION_LISTENERS) { diff --git a/library/impl/src/main/java/org/opendaylight/ovsdb/lib/jsonrpc/JsonRpcEndpoint.java b/library/impl/src/main/java/org/opendaylight/ovsdb/lib/jsonrpc/JsonRpcEndpoint.java index 39c6474bb..4922ac34e 100644 --- a/library/impl/src/main/java/org/opendaylight/ovsdb/lib/jsonrpc/JsonRpcEndpoint.java +++ b/library/impl/src/main/java/org/opendaylight/ovsdb/lib/jsonrpc/JsonRpcEndpoint.java @@ -138,7 +138,7 @@ public class JsonRpcEndpoint { public void processResult(JsonNode response) throws NoSuchMethodException { - LOG.trace("Response : {}", response.toString()); + LOG.trace("Response : {}", response); CallContext returnCtxt = methodContext.remove(response.get("id").asText()); if (returnCtxt == null) { return; @@ -154,7 +154,7 @@ public class JsonRpcEndpoint { Object result1 = objectMapper.convertValue(result, javaType); JsonNode error = response.get("error"); if (error != null && !error.isNull()) { - LOG.error("Error : {}", error.toString()); + LOG.error("Error : {}", error); } returnCtxt.getFuture().set(result1); @@ -216,7 +216,7 @@ public class JsonRpcEndpoint { return; } - LOG.error("No handler for Request : {} on {}", requestJson.toString(), context); + LOG.error("No handler for Request : {} on {}", requestJson, context); } public Map getMethodContext() { diff --git a/library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/ovsdbclient/OvsdbClientTestIT.java b/library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/ovsdbclient/OvsdbClientTestIT.java index b45dd96c1..09c18e1d7 100644 --- a/library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/ovsdbclient/OvsdbClientTestIT.java +++ b/library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/ovsdbclient/OvsdbClientTestIT.java @@ -341,7 +341,7 @@ public class OvsdbClientTestIT extends LibraryIntegrationTestBase { ovs = LibraryIntegrationTestUtils.getTestConnection(this); assertNotNull("Failed to get connection to ovsdb node", ovs); - LOG.info("Connection Info: {}", ovs.getConnectionInfo().toString()); + LOG.info("Connection Info: {}", ovs.getConnectionInfo()); testGetDBs(); dbSchema = ovs.getSchema(LibraryIntegrationTestUtils.OPEN_VSWITCH).get(); } diff --git a/library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/ovsdbclient/OvsdbClientTestTypedIT.java b/library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/ovsdbclient/OvsdbClientTestTypedIT.java index 975e40396..af1cdc01f 100644 --- a/library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/ovsdbclient/OvsdbClientTestTypedIT.java +++ b/library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/ovsdbclient/OvsdbClientTestTypedIT.java @@ -113,7 +113,7 @@ public class OvsdbClientTestTypedIT extends LibraryIntegrationTestBase { } ovs = LibraryIntegrationTestUtils.getTestConnection(this); assertNotNull("Failed to get connection to ovsdb node", ovs); - LOG.info("Connection Info: {}", ovs.getConnectionInfo().toString()); + LOG.info("Connection Info: {}", ovs.getConnectionInfo()); testGetDBs(); dbSchema = ovs.getSchema(LibraryIntegrationTestUtils.OPEN_VSWITCH).get(); } diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbAutoAttachRemovedCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbAutoAttachRemovedCommand.java index ee0a32b7e..d420ec801 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbAutoAttachRemovedCommand.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbAutoAttachRemovedCommand.java @@ -60,10 +60,10 @@ public class OvsdbAutoAttachRemovedCommand extends AbstractTransactionCommand { .augmentation(OvsdbNodeAugmentation.class) .child(Autoattach.class, autoAttachKey); transaction.delete(LogicalDatastoreType.OPERATIONAL, iid); - LOG.debug("AutoAttach table {} for Ovsdb Node {} is deleted", autoAttachUuid.toString(), + LOG.debug("AutoAttach table {} for Ovsdb Node {} is deleted", autoAttachUuid, ovsdbNode.get().getNodeId()); } else { - LOG.warn("AutoAttach table {} not found for Ovsdb Node {} to delete", autoAttachUuid.toString(), + LOG.warn("AutoAttach table {} not found for Ovsdb Node {} to delete", autoAttachUuid, ovsdbNode.get().getNodeId()); } } diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbQosRemovedCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbQosRemovedCommand.java index 95e8389f3..1332226ff 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbQosRemovedCommand.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbQosRemovedCommand.java @@ -71,7 +71,7 @@ public class OvsdbQosRemovedCommand extends AbstractTransactionCommand { private QosEntriesKey getQosEntriesKey(Node node, UUID qosUuid) { List qosList = node.augmentation(OvsdbNodeAugmentation.class).getQosEntries(); if (qosList == null || qosList.isEmpty()) { - LOG.debug("Deleting Qos {}, Ovsdb Node {} does not have a Qos list.", qosUuid.toString(), node); + LOG.debug("Deleting Qos {}, Ovsdb Node {} does not have a Qos list.", qosUuid, node); return null; } Iterator itr = qosList.iterator(); @@ -82,7 +82,7 @@ public class OvsdbQosRemovedCommand extends AbstractTransactionCommand { return qos.key(); } } - LOG.debug("Deleted Queue {} not found in Ovsdb Node {}", qosUuid.toString(), node); + LOG.debug("Deleted Queue {} not found in Ovsdb Node {}", qosUuid, node); return null; } diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbQueueRemovedCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbQueueRemovedCommand.java index a1d0c6805..cc0b0dc2b 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbQueueRemovedCommand.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbQueueRemovedCommand.java @@ -71,7 +71,7 @@ public class OvsdbQueueRemovedCommand extends AbstractTransactionCommand { private QueuesKey getQueueKey(Node node, UUID queueUuid) { List queueList = node.augmentation(OvsdbNodeAugmentation.class).getQueues(); if (queueList == null || queueList.isEmpty()) { - LOG.debug("Deleting Queue {}, Ovsdb Node {} does not have a Queue list.", queueUuid.toString(), node); + LOG.debug("Deleting Queue {}, Ovsdb Node {} does not have a Queue list.", queueUuid, node); return null; } Iterator itr = queueList.iterator(); @@ -82,7 +82,7 @@ public class OvsdbQueueRemovedCommand extends AbstractTransactionCommand { return queue.key(); } } - LOG.debug("Deleted Queue {} not found in Ovsdb Node {}", queueUuid.toString(), node); + LOG.debug("Deleted Queue {} not found in Ovsdb Node {}", queueUuid, node); return null; } diff --git a/southbound/southbound-it/src/test/java/org/opendaylight/ovsdb/southbound/it/SouthboundIT.java b/southbound/southbound-it/src/test/java/org/opendaylight/ovsdb/southbound/it/SouthboundIT.java index e64f10ee4..82e4dd3dd 100644 --- a/southbound/southbound-it/src/test/java/org/opendaylight/ovsdb/southbound/it/SouthboundIT.java +++ b/southbound/southbound-it/src/test/java/org/opendaylight/ovsdb/southbound/it/SouthboundIT.java @@ -880,7 +880,7 @@ public class SouthboundIT extends AbstractMdsalTestBase { ovsdbBridgeAugmentationBuilder.setControllerEntry(controllerEntries); ovsdbBridgeAugmentationBuilder.setBridgeOtherConfigs(otherConfigs); bridgeNodeBuilder.addAugmentation(OvsdbBridgeAugmentation.class, ovsdbBridgeAugmentationBuilder.build()); - LOG.debug("Built with the intent to store bridge data {}", ovsdbBridgeAugmentationBuilder.toString()); + LOG.debug("Built with the intent to store bridge data {}", ovsdbBridgeAugmentationBuilder); Assert.assertTrue( mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, bridgeIid, bridgeNodeBuilder.build())); try { @@ -2074,7 +2074,7 @@ public class SouthboundIT extends AbstractMdsalTestBase { helper.writeValues(bridgeCreateAugmentationBuilder, updateFromTestCase.inputValues); bridgeCreateNodeBuilder.addAugmentation(OvsdbBridgeAugmentation.class, bridgeCreateAugmentationBuilder.build()); - LOG.debug("Built with the intent to store bridge data {}", bridgeCreateAugmentationBuilder.toString()); + LOG.debug("Built with the intent to store bridge data {}", bridgeCreateAugmentationBuilder); Assert.assertTrue(mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, bridgeIid, bridgeCreateNodeBuilder.build())); Thread.sleep(OVSDB_UPDATE_TIMEOUT); -- 2.36.6