forked from apache/doris
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
410 additions
and
91 deletions.
There are no files selected for viewing
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
64 changes: 64 additions & 0 deletions
64
fe/fe-core/src/main/java/org/apache/doris/nereids/worker/BackendWorker.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,64 @@ | ||
// 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 | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// 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.doris.nereids.worker; | ||
|
||
import org.apache.doris.system.Backend; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.List; | ||
|
||
/** BackendWorker */ | ||
public class BackendWorker implements Worker { | ||
private final Backend backend; | ||
|
||
public BackendWorker(Backend backend) { | ||
this.backend = backend; | ||
} | ||
|
||
@Override | ||
public String address() { | ||
return backend.getAddress(); | ||
} | ||
|
||
@Override | ||
public boolean available() { | ||
return backend.isQueryAvailable(); | ||
} | ||
|
||
@Override | ||
public Workload workload() { | ||
return new Workload() { | ||
@Override | ||
public int compareTo(@NotNull Workload workload) { | ||
return 0; | ||
} | ||
}; | ||
} | ||
|
||
@Override | ||
public WorkerGroup team() { | ||
return new WorkerGroup() { | ||
@Override | ||
public List<Worker> filterWorkers(WorkerPool workerPool) { | ||
return ImmutableList.of(); | ||
} | ||
}; | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
fe/fe-core/src/main/java/org/apache/doris/nereids/worker/ReplicaLocation.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,73 @@ | ||
// 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 | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// 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.doris.nereids.worker; | ||
|
||
import org.apache.doris.catalog.Env; | ||
import org.apache.doris.common.NereidsException; | ||
import org.apache.doris.nereids.worker.job.DataLocation; | ||
import org.apache.doris.nereids.worker.job.UnassignedNearStorageJob.DataId; | ||
import org.apache.doris.nereids.worker.job.UnassignedNearStorageJob.ReplicaId; | ||
import org.apache.doris.system.Backend; | ||
|
||
import com.google.common.collect.ImmutableMap; | ||
|
||
import java.util.Objects; | ||
|
||
public class ReplicaLocation implements DataLocation { | ||
public final long backendId; | ||
public final long tabletId; | ||
public final String host; | ||
public final int port; | ||
|
||
public ReplicaLocation(long backendId, long tabletId, String host, int port) { | ||
this.backendId = backendId; | ||
this.tabletId = tabletId; | ||
this.host = Objects.requireNonNull(host, "host can not be null"); | ||
this.port = port; | ||
} | ||
|
||
@Override | ||
public DataId dataId() { | ||
return new ReplicaId(backendId, host, port); | ||
} | ||
|
||
@Override | ||
public String location() { | ||
return host + ":" + port; | ||
} | ||
|
||
@Override | ||
public Worker toWorker() { | ||
try { | ||
ImmutableMap<Long, Backend> backendsWithIdByCurrentCluster = Env.getCurrentSystemInfo() | ||
.getBackendsWithIdByCurrentCluster(); | ||
Backend backend = backendsWithIdByCurrentCluster.get(backendId); | ||
if (backend == null) { | ||
throw new IllegalStateException("Backend " + backendId + " is not exist"); | ||
} | ||
return new BackendWorker(backend); | ||
} catch (Exception t) { | ||
throw new NereidsException("Get worker failed: " + this + ". Cause: " + t, t); | ||
} | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "backendId=" + location() + ", tabletId=" + tabletId; | ||
} | ||
} |
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
64 changes: 64 additions & 0 deletions
64
fe/fe-core/src/main/java/org/apache/doris/nereids/worker/TabletTopology.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,64 @@ | ||
// 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 | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// 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.doris.nereids.worker; | ||
|
||
import org.apache.doris.nereids.worker.job.DataLocation; | ||
import org.apache.doris.nereids.worker.job.UnassignedNearStorageJob.DataId; | ||
import org.apache.doris.nereids.worker.job.UnassignedNearStorageJob.TabletId; | ||
import org.apache.doris.planner.OlapScanNode; | ||
import org.apache.doris.thrift.TNetworkAddress; | ||
import org.apache.doris.thrift.TScanRangeLocation; | ||
import org.apache.doris.thrift.TScanRangeLocations; | ||
|
||
import com.google.common.collect.ArrayListMultimap; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** TabletTopology */ | ||
public class TabletTopology implements DataTopology { | ||
private Map<DataId, List<DataLocation>> topology; | ||
|
||
public TabletTopology(List<OlapScanNode> olapScanNodes) { | ||
ArrayListMultimap<DataId, DataLocation> topology = ArrayListMultimap.create(); | ||
for (OlapScanNode olapScanNode : olapScanNodes) { | ||
List<TScanRangeLocations> tabletLocations = olapScanNode.getScanRangeLocations(0); | ||
if (tabletLocations == null || tabletLocations.isEmpty()) { | ||
continue; | ||
} | ||
for (TScanRangeLocations tabletLocation : tabletLocations) { | ||
long tabletId = tabletLocation.getScanRange().getPaloScanRange().getTabletId(); | ||
List<TScanRangeLocation> replicaLocations = tabletLocation.getLocations(); | ||
for (TScanRangeLocation replicaLocation : replicaLocations) { | ||
long backendId = replicaLocation.getBackendId(); | ||
TNetworkAddress server = replicaLocation.getServer(); | ||
topology.put( | ||
new TabletId(tabletId), | ||
new ReplicaLocation(backendId, tabletId, server.getHostname(), server.getPort()) | ||
); | ||
} | ||
} | ||
} | ||
this.topology = (Map) topology.asMap(); | ||
} | ||
|
||
@Override | ||
public Map<DataId, List<DataLocation>> dataToReplicas() { | ||
return topology; | ||
} | ||
} |
Oops, something went wrong.