use of io.dingodb.meta.Location in project dingo by dingodb.
the class JobRunner method distributeTasks.
/**
* Distribute the tasks.
*
* @return the root task
*/
private Task distributeTasks() {
Task rootTask = null;
for (Task task : job.getTasks()) {
if (task.getRoot() != null) {
rootTask = task;
continue;
}
Location location = task.getLocation();
if (!location.equals(Services.META.currentLocation())) {
try {
Channel channel = Services.openNewSysChannel(location.getHost(), location.getPort());
Message msg = SimpleMessage.builder().tag(SimpleTag.TASK_TAG).content(task.serialize()).build();
channel.send(msg);
channel.close();
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("Error to distribute tasks.", e);
}
}
}
assert rootTask != null : "There must be one and only one root task.";
return rootTask;
}
use of io.dingodb.meta.Location in project dingo by dingodb.
the class PartitionOperator method createOutputs.
public void createOutputs(String tableName, @Nonnull Map<String, Location> partLocations) {
outputs = new HashMap<>(partLocations.size());
for (Map.Entry<String, Location> partLocation : partLocations.entrySet()) {
OutputHint hint = OutputHint.of(tableName, partLocation.getKey());
hint.setLocation(partLocation.getValue());
Output output = OutputIml.of(this);
output.setHint(hint);
outputs.put(partLocation.getKey(), output);
}
}
use of io.dingodb.meta.Location in project dingo by dingodb.
the class MetaTestService method createTable.
@Override
public void createTable(@Nonnull String tableName, @Nonnull TableDefinition tableDefinition) {
try {
OutputStream os = new FileOutputStream(metaFile(tableName));
tableDefinition.writeJson(os);
// force reload
tableDefinitionMap = null;
Map<String, Location> partLocations = getPartLocations(tableName);
for (Map.Entry<String, Location> entry : partLocations.entrySet()) {
StoreInstance store = Services.KV_STORE.getInstance(entry.getValue().getPath());
new PartInKvStore(store.getKvBlock(new TableId(getTableKey(tableName)), entry.getKey()), tableDefinition.getTupleSchema(), tableDefinition.getKeyMapping());
}
} catch (IOException e) {
log.error("Failed to write table definition: {}", tableDefinition);
throw new AssertionError("Failed to write table definition.");
}
}
use of io.dingodb.meta.Location in project dingo by dingodb.
the class TableMetaAdaptorImpl method rangeLocationGroup.
@Override
public NavigableMap<byte[], LocationGroup> rangeLocationGroup() {
NavigableMap<byte[], LocationGroup> result = new TreeMap<>(BytesUtil.getDefaultByteArrayComparator());
Map<GeneralId, AppView<?, ?>> map = this.scheduleMetaAdaptor.namespaceView().appViews();
for (Map.Entry<GeneralId, AppView<?, ?>> entry : map.entrySet()) {
if (entry.getValue() instanceof RegionView) {
RegionView view = (RegionView) entry.getValue();
ExecutorView executorView = this.scheduleMetaAdaptor.executorView(view.leader());
Endpoint endpoint = executorView.stats().getLocation();
Location location = new Location(endpoint.getIp(), endpoint.getPort(), DATA_DIR);
List<Location> locationList = view.nodeResources().stream().map(id -> this.scheduleMetaAdaptor.namespaceView().<ExecutorView>getResourceView(id)).map(ExecutorView::location).collect(Collectors.toList());
LocationGroup locationGroup = new LocationGroup(location, locationList);
RegionApp regionApp = this.scheduleMetaAdaptor.regionApp(view.app());
result.put(BytesUtil.nullToEmpty(regionApp.startKey()), locationGroup);
}
}
return result;
}
Aggregations