public BlockInfo(){ this.dnInfo = new DataNodeInfo(); this.lba = 0; this.addr = 0; this.length = 0; this.lkey = 0; }
void setDataNodeInfo(DataNodeInfo info) { this.storageType = info.getStorageType(); this.storageClass = info.getStorageClass(); this.locationClass = info.getLocationClass(); for (int i = 0; i < ipAddress.length; i++){ this.ipAddress[i] = info.getIpAddress()[i]; } this.port = info.getPort(); }
DataNodeBlocks getDataNode(DataNodeInfo dataNode) { return membership.get(dataNode.key()); }
public static InetSocketAddress datanodeInfo2SocketAddr(DataNodeInfo dnInfo) throws UnknownHostException{ return new InetSocketAddress(InetAddress.getByAddress(dnInfo.getIpAddress()), dnInfo.getPort()); }
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(); hosts[0] = getMappedLocation(address.getAddress().getCanonicalHostName()); topology[0] = "/default-rack/" + names[0]; storageType[0] = mainDataNode.getStorageType(); storageClass[0] = mainDataNode.getStorageClass(); locationTiers[0] = mainDataNode.getLocationClass(); for (int j = 1; j < locationSize; j++){ DataNodeInfo replicaDataNode = dataNodeArray.get(blockIndex); hosts[j] = getMappedLocation(address.getAddress().getCanonicalHostName()); topology[j] = "/default-rack/" + names[j]; storageType[j] = replicaDataNode.getStorageType(); storageClass[j] = replicaDataNode.getStorageClass(); locationTiers[j] = replicaDataNode.getLocationClass(); blockIndex = (blockIndex + 1) % dataNodeArray.size();
public DataNodeBlocks getDataNode(DataNodeInfo dnInfo) { int storageClass = dnInfo.getStorageClass(); return storageClasses[storageClass].getDataNode(dnInfo); }
public void update(ByteBuffer buffer) { try { dnInfo.update(buffer); } catch (UnknownHostException e) { e.printStackTrace(); } } }
public int write(ByteBuffer buffer) { int written = dnInfo.write(buffer); return written; }
public StorageEndpoint getDataEndpoint(DataNodeInfo dataNodeInfo) throws IOException, InterruptedException { StorageEndpointCache cache = storageCaches.get(dataNodeInfo.getStorageType()); StorageEndpoint endpoint = cache.getDataEndpoint(dataNodeInfo); return endpoint; // return storageCaches.get(dataNodeInfo.getStorageType()).getDataEndpoint(dataNodeInfo); }
public boolean regionExists(BlockInfo region) { int storageClass = region.getDnInfo().getStorageClass(); return storageClasses[storageClass].regionExists(region); }
public void update(ByteBuffer buffer) throws UnknownHostException{ this.dnInfo.update(buffer); this.lba = buffer.getLong(); this.addr = buffer.getLong(); this.length = buffer.getInt(); this.lkey = buffer.getInt(); }
public int write(ByteBuffer buffer){ this.getDnInfo().write(buffer); buffer.putLong(this.getLba()); buffer.putLong(this.getAddr()); buffer.putInt(this.getLength()); buffer.putInt(this.getLkey()); return CSIZE; }
public static DataNodeBlocks fromDataNodeInfo(DataNodeInfo dnInfo) throws UnknownHostException{ DataNodeBlocks dnInfoNn = new DataNodeBlocks(dnInfo.getStorageType(), dnInfo.getStorageClass(), dnInfo.getLocationClass(), dnInfo.getIpAddress(), dnInfo.getPort()); return dnInfoNn; }
public GetDataNodeReq(){ this.dnInfo = new DataNodeInfo(); }
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 short addBlock(NameNodeBlockInfo blockInfo) throws UnknownHostException { int storageClass = blockInfo.getDnInfo().getStorageClass(); return storageClasses[storageClass].addBlock(blockInfo); }
public DataNodeStatistics getDataNode() throws Exception{ InetSocketAddress inetAddress = serverAddress; DataNodeInfo dnInfo = new DataNodeInfo(storageType, storageClass.value(), locationClass.value(), inetAddress.getAddress().getAddress(), inetAddress.getPort()); return this.rpcConnection.getDataNode(dnInfo).get(CrailConstants.RPC_TIMEOUT, TimeUnit.MILLISECONDS).getStatistics(); } }
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) { int storageClass = region.getDnInfo().getStorageClass(); return storageClasses[storageClass].updateRegion(region); }
public void setBlock(long lba, long addr, int length, int key) throws Exception { InetSocketAddress inetAddress = serverAddress; DataNodeInfo dnInfo = new DataNodeInfo(storageType, storageClass.value(), locationClass.value(), inetAddress.getAddress().getAddress(), inetAddress.getPort()); BlockInfo blockInfo = new BlockInfo(dnInfo, lba, addr, length, key); RpcVoid res = rpcConnection.setBlock(blockInfo).get(CrailConstants.RPC_TIMEOUT, TimeUnit.MILLISECONDS); if (res.getError() != RpcErrors.ERR_OK){ LOG.info("setBlock: " + RpcErrors.messages[res.getError()]); throw new IOException("setBlock: " + RpcErrors.messages[res.getError()]); } }