bharatviswa504 commented on a change in pull request #2655:
URL: https://github.com/apache/ozone/pull/2655#discussion_r718937983
##########
File path:
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/OzoneClientProducer.java
##########
@@ -83,65 +75,20 @@ public OzoneClient createClient() throws
WebApplicationException,
return client;
}
- @PreDestroy
- public void destroy() throws IOException {
- client.close();
- }
-
private OzoneClient getClient(OzoneConfiguration config)
throws WebApplicationException {
OzoneClient ozoneClient = null;
try {
- SignatureInfo signatureInfo = signatureProcessor.parseSignature();
-
- String stringToSign = "";
- if (signatureInfo.getVersion() == Version.V4) {
- stringToSign =
- StringToSignProducer.createSignatureBase(signatureInfo, context);
- }
-
- String awsAccessId = signatureInfo.getAwsAccessId();
- validateAccessId(awsAccessId);
-
- UserGroupInformation remoteUser =
- UserGroupInformation.createRemoteUser(awsAccessId);
- if (OzoneSecurityUtil.isSecurityEnabled(config)) {
- LOG.debug("Creating s3 auth info for client.");
-
- if (signatureInfo.getVersion() == Version.NONE) {
- throw MALFORMED_HEADER;
- }
-
- OzoneTokenIdentifier identifier = new OzoneTokenIdentifier();
- identifier.setTokenType(S3AUTHINFO);
- identifier.setStrToSign(stringToSign);
- identifier.setSignature(signatureInfo.getSignature());
- identifier.setAwsAccessId(awsAccessId);
- identifier.setOwner(new Text(awsAccessId));
- if (LOG.isTraceEnabled()) {
- LOG.trace("Adding token for service:{}", omService);
- }
- Token<OzoneTokenIdentifier> token = new Token(identifier.getBytes(),
- identifier.getSignature().getBytes(StandardCharsets.UTF_8),
- identifier.getKind(),
- omService);
- remoteUser.addToken(token);
- }
+ this.remoteUser = UserGroupInformation.getCurrentUser();
ozoneClient =
- remoteUser.doAs((PrivilegedExceptionAction<OzoneClient>) () -> {
- return createOzoneClient();
- });
- } catch (OS3Exception ex) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Error during Client Creation: ", ex);
- }
- throw wrapOS3Exception(ex);
- } catch (Exception e) {
+ OzoneClientCache.getOzoneClientInstance(omServiceID,
Review comment:
> In that case, for the client, it can be swapped with a prior release
hadoop rpc support
Not understood what is meant by this and it is not clear how can we use
hadoop rpc with change in code to use single client?
##########
File path:
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/OzoneClientProducer.java
##########
@@ -83,65 +75,20 @@ public OzoneClient createClient() throws
WebApplicationException,
return client;
}
- @PreDestroy
- public void destroy() throws IOException {
- client.close();
- }
-
private OzoneClient getClient(OzoneConfiguration config)
throws WebApplicationException {
OzoneClient ozoneClient = null;
try {
- SignatureInfo signatureInfo = signatureProcessor.parseSignature();
-
- String stringToSign = "";
- if (signatureInfo.getVersion() == Version.V4) {
- stringToSign =
- StringToSignProducer.createSignatureBase(signatureInfo, context);
- }
-
- String awsAccessId = signatureInfo.getAwsAccessId();
- validateAccessId(awsAccessId);
-
- UserGroupInformation remoteUser =
- UserGroupInformation.createRemoteUser(awsAccessId);
- if (OzoneSecurityUtil.isSecurityEnabled(config)) {
- LOG.debug("Creating s3 auth info for client.");
-
- if (signatureInfo.getVersion() == Version.NONE) {
- throw MALFORMED_HEADER;
- }
-
- OzoneTokenIdentifier identifier = new OzoneTokenIdentifier();
- identifier.setTokenType(S3AUTHINFO);
- identifier.setStrToSign(stringToSign);
- identifier.setSignature(signatureInfo.getSignature());
- identifier.setAwsAccessId(awsAccessId);
- identifier.setOwner(new Text(awsAccessId));
- if (LOG.isTraceEnabled()) {
- LOG.trace("Adding token for service:{}", omService);
- }
- Token<OzoneTokenIdentifier> token = new Token(identifier.getBytes(),
- identifier.getSignature().getBytes(StandardCharsets.UTF_8),
- identifier.getKind(),
- omService);
- remoteUser.addToken(token);
- }
+ this.remoteUser = UserGroupInformation.getCurrentUser();
ozoneClient =
- remoteUser.doAs((PrivilegedExceptionAction<OzoneClient>) () -> {
- return createOzoneClient();
- });
- } catch (OS3Exception ex) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Error during Client Creation: ", ex);
- }
- throw wrapOS3Exception(ex);
- } catch (Exception e) {
+ OzoneClientCache.getOzoneClientInstance(omServiceID,
Review comment:
> In that case, for the client, it can be swapped with a prior release
hadoop rpc support
Not understood what is meant by this and it is not clear how can we use
hadoop rpc with change in code to use single client?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]