Esempio n. 1
0
        public static Counters NewCounters()
        {
            Counters hc = new Counters();

            foreach (JobCounter c in JobCounter.Values())
            {
                hc.FindCounter(c).SetValue((long)(Math.Random() * 1000));
            }
            foreach (TaskCounter c_1 in TaskCounter.Values())
            {
                hc.FindCounter(c_1).SetValue((long)(Math.Random() * 1000));
            }
            int nc = FileSystemCounter.Values().Length * 4;

            for (int i = 0; i < nc; ++i)
            {
                foreach (FileSystemCounter c_2 in FileSystemCounter.Values())
                {
                    hc.FindCounter(FsSchemes.Next(), c_2).SetValue((long)(Math.Random() * Dt));
                }
            }
            for (int i_1 = 0; i_1 < 2 * 3; ++i_1)
            {
                hc.FindCounter(UserCounterGroups.Next(), UserCounters.Next()).SetValue((long)(Math
                                                                                              .Random() * 100000));
            }
            return(hc);
        }
Esempio n. 2
0
 public virtual C FindCounter(string scheme, FileSystemCounter key)
 {
     lock (this)
     {
         return(((FileSystemCounterGroup <C>)GetGroup(typeof(FileSystemCounter).FullName).GetUnderlyingGroup
                     ()).FindCounter(scheme, key));
     }
 }
 public FSCounter(string scheme, FileSystemCounter @ref)
 {
     // intern/sanity check
     // C[] would need Array.newInstance which requires a Class<C> reference.
     // Just a few local casts probably worth not having to carry it around.
     this.scheme = scheme;
     key         = @ref;
 }
 public virtual C FindCounter(string counterName, bool create)
 {
     try
     {
         string[] pair = ParseCounterName(counterName);
         return(FindCounter(pair[0], FileSystemCounter.ValueOf(pair[1])));
     }
     catch (Exception e)
     {
         if (create)
         {
             throw new ArgumentException(e);
         }
         Log.Warn(counterName + " is not a recognized counter.");
         return(null);
     }
 }
        /// <exception cref="System.IO.IOException"/>
        public virtual void ReadFields(DataInput @in)
        {
            int numSchemes = WritableUtils.ReadVInt(@in);

            // #scheme
            FileSystemCounter[] enums = FileSystemCounter.Values();
            for (int i = 0; i < numSchemes; ++i)
            {
                string scheme = WritableUtils.ReadString(@in);
                // scheme
                int numCounters = WritableUtils.ReadVInt(@in);
                // #counter
                for (int j = 0; j < numCounters; ++j)
                {
                    FindCounter(scheme, enums[WritableUtils.ReadVInt(@in)]).SetValue(WritableUtils.ReadVLong
                                                                                         (@in));
                }
            }
        }
 public virtual C FindCounter(string scheme, FileSystemCounter key)
 {
     lock (this)
     {
         string   canonicalScheme = CheckScheme(scheme);
         object[] counters        = map[canonicalScheme];
         int      ord             = (int)(key);
         if (counters == null)
         {
             counters             = new object[FileSystemCounter.Values().Length];
             map[canonicalScheme] = counters;
             counters[ord]        = NewCounter(canonicalScheme, key);
         }
         else
         {
             if (counters[ord] == null)
             {
                 counters[ord] = NewCounter(canonicalScheme, key);
             }
         }
         return((C)counters[ord]);
     }
 }
Esempio n. 7
0
 // Mix file system group implementation into the CounterGroup interface
 protected internal override Counter NewCounter(string scheme, FileSystemCounter key
                                                )
 {
     return(new FileSystemCounterGroup.FSCounter(scheme, key));
 }
 /// <summary>Abstract factory method to create a file system counter</summary>
 /// <param name="scheme">of the file system</param>
 /// <param name="key">the enum of the file system counter</param>
 /// <returns>a new file system counter</returns>
 protected internal abstract C NewCounter(string scheme, FileSystemCounter key);