我将所有对象从MongoDB迁移到AWS S3时遇到问题。我的Mongo集合中有66k对象,我想将它们迁移到S3,因为S3更便宜。
我正在从Mongo流出文件,获取ObjectID并将其设置为S3中对象的键。
这是代码。
FileController.scala
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table id="saptable">
<thead>
<tr>
<th>Item Name</th>
<th>Item Code</th>
<th>SAP Quantity</th>
</tr>
</thead>
<tbody>
<tr>
<td>
121
</td>
<td>
register121
</td>
<td>
34344
</td>
</tr>
<tr>
<td>
121
</td>
<td>
register121
</td>
<td>
34344
</td>
</tr>
</tbody>
</table>
DocumentRepository.scala
def streamFiles = {
val enumerator = collection.find(BSONDocument()).cursor[BSONDocument].enumerate()
val processDocuments: Iteratee[BSONDocument, Unit] =
Iteratee.foreach { document =>
val documentJs = Json.toJson(document)
val expiration = (documentJs \ "expiresOn").asOpt[DateTime]
documentRepository.save(documentJs, expiration)
}
enumerator.apply(processDocuments)
}
CloudRepository.scala
def save(jsValue: JsValue, expiration: Option[DateTime]): Future[Try[String]] = {
val key = (jsValue \ "_id").as[BSONObjectID].stringify
cloudStorage.save(jsValue, key, expiration).map {_.map { value => key }}
}
当我在具有16 GB RAM的机器上运行它时,10分钟后它达到了最大内存。它只迁移了7k我的对象......其中100个未能保存从S3中获取此错误:
任何想法发生了什么或做了什么?
编辑:库和版本