Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
// This file is part of OpenTSDB.
// Copyright (C) 2018 The OpenTSDB Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package net.opentsdb.data;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.hbase.async.CallQueueTooBigException;
import org.hbase.async.HBaseException;
import org.hbase.async.PleaseThrottleException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.stumbleupon.async.Callback;
import net.opentsdb.core.IncomingDataPoint;
import net.opentsdb.core.Tags;
import net.opentsdb.tsd.KafkaRpcPluginThread;
import net.opentsdb.tsd.KafkaRpcPluginThread.CounterType;
import net.opentsdb.uid.FailedToAssignUniqueIdException;
public class Metric extends IncomingDataPoint implements TypedIncomingData {
private static final Logger LOG = LoggerFactory.getLogger(Metric.class);
/** The time, in ms, when this data point was sent to Kafka for requeueing */
private long requeue_ts;
public Metric() {
}
public Metric(final String metric,
final long timestamp,
final String value,
final Map tags) {
try {
// Because 2.3 still has the fields private we can't set them directly
// thus we do the happy fun disgustingly ugly and slow reflection dance.
Field temp = IncomingDataPoint.class.getDeclaredField("metric");
temp.setAccessible(true);
temp.set(this, metric);
temp.setAccessible(false);
temp = IncomingDataPoint.class.getDeclaredField("timestamp");
temp.setAccessible(true);
temp.set(this, timestamp);
temp.setAccessible(false);
temp = IncomingDataPoint.class.getDeclaredField("value");
temp.setAccessible(true);
temp.set(this, value);
temp.setAccessible(false);
temp = IncomingDataPoint.class.getDeclaredField("tags");
temp.setAccessible(true);
temp.set(this, tags);
temp.setAccessible(false);
} catch (NoSuchFieldException e) {
throw new IllegalStateException("WTF? The IncomingDataPoints class was "
+ "missing a field.", e);
} catch (SecurityException e) {
throw new IllegalStateException("WTF? Security issue with the "
+ "IncomingDataPoints class.", e);
} catch (IllegalArgumentException e) {
throw new IllegalStateException("WTF? Failed to set a value on the "
+ "IncomingDataPoints class.", e);
} catch (IllegalAccessException e) {
throw new IllegalStateException("WTF? Security issue with the "
+ "IncomingDataPoints class.", e);
}
}
/** @return The requeue timestamp in milliseconds */
public long getRequeueTS() {
return requeue_ts;
}
/** @param requeue_ts The timestamp to set */
public void setRequeueTS(final long requeue_ts) {
this.requeue_ts = requeue_ts;
}
@Override
public void processData(final KafkaRpcPluginThread consumer,
final long receive_time) {
if (requeue_ts > 0) {
consumer.incrementNamespaceCounter(CounterType.ReadRequeuedRaw, getMetric());
} else {
consumer.incrementNamespaceCounter(CounterType.ReadRaw, getMetric());
}
class SuccessCB implements Callback