Skip to content

Commit

Permalink
Revert "[Refactor]Rename BackendState and BackendStatus (#20545)" (#2…
Browse files Browse the repository at this point in the history
…0819)

This reverts commit 78ebae0.
  • Loading branch information
imay authored Mar 31, 2023
1 parent 0ca4c6d commit 285d5a8
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import com.starrocks.sql.ast.DistributionDesc;
import com.starrocks.sql.ast.HashDistributionDesc;
import com.starrocks.system.DataNode;
import com.starrocks.system.DataNode.DataNodeState;
import com.starrocks.system.DataNode.BackendState;
import com.starrocks.system.SystemInfoService;
import com.starrocks.thrift.TBackendMeta;
import com.starrocks.thrift.TColumnMeta;
Expand Down Expand Up @@ -529,15 +529,15 @@ public void updateMeta(String dbName, TTableMeta meta, List<TBackendMeta> backen
backend.setHttpPort(backendMeta.getHttp_port());
backend.setBrpcPort(backendMeta.getRpc_port());
backend.setAlive(backendMeta.isAlive());
backend.setBackendState(DataNodeState.values()[backendMeta.getState()]);
backend.setBackendState(BackendState.values()[backendMeta.getState()]);
systemInfoService.addBackend(backend);
} else {
backend.setId(backendMeta.getBackend_id());
backend.setBePort(backendMeta.getBe_port());
backend.setHttpPort(backendMeta.getHttp_port());
backend.setBrpcPort(backendMeta.getRpc_port());
backend.setAlive(backendMeta.isAlive());
backend.setBackendState(DataNodeState.values()[backendMeta.getState()]);
backend.setBackendState(BackendState.values()[backendMeta.getState()]);
}
}
LOG.info("TableMetaSyncer finish meta update. partition build cost: {}ms, " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ private static void tabletReport(long backendId, Map<Long, TTablet> backendTable
final SystemInfoService currentSystemInfo = GlobalStateMgr.getCurrentSystemInfo();
DataNode reportBackend = currentSystemInfo.getBackend(backendId);
if (reportBackend != null) {
DataNode.DataNodeStatus backendStatus = reportBackend.getBackendStatus();
DataNode.BackendStatus backendStatus = reportBackend.getBackendStatus();
backendStatus.lastSuccessReportTabletsTime = TimeUtils.longToTimeString(start);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,15 @@
import java.util.Set;

/**
* Hybrid dataNode selector for hive table.
* dataNode is for starrocks, not hdfs dataNode
* Hybrid backend selector for hive table.
* Support hybrid and independent deployment with datanode.
* <p>
* Assign scan ranges to backend:
* 1. local dataNode first,
* 1. local backend first,
* 2. and smallest assigned scan ranges num or scan bytes.
* <p>
* If force_schedule_local variable is set, HybridDataNodeSelector will force to
* assign scan ranges to local dataNode if there has one.
* If force_schedule_local variable is set, HybridBackendSelector will force to
* assign scan ranges to local backend if there has one.
*/

public class HDFSDataNodeSelector implements DataNodeSelector {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3868,7 +3868,7 @@ public void replayUpdateClusterAndBackends(DataNodeIdsUpdateInfo info) {
cluster.removeBackend(id);
backend.setDecommissioned(false);
backend.clearClusterName();
backend.setBackendState(DataNode.DataNodeState.free);
backend.setBackendState(DataNode.BackendState.free);
}
}

Expand Down
16 changes: 8 additions & 8 deletions fe/fe-core/src/main/java/com/starrocks/system/ComputeNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public class ComputeNode implements IComputable, Writable {
// to index the state in some cluster
@SerializedName("backendState")
private volatile int backendState;
// private DataNodeState backendState;
// private BackendState backendState;

@SerializedName("heartbeatErrMsg")
private String heartbeatErrMsg = "";
Expand Down Expand Up @@ -113,7 +113,7 @@ public ComputeNode() {
this.beRpcPort = 0;

this.ownerClusterName = "";
this.backendState = DataNode.DataNodeState.free.ordinal();
this.backendState = DataNode.BackendState.free.ordinal();

this.decommissionType = DecommissionType.SystemDecommission.ordinal();
}
Expand All @@ -133,7 +133,7 @@ public ComputeNode(long id, String host, int heartbeatPort) {
this.isDecommissioned = new AtomicBoolean(false);

this.ownerClusterName = "";
this.backendState = DataNode.DataNodeState.free.ordinal();
this.backendState = DataNode.BackendState.free.ordinal();
this.decommissionType = DecommissionType.SystemDecommission.ordinal();
}

Expand Down Expand Up @@ -235,7 +235,7 @@ public void setHost(String host) {
this.host = host;
}

public void setBackendState(DataNode.DataNodeState state) {
public void setBackendState(DataNode.BackendState state) {
this.backendState = state.ordinal();
}

Expand Down Expand Up @@ -377,14 +377,14 @@ public void clearClusterName() {
ownerClusterName = "";
}

public DataNode.DataNodeState getBackendState() {
public DataNode.BackendState getBackendState() {
switch (backendState) {
case 0:
return DataNode.DataNodeState.using;
return DataNode.BackendState.using;
case 1:
return DataNode.DataNodeState.offline;
return DataNode.BackendState.offline;
default:
return DataNode.DataNodeState.free;
return DataNode.BackendState.free;
}
}

Expand Down
18 changes: 9 additions & 9 deletions fe/fe-core/src/main/java/com/starrocks/system/DataNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
*/
public class DataNode extends ComputeNode {

public enum DataNodeState {
public enum BackendState {
using, /* backend belongs to a cluster*/
offline,
free /* backend is not belong to any clusters */
Expand All @@ -84,8 +84,8 @@ public enum DataNodeState {
// this field is set by tablet report, and just for metric monitor, no need to persist.
private volatile long tabletMaxCompactionScore = 0;

// additional dataNodeStatus information for BE, display in JSON format
private final DataNodeStatus dataNodeStatus = new DataNodeStatus();
// additional backendStatus information for BE, display in JSON format
private final BackendStatus backendStatus = new BackendStatus();

public DataNode() {
super();
Expand Down Expand Up @@ -294,8 +294,8 @@ public void setStorageMediumForAllDisks(TStorageMedium m) {
}
}

public DataNodeStatus getBackendStatus() {
return dataNodeStatus;
public BackendStatus getBackendStatus() {
return backendStatus;
}

public static DataNode read(DataInput in) throws IOException {
Expand Down Expand Up @@ -368,7 +368,7 @@ public void readFields(DataInput in) throws IOException {
setBackendState(in.readInt());
setDecommissionType(in.readInt());
} else {
setBackendState(DataNodeState.using.ordinal());
setBackendState(BackendState.using.ordinal());
setDecommissionType(DecommissionType.SystemDecommission.ordinal());
}

Expand Down Expand Up @@ -437,11 +437,11 @@ private int getDiskNum() {
/**
* Note: This class must be a POJO in order to display in JSON format
* Add additional information in the class to show in `show backends`
* if just change new added dataNodeStatus, you can do like following
* DataNodeStatus status = Backend.getBackendStatus();
* if just change new added backendStatus, you can do like following
* BackendStatus status = Backend.getBackendStatus();
* status.newItem = xxx;
*/
public class DataNodeStatus {
public class BackendStatus {
// this will be output as json, so not using FeConstants.null_string;
public String lastSuccessReportTabletsTime = "N/A";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
import com.starrocks.service.FrontendOptions;
import com.starrocks.sql.ast.DropBackendClause;
import com.starrocks.sql.ast.ModifyBackendAddressClause;
import com.starrocks.system.DataNode.DataNodeState;
import com.starrocks.system.DataNode.BackendState;
import com.starrocks.thrift.TNetworkAddress;
import com.starrocks.thrift.TStatusCode;
import com.starrocks.thrift.TStorageMedium;
Expand Down Expand Up @@ -174,7 +174,7 @@ private void setComputeNodeOwner(ComputeNode computeNode) {
final Cluster cluster = GlobalStateMgr.getCurrentState().getCluster();
Preconditions.checkState(cluster != null);
cluster.addComputeNode(computeNode.getId());
computeNode.setBackendState(DataNodeState.using);
computeNode.setBackendState(BackendState.using);
}

public boolean isSingleBackendAndComputeNode() {
Expand Down Expand Up @@ -223,7 +223,7 @@ private void setBackendOwner(DataNode backend) {
final Cluster cluster = GlobalStateMgr.getCurrentState().getCluster();
Preconditions.checkState(cluster != null);
cluster.addBackend(backend.getId());
backend.setBackendState(DataNodeState.using);
backend.setBackendState(BackendState.using);
}

// Final entry of adding backend
Expand Down Expand Up @@ -948,13 +948,13 @@ public static Pair<String, Integer> validateHostAndPort(String hostPort) throws

public void replayAddComputeNode(ComputeNode newComputeNode) {
// update idToComputeNode
newComputeNode.setBackendState(DataNode.DataNodeState.using);
newComputeNode.setBackendState(BackendState.using);
Map<Long, ComputeNode> copiedComputeNodes = Maps.newHashMap(idToComputeNodeRef);
copiedComputeNodes.put(newComputeNode.getId(), newComputeNode);
idToComputeNodeRef = ImmutableMap.copyOf(copiedComputeNodes);

// to add compute to DEFAULT_CLUSTER
if (newComputeNode.getBackendState() == DataNodeState.using) {
if (newComputeNode.getBackendState() == BackendState.using) {
final Cluster cluster = GlobalStateMgr.getCurrentState().getCluster();
if (null != cluster) {
// replay log
Expand All @@ -969,7 +969,7 @@ public void replayAddComputeNode(ComputeNode newComputeNode) {
public void replayAddBackend(DataNode newBackend) {
// update idToBackend
if (GlobalStateMgr.getCurrentStateJournalVersion() < FeMetaVersion.VERSION_30) {
newBackend.setBackendState(DataNodeState.using);
newBackend.setBackendState(BackendState.using);
}
Map<Long, DataNode> copiedBackends = Maps.newHashMap(idToBackendRef);
copiedBackends.put(newBackend.getId(), newBackend);
Expand All @@ -981,7 +981,7 @@ public void replayAddBackend(DataNode newBackend) {
idToReportVersionRef = ImmutableMap.copyOf(copiedReportVerions);

// to add be to DEFAULT_CLUSTER
if (newBackend.getBackendState() == DataNodeState.using) {
if (newBackend.getBackendState() == BackendState.using) {
final Cluster cluster = GlobalStateMgr.getCurrentState().getCluster();
if (null != cluster) {
// replay log
Expand Down

0 comments on commit 285d5a8

Please sign in to comment.