[
https://issues.apache.org/jira/browse/HDDS-14470?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Tsz-wo Sze updated HDDS-14470:
------------------------------
Description:
{code}
//OMFailoverProxyProviderBase
private Map<String, OMProxyInfo<T>> omProxies;
private List<String> omNodesInOrder;
{code}
OMFailoverProxyProviderBase currently has
- omProxies: nodeId -> OMProxyInfo (Note that OMProxyInfo has a getNodeId()
method.)
- omNodesInOrder: int -> nodeId (Note that the ints specify the ordering of the
proxies)
When getting an OMProxyInfo from an int, it needs to get the nodeId and then
lookup the omProxies map for OMProxyInfo. The map lookup is unnecessary.
In this JIRA, we improve the data structures by replacing them with the
following:
{code}
/** A list of proxies in a particular order. */
private final List<OMProxyInfo<P>> proxies;
/**
* The ordering of the nodes.
* <p>
* Invariant 1: Given a nodeId, let Integer i = ordering.get(nodeId);
* If i != null, then nodeId.equals(info.getNodeId()) == true,
where info = proxies.get(i).
* Otherwise, i == null, then nodeId.equals(info.getNodeId())
== false for any info in proxies.
* <p>
* Invariant 2: Given 0 <= i < proxies.size(), let nodeId =
proxies.get(i).getNodeId().
* Then, ordering.get(nodeId) == i.
*/
private final SortedMap<String, Integer> ordering;
{code}
was:
{code}
//OMFailoverProxyProviderBase
private Map<String, OMProxyInfo<T>> omProxies;
private List<String> omNodesInOrder;
{code}
OMFailoverProxyProviderBase currently has
- omProxies: nodeId -> OMProxyInfo (Note that OMProxyInfo has a getNodeId()
method.)
- omNodesInOrder: int -> nodeId (Note that the ints specify the ordering of the
proxies)
When getting an OMProxyInfo from an int, it needs to get the nodeId and then
lookup the omProxies map for OMProxyInfo. The map lookup is unnecessary.
In this JIRA, we improve the data structures by replacing them with the
following:
{code}
// Suggested improvement
/** A list of proxies in a particular order. */
private final List<OMProxyInfo<P>> proxies;
/**
* The ordering of the nodes.
* <p>
* Invariant 1: Given a nodeId, let Integer i = ordering.get(nodeId);
* If i != null, let info = proxies.get(i), then
nodeId.equals(info.getNodeId()) == true.
* Otherwise, nodeId.equals(info.getNodeId()) == false for any
info in proxies.
* <p>
* Invariant 2: Given a 0 <= i < proxies.size(), let nodeId =
proxies.get(i).getNodeId().
* Then, ordering.get(nodeId) == i.
*/
private final SortedMap<String, Integer> ordering;
{code}
> Improve the data structures in OMFailoverProxyProviderBase
> ----------------------------------------------------------
>
> Key: HDDS-14470
> URL: https://issues.apache.org/jira/browse/HDDS-14470
> Project: Apache Ozone
> Issue Type: Sub-task
> Components: common
> Reporter: Tsz-wo Sze
> Assignee: Tsz-wo Sze
> Priority: Major
>
> {code}
> //OMFailoverProxyProviderBase
> private Map<String, OMProxyInfo<T>> omProxies;
> private List<String> omNodesInOrder;
> {code}
> OMFailoverProxyProviderBase currently has
> - omProxies: nodeId -> OMProxyInfo (Note that OMProxyInfo has a getNodeId()
> method.)
> - omNodesInOrder: int -> nodeId (Note that the ints specify the ordering of
> the proxies)
> When getting an OMProxyInfo from an int, it needs to get the nodeId and then
> lookup the omProxies map for OMProxyInfo. The map lookup is unnecessary.
> In this JIRA, we improve the data structures by replacing them with the
> following:
> {code}
> /** A list of proxies in a particular order. */
> private final List<OMProxyInfo<P>> proxies;
> /**
> * The ordering of the nodes.
> * <p>
> * Invariant 1: Given a nodeId, let Integer i = ordering.get(nodeId);
> * If i != null, then nodeId.equals(info.getNodeId()) ==
> true, where info = proxies.get(i).
> * Otherwise, i == null, then
> nodeId.equals(info.getNodeId()) == false for any info in proxies.
> * <p>
> * Invariant 2: Given 0 <= i < proxies.size(), let nodeId =
> proxies.get(i).getNodeId().
> * Then, ordering.get(nodeId) == i.
> */
> private final SortedMap<String, Integer> ordering;
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]