Answer(InvocationOnMock invocation) { object[] args = invocation.GetArguments(); NUnit.Framework.Assert.AreEqual(2, args.Length); ClientDatanodeProtocolProtos.GetReplicaVisibleLengthRequestProto req = (ClientDatanodeProtocolProtos.GetReplicaVisibleLengthRequestProto )args[1]; ICollection <TokenIdentifier> tokenIds = UserGroupInformation.GetCurrentUser().GetTokenIdentifiers (); NUnit.Framework.Assert.AreEqual("Only one BlockTokenIdentifier expected", 1, tokenIds .Count); long result = 0; foreach (TokenIdentifier tokenId in tokenIds) { BlockTokenIdentifier id = (BlockTokenIdentifier)tokenId; Log.Info("Got: " + id.ToString()); NUnit.Framework.Assert.IsTrue("Received BlockTokenIdentifier is wrong", ident.Equals (id)); sm.CheckAccess(id, null, PBHelper.Convert(req.GetBlock()), BlockTokenSecretManager.AccessMode .Write); result = id.GetBlockId(); } return((ClientDatanodeProtocolProtos.GetReplicaVisibleLengthResponseProto)ClientDatanodeProtocolProtos.GetReplicaVisibleLengthResponseProto .NewBuilder().SetLength(result).Build()); }
/// <exception cref="System.IO.IOException"/> public virtual long GetReplicaVisibleLength(ExtendedBlock b) { ClientDatanodeProtocolProtos.GetReplicaVisibleLengthRequestProto req = ((ClientDatanodeProtocolProtos.GetReplicaVisibleLengthRequestProto )ClientDatanodeProtocolProtos.GetReplicaVisibleLengthRequestProto.NewBuilder().SetBlock (PBHelper.Convert(b)).Build()); try { return(rpcProxy.GetReplicaVisibleLength(NullController, req).GetLength()); } catch (ServiceException e) { throw ProtobufHelper.GetRemoteException(e); } }
GetReplicaVisibleLength(RpcController unused, ClientDatanodeProtocolProtos.GetReplicaVisibleLengthRequestProto request) { long len; try { len = impl.GetReplicaVisibleLength(PBHelper.Convert(request.GetBlock())); } catch (IOException e) { throw new ServiceException(e); } return((ClientDatanodeProtocolProtos.GetReplicaVisibleLengthResponseProto)ClientDatanodeProtocolProtos.GetReplicaVisibleLengthResponseProto .NewBuilder().SetLength(len).Build()); }