-
Notifications
You must be signed in to change notification settings - Fork 537
HDDS-11975. wrap TermIndex in ExecutionContext #7602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,47 @@ | ||||||
/** | ||||||
* Licensed to the Apache Software Foundation (ASF) under one | ||||||
* or more contributor license agreements. See the NOTICE file | ||||||
* distributed with this work for additional information | ||||||
* regarding copyright ownership. The ASF licenses this file | ||||||
* to you under the Apache License, Version 2.0 (the | ||||||
* "License"); you may not use this file except in compliance | ||||||
* with the License. You may obtain a copy of the License at | ||||||
* <p> | ||||||
* http://www.apache.org/licenses/LICENSE-2.0 | ||||||
* <p> | ||||||
* Unless required by applicable law or agreed to in writing, software | ||||||
* distributed under the License is distributed on an "AS IS" BASIS, | ||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||
* See the License for the specific language governing permissions and | ||||||
* limitations under the License. | ||||||
*/ | ||||||
package org.apache.hadoop.ozone.om.ratis; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be located in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will follow below structure,
|
||||||
|
||||||
import org.apache.ratis.server.protocol.TermIndex; | ||||||
|
||||||
/** | ||||||
* context required for execution of request. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
*/ | ||||||
public class ExecutionContext { | ||||||
private long index; | ||||||
sumitagrawl marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
private TermIndex termIndex; | ||||||
|
||||||
public long getIndex() { | ||||||
return index; | ||||||
} | ||||||
|
||||||
public void setIndex(long index) { | ||||||
this.index = index; | ||||||
} | ||||||
|
||||||
public TermIndex getTermIndex() { | ||||||
if (null == termIndex) { | ||||||
return TermIndex.valueOf(-1, index); | ||||||
} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move this to the constructor? |
||||||
return termIndex; | ||||||
} | ||||||
|
||||||
public void setTermIndex(TermIndex termIndex) { | ||||||
this.termIndex = termIndex; | ||||||
} | ||||||
} |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -23,7 +23,7 @@ | |||||||||
import org.apache.commons.lang3.StringUtils; | ||||||||||
import org.apache.hadoop.hdds.utils.TransactionInfo; | ||||||||||
import org.apache.hadoop.ozone.om.helpers.OMAuditLogger; | ||||||||||
import org.apache.ratis.server.protocol.TermIndex; | ||||||||||
import org.apache.hadoop.ozone.om.ratis.ExecutionContext; | ||||||||||
import org.apache.hadoop.ipc.ProtobufRpcEngine; | ||||||||||
import org.apache.hadoop.ozone.OmUtils; | ||||||||||
import org.apache.hadoop.ozone.OzoneConsts; | ||||||||||
|
@@ -140,12 +140,15 @@ public void handleRequestFailure(OzoneManager ozoneManager) { | |||||||||
* | ||||||||||
* @return the response that will be returned to the client. | ||||||||||
*/ | ||||||||||
public abstract OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, TermIndex termIndex); | ||||||||||
public abstract OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, ExecutionContext context); | ||||||||||
|
||||||||||
/** For testing only. */ | ||||||||||
@VisibleForTesting | ||||||||||
public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, long transactionLogIndex) { | ||||||||||
return validateAndUpdateCache(ozoneManager, TransactionInfo.getTermIndex(transactionLogIndex)); | ||||||||||
ExecutionContext context = new ExecutionContext(); | ||||||||||
context.setTermIndex(TransactionInfo.getTermIndex(transactionLogIndex)); | ||||||||||
context.setIndex(transactionLogIndex); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please improve safety of
public static ExecutionContext of(long index)
public static ExecutionContext of(TermIndex termIndex) This reduces steps required in code that creates instances, and ensures only valid
Suggested change
If you plan to add many more members, then add builder instead of factory. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @adoroszlai updated ... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @sumitagrawl for updating the patch. Original suggestion simplifies callers and also ensures public static ExecutionContext of(long index)
public static ExecutionContext of(TermIndex termIndex) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @adoroszlai index: OM managed index -- it will be different of ratis index. But both is required to be part of ExecutionContext, used Once number of params increases, will change to Builder pattern on need basis, which will have only few place to change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will you have non-Ratis There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, Default, will be using OM managed index (non-ratis). Once if removed ratis index in above cases with new flow, will remove this parameter in this class. |
||||||||||
return validateAndUpdateCache(ozoneManager, context); | ||||||||||
} | ||||||||||
|
||||||||||
@VisibleForTesting | ||||||||||
|
Uh oh!
There was an error while loading. Please reload this page.