DataNodeBlocks getDataNode(DataNodeInfo dataNode) { return membership.get(dataNode.key()); }
public StorageEndpoint getDataEndpoint(DataNodeInfo dataNodeInfo) throws IOException, InterruptedException { StorageEndpoint endpoint = cache.get(dataNodeInfo.key()); if (endpoint == null) { Object lock = getLock(dataNodeInfo.key()); synchronized (lock) { endpoint = cache.get(dataNodeInfo.key()); if (endpoint == null){ endpoint = storageClient.createEndpoint(dataNodeInfo); cache.put(dataNodeInfo.key(), endpoint); if (CrailConstants.DEBUG) { LOG.info("EndpointCache miss " + CrailUtils.datanodeInfo2SocketAddr(dataNodeInfo) + ", fsId " + fsId + ", cache size " + cache.size()); } } } } else { if (CrailConstants.DEBUG) { LOG.info("EndpointCache hit " + CrailUtils.datanodeInfo2SocketAddr(dataNodeInfo) + ", fsId " + fsId); } } return endpoint; }
public boolean regionExists(BlockInfo region) { long dnAddress = region.getDnInfo().key(); DataNodeBlocks current = membership.get(dnAddress); if (current == null) { return false; } else { return current.regionExists(region); } }
public short updateRegion(BlockInfo region) { long dnAddress = region.getDnInfo().key(); DataNodeBlocks current = membership.get(dnAddress); if (current == null) { return RpcErrors.ERR_ADD_BLOCK_FAILED; } else { return current.updateRegion(region); } }
short addBlock(NameNodeBlockInfo block) throws UnknownHostException { long dnAddress = block.getDnInfo().key(); DataNodeBlocks current = membership.get(dnAddress); if (current == null) { current = DataNodeBlocks.fromDataNodeInfo(block.getDnInfo()); addDataNode(current); } current.touch(); current.addFreeBlock(block); return RpcErrors.ERR_OK; }
dataNodeSet.put(dataNodeInfo.key(), dataNodeInfo); CoreBlockLocation location = new CoreBlockLocation(); location.setOffset(current); DataNodeInfo mainDataNode = dataNodeSet.get(dnInfo.key()); InetSocketAddress address = CrailUtils.datanodeInfo2SocketAddr(mainDataNode); names[0] = getMappedLocation(address.getAddress().getCanonicalHostName()) + ":" + address.getPort();