本文整理了Java中org.snmp4j.smi.OID.nextPeer()
方法的一些代码示例,展示了OID.nextPeer()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OID.nextPeer()
方法的具体详情如下:
包路径:org.snmp4j.smi.OID
类名称:OID
方法名:nextPeer
[英]Returns the next following OID with the same or lesser size (length).
[中]返回具有相同或更小大小(长度)的下一个OID。
代码示例来源:origin: org.snmp4j/snmp4j-agent
@Override
public OID getUpperBound() {
if (upperBound == null) {
upperBound = new OID(getLowerBound().nextPeer());
}
return upperBound;
}
代码示例来源:origin: org.kaazing/snmp4j-agent
public OID getUpperBound() {
if (upperBound == null) {
upperBound = new OID(getLowerBound().nextPeer());
}
return upperBound;
}
代码示例来源:origin: org.snmp4j/snmp4j-agent
public MOSubtreeProxy(Session session, SnmpTargetMIB targetMIB,
OctetString proxyName,
OID subtreeOID, OctetString contextEngineID,
OctetString contextName, OctetString targetName) {
this.session = session;
this.targetMIB = targetMIB;
this.proxyName = proxyName;
this.contextName = contextName;
this.scope = new DefaultMOScope(subtreeOID, true, subtreeOID.nextPeer(), false);
this.targetName = targetName;
this.contextEngineID = contextEngineID;
this.pduFactory = new DefaultPDUFactory(PDU.GETNEXT, contextEngineID, contextName);
}
代码示例来源:origin: org.snmp4j/snmp4j-agent
@Override
public int viewTreeFamilyEntryCount(OctetString viewName) {
OID lowerBound = viewName.toSubIndex(false);
OID upperBound = new OID(lowerBound).nextPeer();
return vacmViewTreeFamilyTableModel.getRows(lowerBound, upperBound).size();
}
代码示例来源:origin: org.snmp4j/snmp4j-agent
@Override
public int accessEntryCount(OctetString groupName) {
OID lowerBound = groupName.toSubIndex(false);
OID upperBound = new OID(lowerBound).nextPeer();
return vacmAccessTableModel.getRows(lowerBound, upperBound).size();
}
代码示例来源:origin: com.github.kaitoy.sneo/sneo-core
public List<VariableBinding> walkMib(String strOid, int count) {
OID oid = new OID(strOid);
DefaultMOContextScope scope
= new DefaultMOContextScope(
new OctetString(FILEMIB_CONTEXT),
oid, true, oid.nextPeer(), false
);
ManagedObject mo = server.lookup(new DefaultMOQuery(scope, false));
if (mo == null) {
return new ArrayList<VariableBinding>(0);
}
if (mo instanceof MutableStaticMOGroup) {
return ((MutableStaticMOGroup)mo).walk(oid, count);
}
else {
return new ArrayList<VariableBinding>(0);
}
}
代码示例来源:origin: org.snmp4j/snmp4j
private synchronized void listLoggers(Snmp snmp, Target target, PDUFactory pduFactory) {
TableUtils tableUtils = new TableUtils(snmp, pduFactory);
OID lowerBound = null;
OID upperBound = null;
String filter = (String) ArgumentParser.getValue(parameters, "filter", 0);
if (filter != null) {
OctetString filterString = new OctetString(filter);
lowerBound = filterString.toSubIndex(true);
upperBound = lowerBound.nextPeer();
}
LoggerListListener lll = new LoggerListListener();
tableUtils.getTable(target, SNMP4J_LOGGER_OIDS, lll, this,
lowerBound, upperBound);
while (!lll.isFinished()) {
try {
wait();
}
catch (InterruptedException ex) {
// ignore
}
}
}
代码示例来源:origin: org.kaazing/snmp4j
private synchronized void listLoggers(Snmp snmp, Target target, PDUFactory pduFactory) {
TableUtils tableUtils = new TableUtils(snmp, pduFactory);
OID lowerBound = null;
OID upperBound = null;
String filter = (String) ArgumentParser.getValue(parameters, "filter", 0);
if (filter != null) {
OctetString filterString = new OctetString(filter);
lowerBound = filterString.toSubIndex(true);
upperBound = lowerBound.nextPeer();
}
LoggerListListener lll = new LoggerListListener();
tableUtils.getTable(target, SNMP4J_LOGGER_OIDS, lll, this,
lowerBound, upperBound);
while (!lll.isFinished()) {
try {
wait();
}
catch (InterruptedException ex) {
}
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.snmp4j
private synchronized void listLoggers(Snmp snmp, Target target, PDUFactory pduFactory) {
TableUtils tableUtils = new TableUtils(snmp, pduFactory);
OID lowerBound = null;
OID upperBound = null;
String filter = (String) ArgumentParser.getValue(parameters, "filter", 0);
if (filter != null) {
OctetString filterString = new OctetString(filter);
lowerBound = filterString.toSubIndex(true);
upperBound = lowerBound.nextPeer();
}
LoggerListListener lll = new LoggerListListener();
tableUtils.getTable(target, SNMP4J_LOGGER_OIDS, lll, this,
lowerBound, upperBound);
while (!lll.isFinished()) {
try {
wait();
}
catch (InterruptedException ex) {
// ignore
}
}
}
代码示例来源:origin: com.github.kaitoy.sneo/sneo-core
public VariableBinding getMib(String strOid, String communityStringIndex) {
if (
communityStringIndex.length() != 0
&& !communityStringIndexes.contains(communityStringIndex)
) {
return null;
}
OID oid = new OID(strOid);
DefaultMOContextScope scope =
new DefaultMOContextScope(
new OctetString(
getContextNameForCommunityStringIndex(communityStringIndex)
),
oid, true, oid.nextPeer(), false
);
ManagedObject mo = server.lookup(new DefaultMOQuery(scope, false));
if (mo == null) {
return null;
}
if (mo instanceof MutableStaticMOGroup) {
return new VariableBinding(oid, ((MutableStaticMOGroup)mo).get(oid));
}
else {
return null;
}
}
代码示例来源:origin: com.github.kaitoy.sneo/sneo-core
/**
* Creates a static managed object group for the sub-tree with the specified
* root OID.
* @param root
* the root OID of the sub-tree to be registered by this managed object.
* @param vbs
* the variable bindings to be returned in this sub-tree.
*/
public MutableStaticMOGroup(OID root, VariableBinding[] vbs) {
this.root = root;
this.scope = new DefaultMOScope(root, true, root.nextPeer(), false);
variableBindings = new TreeMap<OID, Variable>();
for (int i = 0; i < vbs.length; i++) {
if ((vbs[i].getOid() != null) && (vbs[i].getVariable() != null)) {
if (
(vbs[i].getOid().size() >= root.size())
&& (vbs[i].getOid().leftMostCompare(root.size(), root) == 0)
) {
this.variableBindings.put(vbs[i].getOid(), vbs[i].getVariable());
}
}
}
}
代码示例来源:origin: org.snmp4j/snmp4j
/**
* Returns the next following OID with the same or lesser size (length).
*
* @return OID
* the next OID on the same or upper level or a clone of this OID, if
* it has a zero length or is 2^32-1.
* @since 1.7
*/
public final OID nextPeer() {
OID next = new OID(this);
if ((next.size() > 0) && (last() != MAX_SUBID_VALUE)) {
next.set(next.size() - 1, last() + 1);
} else if (next.size() > 1) {
next.trim(1);
next = next.nextPeer();
}
return next;
}
代码示例来源:origin: org.snmp4j/snmp4j-agent
/**
* Creates a static managed object group for the sub-tree with the specified
* root OID.
* @param root
* the root OID of the sub-tree to be registered by this managed object.
* @param vbs
* the variable bindings to be returned in this sub-tree.
*/
public StaticMOGroup(OID root, VariableBinding[] vbs) {
this.root = root;
this.scope = new DefaultMOScope(root, true, root.nextPeer(), false);
for (VariableBinding vb : vbs) {
if ((vb.getOid() != null) && (vb.getVariable() != null)) {
if ((vb.getOid().size() >= root.size()) &&
(vb.getOid().leftMostCompare(root.size(), root) == 0)) {
this.vbs.put(vb.getOid(), vb.getVariable());
}
}
}
}
代码示例来源:origin: com.github.kaitoy.sneo/sneo-core
public VariableBinding getMib(String strOid) {
OID oid = new OID(strOid);
DefaultMOContextScope scope =
new DefaultMOContextScope(
new OctetString(FILEMIB_CONTEXT),
oid, true, oid.nextPeer(), false
);
ManagedObject mo = server.lookup(new DefaultMOQuery(scope, false));
if (mo == null) {
return null;
}
if (mo instanceof MutableStaticMOGroup) {
return new VariableBinding(oid, ((MutableStaticMOGroup)mo).get(oid));
}
else {
return null;
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.snmp4j
/**
* Returns the next following OID with the same or lesser size (length).
* @return OID
* the next OID on the same or upper level or a clone of this OID, if
* it has a zero length or is 2^32-1.
* @since 1.7
*/
public final OID nextPeer() {
OID next = new OID(this);
if ((next.size() > 0) && (last() != MAX_SUBID_VALUE)) {
next.set(next.size()-1, last()+1);
}
else if (next.size() > 1) {
next.trim(1);
next = next.nextPeer();
}
return next;
}
代码示例来源:origin: org.kaazing/snmp4j-agent
/**
* Creates a static managed object group for the sub-tree with the specified
* root OID.
* @param root
* the root OID of the sub-tree to be registered by this managed object.
* @param vbs
* the variable bindings to be returned in this sub-tree.
*/
public StaticMOGroup(OID root, VariableBinding[] vbs) {
this.root = root;
this.scope = new DefaultMOScope(root, true, root.nextPeer(), false);
for (int i=0; i<vbs.length; i++) {
if ((vbs[i].getOid() != null) && (vbs[i].getVariable() != null)) {
if ((vbs[i].getOid().size() >= root.size()) &&
(vbs[i].getOid().leftMostCompare(root.size(), root) == 0)) {
this.vbs.put(vbs[i].getOid(), vbs[i].getVariable());
}
}
}
}
代码示例来源:origin: org.kaazing/snmp4j
/**
* Returns the next following OID with the same or lesser size (length).
* @return OID
* the next OID on the same or upper level or a clone of this OID, if
* it has a zero length or is 2^32-1.
* @since 1.7
*/
public final OID nextPeer() {
OID next = new OID(this);
if ((next.size() > 0) && (last() != MAX_SUBID_VALUE)) {
next.set(next.size()-1, last()+1);
}
else if (next.size() > 1) {
next.trim(1);
next = nextPeer();
}
return next;
}
代码示例来源:origin: org.kaazing/snmp4j-agent
private void deleteLogRows(long limit, OctetString profileName) {
long delta = nlmLogEntry.getModel().getRowCount() - limit;
if (delta > 0) {
synchronized (nlmLogEntries) {
for (int i=0; (i<delta) && (nlmLogEntries.size()>0); i++) {
OID firstIndex = (OID) nlmLogEntries.remove(0);
if (firstIndex != null) {
nlmLogEntry.removeRow(firstIndex);
((DefaultMOMutableTableModel)
nlmLogVariableEntryModel).removeRows(firstIndex, firstIndex.nextPeer());
NlmStatsLogEntryRow statsRow = (NlmStatsLogEntryRow)
nlmStatsLogEntryModel.getRow(firstIndex.trim());
if (statsRow != null) {
statsRow.getNlmStatsLogNotificationsBumped().increment();
}
((Counter32)nlmStatsGlobalNotificationsBumped.getValue()).increment();
if (profileName != null) {
NlmStatsLogEntryRow profile = (NlmStatsLogEntryRow)
nlmStatsLogEntry.getModel().getRow(profileName.toSubIndex(false));
if (profile != null) {
profile.getNlmStatsLogNotificationsBumped().increment();
}
}
}
}
}
}
}
代码示例来源:origin: com.github.kaitoy.sneo/sneo-core
public Variable setMib(String strVarBind) throws ParseException {
VariableBinding varBind
= ColonSeparatedOidTypeValueVariableTextFormat.getInstance()
.parseVariableBinding(strVarBind);
OID oid = varBind.getOid();
DefaultMOContextScope scope
= new DefaultMOContextScope(
new OctetString(FILEMIB_CONTEXT),
oid, true, oid.nextPeer(), false
);
ManagedObject mo = server.lookup(new DefaultMOQuery(scope, true));
if (mo == null) {
return Null.noSuchObject;
}
if (!(mo instanceof MutableStaticMOGroup)) {
return Null.noSuchObject;
}
return ((MutableStaticMOGroup)mo).set(
oid,
varBind.getVariable()
);
}
代码示例来源:origin: org.snmp4j/snmp4j-agent
@Override
public OID forwardTranslate(OID oid) {
if (oid != null) {
OID translated;
if ((oid.size() >= scope.getLowerBound().size()) && (oid.startsWith(scope.getLowerBound()))) {
OID remote = new OID(remoteOID);
int[] suffix = new int[oid.size() - scope.getLowerBound().size()];
if (suffix.length > 0) {
System.arraycopy(oid.getValue(), scope.getLowerBound().size(), suffix, 0, suffix.length);
remote.append(new OID(suffix));
}
translated = remote;
}
else if (oid.compareTo(scope.getLowerBound()) < 0) {
translated = new OID(remoteOID);
}
else {
translated = remoteOID.nextPeer();
}
if (logger.isDebugEnabled()) {
logger.debug("Forward OID translation '"+oid+"'->'"+translated);
}
return translated;
}
return null;
}
内容来源于网络,如有侵权,请联系作者删除!