Exemple #1
0
            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());
            }
Exemple #2
0
        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());
        }