-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BMM Restart Improvements Part 1. Leader Coordinator Issuing Assignmen…
…t Tokens (#919) Leader Coordinator is issuing assignment tokens for stopping streams
- Loading branch information
Showing
6 changed files
with
269 additions
and
1 deletion.
There are no files selected for viewing
91 changes: 91 additions & 0 deletions
91
datastream-server/src/main/java/com/linkedin/datastream/server/AssignmentToken.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/** | ||
* Copyright 2022 LinkedIn Corporation. All rights reserved. | ||
* Licensed under the BSD 2-Clause License. See the LICENSE file in the project root for license information. | ||
* See the NOTICE file in the project root for additional information regarding copyright ownership. | ||
*/ | ||
package com.linkedin.datastream.server; | ||
|
||
import com.linkedin.datastream.common.JsonUtils; | ||
|
||
|
||
/** | ||
* Data structure to store assignment tokens. These are used as a mechanism for followers to signal the leader that | ||
* they handled assignment change | ||
*/ | ||
public final class AssignmentToken { | ||
private String _issuedBy; | ||
private String _issuedFor; | ||
private long _timestamp; | ||
|
||
/** | ||
* Constructor for {@link AssignmentToken} | ||
*/ | ||
public AssignmentToken(String issuedBy, String issuedFor) { | ||
_issuedBy = issuedBy; | ||
_issuedFor = issuedFor; | ||
_timestamp = System.currentTimeMillis(); | ||
} | ||
|
||
/** | ||
* Default constructor for {@link AssignmentToken}, required for json ser/de | ||
*/ | ||
public AssignmentToken() { | ||
|
||
} | ||
|
||
/** | ||
* Creates {@link AssignmentToken} instance from JSON | ||
*/ | ||
public static AssignmentToken fromJson(String json) { | ||
return JsonUtils.fromJson(json, AssignmentToken.class); | ||
} | ||
|
||
/** | ||
* Converts the object to JSON | ||
*/ | ||
public String toJson() { | ||
return JsonUtils.toJson(this); | ||
} | ||
|
||
/** | ||
* Gets the name of the leader host that issued the token | ||
*/ | ||
public String getIssuedBy() { | ||
return _issuedBy; | ||
} | ||
|
||
/** | ||
* Gets the name of the host for which the token was issued | ||
*/ | ||
public String getIssuedFor() { | ||
return _issuedFor; | ||
} | ||
|
||
/** | ||
* Gets the timestamp (in UNIX epoch format) for when the token was issued | ||
*/ | ||
public long getTimestamp() { | ||
return _timestamp; | ||
} | ||
|
||
/** | ||
* Sets the name of the leader host that issued the token | ||
*/ | ||
public void setIssuedBy(String issuedBy) { | ||
_issuedBy = issuedBy; | ||
} | ||
|
||
/** | ||
* Sets the name of the host for which the token was issued | ||
*/ | ||
public void setIssuedFor(String issuedFor) { | ||
_issuedFor = issuedFor; | ||
} | ||
|
||
/** | ||
* Sets the timestamp (in UNIX epoch format) for when the token was issued | ||
*/ | ||
public void setTimestamp(long timestamp) { | ||
_timestamp = timestamp; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters