本文整理汇总了Java中org.snmp4j.smi.Counter64类的典型用法代码示例。如果您正苦于以下问题:Java Counter64类的具体用法?Java Counter64怎么用?Java Counter64使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Counter64类属于org.snmp4j.smi包,在下文中一共展示了Counter64类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getDataType
import org.snmp4j.smi.Counter64; //导入依赖的package包/类
public static SNMPDataType getDataType(Variable var){
SNMPDataType retVal = SNMPDataType.INT;
/*
* org.snmp4j.smi.Variable implementations
* AbstractVariable, BitString,
* Counter32, Counter64, Gauge32, Integer32, UnsignedInteger32,
* TimeTicks,
* OctetString,
* GenericAddress, IpAddress, Null, OID, Opaque, SMIAddress, SshAddress, TcpAddress, TlsAddress,
* TransportIpAddress, TsmSecurityParameters, UdpAddress, VariantVariable
* SNMPDataType: STRING,INT,LONG,FLOAT,TICKS,OCTIN,OCTOUT,COUNT, OTHER
*/
if(var instanceof TimeTicks) {
retVal = SNMPDataType.TICKS;
} else if(var instanceof Counter64 || var instanceof Counter32) {
retVal = SNMPDataType.COUNT;
} else if(var instanceof Integer32 || var instanceof UnsignedInteger32) {
retVal = SNMPDataType.COUNT;
} else if(var instanceof Gauge32) {
retVal = SNMPDataType.COUNT;
} else if(var instanceof OctetString) {
retVal = SNMPDataType.STRING;
}
return retVal;
}
开发者ID:PRTG,项目名称:JMXMiniProbe,代码行数:26,代码来源:SNMPUtil.java
示例2: toLong
import org.snmp4j.smi.Counter64; //导入依赖的package包/类
public long toLong() {
switch (m_value.getSyntax()) {
case SMIConstants.SYNTAX_COUNTER64:
return ((Counter64)m_value).getValue();
case SMIConstants.SYNTAX_INTEGER:
return ((Integer32)m_value).getValue();
case SMIConstants.SYNTAX_COUNTER32:
case SMIConstants.SYNTAX_TIMETICKS:
case SMIConstants.SYNTAX_UNSIGNED_INTEGER32:
return ((UnsignedInteger32)m_value).getValue();
case SMIConstants.SYNTAX_OCTET_STRING:
return (convertStringToLong());
default:
return Long.parseLong(m_value.toString());
}
}
开发者ID:qoswork,项目名称:opennmszh,代码行数:17,代码来源:Snmp4JValue.java
示例3: toBigInteger
import org.snmp4j.smi.Counter64; //导入依赖的package包/类
public BigInteger toBigInteger() {
switch (m_value.getSyntax()) {
case SMIConstants.SYNTAX_COUNTER64:
final Counter64 cnt = (Counter64)m_value;
if (cnt.getValue() > 0) {
return BigInteger.valueOf(cnt.getValue());
} else {
return new BigInteger(cnt.toString());
}
case SMIConstants.SYNTAX_INTEGER:
return BigInteger.valueOf(((Integer32)m_value).getValue());
case SMIConstants.SYNTAX_COUNTER32:
case SMIConstants.SYNTAX_TIMETICKS:
case SMIConstants.SYNTAX_UNSIGNED_INTEGER32:
return BigInteger.valueOf(((UnsignedInteger32)m_value).getValue());
default:
return new BigInteger(m_value.toString());
}
}
开发者ID:qoswork,项目名称:opennmszh,代码行数:20,代码来源:Snmp4JValue.java
示例4: testModify
import org.snmp4j.smi.Counter64; //导入依赖的package包/类
@Test
public void testModify() throws Exception {
final ModifierProperties modifierProperties = new ModifierProperties();
modifierProperties.put("minimum", UnsignedLong.ZERO);
modifierProperties.put("maximum", UnsignedLong.valueOf(10L));
modifierProperties.put("minimumStep", UnsignedLong.valueOf(1L));
modifierProperties.put("maximumStep", UnsignedLong.valueOf(10L));
final Counter64Modifier modifier = new Counter64Modifier();
modifier.init(modifierProperties);
final Counter64 counter64 = new Counter64(0);
assertEquals(counter64.getValue(), 0);
final Counter64 modifiedVariable = modifier.modify(counter64);
assertNotEquals(modifiedVariable.getValue(), 0);
}
开发者ID:1and1,项目名称:snmpman,代码行数:18,代码来源:Counter64ModifierTest.java
示例5: newVarbind
import org.snmp4j.smi.Counter64; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Varbind newVarbind(String oid, Object value) {
VariableBinding varbind = resolveOid(oid);
int syntax = mib.syntaxForObject(varbind.getOid().toString());
Variable variable = AbstractVariable.createFromSyntax(syntax);
if (variable instanceof Integer32) {
((Integer32) variable).setValue(((Number) value).intValue());
}
else if (variable instanceof UnsignedInteger32) {
((UnsignedInteger32) variable).setValue(Math.abs(((Number) value).longValue()));
}
else if (variable instanceof Counter64) {
((Counter64) variable).setValue(((Number) value).longValue());
}
else if (variable instanceof OctetString) {
if (value instanceof String) {
((OctetString) variable).setValue((String) value);
}
else {
((OctetString) variable).setValue((byte[]) value);
}
}
else if (variable instanceof OID) {
if (value instanceof String) {
((OID) variable).setValue((String) value);
}
else {
((OID) variable).setValue((int[]) value);
}
}
else {
throw new IllegalStateException("unrecognized type");
}
varbind.setVariable(variable);
return varbindFactory.newVarbind(varbind);
}
开发者ID:soulwing,项目名称:tnm4j,代码行数:41,代码来源:Snmp4jContext.java
示例6: newVariable
import org.snmp4j.smi.Counter64; //导入依赖的package包/类
static Variable newVariable(int syntax, Object value) {
Variable variable = AbstractVariable.createFromSyntax(syntax);
if (variable instanceof Integer32) {
((Integer32) variable).setValue(((Number) value).intValue());
}
else if (variable instanceof UnsignedInteger32) {
((UnsignedInteger32) variable).setValue(Math.abs(((Number) value).longValue()));
}
else if (variable instanceof Counter64) {
((Counter64) variable).setValue(((Number) value).longValue());
}
else if (variable instanceof OctetString) {
if (value instanceof String) {
((OctetString) variable).setValue((String) value);
}
else {
((OctetString) variable).setValue((byte[]) value);
}
}
else if (variable instanceof OID) {
if (value instanceof String) {
((OID) variable).setValue((String) value);
}
else {
((OID) variable).setValue((int[]) value);
}
}
else {
throw new IllegalStateException("unrecognized type");
}
return variable;
}
开发者ID:soulwing,项目名称:tnm4j,代码行数:33,代码来源:Snmp4jVarbind.java
示例7: toInt
import org.snmp4j.smi.Counter64; //导入依赖的package包/类
public int toInt() {
switch (m_value.getSyntax()) {
case SMIConstants.SYNTAX_COUNTER64:
return (int)((Counter64)m_value).getValue();
case SMIConstants.SYNTAX_INTEGER:
return ((Integer32)m_value).getValue();
case SMIConstants.SYNTAX_COUNTER32:
case SMIConstants.SYNTAX_TIMETICKS:
case SMIConstants.SYNTAX_UNSIGNED_INTEGER32:
return (int)((UnsignedInteger32)m_value).getValue();
default:
return Integer.parseInt(m_value.toString());
}
}
开发者ID:qoswork,项目名称:opennmszh,代码行数:15,代码来源:Snmp4JValue.java
示例8: modify
import org.snmp4j.smi.Counter64; //导入依赖的package包/类
@Override
public Counter64 modify(final Counter64 variable) {
UnsignedLong currentValue = UnsignedLong.valueOf(variable.toString());
if (currentValue.compareTo(minimum) < 0 || currentValue.compareTo(maximum) > 0) {
currentValue = minimum;
}
final UnsignedLong step = UnsignedLong.valueOf((long) (Math.random() * maximumStep.minus(minimumStep).longValue())).plus(minimumStep);
final UnsignedLong newValue = currentValue.plus(step);
return new Counter64(newValue.longValue());
}
开发者ID:1and1,项目名称:snmpman,代码行数:13,代码来源:Counter64Modifier.java
示例9: castToLong
import org.snmp4j.smi.Counter64; //导入依赖的package包/类
public static long castToLong(Variable variable) {
switch (variable.getSyntax()) {
case SMIConstants.SYNTAX_GAUGE32:
return ((Gauge32) variable).toLong();
case SMIConstants.SYNTAX_COUNTER32:
return ((Counter32) variable).toLong();
case SMIConstants.SYNTAX_COUNTER64:
return ((Counter64) variable).toLong();
case SMIConstants.SYNTAX_TIMETICKS:
return ((TimeTicks) variable).toLong();
default:
throw new IllegalArgumentException("Unsupported cast from "
+ variable.getSyntaxString() + " to long");
}
}
开发者ID:ccascone,项目名称:JNetMan,代码行数:16,代码来源:SnmpHelper.java
示例10: updateCounter64Value
import org.snmp4j.smi.Counter64; //导入依赖的package包/类
public void updateCounter64Value(String oid, long val) {
updateValue(oid, new Counter64(val));
}
开发者ID:qoswork,项目名称:opennmszh,代码行数:4,代码来源:MockSnmpAgent.java
示例11: getCounter64
import org.snmp4j.smi.Counter64; //导入依赖的package包/类
public SnmpValue getCounter64(BigInteger bigInt) {
return new Snmp4JValue(new Counter64(bigInt.longValue()));
}
开发者ID:qoswork,项目名称:opennmszh,代码行数:4,代码来源:Snmp4JValueFactory.java
示例12: updateCounter64Value
import org.snmp4j.smi.Counter64; //导入依赖的package包/类
/**
* <p>updateCounter64Value</p>
*
* @param oid a {@link java.lang.String} object.
* @param val a long.
*/
public void updateCounter64Value(String oid, long val) {
updateValue(oid, new Counter64(val));
}
开发者ID:vishwaabhinav,项目名称:OpenNMS,代码行数:10,代码来源:MockSnmpAgent.java
注:本文中的org.snmp4j.smi.Counter64类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论