You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@uniffle.apache.org by "zuston (via GitHub)" <gi...@apache.org> on 2023/04/27 06:26:42 UTC
[GitHub] [incubator-uniffle] zuston opened a new pull request, #847: [#845] feat(storage): Introduce capacity based storage chooser strategy
zuston opened a new pull request, #847:
URL: https://github.com/apache/incubator-uniffle/pull/847
### What changes were proposed in this pull request?
Introduce pluggable storage chooser strategies for local storage,
including hash-based(default) and capacity-based
### Why are the changes needed?
Currently, the local storage of per-partition is selected by hash strategy.
This is simple but will cause many problems, like many huge partitions
will store in the same local disk, if the hash number is same.
I know this is rare but it has happened in our internal env.
So it's better to support remaining space based storage selector for per-partition.
And I will introduce the pluggable local storage selector,
but I'm not sure whether it could support multiple disk storages for one-partition.
Anyway, the pluggable storage selector for localStorageManager is the first step to achieve above.
### Does this PR introduce _any_ user-facing change?
Yes. Doc will be added later.
### How was this patch tested?
1. UTs
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org
[GitHub] [incubator-uniffle] jerqi commented on pull request #847: [#845] feat(storage): Introduce available space based storage choosing policy
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on PR #847:
URL: https://github.com/apache/incubator-uniffle/pull/847#issuecomment-1537141868
Do you consider reading data if we use another storage choose policy?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org
[GitHub] [incubator-uniffle] advancedxy commented on a diff in pull request #847: [#845] feat(storage): Introduce available space based storage choosing policy
Posted by "advancedxy (via GitHub)" <gi...@apache.org>.
advancedxy commented on code in PR #847:
URL: https://github.com/apache/incubator-uniffle/pull/847#discussion_r1186984368
##########
docs/server_guide.md:
##########
@@ -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.|
Review Comment:
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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org
[GitHub] [incubator-uniffle] smallzhongfeng commented on a diff in pull request #847: [#845] feat(storage): Introduce available space based storage choosing policy
Posted by "smallzhongfeng (via GitHub)" <gi...@apache.org>.
smallzhongfeng commented on code in PR #847:
URL: https://github.com/apache/incubator-uniffle/pull/847#discussion_r1187107339
##########
server/src/test/java/org/apache/uniffle/server/storage/local/AvailableSpaceStorageChoosingPolicyTest.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * 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;
Review Comment:
Yes, maybe we should reconstruct the package name of the shuffle server.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org
[GitHub] [incubator-uniffle] jerqi commented on a diff in pull request #847: [#845] feat(storage): Introduce available space based storage choosing policy
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #847:
URL: https://github.com/apache/incubator-uniffle/pull/847#discussion_r1186824704
##########
common/src/main/java/org/apache/uniffle/common/util/ClassUtils.java:
##########
@@ -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)
Review Comment:
https://github.com/apache/incubator-uniffle/issues/434
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org
[GitHub] [incubator-uniffle] zuston commented on pull request #847: [#845] feat(storage): Introduce available space based storage choosing policy
Posted by "zuston (via GitHub)" <gi...@apache.org>.
zuston commented on PR #847:
URL: https://github.com/apache/incubator-uniffle/pull/847#issuecomment-1537119724
If you have time, could you help take a look ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org
[GitHub] [incubator-uniffle] zuston commented on pull request #847: [#845] feat(storage): Introduce available space based storage choosing policy
Posted by "zuston (via GitHub)" <gi...@apache.org>.
zuston commented on PR #847:
URL: https://github.com/apache/incubator-uniffle/pull/847#issuecomment-1534219583
PTAL @jerqi Round-robin could be supported in the future.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org
[GitHub] [incubator-uniffle] codecov-commenter commented on pull request #847: [#845] feat(storage): Introduce capacity based storage chooser strategy
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #847:
URL: https://github.com/apache/incubator-uniffle/pull/847#issuecomment-1524889287
## [Codecov](https://codecov.io/gh/apache/incubator-uniffle/pull/847?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#847](https://codecov.io/gh/apache/incubator-uniffle/pull/847?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (8ff6e6c) into [master](https://codecov.io/gh/apache/incubator-uniffle/commit/4ce4a8ddfa7edccee033e73ca16face959a34c1b?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (4ce4a8d) will **increase** coverage by `2.32%`.
> The diff coverage is `70.00%`.
> :exclamation: Current head 8ff6e6c differs from pull request most recent head 270e5d6. Consider uploading reports for the commit 270e5d6 to get more accurate results
```diff
@@ Coverage Diff @@
## master #847 +/- ##
============================================
+ Coverage 56.99% 59.32% +2.32%
- Complexity 2137 2168 +31
============================================
Files 321 305 -16
Lines 15642 13358 -2284
Branches 1243 1248 +5
============================================
- Hits 8915 7924 -991
+ Misses 6220 5000 -1220
+ Partials 507 434 -73
```
| [Impacted Files](https://codecov.io/gh/apache/incubator-uniffle/pull/847?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...ava/org/apache/uniffle/common/util/ClassUtils.java](https://codecov.io/gh/apache/incubator-uniffle/pull/847?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS91bmlmZmxlL2NvbW1vbi91dGlsL0NsYXNzVXRpbHMuamF2YQ==) | `0.00% <0.00%> (ø)` | |
| [...rg/apache/uniffle/storage/common/LocalStorage.java](https://codecov.io/gh/apache/incubator-uniffle/pull/847?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3RvcmFnZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvdW5pZmZsZS9zdG9yYWdlL2NvbW1vbi9Mb2NhbFN0b3JhZ2UuamF2YQ==) | `61.36% <0.00%> (+0.59%)` | :arrow_up: |
| [...he/uniffle/server/storage/LocalStorageManager.java](https://codecov.io/gh/apache/incubator-uniffle/pull/847?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2VydmVyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS91bmlmZmxlL3NlcnZlci9zdG9yYWdlL0xvY2FsU3RvcmFnZU1hbmFnZXIuamF2YQ==) | `84.97% <70.00%> (-1.00%)` | :arrow_down: |
| [.../server/storage/local/HashBasedStorageChooser.java](https://codecov.io/gh/apache/incubator-uniffle/pull/847?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2VydmVyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS91bmlmZmxlL3NlcnZlci9zdG9yYWdlL2xvY2FsL0hhc2hCYXNlZFN0b3JhZ2VDaG9vc2VyLmphdmE=) | `92.30% <92.30%> (ø)` | |
| [...a/org/apache/uniffle/server/ShuffleServerConf.java](https://codecov.io/gh/apache/incubator-uniffle/pull/847?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2VydmVyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS91bmlmZmxlL3NlcnZlci9TaHVmZmxlU2VydmVyQ29uZi5qYXZh) | `99.43% <100.00%> (+<0.01%)` | :arrow_up: |
| [...ver/storage/local/CapacityBasedStorageChooser.java](https://codecov.io/gh/apache/incubator-uniffle/pull/847?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2VydmVyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS91bmlmZmxlL3NlcnZlci9zdG9yYWdlL2xvY2FsL0NhcGFjaXR5QmFzZWRTdG9yYWdlQ2hvb3Nlci5qYXZh) | `100.00% <100.00%> (ø)` | |
... and [28 files with indirect coverage changes](https://codecov.io/gh/apache/incubator-uniffle/pull/847/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org
[GitHub] [incubator-uniffle] zuston commented on pull request #847: [#845] feat(storage): Introduce capacity based storage chooser strategy
Posted by "zuston (via GitHub)" <gi...@apache.org>.
zuston commented on PR #847:
URL: https://github.com/apache/incubator-uniffle/pull/847#issuecomment-1526942202
cc @jerqi . PTAL.
BTW. the failed test case is not the logic error. Please ignore
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org
[GitHub] [incubator-uniffle] jerqi commented on a diff in pull request #847: [#845] feat(storage): Introduce available space based storage choosing policy
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #847:
URL: https://github.com/apache/incubator-uniffle/pull/847#discussion_r1186800998
##########
server/src/test/java/org/apache/uniffle/server/storage/local/AvailableSpaceStorageChoosingPolicyTest.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * 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;
Review Comment:
Could we have a better package name? The `local` have a different style from other packages. Maybe we could a better shuffle server package organization like coordinator. @smallzhongfeng Do you have some suggestion?
##########
common/src/main/java/org/apache/uniffle/common/util/ClassUtils.java:
##########
@@ -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)
Review Comment:
We seems have many similar places like the some strategies class. Could we unify them?
##########
server/src/main/java/org/apache/uniffle/server/storage/local/StorageChoosingPolicy.java:
##########
@@ -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> {
+
+ T choose(ShuffleDataFlushEvent event, T... candidates);
Review Comment:
Why do we use array as parameter? Collection seems better than array according to the book <<Effective Java>>.
##########
server/src/main/java/org/apache/uniffle/server/storage/local/StorageChoosingPolicy.java:
##########
@@ -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> {
Review Comment:
What's the difference between `policy` and `strategy`? Could we have a unify style?
##########
server/src/main/java/org/apache/uniffle/server/storage/local/StorageChoosingPolicy.java:
##########
@@ -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> {
+
+ T choose(ShuffleDataFlushEvent event, T... candidates);
Review Comment:
Could we have better name? What's the difference between `choose` and `select`? Should we have a unify style?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org
[GitHub] [incubator-uniffle] advancedxy commented on a diff in pull request #847: [#845] feat(storage): Introduce available space based storage choosing policy
Posted by "advancedxy (via GitHub)" <gi...@apache.org>.
advancedxy commented on code in PR #847:
URL: https://github.com/apache/incubator-uniffle/pull/847#discussion_r1186986797
##########
server/src/main/java/org/apache/uniffle/server/storage/local/AvailableSpaceStorageChoosingPolicy.java:
##########
@@ -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;
+ }
+
+ 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);
Review Comment:
max rather than `sort then get first`?
##########
server/src/main/java/org/apache/uniffle/server/storage/local/AvailableSpaceStorageChoosingPolicy.java:
##########
@@ -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;
+ }
Review Comment:
Seems like this method should be moved to interface's default method, such as `getDefaultCandidates`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org
Re: [PR] [#845] feat(storage): Introduce available space based storage choosing policy [incubator-uniffle]
Posted by "zuston (via GitHub)" <gi...@apache.org>.
zuston closed pull request #847: [#845] feat(storage): Introduce available space based storage choosing policy
URL: https://github.com/apache/incubator-uniffle/pull/847
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org
[GitHub] [incubator-uniffle] zuston commented on pull request #847: [#845] feat(storage): Introduce available space based storage choosing policy
Posted by "zuston (via GitHub)" <gi...@apache.org>.
zuston commented on PR #847:
URL: https://github.com/apache/incubator-uniffle/pull/847#issuecomment-1537271050
> Do you consider reading data if we use another storage choose policy?
The partition->disk mapping has been supported in #424.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org
[GitHub] [incubator-uniffle] jerqi commented on a diff in pull request #847: [#845] feat(storage): Introduce available space based storage choosing policy
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #847:
URL: https://github.com/apache/incubator-uniffle/pull/847#discussion_r1186802363
##########
server/src/main/java/org/apache/uniffle/server/storage/local/StorageChoosingPolicy.java:
##########
@@ -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> {
+
+ T choose(ShuffleDataFlushEvent event, T... candidates);
Review Comment:
For strategy, we should add some Java docs to explain the function of this interface and tell other developer how to extend this interface.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org