Ejemplo n.º 1
0
    def _cosmos_create(self, file_name):
        # Step 1: interact with the namenode
        url = self.cosmos_url + '/webhdfs/v1' + self.base_dir + '/' + file_name + '?op=create&user.name=' + self.cosmos_user
        r = do_put(self.logger, url)
        if r.status_code != 307:
            raise Exception('expecting 307 but getting ' + str(r.status_code))

        url = self.cosmos_url + '/webhdfs/v1' + self.base_dir + '/' + file_name + '?op=create&user.name=' + self.cosmos_user + '&data=true'
        headers = {'Content-Type': 'application/octet-stream'}
        r = do_put(self.logger, url, headers=headers)
        if r.status_code != 201:
            raise Exception('expecting 201 but getting ' + str(r.status_code))
Ejemplo n.º 2
0
    def _cosmos_create(self, file_name):
        # Step 1: interact with the namenode
        url = self.cosmos_url + '/webhdfs/v1' + self.base_dir + '/' + file_name + '?op=create&user.name=' + self.cosmos_user
        r = do_put(self.logger, url)
        if r.status_code != 307:
            raise Exception('expecting 307 but getting ' + str(r.status_code))

        # Grab datanode from Location header
        actual_datanode = self._resolve_datanode(r.headers['Location'])

        # Step 2: interact with the datanode
        url = 'http://' + actual_datanode + '/webhdfs/v1' + self.base_dir + '/' + file_name + '?op=create&user.name=' + self.cosmos_user
        r = do_put(self.logger, url)
        if r.status_code != 201:
            raise Exception('expecting 201 but getting ' + str(r.status_code))