org.snmp4j.smi.OID.trim()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(163)

本文整理了Java中org.snmp4j.smi.OID.trim()方法的一些代码示例,展示了OID.trim()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OID.trim()方法的具体详情如下:
包路径:org.snmp4j.smi.OID
类名称:OID
方法名:trim

OID.trim介绍

[英]Returns a new copy of this OID with the last sub-indentifier removed.
[中]返回此OID的新副本,并删除最后一个子标识符。

代码示例

代码示例来源:origin: org.kaazing/snmp4j-agent

public Object getLink(OID oid) {
 if (links != null) {
  OID searchOID = new OID(oid);
  Object result = null;
  while ((searchOID.size() > 0) &&
      ((result = links.get(searchOID)) == null)) {
   searchOID.trim(1);
  }
  return result;
 }
 return null;
}

代码示例来源:origin: org.snmp4j/snmp4j-agent

@Override
public Object getLink(OID oid) {
 if (links != null) {
  OID searchOID = new OID(oid);
  Object result = null;
  while ((searchOID.size() > 0) &&
      ((result = links.get(searchOID)) == null)) {
   searchOID.trim(1);
  }
  return result;
 }
 return null;
}

代码示例来源:origin: fbacchella/jrds

@Override
public Map<OID, Object> getNewSampleValuesConnected(SnmpConnection cnx) {
  Map<OID, Object> retValue = null;
  Set<OID> oids = getOidSet();
  if(oids != null) {
    try {
      Map<OID, Object> rawValues = requester.doSnmpGet(cnx, oids);
      retValue = new HashMap<OID, Object>(rawValues.size());
      for(Map.Entry<OID, Object> e: rawValues.entrySet()) {
        OID oid = new OID(e.getKey());
        oid.trim(getSuffixLength());
        retValue.put(oid, e.getValue());
      }
    } catch (IOException e) {
      log(Level.ERROR, e, "IO Error: %s", e.getMessage());
    }
  }
  return retValue;
}

代码示例来源:origin: org.jboss.jbossas/jboss-snmp

tables.add(coid.trim());

代码示例来源:origin: org.mobicents.tools.snmp.adaptor/core

tables.add(coid.trim());

代码示例来源:origin: org.kaazing/snmp4j-agent

private boolean checkLimits(MOTableRowEvent event) {
 int limit = maxNumRows;
 if ((limits != null) && (!limits.isEmpty())) {
  OID search = new OID(event.getTable().getOID());
  while (search.size() > 0) {
   Integer l = (Integer) limits.get(search);
   if (l != null) {
    limit = l.intValue();
    break;
   }
   else {
    search.trim(1);
   }
  }
 }
 int currentSize = 0;
 if (limit > 0) {
  currentSize = event.getTable().getModel().getRowCount();
  if (currentSize >= limit) {
   // remove eldest
   return removeEldest(event, (currentSize - limit) + 1);
  }
 }
 return ((limit <= 0) || (currentSize < limit));
}

代码示例来源:origin: org.snmp4j/snmp4j-agent

private boolean checkLimits(MOTableRowEvent<R> event) {
 int limit = maxNumRows;
 if ((limits != null) && (!limits.isEmpty())) {
  OID search = new OID(event.getTable().getOID());
  while (search.size() > 0) {
   Integer l = limits.get(search);
   if (l != null) {
    limit = l;
    break;
   }
   else {
    search.trim(1);
   }
  }
 }
 int currentSize = 0;
 if (limit > 0) {
  currentSize = event.getTable().getModel().getRowCount();
  if (currentSize >= limit) {
   // remove eldest
   return removeEldest(event, (currentSize - limit) + 1);
  }
 }
 return (limit <= 0);
}

代码示例来源:origin: org.kaazing/snmp4j-agent

OID sk = new OID(k.getValue(), 0, k.size()-1);
while ((sk.size() > 0) &&  (roots.get(sk) == null)) {
 sk.trim(1);

代码示例来源:origin: org.mobicents.tools.snmp.adaptor/core

log.info("snmpReceivedSet: attempt to set a non-existent instance: " + oid.last() + " of object: " + oid.trim(), e);
undoSets(modified);
makeErrorPdu(response, pdu, errorIndex, PDU.noCreation);

代码示例来源:origin: org.jboss.jbossas/jboss-snmp

log.info("snmpReceivedSet: attempt to set a non-existent instance: " + oid.last() + " of object: " + oid.trim(), e);
undoSets(modified);
makeErrorPdu(response, pdu, errorIndex, PDU.noCreation);

代码示例来源: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.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

/**
 * 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

ageOut * 6000) {
NlmStatsLogEntryRow statsRow = (NlmStatsLogEntryRow)
  nlmStatsLogEntryModel.getRow(row.getIndex().trim());
if (statsRow != null) {
 statsRow.getNlmStatsLogNotificationsBumped().increment();

代码示例来源: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: org.snmp4j/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 = 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: org.snmp4j/snmp4j-agent

OID sk = new OID(k.getValue(), 0, k.size() - 1);
while ((sk.size() > 0) && (roots.get(sk) == null)) {
  sk.trim(1);

代码示例来源:origin: org.snmp4j/snmp4j-agent

if (uptime.getValue() - row.getNlmLogTime().getValue() >
  ageOut * 6000) {
 NlmStatsLogEntryRow statsRow = nlmStatsLogEntryModel.getRow(row.getIndex().trim());
 if (statsRow != null) {
  statsRow.getNlmStatsLogNotificationsBumped().increment();

代码示例来源:origin: org.snmp4j/snmp4j-agent

targetV1.setSpecificTrap(trapOID.get(trapOID.size() - 1));
  OID enterprise = new OID(trapOID);
  enterprise.trim(2);
  targetV1.setEnterprise(enterprise);
} else if (trapOID.size() > 1) {
  targetV1.setSpecificTrap(trapOID.get(trapOID.size() - 1));
  OID enterprise = new OID(trapOID);
  enterprise.trim(1);
  targetV1.setEnterprise(enterprise);

代码示例来源:origin: org.kaazing/snmp4j-agent

targetV1.setSpecificTrap(trapOID.get(trapOID.size() - 1));
OID enterprise = new OID(trapOID);
enterprise.trim(2);
targetV1.setEnterprise(enterprise);
targetV1.setSpecificTrap(trapOID.get(trapOID.size() - 1));
OID enterprise = new OID(trapOID);
enterprise.trim(1);
targetV1.setEnterprise(enterprise);

相关文章