-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Make WorkerInfo enum (and some small refactors) #18460
Conversation
@@ -33,7 +33,7 @@ public final class WorkerInfo implements Serializable { | |||
private WorkerIdentity mIdentity; | |||
private WorkerNetAddress mAddress = new WorkerNetAddress(); | |||
private int mLastContactSec; | |||
private String mState = ""; | |||
private WorkerState mState = WorkerState.UNRECOGNIZED; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to assign a default value for worker state. A UNRECOGNIZED
state means either the code that creates the WorkerInfo
object did not set its state explicitly, or the worker is unknown to the membership service (e.g. never registered).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
/*** | ||
* The worker state maintained by master. | ||
*/ | ||
public enum WorkerState { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
anchor: moved from dora/core/common/src/main/java/alluxio/master/WorkerState.java
if (Modifier.isStatic(fieldModifiers) || Modifier.isFinal(fieldModifiers)) { | ||
continue; | ||
} | ||
field.setAccessible(true); | ||
// set fields in the copy to their default value | ||
field.set(copied, Defaults.defaultValue(field.getType())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol, works for me
alluxio-bot, merge this please |
### What changes are proposed in this pull request? 1. Move `WorkerState` enum from master package to the wire package. 2. Add a new worker state `UNRECOGNIZED` and use it as the default state. 3. Make worker state in `WorkerInfo` an enum. 4. Add copy constructors to `WorkerInfo` and `WorkerNetAddress`. ### Why are the changes needed? 1. Make sure the state of worker can be enumerated. 2. Allow safely copying mutable `WorkerInfo` and `WorkerNetAddress` objects. ### Does this PR introduce any user facing changes? No. pr-link: Alluxio#18460 change-id: cid-8daf9c1e3ebe8e862a9b0dabb669c80918f5b8b0
What changes are proposed in this pull request?
WorkerState
enum from master package to the wire package.UNRECOGNIZED
and use it as the default state.WorkerInfo
an enum.WorkerInfo
andWorkerNetAddress
.Why are the changes needed?
WorkerInfo
andWorkerNetAddress
objects.Does this PR introduce any user facing changes?
No.