本文整理汇总了Java中com.thinkaurelius.titan.util.stats.MetricManager类的典型用法代码示例。如果您正苦于以下问题:Java MetricManager类的具体用法?Java MetricManager怎么用?Java MetricManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MetricManager类属于com.thinkaurelius.titan.util.stats包,在下文中一共展示了MetricManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runWithMetrics
import com.thinkaurelius.titan.util.stats.MetricManager; //导入依赖的package包/类
static <T> T runWithMetrics(String prefix, String storeName, String name, IOCallable<T> impl) throws IOException {
if (null == prefix) {
return impl.call();
}
Preconditions.checkNotNull(name);
Preconditions.checkNotNull(impl);
final MetricManager mgr = MetricManager.INSTANCE;
mgr.getCounter(prefix, storeName, name, M_CALLS).inc();
final Timer.Context tc = mgr.getTimer(prefix, storeName, name, M_TIME).time();
try {
return impl.call();
} catch (IOException e) {
mgr.getCounter(prefix, storeName, name, M_EXCEPTIONS).inc();
throw e;
} finally {
tc.stop();
}
}
示例2: getEdges
import com.thinkaurelius.titan.util.stats.MetricManager; //导入依赖的package包/类
@Override
public Iterable<TitanEdge> getEdges(RelationIdentifier... ids) {
verifyOpen();
if (ids==null || ids.length==0) return new VertexCentricEdgeIterable(getInternalVertices(),RelationCategory.EDGE);
if (null != config.getGroupName()) {
MetricManager.INSTANCE.getCounter(config.getGroupName(), "db", "getEdgesByID").inc();
}
List<TitanEdge> result = new ArrayList<>(ids.length);
for (RelationIdentifier id : ids) {
if (id==null) continue;
TitanEdge edge = id.findEdge(this);
if (edge!=null && !edge.isRemoved()) result.add(edge);
}
return result;
}
示例3: rollback
import com.thinkaurelius.titan.util.stats.MetricManager; //导入依赖的package包/类
@Override
public synchronized void rollback() {
Preconditions.checkArgument(isOpen(), "The transaction has already been closed");
boolean success = false;
if (null != config.getGroupName()) {
MetricManager.INSTANCE.getCounter(config.getGroupName(), "tx", "rollback").inc();
}
try {
txHandle.rollback();
success = true;
} catch (Exception e) {
throw new TitanException("Could not rollback transaction due to exception", e);
} finally {
releaseTransaction();
if (null != config.getGroupName() && !success) {
MetricManager.INSTANCE.getCounter(config.getGroupName(), "tx", "rollback.exceptions").inc();
}
}
}
示例4: runWithMetrics
import com.thinkaurelius.titan.util.stats.MetricManager; //导入依赖的package包/类
private <T> T runWithMetrics(String opName, Function<Void,T> impl) {
Preconditions.checkNotNull(opName);
Preconditions.checkNotNull(impl);
final MetricManager mgr = MetricManager.INSTANCE;
mgr.getCounter(metricsPrefix, opName, M_CALLS).inc();
final Timer.Context tc = mgr.getTimer(metricsPrefix, opName, M_TIME).time();
try {
return impl.apply(null);
} catch (RuntimeException e) {
mgr.getCounter(metricsPrefix, opName, M_EXCEPTIONS).inc();
throw e;
} finally {
tc.stop();
}
}
示例5: rollback
import com.thinkaurelius.titan.util.stats.MetricManager; //导入依赖的package包/类
@Override
public synchronized void rollback() {
Preconditions.checkArgument(isOpen(), "The transaction has already been closed");
boolean success = false;
if (null != config.getGroupName()) {
MetricManager.INSTANCE.getCounter(config.getGroupName(), "tx", "rollback").inc();
}
try {
txHandle.rollback();
success = true;
} catch (Exception e) {
throw new TitanException("Could not rollback transaction due to exception", e);
} finally {
close();
if (null != config.getGroupName() && !success) {
MetricManager.INSTANCE.getCounter(config.getGroupName(), "tx", "rollback.exceptions").inc();
}
}
}
示例6: deleteLocks
import com.thinkaurelius.titan.util.stats.MetricManager; //导入依赖的package包/类
@Override
public void deleteLocks(StoreTransaction tx) throws TemporaryLockingException, PermanentLockingException {
if (null != tx.getConfiguration().getGroupName()) {
MetricManager.INSTANCE.getCounter(tx.getConfiguration().getGroupName(), M_LOCKS, M_DELETE, M_CALLS).inc();
}
Map<KeyColumn, S> m = lockState.getLocksForTx(tx);
Iterator<KeyColumn> iter = m.keySet().iterator();
while (iter.hasNext()) {
KeyColumn kc = iter.next();
S ls = m.get(kc);
try {
deleteSingleLock(kc, ls, tx);
} catch (AssertionError ae) {
throw ae; // Concession to ease testing with mocks & behavior verification
} catch (Throwable t) {
log.error("Exception while deleting lock on " + kc, t);
if (null != tx.getConfiguration().getGroupName()) {
MetricManager.INSTANCE.getCounter(tx.getConfiguration().getGroupName(), M_LOCKS, M_DELETE, M_CALLS).inc();
}
}
// Regardless of whether we successfully deleted the lock from storage, take it out of the local mediator
llm.unlock(kc, tx);
iter.remove();
}
}
示例7: recordSliceMetrics
import com.thinkaurelius.titan.util.stats.MetricManager; //导入依赖的package包/类
private void recordSliceMetrics(StoreTransaction txh, List<Entry> row) {
if (!txh.getConfiguration().hasGroupName())
return;
String p = txh.getConfiguration().getGroupName();
final MetricManager mgr = MetricManager.INSTANCE;
mgr.getCounter(p, metricsStoreName, M_GET_SLICE, M_ENTRIES_COUNT).inc(row.size());
mgr.getHistogram(p, metricsStoreName, M_GET_SLICE, M_ENTRIES_HISTO).update(row.size());
}
示例8: getVertex
import com.thinkaurelius.titan.util.stats.MetricManager; //导入依赖的package包/类
@Override
public TitanVertex getVertex(long vertexid) {
verifyOpen();
if (null != config.getGroupName()) {
MetricManager.INSTANCE.getCounter(config.getGroupName(), "db", "getVertexByID").inc();
}
if (!isValidVertexId(vertexid)) return null;
//Make canonical partitioned vertex id
if (idInspector.isPartitionedVertex(vertexid)) vertexid=idManager.getCanonicalVertexId(vertexid);
InternalVertex v = null;
v = vertexCache.get(vertexid, externalVertexRetriever);
return (null == v || v.isRemoved()) ? null : v;
}
示例9: commit
import com.thinkaurelius.titan.util.stats.MetricManager; //导入依赖的package包/类
@Override
public synchronized void commit() {
Preconditions.checkArgument(isOpen(), "The transaction has already been closed");
boolean success = false;
if (null != config.getGroupName()) {
MetricManager.INSTANCE.getCounter(config.getGroupName(), "tx", "commit").inc();
}
try {
if (hasModifications()) {
graph.commit(addedRelations.getAll(), deletedRelations.values(), this);
} else {
txHandle.commit();
}
success = true;
} catch (Exception e) {
try {
txHandle.rollback();
} catch (BackendException e1) {
throw new TitanException("Could not rollback after a failed commit", e);
}
throw new TitanException("Could not commit transaction due to exception during persistence", e);
} finally {
releaseTransaction();
if (null != config.getGroupName() && !success) {
MetricManager.INSTANCE.getCounter(config.getGroupName(), "tx", "commit.exceptions").inc();
}
}
}
示例10: configureMetricsSlf4jReporter
import com.thinkaurelius.titan.util.stats.MetricManager; //导入依赖的package包/类
private void configureMetricsSlf4jReporter() {
if (configuration.has(METRICS_SLF4J_INTERVAL)) {
// null loggerName is allowed -- that means Metrics will use its internal default
MetricManager.INSTANCE.addSlf4jReporter(configuration.get(METRICS_SLF4J_INTERVAL),
configuration.has(METRICS_SLF4J_LOGGER) ? configuration.get(METRICS_SLF4J_LOGGER) : null);
}
}
示例11: configureMetricsGangliaReporter
import com.thinkaurelius.titan.util.stats.MetricManager; //导入依赖的package包/类
private void configureMetricsGangliaReporter() {
if (configuration.has(GANGLIA_HOST_OR_GROUP)) {
final String host = configuration.get(GANGLIA_HOST_OR_GROUP);
final Duration ival = configuration.get(GANGLIA_INTERVAL);
final Integer port = configuration.get(GANGLIA_PORT);
final UDPAddressingMode addrMode;
final String addrModeStr = configuration.get(GANGLIA_ADDRESSING_MODE);
if (addrModeStr.equalsIgnoreCase("multicast")) {
addrMode = UDPAddressingMode.MULTICAST;
} else if (addrModeStr.equalsIgnoreCase("unicast")) {
addrMode = UDPAddressingMode.UNICAST;
} else throw new AssertionError();
final Boolean proto31 = configuration.get(GANGLIA_USE_PROTOCOL_31);
final int ttl = configuration.get(GANGLIA_TTL);
final UUID uuid = configuration.has(GANGLIA_UUID)? UUID.fromString(configuration.get(GANGLIA_UUID)):null;
String spoof = null;
if (configuration.has(GANGLIA_SPOOF)) spoof = configuration.get(GANGLIA_SPOOF);
try {
MetricManager.INSTANCE.addGangliaReporter(host, port, addrMode, ttl, proto31, uuid, spoof, ival);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
示例12: configureMetricsGraphiteReporter
import com.thinkaurelius.titan.util.stats.MetricManager; //导入依赖的package包/类
private void configureMetricsGraphiteReporter() {
if (configuration.has(GRAPHITE_HOST)) {
MetricManager.INSTANCE.addGraphiteReporter(configuration.get(GRAPHITE_HOST),
configuration.get(GRAPHITE_PORT),
configuration.get(GRAPHITE_PREFIX),
configuration.get(GRAPHITE_INTERVAL));
}
}
示例13: commit
import com.thinkaurelius.titan.util.stats.MetricManager; //导入依赖的package包/类
@Override
public synchronized void commit() {
Preconditions.checkArgument(isOpen(), "The transaction has already been closed");
boolean success = false;
if (null != config.getGroupName()) {
MetricManager.INSTANCE.getCounter(config.getGroupName(), "tx", "commit").inc();
}
try {
if (hasModifications()) {
graph.commit(addedRelations.getAll(), deletedRelations.values(), this);
} else {
txHandle.commit();
}
success = true;
} catch (Exception e) {
try {
txHandle.rollback();
} catch (BackendException e1) {
throw new TitanException("Could not rollback after a failed commit", e);
}
throw new TitanException("Could not commit transaction due to exception during persistence", e);
} finally {
close();
if (null != config.getGroupName() && !success) {
MetricManager.INSTANCE.getCounter(config.getGroupName(), "tx", "commit.exceptions").inc();
}
}
}
示例14: open
import com.thinkaurelius.titan.util.stats.MetricManager; //导入依赖的package包/类
@Override
public void open(WriteConfiguration config) {
metric = MetricManager.INSTANCE;
super.open(config);
}
示例15: resetMetrics
import com.thinkaurelius.titan.util.stats.MetricManager; //导入依赖的package包/类
private void resetMetrics() {
MetricManager.INSTANCE.getRegistry().removeMatching(MetricFilter.ALL);
}