RexXiong commented on code in PR #2595:
URL: https://github.com/apache/celeborn/pull/2595#discussion_r1663258184
##########
common/src/main/scala/org/apache/celeborn/common/CelebornConf.scala:
##########
@@ -2814,6 +2827,30 @@ object CelebornConf extends Logging {
.timeConf(TimeUnit.MILLISECONDS)
.createWithDefaultString("1000ms")
+ val WORKER_STORAGE_CREATE_FILE_POLICY: OptionalConfigEntry[String] =
+ buildConf("celeborn.worker.storage.storagePolicy.createFilePolicy")
+ .categories("worker")
+ .doc("This defined the order for create files if the storages are
available. Available storages: MEMORY,SSD,HDD,HDFS")
Review Comment:
nit: This defined the order for creating files across available storages.
Available storages options are: MEMORY,SSD,HDD,HDFS,OSS
##########
common/src/main/scala/org/apache/celeborn/common/CelebornConf.scala:
##########
@@ -2814,6 +2827,30 @@ object CelebornConf extends Logging {
.timeConf(TimeUnit.MILLISECONDS)
.createWithDefaultString("1000ms")
+ val WORKER_STORAGE_CREATE_FILE_POLICY: OptionalConfigEntry[String] =
+ buildConf("celeborn.worker.storage.storagePolicy.createFilePolicy")
+ .categories("worker")
+ .doc("This defined the order for create files if the storages are
available. Available storages: MEMORY,SSD,HDD,HDFS")
+ .version("0.5.1")
+ .stringConf
+ .checkValue(
+ _.split(",").map(str =>
StorageInfo.typeNames.contains(str.trim.toUpperCase)).forall(p =>
+ p),
+ "Will use default create file order. Default order:
MEMORY,SSD,HDD,HDFS")
Review Comment:
nit: MEMORY,SSD,HDD,HDFS,OSS
##########
common/src/main/scala/org/apache/celeborn/common/CelebornConf.scala:
##########
@@ -2814,6 +2827,30 @@ object CelebornConf extends Logging {
.timeConf(TimeUnit.MILLISECONDS)
.createWithDefaultString("1000ms")
+ val WORKER_STORAGE_CREATE_FILE_POLICY: OptionalConfigEntry[String] =
+ buildConf("celeborn.worker.storage.storagePolicy.createFilePolicy")
+ .categories("worker")
+ .doc("This defined the order for create files if the storages are
available. Available storages: MEMORY,SSD,HDD,HDFS")
+ .version("0.5.1")
+ .stringConf
+ .checkValue(
+ _.split(",").map(str =>
StorageInfo.typeNames.contains(str.trim.toUpperCase)).forall(p =>
+ p),
+ "Will use default create file order. Default order:
MEMORY,SSD,HDD,HDFS")
+ .createOptional
+
+ val WORKER_STORAGE_EVICT_POLICY: OptionalConfigEntry[String] =
+ buildConf("celeborn.worker.storage.storagePolicy.evictPolicy")
+ .categories("worker")
+ .doc("This define the order of evict files if the storages are
available. Available storages: MEMORY,SSD,HDD,HDFS. Definition:
StorageTypes|StorageTypes|StorageTypes.")
Review Comment:
eg: MEMORY,SSD|SSD,HDFS
##########
worker/src/main/scala/org/apache/celeborn/service/deploy/worker/storage/StoragePolicy.scala:
##########
@@ -0,0 +1,109 @@
+/*
+ * 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.celeborn.service.deploy.worker.storage
+
+import org.apache.celeborn.common.CelebornConf
+import org.apache.celeborn.common.exception.CelebornIOException
+import org.apache.celeborn.common.internal.Logging
+import org.apache.celeborn.common.metrics.source.AbstractSource
+import org.apache.celeborn.common.protocol.StorageInfo
+
+object StoragePolicy extends Logging {
Review Comment:
IMO StoragePolicy belongs to StorageManager, better not expose StoragePolicy
to CelebornFile.
##########
worker/src/main/scala/org/apache/celeborn/service/deploy/worker/storage/CelebornFileProxy.scala:
##########
@@ -0,0 +1,58 @@
+/*
+ * 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.celeborn.service.deploy.worker.storage
+
+import io.netty.buffer.ByteBuf
+
+import org.apache.celeborn.common.CelebornConf
+import org.apache.celeborn.common.metrics.source.AbstractSource
+
+class CelebornFileProxy(
+ partitionDataWriterContext: PartitionDataWriterContext,
+ storageManager: StorageManager,
+ conf: CelebornConf,
+ source: AbstractSource) {
+ var currentFile: CelebornFile = _
+ var flusher: Flusher = null
+ var flushWorkerIndex = 0
+
+ currentFile = StoragePolicy.createFile(partitionDataWriterContext)
+
+ def write(buf: ByteBuf) = {
+ this.synchronized {
+ currentFile.write(buf)
+ }
+ }
+
+ def evict(force: Boolean) = {
+ if (currentFile.needEvict || force) {
+ this.synchronized {
+ val nFile = StoragePolicy.getEvictedFile(currentFile,
partitionDataWriterContext)
+ currentFile.evict(nFile)
+ currentFile = nFile
+ }
+ }
+ }
+
+ def close(): Unit = {}
+
+ def isMemoryShuffleFile: Boolean = {
+ currentFile.isInstanceOf[CelebornMemoryFile]
Review Comment:
Check storage type instead using isInstanceOf
##########
worker/src/main/scala/org/apache/celeborn/service/deploy/worker/storage/StoragePolicy.scala:
##########
@@ -0,0 +1,109 @@
+/*
+ * 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.celeborn.service.deploy.worker.storage
+
+import org.apache.celeborn.common.CelebornConf
+import org.apache.celeborn.common.exception.CelebornIOException
+import org.apache.celeborn.common.internal.Logging
+import org.apache.celeborn.common.metrics.source.AbstractSource
+import org.apache.celeborn.common.protocol.StorageInfo
+
+object StoragePolicy extends Logging {
+ var storageManager: StorageManager = _
+ var conf: CelebornConf = _
+ var createFileOrder: Option[List[String]] = _
+ var evictFileOrder: Option[Map[String, List[String]]] = _
+ var source: AbstractSource = _
+
+ def initlize(
+ conf: CelebornConf,
+ storageManager: StorageManager,
+ abstractSource: AbstractSource): Unit = {
+ this.storageManager = storageManager
+ this.conf = conf
+ this.createFileOrder = conf.workerStoragePolicyCreateFilePolicy
+ this.evictFileOrder = conf.workerStoragePolicyEvictFilePolicy
+ this.source = abstractSource
+ }
+
+ def getEvictedFile(
Review Comment:
Add UT for getEvictedFile
##########
worker/src/main/scala/org/apache/celeborn/service/deploy/worker/storage/StoragePolicy.scala:
##########
@@ -0,0 +1,109 @@
+/*
+ * 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.celeborn.service.deploy.worker.storage
+
+import org.apache.celeborn.common.CelebornConf
+import org.apache.celeborn.common.exception.CelebornIOException
+import org.apache.celeborn.common.internal.Logging
+import org.apache.celeborn.common.metrics.source.AbstractSource
+import org.apache.celeborn.common.protocol.StorageInfo
+
+object StoragePolicy extends Logging {
+ var storageManager: StorageManager = _
+ var conf: CelebornConf = _
+ var createFileOrder: Option[List[String]] = _
+ var evictFileOrder: Option[Map[String, List[String]]] = _
+ var source: AbstractSource = _
+
+ def initlize(
+ conf: CelebornConf,
+ storageManager: StorageManager,
+ abstractSource: AbstractSource): Unit = {
+ this.storageManager = storageManager
+ this.conf = conf
+ this.createFileOrder = conf.workerStoragePolicyCreateFilePolicy
+ this.evictFileOrder = conf.workerStoragePolicyEvictFilePolicy
+ this.source = abstractSource
+ }
+
+ def getEvictedFile(
+ celebornFile: CelebornFile,
+ partitionDataWriterContext: PartitionDataWriterContext): CelebornFile = {
+ if (evictFileOrder.isDefined) {
+ if (evictFileOrder.get.contains(celebornFile.storageType.name())) {
Review Comment:
How about `val order =
evictFileOrder.get.get(celebornFile.storageType.name())
if (null != order) {
return createFile(partitionDataWriterContext, order)
}
null`
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]