Create a new BlockInfo object using the specified information. The peers list is empty.
165592
def createBlockinfoByBlockIndex(blockIndex)
      pieceIndex = blockIndex / @blockSize
      offset = (blockIndex % @blocksPerPiece)*@blockSize
      length = @blockSize
      raise "offset in piece is not divisible by block size" if offset % @blockSize != 0
      BlockInfo.new(pieceIndex, offset, length, [], blockIndex)
    end
568862
function createEmptyContent(opts: Options): Block {
    return Block.create({
        type: opts.typeContent,
        nodes: [Text.create()]
    });
}
1172984
function createPeerInstance(id)
    {
        var peer              = new ConnectaPeer(id,stunUrls);
        peer.onIceCandidate   = gotIceCandidate;
        peer.onDescription    = createdDescription;
        peer.onRemoteStream   = gotRemoteStream;
        peer.onConnected      = onPeerConnected;
        peer.onMessage        = onPeerMessage;
        peer.onBytesMessage   = onBytesMessage;
        peer.onConnectionFail = onPeerFailed;
        peer.onClosed         = onPeerClose;
        peer.onError          = onPeerError;
        peer.onChannelState   = onPeerState;
        scope.peers[id]       = peer;
        
        peer.init();

        return peer;
    }
1210304
public static void create( String baseName ,
                               File dataFolder ,
                               int blockCount ,
                               int blockSize ,
                               boolean forceSync ) throws DataStoreException
    {
        if (blockCount <= 0)
            throw new DataStoreException("Block count should be > 0");
        if (blockSize <= 0)
            throw new DataStoreException("Block size should be > 0");
        
        File atFile = new File(dataFolder,baseName+AbstractBlockBasedDataStore.ALLOCATION_TABLE_SUFFIX);
        File dataFile = new File(dataFolder,baseName+AbstractBlockBasedDataStore.DATA_FILE_SUFFIX);
        if (atFile.exists())
            throw new DataStoreException("Cannot create store filesystem : "+atFile.getAbsolutePath()+" already exists");
        if (dataFile.exists())
            throw new DataStoreException("Cannot create store filesystem : "+dataFile.getAbsolutePath()+" already exists");
        
        initAllocationTable(atFile,
                            blockCount,
                            blockSize,
                            forceSync);
        initDataFile(dataFile,
                     blockCount,
                     blockSize,
                     forceSync);
    }
311579
BlockInfo[] setReplication(String src,
                         short replication,
                         int[] oldReplication
                         ) throws IOException {
    waitForReady();
    BlockInfo[] fileBlocks = unprotectedSetReplication(src, replication, oldReplication);
    if (fileBlocks != null)  // log replication change
      fsImage.getEditLog().logSetReplication(src, replication);
    return fileBlocks;
  }
426796
public static SyncPointInfo fromProto(alluxio.grpc.SyncPointInfo syncPointInfo) {
    SyncStatus syncStatus;
    switch (syncPointInfo.getSyncStatus()) {
      case Not_Initially_Synced:
        syncStatus = SyncStatus.NOT_INITIALLY_SYNCED;
        break;
      case Syncing:
        syncStatus = SyncStatus.SYNCING;
        break;
      case Initially_Synced:
        syncStatus = SyncStatus.INITIALLY_SYNCED;
        break;
      default:
        syncStatus = SyncStatus.NOT_INITIALLY_SYNCED;
    }
    return new SyncPointInfo(new AlluxioURI(syncPointInfo.getSyncPointUri()), syncStatus);
  }
227529
def atlas_init_peer_info( peer_table, peer_hostport, blacklisted=False, whitelisted=False ):
    
    peer_table[peer_hostport] = {
        "time": [],
        "zonefile_inv": "",
        "blacklisted": blacklisted,
        "whitelisted": whitelisted
    }
1130318
def initpeer(self, sock):
        '''
        
        '''
        location_json = requests.request("GET", "http://freegeoip.net/json/"
                                         + sock.getpeername()[0]).content
        location = json.loads(location_json)
        tpeer = peer.Peer(sock, self.reactor, self, location)
        self.peer_dict[sock] = tpeer
        self.reactor.select_list.append(tpeer)
232122
DatanodeBlockInfo addBlockInfo(Block block,
      DatanodeBlockInfo replicaInfo) {
    return getBlockBucket(block).addBlockInfo(block, replicaInfo);
  }
156660
def notify_block_new(self, block):
        """"""
        payload = block.SerializeToString()
        self._notify(
            "consensus_notifier_notify_block_new", payload, len(payload))
563226
private void add_new_block_to_freelist(long addr, int size, int ql_index)
    {
        Block block = new Block();

        block.address = addr;
        block.size = size;
        add_block_to_freelist(block, ql_index);
        free_blocks++;
        free_words += size;
    }
429365
public BlockInfo getBlockInfo(final long blockId) throws IOException {
    return retryRPC(() -> {
      return GrpcUtils.fromProto(
          mClient.getBlockInfo(GetBlockInfoPRequest.newBuilder().setBlockId(blockId).build())
              .getBlockInfo());
    });
  }
