/// <summary>Returns a user-friendly description of this directory</summary>
 public override string ToString()
 {
     return($"DirectorySubspace(path={this.Path.ToString()}, prefix={FdbKey.Dump(GetPrefixUnsafe())})");
 }
Пример #2
0
 public override string ToString()
 {
     return("Watch(" + FdbKey.Dump(this.Key) + ")");
 }
Пример #3
0
 /// <summary>Returns a printable version of the range</summary>
 public override string ToString()
 {
     return("{" + FdbKey.PrettyPrint(m_begin, FdbKey.PrettyPrintMode.Begin) + ", " + FdbKey.PrettyPrint(m_end, FdbKey.PrettyPrintMode.End) + "}");
 }
Пример #4
0
            internal static Exception InvalidKeyOutsideDatabaseNamespace(IFdbDatabase db, Slice key)
            {
                Contract.Requires(db != null);
                return(new FdbException(
                           FdbError.KeyOutsideLegalRange,
#if DEBUG
                           String.Format("An attempt was made to use a key '{2}' that is outside of the global namespace {0} of database '{1}'", db.GlobalSpace, db.Name, FdbKey.Dump(key))
#else
                           String.Format("An attempt was made to use a key that is outside of the global namespace {0} of database '{1}'", db.GlobalSpace, db.Name)
#endif
                           ));
            }
 public override string ToString()
 {
     return($"DirectoryPartition(path={this.Descriptor.Path.ToString()}, prefix={FdbKey.Dump(GetPrefixUnsafe())})");
 }
        /// <summary>
        /// Returns a list of public network addresses as strings, one for each of the storage servers responsible for storing <paramref name="key"/> and its associated value
        /// </summary>
        /// <param name="key">Name of the key whose location is to be queried.</param>
        /// <returns>Task that will return an array of strings, or an exception</returns>
        public Task <string[]> GetAddressesForKeyAsync(Slice key)
        {
            EnsureCanRead();

            m_database.EnsureKeyIsValid(ref key);

#if DEBUG
            if (Logging.On && Logging.IsVerbose)
            {
                Logging.Verbose(this, "GetAddressesForKeyAsync", String.Format("Getting addresses for key '{0}'", FdbKey.Dump(key)));
            }
#endif

            return(m_handler.GetAddressesForKeyAsync(key, cancellationToken: m_cancellation));
        }
        /// <summary>Modify the database snapshot represented by this transaction to perform the operation indicated by <paramref name="mutation"/> with operand <paramref name="param"/> to the value stored by the given key.</summary>
        /// <param name="key">Name of the key whose value is to be mutated.</param>
        /// <param name="param">Parameter with which the atomic operation will mutate the value associated with key_name.</param>
        /// <param name="mutation">Type of mutation that should be performed on the key</param>
        public void Atomic(Slice key, Slice param, FdbMutationType mutation)
        {
            //note: this method as many names in the various bindings:
            // - C API   : fdb_transaction_atomic_op(...)
            // - Java    : tr.Mutate(..)
            // - Node.js : tr.add(..), tr.max(..), ...

            EnsureCanWrite();

            m_database.EnsureKeyIsValid(ref key);
            m_database.EnsureValueIsValid(ref param);

            //The C API does not fail immediately if the mutation type is not valid, and only fails at commit time.
            EnsureMutationTypeIsSupported(mutation, Fdb.ApiVersion);

#if DEBUG
            if (Logging.On && Logging.IsVerbose)
            {
                Logging.Verbose(this, "AtomicCore", String.Format("Atomic {0} on '{1}' = {2}", mutation.ToString(), FdbKey.Dump(key), Slice.Dump(param)));
            }
#endif

            m_handler.Atomic(key, param, mutation);
        }
        protected void FailKeyOutOfBound(Slice key)
        {
#if DEBUG
            // only in debug mode, because have the key and subspace in the exception message could leak sensitive information
            string msg = String.Format("The key {0} does not belong to subspace {1}", FdbKey.Dump(key), this.ToString());
#else
            string msg = "The specifed key does not belong to this subspace";
#endif
            throw new ArgumentException(msg, "key");
        }