-
Notifications
You must be signed in to change notification settings - Fork 170
[#845] feat(storage): Introduce available space based storage choosing policy #847
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
Changes from all commits
5dd5d49
b1d3afe
33eea6a
599f676
8ff6e6c
270e5d6
108d0d6
048646c
36ea15a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,7 +28,6 @@ deploy/kubernetes/docker/hadoopconfig/* | |
| *.dll | ||
| *.so | ||
| *.dylib | ||
| local | ||
| vendor | ||
| VERSION | ||
| testbin/* | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| /* | ||
| * 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.uniffle.common.util; | ||
|
|
||
| import java.lang.reflect.Constructor; | ||
| import java.util.stream.Stream; | ||
|
|
||
| import org.apache.commons.lang3.tuple.Pair; | ||
|
|
||
| import org.apache.uniffle.common.exception.RssException; | ||
|
|
||
| public class ClassUtils { | ||
|
|
||
| @SuppressWarnings("unchecked") | ||
| public static <T> T instantiate(Class<T> clazz, Pair<Class<T>, Object>... typeAndVals) | ||
| throws RssException { | ||
| try { | ||
| if (typeAndVals == null || typeAndVals.length == 0) { | ||
| return clazz.getConstructor().newInstance(); | ||
| } | ||
| Class<T>[] types = Stream.of(typeAndVals).map(x -> x.getLeft()).toArray(Class[]::new); | ||
| Constructor<T> constructor = clazz.getConstructor(types); | ||
| return constructor.newInstance( | ||
| Stream.of(typeAndVals).map(x -> x.getRight()).toArray(Object[]::new) | ||
| ); | ||
| } catch (Exception e) { | ||
| throw new RssException(e); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,6 +91,7 @@ This document will introduce how to deploy Uniffle shuffle servers. | |
| | rss.server.max.concurrency.of.single.partition.writer | 1 | The max concurrency of single partition writer, the data partition file number is equal to this value. Default value is 1. This config could improve the writing speed, especially for huge partition. | | ||
| | rss.metrics.reporter.class | - | The class of metrics reporter. | | ||
| |rss.server.multistorage.manager.selector.class | org.apache.uniffle.server.storage.multi.DefaultStorageManagerSelector | The manager selector strategy for `MEMORY_LOCALFILE_HDFS`. Default value is `DefaultStorageManagerSelector`, and another `HugePartitionSensitiveStorageManagerSelector` will flush only huge partition's data to cold storage. | | ||
| |rss.server.localstorage.storage.choosing.policy.class|org.apache.uniffle.server.storage.local.HashStorageChoosingPolicy|For localstorage, the storage choosing policy is for per-partition. Default value is the hash-based disk selector.| | ||
|
Comment on lines
93
to
+94
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these two configurations seems related. Do you think it's possible to merge these configurations in next release, so users don't have to be confused by too many configurations. |
||
|
|
||
| ### Advanced Configurations | ||
| |Property Name|Default| Description | | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| /* | ||
| * 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.uniffle.server.storage.local; | ||
|
|
||
| import java.math.BigDecimal; | ||
| import java.util.Arrays; | ||
| import java.util.List; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| import org.apache.uniffle.server.ShuffleDataFlushEvent; | ||
| import org.apache.uniffle.storage.common.LocalStorage; | ||
|
|
||
| public class AvailableSpaceStorageChoosingPolicy implements StorageChoosingPolicy<LocalStorage> { | ||
|
|
||
| @Override | ||
| public LocalStorage choose(ShuffleDataFlushEvent event, LocalStorage... storages) { | ||
| final List<LocalStorage> candidates = Arrays.stream(storages) | ||
| .filter(x -> x.canWrite() && !x.isCorrupted()) | ||
| .collect(Collectors.toList()); | ||
|
|
||
| if (candidates.size() == 0) { | ||
| return null; | ||
| } | ||
|
Comment on lines
+32
to
+38
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like this method should be moved to interface's default method, such as |
||
|
|
||
| candidates.sort((s1, s2) -> { | ||
| BigDecimal s1UsedRatio = BigDecimal.valueOf(s1.getDiskSize()).divide(BigDecimal.valueOf(s1.getCapacity())); | ||
| BigDecimal s2UsedRatio = BigDecimal.valueOf(s2.getDiskSize()).divide(BigDecimal.valueOf(s2.getCapacity())); | ||
| return s1UsedRatio.compareTo(s2UsedRatio); | ||
| }); | ||
|
|
||
| return candidates.get(0); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. max rather than |
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| /* | ||
| * 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.uniffle.server.storage.local; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.List; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| import org.apache.uniffle.server.ShuffleDataFlushEvent; | ||
| import org.apache.uniffle.storage.common.LocalStorage; | ||
| import org.apache.uniffle.storage.util.ShuffleStorageUtils; | ||
|
|
||
| public class HashStorageChoosingPolicy implements StorageChoosingPolicy<LocalStorage> { | ||
|
|
||
| @Override | ||
| public LocalStorage choose(ShuffleDataFlushEvent event, LocalStorage... storages) { | ||
| List<LocalStorage> candidates = Arrays.stream(storages) | ||
| .filter(x -> x.canWrite() && !x.isCorrupted()) | ||
| .collect(Collectors.toList()); | ||
|
|
||
| if (candidates.size() == 0) { | ||
| return null; | ||
| } | ||
|
|
||
| String appId = event.getAppId(); | ||
| int shuffleId = event.getShuffleId(); | ||
| int partitionId = event.getStartPartition(); | ||
| final LocalStorage selectedStorage = candidates.get( | ||
| ShuffleStorageUtils.getStorageIndex( | ||
| candidates.size(), | ||
| appId, | ||
| shuffleId, | ||
| partitionId | ||
| ) | ||
| ); | ||
| return selectedStorage; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| /* | ||
| * 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.uniffle.server.storage.local; | ||
|
|
||
| import org.apache.uniffle.server.ShuffleDataFlushEvent; | ||
| import org.apache.uniffle.storage.common.Storage; | ||
|
|
||
| public interface StorageChoosingPolicy<T extends Storage> { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the difference between |
||
|
|
||
| T choose(ShuffleDataFlushEvent event, T... candidates); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we have better name? What's the difference between
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we use array as parameter? Collection seems better than array according to the book <>.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For strategy, we should add some Java docs to explain the function of this interface and tell other developer how to extend this interface. |
||
|
|
||
| } | ||
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.
We seems have many similar places like the some strategies class. Could we unify them?
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.
#434