Ejemplo n.º 1
0
    def importData(self, assetstore, params):
        self.requireParams(('parentId', 'path'), params)

        user = self.getCurrentUser()
        parentType = params.get('parentType', 'folder')
        if parentType not in ('user', 'collection', 'folder'):
            raise RestException('Invalid parentType.')

        parent = self.model(parentType).load(params['parentId'],
                                             force=True,
                                             exc=True)

        progress = self.boolParam('progress', params, default=False)
        client = HdfsClient(host=assetstore['hdfs']['host'],
                            port=assetstore['hdfs']['port'],
                            use_trash=False)
        path = params['path']

        with ProgressContext(progress,
                             user=user,
                             title='Importing data from HDFS') as ctx:
            try:
                self._importData(parentType, parent, assetstore, client, path,
                                 ctx, user)
            except FileNotFoundException:
                raise RestException('File not found: %s.' % path)
Ejemplo n.º 2
0
 def _getClient(assetstore):
     return HdfsClient(
         host=assetstore['hdfs']['host'],
         port=assetstore['hdfs']['port'],
         use_trash=False,
         effective_user=HdfsAssetstoreAdapter._getHdfsUser(assetstore))