本文整理汇总了Java中org.snmp4j.util.TreeEvent类的典型用法代码示例。如果您正苦于以下问题:Java TreeEvent类的具体用法?Java TreeEvent怎么用?Java TreeEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TreeEvent类属于org.snmp4j.util包,在下文中一共展示了TreeEvent类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getAddDropPort
import org.snmp4j.util.TreeEvent; //导入依赖的package包/类
private PortNumber getAddDropPort(int channel, boolean isAddPort) {
OID oid = new OID(CTRL_CHANNEL_ADD_DROP_PORT_INDEX + (isAddPort ? "1" : "2"));
for (TreeEvent event : snmp.get(oid)) {
if (event == null) {
return null;
}
VariableBinding[] varBindings = event.getVariableBindings();
for (VariableBinding varBinding : varBindings) {
if (varBinding.getOid().last() == channel) {
int port = varBinding.getVariable().toInt();
if (!isAddPort) {
port += DROP_PORT_OFFSET;
}
return PortNumber.portNumber(port);
}
}
}
return null;
}
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:LumentumFlowRuleProgrammable.java
示例2: snmpWalk
import org.snmp4j.util.TreeEvent; //导入依赖的package包/类
/**
* Triggers snmpwalk command.
*
* @param oid oid
* @param target {@link org.snmp4j.Target}
* @return response from SNMP server
* @throws IllegalStateException
*/
public List<String> snmpWalk(OID oid, Target target) {
validateSnmpClient();
final List<TreeEvent> events = prepareTreeUtils().getSubtree(target, oid);
if (events == null || events.size() == 0) {
throw new IllegalStateException("Wrapper Error: Response is null");
}
List<String> response = new ArrayList<String>();
for(TreeEvent event : events) {
if (event.isError()) {
throw new IllegalStateException(prepareErrorExceptionForWalk(oid, event));
}
final VariableBinding[] varBindings = event.getVariableBindings();
if (varBindings == null || varBindings.length == 0) {
throw new IllegalStateException("SNMPWrapper Error: Response is null");
}
for (VariableBinding varBinding : varBindings) {
response.add(varBinding.toString());
}
}
return response;
}
开发者ID:smartenit-eu,项目名称:smartenit,代码行数:33,代码来源:SNMPWrapper.java
示例3: getAlarmId
import org.snmp4j.util.TreeEvent; //导入依赖的package包/类
private int getAlarmId(TreeEvent treeEvents) {
VariableBinding[] varBindings = treeEvents.getVariableBindings();
for (VariableBinding varBinding : varBindings) {
return varBinding.getVariable().toInt();
}
return -1;
}
开发者ID:shlee89,项目名称:athena,代码行数:8,代码来源:LumentumAlarmConsumer.java
示例4: fetchRules
import org.snmp4j.util.TreeEvent; //导入依赖的package包/类
private List<FlowRule> fetchRules(OID oid, boolean isAdd, PortNumber linePort) {
List<FlowRule> rules = new LinkedList<>();
for (TreeEvent event : snmp.get(oid)) {
if (event == null) {
continue;
}
VariableBinding[] varBindings = event.getVariableBindings();
for (VariableBinding varBinding : varBindings) {
CrossConnectCache cache = this.handler().get(CrossConnectCache.class);
if (varBinding.getVariable().toInt() == IN_SERVICE) {
int channel = varBinding.getOid().removeLast();
PortNumber addDropPort = getAddDropPort(channel, isAdd);
if (addDropPort == null) {
continue;
}
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchInPort(isAdd ? addDropPort : linePort)
.add(Criteria.matchOchSignalType(OchSignalType.FIXED_GRID))
.add(Criteria.matchLambda(toOchSignal(channel)))
.build();
TrafficTreatment treatment = DefaultTrafficTreatment.builder()
.setOutput(isAdd ? linePort : addDropPort)
.build();
// Lookup flow ID and priority
int hash = Objects.hash(data().deviceId(), selector, treatment);
Pair<FlowId, Integer> lookup = cache.get(hash);
if (lookup == null) {
continue;
}
FlowRule fr = DefaultFlowRule.builder()
.forDevice(data().deviceId())
.makePermanent()
.withSelector(selector)
.withTreatment(treatment)
.withPriority(lookup.getRight())
.withCookie(lookup.getLeft().value())
.build();
rules.add(fr);
}
}
}
return rules;
}
开发者ID:shlee89,项目名称:athena,代码行数:52,代码来源:LumentumFlowRuleProgrammable.java
示例5: get
import org.snmp4j.util.TreeEvent; //导入依赖的package包/类
public List<TreeEvent> get(OID oid) {
TreeUtils treeUtils = new TreeUtils(snmp, new DefaultPDUFactory());
treeUtils.setMaxRepetitions(MAX_REPETITIONS);
return treeUtils.getSubtree(target, oid);
}
开发者ID:shlee89,项目名称:athena,代码行数:6,代码来源:LumentumSnmpDevice.java
示例6: getPorts
import org.snmp4j.util.TreeEvent; //导入依赖的package包/类
private List<PortDescription> getPorts() {
try {
snmp = new LumentumSnmpDevice(handler().data().deviceId());
} catch (IOException e) {
log.error("Failed to connect to device: ", e);
return Collections.emptyList();
}
List<PortDescription> ports = Lists.newLinkedList();
OID[] oids = {
new OID(CTRL_PORT_STATE + "1"),
new OID(CTRL_PORT_STATE + "2")
};
for (OID oid : oids) {
for (TreeEvent event : snmp.get(oid)) {
if (event != null) {
VariableBinding[] varBindings = event.getVariableBindings();
for (VariableBinding varBinding : varBindings) {
if (varBinding.getVariable().toInt() == 1) {
int portNumber = varBinding.getOid().removeLast();
int portDirection = varBinding.getOid().removeLast();
SparseAnnotations ann = DefaultAnnotations.builder()
.set(AnnotationKeys.PORT_NAME, portDirection + "-" + portNumber)
.build();
PortDescription p = omsPortDescription(
PortNumber.portNumber(ports.size() + 1),
true,
LumentumSnmpDevice.START_CENTER_FREQ,
LumentumSnmpDevice.END_CENTER_FREQ,
LumentumSnmpDevice.CHANNEL_SPACING.frequency(),
ann);
ports.add(p);
}
}
}
}
}
// Create LINE IN and LINE OUT ports as these are not reported through SNMP
SparseAnnotations annLineIn = DefaultAnnotations.builder()
.set(AnnotationKeys.PORT_NAME, "LINE IN")
.build();
ports.add(omsPortDescription(
PortNumber.portNumber(ports.size() + 1),
true,
LumentumSnmpDevice.START_CENTER_FREQ,
LumentumSnmpDevice.END_CENTER_FREQ,
LumentumSnmpDevice.CHANNEL_SPACING.frequency(),
annLineIn
));
SparseAnnotations annLineOut = DefaultAnnotations.builder()
.set(AnnotationKeys.PORT_NAME, "LINE OUT")
.build();
ports.add(omsPortDescription(
PortNumber.portNumber(ports.size() + 1),
true,
LumentumSnmpDevice.START_CENTER_FREQ,
LumentumSnmpDevice.END_CENTER_FREQ,
LumentumSnmpDevice.CHANNEL_SPACING.frequency(),
annLineOut
));
return ports;
}
开发者ID:shlee89,项目名称:athena,代码行数:70,代码来源:LumentumRoadmDeviceDescription.java
示例7: prepareErrorExceptionForWalk
import org.snmp4j.util.TreeEvent; //导入依赖的package包/类
protected String prepareErrorExceptionForWalk(OID oid, TreeEvent event) {
final StringBuilder error = new StringBuilder("SNMPWrapper Error:\n");
error.append("[").append(oid).append(" = ")
.append(event.getErrorMessage()).append("]");
return error.toString();
}
开发者ID:smartenit-eu,项目名称:smartenit,代码行数:7,代码来源:SNMPWrapper.java
示例8: getPorts
import org.snmp4j.util.TreeEvent; //导入依赖的package包/类
private List<PortDescription> getPorts() {
try {
snmp = new LumentumSnmpDevice(handler().data().deviceId());
} catch (IOException e) {
log.error("Failed to connect to device: ", e);
return Collections.emptyList();
}
List<PortDescription> ports = Lists.newLinkedList();
OID[] oids = {
new OID(CTRL_PORT_STATE + "1"),
new OID(CTRL_PORT_STATE + "2")
};
for (OID oid : oids) {
for (TreeEvent event : snmp.get(oid)) {
if (event != null) {
VariableBinding[] varBindings = event.getVariableBindings();
for (VariableBinding varBinding : varBindings) {
if (varBinding.getVariable().toInt() == 1) {
int portNumber = varBinding.getOid().removeLast();
int portDirection = varBinding.getOid().removeLast();
SparseAnnotations ann = DefaultAnnotations.builder()
.set(AnnotationKeys.PORT_NAME, portDirection + "-" + portNumber)
.build();
PortDescription p = omsPortDescription(
PortNumber.portNumber(ports.size() + 1L),
true,
LumentumSnmpDevice.START_CENTER_FREQ,
LumentumSnmpDevice.END_CENTER_FREQ,
LumentumSnmpDevice.CHANNEL_SPACING.frequency(),
ann);
ports.add(p);
}
}
}
}
}
// Create LINE IN and LINE OUT ports as these are not reported through SNMP
SparseAnnotations annLineIn = DefaultAnnotations.builder()
.set(AnnotationKeys.PORT_NAME, "LINE IN")
.build();
ports.add(omsPortDescription(
PortNumber.portNumber(ports.size() + 1L),
true,
LumentumSnmpDevice.START_CENTER_FREQ,
LumentumSnmpDevice.END_CENTER_FREQ,
LumentumSnmpDevice.CHANNEL_SPACING.frequency(),
annLineIn
));
SparseAnnotations annLineOut = DefaultAnnotations.builder()
.set(AnnotationKeys.PORT_NAME, "LINE OUT")
.build();
ports.add(omsPortDescription(
PortNumber.portNumber(ports.size() + 1L),
true,
LumentumSnmpDevice.START_CENTER_FREQ,
LumentumSnmpDevice.END_CENTER_FREQ,
LumentumSnmpDevice.CHANNEL_SPACING.frequency(),
annLineOut
));
return ports;
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:70,代码来源:LumentumRoadmDiscovery.java
注:本文中的org.snmp4j.util.TreeEvent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论