1016525
def _make_info(self, piece_size, progress, walker, piece_callback=None):
        
        # These collect the file descriptions and piece hashes
        file_list = []
        pieces = []

        # Initialize progress state
        hashing_secs = time.time()
        totalsize = -1 if self._fifo else self._calc_size()
        totalhashed = 0

        # Start a new piece
        sha1sum = hashlib.sha1()
        done = 0
        filename = None

        # Hash all files
        for filename in walker:
            # Assemble file info
            filesize = os.path.getsize(filename)
            filepath = filename[len(os.path.dirname(self.datapath) if self._fifo else self.datapath):].lstrip(os.sep)
            file_list.append({
                "length": filesize,
                "path": [fmt.to_utf8(x) for x in fmt.to_unicode(filepath).replace(os.sep, '/').split('/')],
            })
            self.LOG.debug("Hashing %r, size %d..." % (filename, filesize))

            # Open file and hash it
            fileoffset = 0
            handle = open(filename, "rb")
            try:
                while fileoffset < filesize:
                    # Read rest of piece or file, whatever is smaller
                    chunk = handle.read(min(filesize - fileoffset, piece_size - done))
                    sha1sum.update(chunk) # bogus pylint: disable=E1101
                    done += len(chunk)
                    fileoffset += len(chunk)
                    totalhashed += len(chunk)

                    # Piece is done
                    if done == piece_size:
                        pieces.append(sha1sum.digest()) # bogus pylint: disable=E1101
                        if piece_callback:
                            piece_callback(filename, pieces[-1])

                        # Start a new piece
                        sha1sum = hashlib.sha1()
                        done = 0

                    # Report progress
                    if progress:
                        progress(totalhashed, totalsize)
            finally:
                handle.close()

        # Add hash of partial last piece
        if done > 0:
            pieces.append(sha1sum.digest()) # bogus pylint: disable=E1103
            if piece_callback:
                piece_callback(filename, pieces[-1])

        # Build the meta dict
        metainfo = {
            "pieces": b"".join(pieces),
            "piece length": piece_size,
            "name": os.path.basename(self.datapath),
        }

        # Handle directory/FIFO vs. single file
        if self._fifo or os.path.isdir(self.datapath):
            metainfo["files"] = file_list
        else:
            metainfo["length"] = totalhashed

        hashing_secs = time.time() - hashing_secs
        self.LOG.info("Hashing of %s took %.1f secs (%s/s)" % (
            fmt.human_size(totalhashed).strip(), hashing_secs, fmt.human_size(totalhashed / hashing_secs).strip(),
        ))

        # Return validated info dict
        return check_info(metainfo), totalhashed
70570
void insertIntoList(BlockInfo head, int headIndex, BlockInfo tail, int tailIndex, int count) {
    if (head == null)
      return;
    
    // connect tail to now-head
    tail.setNext(tailIndex, blockList);
    if (blockList != null)
      blockList.setPrevious(blockList.findDatanode(this), tail);
    
    // create new head
    blockList = head;
    blockList.setPrevious(headIndex, null);
    
    // add new blocks to the count
    numOfBlocks += count;
  }
984455
def make_blocks(ec_infos, codewords):
    
    data_blocks, error_blocks = [], []
    offset = 0
    for ec_info in ec_infos:
        for i in range(ec_info.num_blocks):
            block = codewords[offset:offset + ec_info.num_data]
            data_blocks.append(block)
            error_blocks.append(make_error_block(ec_info, block))
            offset += ec_info.num_data
    return data_blocks, error_blocks
341596
public void updateInfo(Info info) {
        BoxAPIConnection api = this.getAPI();
        URL url = COLLABORATION_URL_TEMPLATE.build(api.getBaseURL(), this.getID());

        BoxJSONRequest request = new BoxJSONRequest(api, url, "PUT");
        request.setBody(info.getPendingChanges());
        BoxAPIResponse boxAPIResponse = request.send();

        if (boxAPIResponse instanceof BoxJSONResponse) {
            BoxJSONResponse response = (BoxJSONResponse) boxAPIResponse;
            JsonObject jsonObject = JsonObject.readFrom(response.getJSON());
            info.update(jsonObject);
        }
    }
846130
def create_info(name, info_type, url=None, parent=None, id=None,
                context=ctx_default, store=False):
    """"""
    id = str(uuid4()) if id is None else id
    pubsub = _pubsub_key(id)

    info = {'id': id,
            'type': info_type,
            'pubsub': pubsub,
            'url': url,
            'parent': parent,
            'context': context,
            'name': name,
            'status': 'Queued' if info_type == 'job' else None,
            'date_start': None,
            'date_end': None,
            'date_created': str(datetime.now()),
            'result': None}

    if store:
        r_client.set(id, json_encode(info))

        if parent is not None:
            r_client.sadd(_children_key(parent), id)

    return info