Exemplo n.º 1
0
        /// <exception cref="System.IO.IOException"/>
        public KeyManager(string blockpoolID, NamenodeProtocol namenode, bool encryptDataTransfer
                          , Configuration conf)
        {
            this.namenode            = namenode;
            this.encryptDataTransfer = encryptDataTransfer;
            ExportedBlockKeys keys = namenode.GetBlockKeys();

            this.isBlockTokenEnabled = keys.IsBlockTokenEnabled();
            if (isBlockTokenEnabled)
            {
                long updateInterval = keys.GetKeyUpdateInterval();
                long tokenLifetime  = keys.GetTokenLifetime();
                Log.Info("Block token params received from NN: update interval=" + StringUtils.FormatTime
                             (updateInterval) + ", token lifetime=" + StringUtils.FormatTime(tokenLifetime));
                string encryptionAlgorithm = conf.Get(DFSConfigKeys.DfsDataEncryptionAlgorithmKey
                                                      );
                this.blockTokenSecretManager = new BlockTokenSecretManager(updateInterval, tokenLifetime
                                                                           , blockpoolID, encryptionAlgorithm);
                this.blockTokenSecretManager.AddKeys(keys);
                // sync block keys with NN more frequently than NN updates its block keys
                this.blockKeyUpdater = new KeyManager.BlockKeyUpdater(this, updateInterval / 4);
                this.shouldRun       = true;
            }
            else
            {
                this.blockTokenSecretManager = null;
                this.blockKeyUpdater         = null;
            }
        }
Exemplo n.º 2
0
 public DatanodeRegistration(DatanodeID dn, StorageInfo info, ExportedBlockKeys keys
                             , string softwareVersion)
     : base(dn)
 {
     this.storageInfo     = info;
     this.exportedKeys    = keys;
     this.softwareVersion = softwareVersion;
 }
Exemplo n.º 3
0
        public virtual void TestConvertExportedBlockKeys()
        {
            BlockKey[]        keys    = new BlockKey[] { GetBlockKey(2), GetBlockKey(3) };
            ExportedBlockKeys expKeys = new ExportedBlockKeys(true, 9, 10, GetBlockKey(1), keys
                                                              );

            HdfsProtos.ExportedBlockKeysProto expKeysProto = PBHelper.Convert(expKeys);
            ExportedBlockKeys expKeys1 = PBHelper.Convert(expKeysProto);

            Compare(expKeys, expKeys1);
        }
Exemplo n.º 4
0
 internal virtual void Compare(ExportedBlockKeys expKeys, ExportedBlockKeys expKeys1
                               )
 {
     BlockKey[] allKeys  = expKeys.GetAllKeys();
     BlockKey[] allKeys1 = expKeys1.GetAllKeys();
     NUnit.Framework.Assert.AreEqual(allKeys.Length, allKeys1.Length);
     for (int i = 0; i < allKeys.Length; i++)
     {
         Compare(allKeys[i], allKeys1[i]);
     }
     Compare(expKeys.GetCurrentKey(), expKeys1.GetCurrentKey());
     NUnit.Framework.Assert.AreEqual(expKeys.GetKeyUpdateInterval(), expKeys1.GetKeyUpdateInterval
                                         ());
     NUnit.Framework.Assert.AreEqual(expKeys.GetTokenLifetime(), expKeys1.GetTokenLifetime
                                         ());
 }
Exemplo n.º 5
0
        public virtual void TestConvertDatanodeRegistration()
        {
            DatanodeID dnId = DFSTestUtil.GetLocalDatanodeID();

            BlockKey[]        keys    = new BlockKey[] { GetBlockKey(2), GetBlockKey(3) };
            ExportedBlockKeys expKeys = new ExportedBlockKeys(true, 9, 10, GetBlockKey(1), keys
                                                              );
            DatanodeRegistration reg = new DatanodeRegistration(dnId, new StorageInfo(HdfsServerConstants.NodeType
                                                                                      .DataNode), expKeys, "3.0.0");

            DatanodeProtocolProtos.DatanodeRegistrationProto proto = PBHelper.Convert(reg);
            DatanodeRegistration reg2 = PBHelper.Convert(proto);

            Compare(reg.GetStorageInfo(), reg2.GetStorageInfo());
            Compare(reg.GetExportedKeys(), reg2.GetExportedKeys());
            Compare(reg, reg2);
            NUnit.Framework.Assert.AreEqual(reg.GetSoftwareVersion(), reg2.GetSoftwareVersion
                                                ());
        }
Exemplo n.º 6
0
 public KeyUpdateCommand(ExportedBlockKeys keys)
     : base(DatanodeProtocol.DnaAccesskeyupdate)
 {
     this.keys = keys;
 }
Exemplo n.º 7
0
 public virtual void SetExportedKeys(ExportedBlockKeys keys)
 {
     this.exportedKeys = keys;
 }