/** * Create a mutable long integer gauge * @param info metadata of the metric * @param iVal initial value * @return a new gauge object */ public MutableGaugeLong newGauge(MetricsInfo info, long iVal) { MutableGaugeLong ret = new MutableGaugeLong(info, iVal); return addNewMetricIfAbsent(info.name(), ret, MutableGaugeLong.class); }
/** * Create a mutable long integer gauge * @param info metadata of the metric * @param iVal initial value * @return a new gauge object */ public synchronized MutableGaugeLong newGauge(MetricsInfo info, long iVal) { checkMetricName(info.name()); MutableGaugeLong ret = new MutableGaugeLong(info, iVal); metricsMap.put(info.name(), ret); return ret; }
/** * Get a MetricMutableGaugeLong from the storage. If it is not there atomically put it. * * @param gaugeName name of the gauge to create or get. * @param potentialStartingValue value of the new gauge if we have to create it. */ public MutableGaugeLong getGauge(String gaugeName, long potentialStartingValue) { //Try and get the guage. MutableMetric metric = metricsMap.get(gaugeName); //If it's not there then try and put a new one in the storage. if (metric == null) { //Create the potential new gauge. MutableGaugeLong newGauge = new MutableGaugeLong(new MetricsInfoImpl(gaugeName, ""), potentialStartingValue); // Try and put the gauge in. This is atomic. metric = metricsMap.putIfAbsent(gaugeName, newGauge); //If the value we get back is null then the put was successful and we will return that. //otherwise gaugeLong should contain the thing that was in before the put could be completed. if (metric == null) { return newGauge; } } if (!(metric instanceof MutableGaugeLong)) { throw new MetricsException("Metric already exists in registry for metric name: " + gaugeName + " and not of type MetricMutableGaugeLong"); } return (MutableGaugeLong) metric; }
/** * Create a mutable long integer gauge * @param info metadata of the metric * @param iVal initial value * @return a new gauge object */ public MutableGaugeLong newGauge(MetricsInfo info, long iVal) { MutableGaugeLong ret = new MutableGaugeLong(info, iVal); return addNewMetricIfAbsent(info.name(), ret, MutableGaugeLong.class); }
/** * Create a mutable long integer gauge * @param info metadata of the metric * @param iVal initial value * @return a new gauge object */ public MutableGaugeLong newGauge(MetricsInfo info, long iVal) { MutableGaugeLong ret = new MutableGaugeLong(info, iVal); return addNewMetricIfAbsent(info.name(), ret, MutableGaugeLong.class); }
/** * Create a mutable long integer gauge * @param info metadata of the metric * @param iVal initial value * @return a new gauge object */ public MutableGaugeLong newGauge(MetricsInfo info, long iVal) { MutableGaugeLong ret = new MutableGaugeLong(info, iVal); return addNewMetricIfAbsent(info.name(), ret, MutableGaugeLong.class); }
/** * Create a mutable long integer gauge * @param info metadata of the metric * @param iVal initial value * @return a new gauge object */ public synchronized MutableGaugeLong newGauge(MetricsInfo info, long iVal) { checkMetricName(info.name()); MutableGaugeLong ret = new MutableGaugeLong(info, iVal); metricsMap.put(info.name(), ret); return ret; }
/** * Create a mutable long integer gauge * @param info metadata of the metric * @param iVal initial value * @return a new gauge object */ public synchronized MutableGaugeLong newGauge(MetricsInfo info, long iVal) { checkMetricName(info.name()); MutableGaugeLong ret = new MutableGaugeLong(info, iVal); metricsMap.put(info.name(), ret); return ret; }
/** * Create a mutable long integer gauge * @param info metadata of the metric * @param iVal initial value * @return a new gauge object */ public synchronized MutableGaugeLong newGauge(MetricsInfo info, long iVal) { checkMetricName(info.name()); MutableGaugeLong ret = new MutableGaugeLong(info, iVal); metricsMap.put(info.name(), ret); return ret; }
/** * Create a mutable long integer gauge * @param info metadata of the metric * @param iVal initial value * @return a new gauge object */ public synchronized MutableGaugeLong newGauge(MetricsInfo info, long iVal) { checkMetricName(info.name()); MutableGaugeLong ret = new MutableGaugeLong(info, iVal); metricsMap.put(info.name(), ret); return ret; }
/** * Get a MetricMutableGaugeLong from the storage. If it is not there atomically put it. * * @param gaugeName name of the gauge to create or get. * @param potentialStartingValue value of the new gauge if we have to create it. */ public MutableGaugeLong getGauge(String gaugeName, long potentialStartingValue) { //Try and get the guage. MutableMetric metric = metricsMap.get(gaugeName); //If it's not there then try and put a new one in the storage. if (metric == null) { //Create the potential new gauge. MutableGaugeLong newGauge = new MutableGaugeLong(new MetricsInfoImpl(gaugeName, ""), potentialStartingValue); // Try and put the gauge in. This is atomic. metric = metricsMap.putIfAbsent(gaugeName, newGauge); //If the value we get back is null then the put was successful and we will return that. //otherwise gaugeLong should contain the thing that was in before the put could be completed. if (metric == null) { return newGauge; } } if (!(metric instanceof MutableGaugeLong)) { throw new MetricsException("Metric already exists in registry for metric name: " + gaugeName + " and not of type MetricMutableGaugeLong"); } return (MutableGaugeLong) metric; }
/** * Get a MetricMutableGaugeLong from the storage. If it is not there atomically put it. * * @param gaugeName name of the gauge to create or get. * @param potentialStartingValue value of the new gauge if we have to create it. */ public MutableGaugeLong getLongGauge(String gaugeName, long potentialStartingValue) { //Try and get the guage. MutableMetric metric = metricsMap.get(gaugeName); //If it's not there then try and put a new one in the storage. if (metric == null) { //Create the potential new gauge. MutableGaugeLong newGauge = new MutableGaugeLong(new MetricsInfoImpl(gaugeName, ""), potentialStartingValue); // Try and put the gauge in. This is atomic. metric = metricsMap.putIfAbsent(gaugeName, newGauge); //If the value we get back is null then the put was successful and we will return that. //otherwise gaugeLong should contain the thing that was in before the put could be completed. if (metric == null) { return newGauge; } } if (!(metric instanceof MutableGaugeLong)) { throw new MetricsException("Metric already exists in registry for metric name: " + gaugeName + " and not of type MetricMutableGaugeLong"); } return (MutableGaugeLong) metric; }
/** * Get a MetricMutableGaugeLong from the storage. If it is not there atomically put it. * * @param gaugeName name of the gauge to create or get. * @param potentialStartingValue value of the new gauge if we have to create it. */ public MutableGaugeLong getGauge(String gaugeName, long potentialStartingValue) { //Try and get the guage. MutableMetric metric = metricsMap.get(gaugeName); //If it's not there then try and put a new one in the storage. if (metric == null) { //Create the potential new gauge. MutableGaugeLong newGauge = new MutableGaugeLong(new MetricsInfoImpl(gaugeName, ""), potentialStartingValue); // Try and put the gauge in. This is atomic. metric = metricsMap.putIfAbsent(gaugeName, newGauge); //If the value we get back is null then the put was successful and we will return that. //otherwise gaugeLong should contain the thing that was in before the put could be completed. if (metric == null) { return newGauge; } } if (!(metric instanceof MutableGaugeLong)) { throw new MetricsException("Metric already exists in registry for metric name: " + gaugeName + " and not of type MetricMutableGaugeLong"); } return (MutableGaugeLong) metric; }