HDDS-11622. Support domain socket creation#7379
HDDS-11622. Support domain socket creation#7379ChenSammi wants to merge 6 commits intoapache:masterfrom
Conversation
|
|
||
| public static final boolean OZONE_READ_SHORT_CIRCUIT_DEFAULT = false; | ||
| public static final String OZONE_DOMAIN_SOCKET_PATH = "ozone.domain.socket.path"; | ||
| public static final String OZONE_DOMAIN_SOCKET_PATH_DEFAULT = "/var/lib/ozone/dn_socket"; |
There was a problem hiding this comment.
Can we use existing directories like ozone.metadata.dirs or hdds.metadata.dir
There was a problem hiding this comment.
NO. This OZONE_DOMAIN_SOCKET_PATH_DEFAULT file will be created by DomainSocket process. It cannot be an existing file. Also Hadoop native library has different permission requirement on this path.
https://cwiki.apache.org/confluence/display/HADOOP2/SocketPathSecurity
| type = ConfigType.SIZE, | ||
| description = "Buffer size of reader/writer.", | ||
| tags = { ConfigTag.CLIENT, ConfigTag.DATANODE }) | ||
| private int shortCircuitBufferSize = 128 * 1024; |
There was a problem hiding this comment.
HDFS has default short circuit buffer size of 1MB.
There was a problem hiding this comment.
I tested the different values. Bigger buffer size doesn't help to improve the performance.
The short-circuit channel only exchange getBlock request and response. The value is determined by how big will a request and a response of a 256MB block size, 4MB chunk size, 16KB checksum size block. The request is round 500 bytes, and the response is around
30 + 53 * 64 + 6 * 16384 ~ 100k
block size (exclude chunks) - 30 bytes
chunk size (one checksums) - 53 bytes
one checksum size - 6 bytes
| // See #{java.org.apache.hadoop.net.unix.DomainSocket#validateSocketPathSecurity0} | ||
| // for details. | ||
| // | ||
| // So unless you are running as root or the hdfs superuser, you cannot |
There was a problem hiding this comment.
| // So unless you are running as root or the hdfs superuser, you cannot | |
| // So unless you are running as root or the ozone superuser, you cannot |
There was a problem hiding this comment.
the ozone superuser -> an ozone admin ?
There was a problem hiding this comment.
It means the user who launches the service.
| public static synchronized DomainSocketFactory getInstance(ConfigurationSource conf) { | ||
| if (instance == null) { | ||
| instance = new DomainSocketFactory(conf); | ||
| } | ||
| return instance; | ||
| } |
There was a problem hiding this comment.
| public static synchronized DomainSocketFactory getInstance(ConfigurationSource conf) { | |
| if (instance == null) { | |
| instance = new DomainSocketFactory(conf); | |
| } | |
| return instance; | |
| } | |
| public static DomainSocketFactory getInstance(ConfigurationSource conf) { | |
| if (instance == null) { | |
| synchronized (DomainSocketFactory.class) { | |
| instance = new DomainSocketFactory(conf); | |
| } | |
| } | |
| return instance; | |
| } |
Use double-checked locking instead: https://www.baeldung.com/java-singleton-double-checked-locking
|
|
||
| public static final String FEATURE = "short-circuit reads"; | ||
| public static final String FEATURE_FLAG = "SC"; | ||
| private static boolean nativeCodeLoaded = false; |
There was a problem hiding this comment.
May be better nativeLibraryLoaded instead of nativeCodeLoaded.
| long startTime = System.nanoTime(); | ||
| if (!shortCircuitEnabled) { | ||
| LOG.info(FEATURE + " is disabled."); | ||
| pathInfo = PathInfo.NOT_CONFIGURED; |
There was a problem hiding this comment.
We can ignore putting in pathInfo and further into pathMap when shortCircuit is disabled, we can throw exception?
There was a problem hiding this comment.
The DomainSocketFactory.java is an singleton instance. It is only instantiated once. Later reference will call isServiceEnabled and isServiceReady to determine whether DomainSocket can be created or not.
| } | ||
|
|
||
| public static final String FEATURE = "short-circuit reads"; | ||
| public static final String FEATURE_FLAG = "SC"; |
There was a problem hiding this comment.
It will be used in next patch.
jojochuang
left a comment
There was a problem hiding this comment.
Do we plan to add tests around these new code?
We would also need to package libadhoop into Ozone, into Ozone's dev docker image, and add tests for that.
I separated the previous patch into sub patches, for easy review. The separation from an actually complete patch is a little time consuming. The tests will be added in later patches, which require more new logics to run together. |
ashishkumar50
left a comment
There was a problem hiding this comment.
Thanks @ChenSammi for updating the patch, LGTM +1.
|
Thanks @jojochuang @smengcl @ashishkumar50 for the review. I will close this JIRA and provide a new one. I ment to push the patch to the feature branch HDDS-10685. |
What changes were proposed in this pull request?
Implemented a factory to create DomainSocket.
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-11622
How was this patch tested?
It will be tested in next patch.