protected BindEntry clone(){ BindEntry bindEntry = new BindEntry(oid, mName, aName); bindEntry.setAttr(attr); bindEntry.setMbean(mbean); bindEntry.setReadWrite(isReadWrite); bindEntry.setTable(isTable); return bindEntry; } }
/** * Compare two BindEntries. Ordering is defined at oid-level. * * @param other * The BindEntry to compare to. * @return 0 on equals, 1 if this is bigger than other */ public int compareTo(Object other) { if (other == null) throw new NullPointerException("Can't compare to NULL"); if (!(other instanceof BindEntry)) throw new ClassCastException("Parameter is no BindEntry"); // trivial case if (this.equals(other)) return 0; BindEntry obe = (BindEntry) other; // if (getOid().equals(obe.getOid())) // return 0; int res = oid.compareTo(obe.getOid()); return res; }
/** * A string representation of this BindEntry */ public String toString() { StringBuffer buf = new StringBuffer(); buf.append("[oid="); buf.append(oid).append(", mbean="); buf.append(mName).append(", attr="); buf.append(aName).append(", rw=").append(isReadWrite()); buf.append(", table=").append(isTable()); buf.append("]"); return buf.toString(); }
/** * Constructs a new BindEntry. * * @param coid * The SNMP-oid, this entry will use. * @param mbName * The name of an MBean with attribute to query * @param attrName * The name of the attribute to query */ BindEntry(final OID coid, final String mbName, final String attrName) { oid = coid; this.mName = mbName; this.aName = attrName; try { setMbean(new ObjectName(mbName)); setAttr(new Attribute(attrName, null)); } catch (Exception e) { // log.warn(e.toString()); mName = "-unset-"; aName = "-unset-"; } }
if (be != null) { if (log.isTraceEnabled()) log.debug("getValueFor: Found entry " + be.toString() + " for oid " + oid); Object val = server.getAttribute(be.getMbean(), be.getAttr().getName()); OID tableIndexOID = null; if(be.isTable()) { tableIndexOID = be.getTableIndexOID(); throw e; } catch (Exception e) { log.warn("getValueFor: (" + be.getMbean().toString() + ", " + be.getAttr().getName() + ": " + e.toString());
log.trace("setValueFor: " + be.toString()); if (be.isReadWrite() == false) { if (trace) log.trace("setValueFor: this is marked read only"); Object other = server.getAttribute(be.getMbean(), be.getAttr().getName()); Object val = convertVariableToValue(newVal, other); ssy = newVal; OID tableIndexOID = be.getTableIndexOID(); if(tableIndexOID == null) { Attribute at = new Attribute(be.getAttr().getName(), val); server.setAttribute(be.getMbean(), at); } else {
val = server.getAttribute(be.getMbean(), be.getAttr().getName()); } catch(Exception e) { log.error("Impossible to fetch " + be.getAttr().getName()); return null; OID tableIndexOID = be.getTableIndexOID(); if(val instanceof List) { return new OctetString("" + oid.get(oid.size()-1));
BindEntry be = new BindEntry(coid, mmb.getName(), ma.getName()); be.setReadWrite(ma.isReadWrite()); be.setTable(ma.isAttributeTable());
/** * * @param oid * The OID bound to this particular attribute * @param mmb * the name of the MBean server * @param ma * the name of the MBeam attribute the OID is concerning * @param rw * indicates whether this Attribute is read-write or not * (readonly if false) */ private void addBindEntry(OID coid, String mmb, String ma, boolean rw) { BindEntry be = new BindEntry(coid, mmb, ma); be.setReadWrite(rw); if (log.isTraceEnabled()) log.trace("New bind entry " + be); if (tableBindings.containsKey(coid)) { log.info("Duplicate oid " + coid + RequestHandlerImpl.SKIP_ENTRY); } if (mmb == null || mmb.equals("")) { log.info("Invalid mbean name for oid " + coid + RequestHandlerImpl.SKIP_ENTRY); } if (ma == null || ma.equals("")) { log.info("Invalid attribute name " + ma + " for oid " + coid + RequestHandlerImpl.SKIP_ENTRY); } tableBindings.put(coid, be); }
/** * * @param oid * @return */ public BindEntry getTableBinding(OID oid, boolean isRowEntry) { Set<Entry<OID,BindEntry>> entries = null; // if(isRowEntry) { // entries = tableRowEntryMappings.entrySet(); // } else { entries = tableMappings.entrySet(); // } for (Entry<OID,BindEntry> entry : entries) { if (oid.startsWith(entry.getKey())) { BindEntry value = entry.getValue(); BindEntry bindEntry = (BindEntry) value.clone(); int[] oidValue = oid.getValue(); int[] subOid = new int[oid.size() - entry.getKey().size()]; System.arraycopy(oidValue, entry.getKey().size(), subOid, 0, oid.size() - entry.getKey().size()); if(subOid.length > 0) { bindEntry.setTableIndexOID(new OID(subOid)); } return bindEntry; } } return null; }
if (be != null) { if (log.isTraceEnabled()) log.debug("getValueFor: Found entry " + be.toString() + " for oid " + oid); Object val = server.getAttribute(be.getMbean(), be.getAttr().getName()); OID tableIndexOID = null; if(be.isTable()) { tableIndexOID = be.getTableIndexOID(); throw e; } catch (Exception e) { log.warn("getValueFor: (" + be.getMbean().toString() + ", " + be.getAttr().getName() + ": " + e.toString());
log.trace("setValueFor: " + be.toString()); if (be.isReadWrite() == false) { if (trace) log.trace("setValueFor: this is marked read only"); Object other = server.getAttribute(be.getMbean(), be.getAttr().getName()); Object val = convertVariableToValue(newVal, other); ssy = newVal; OID tableIndexOID = be.getTableIndexOID(); if(tableIndexOID == null) { Attribute at = new Attribute(be.getAttr().getName(), val); server.setAttribute(be.getMbean(), at); } else {
val = server.getAttribute(be.getMbean(), be.getAttr().getName()); } catch(Exception e) { log.error("Impossible to fetch " + be.getAttr().getName()); return null; OID tableIndexOID = be.getTableIndexOID(); if(val instanceof List) { return new OctetString("" + oid.get(oid.size()-1));
BindEntry be = new BindEntry(coid, mmb.getName(), ma.getName()); be.setReadWrite(ma.isReadWrite()); be.setTable(ma.isAttributeTable());
/** * * @param oid * The OID bound to this particular attribute * @param mmb * the name of the MBean server * @param ma * the name of the MBeam attribute the OID is concerning * @param rw * indicates whether this Attribute is read-write or not * (readonly if false) */ private void addBindEntry(OID coid, String mmb, String ma, boolean rw) { BindEntry be = new BindEntry(coid, mmb, ma); be.setReadWrite(rw); if (log.isTraceEnabled()) log.trace("New bind entry " + be); if (tableBindings.containsKey(coid)) { log.info("Duplicate oid " + coid + RequestHandlerImpl.SKIP_ENTRY); } if (mmb == null || mmb.equals("")) { log.info("Invalid mbean name for oid " + coid + RequestHandlerImpl.SKIP_ENTRY); } if (ma == null || ma.equals("")) { log.info("Invalid attribute name " + ma + " for oid " + coid + RequestHandlerImpl.SKIP_ENTRY); } tableBindings.put(coid, be); }
/** * Constructs a new BindEntry. * * @param coid * The SNMP-oid, this entry will use. * @param mbName * The name of an MBean with attribute to query * @param attrName * The name of the attribute to query */ BindEntry(final OID coid, final String mbName, final String attrName) { oid = coid; this.mName = mbName; this.aName = attrName; try { setMbean(new ObjectName(mbName)); setAttr(new Attribute(attrName, null)); } catch (Exception e) { // log.warn(e.toString()); mName = "-unset-"; aName = "-unset-"; } }
/** * * @param oid * @return */ public BindEntry getTableBinding(OID oid, boolean isRowEntry) { Set<Entry<OID,BindEntry>> entries = null; // if(isRowEntry) { // entries = tableRowEntryMappings.entrySet(); // } else { entries = tableMappings.entrySet(); // } for (Entry<OID,BindEntry> entry : entries) { if (oid.startsWith(entry.getKey())) { BindEntry value = entry.getValue(); BindEntry bindEntry = (BindEntry) value.clone(); int[] oidValue = oid.getValue(); int[] subOid = new int[oid.size() - entry.getKey().size()]; System.arraycopy(oidValue, entry.getKey().size(), subOid, 0, oid.size() - entry.getKey().size()); if(subOid.length > 0) { bindEntry.setTableIndexOID(new OID(subOid)); } return bindEntry; } } return null; }
protected BindEntry clone(){ BindEntry bindEntry = new BindEntry(oid, mName, aName); bindEntry.setAttr(attr); bindEntry.setMbean(mbean); bindEntry.setReadWrite(isReadWrite); bindEntry.setTable(isTable); return bindEntry; } }
val = server.getAttribute(be.getMbean(), be.getAttr().getName()); } catch(Exception e) { log.error("Impossible to fetch " + be.getAttr().getName()); return null; OID tableIndexOID = be.getTableIndexOID(); if(tableIndexOID == null) { if(val instanceof Map) {
/** * * @param oid The OID bound to this particular attribute * @param mmb the name of the MBean server * @param ma the name of the MBeam attribute the OID is concerning * @param rw indicates whether this Attribute is read-write or not (readonly if false) */ private void addBindEntry(String oid, String mmb, String ma, boolean rw){ OID coid = new OID(oid); BindEntry be = new BindEntry(coid, mmb, ma); be.setReadWrite(rw); if (log.isTraceEnabled()) log.trace("New bind entry " + be); if (bindings.containsKey(coid)) { log.info("Duplicate oid " + oid + SKIP_ENTRY); } if (mmb == null || mmb.equals("")) { log.info("Invalid mbean name for oid " + oid + SKIP_ENTRY); } if (ma == null || ma.equals("")) { log.info("Invalid attribute name " + ma + " for oid " + oid + SKIP_ENTRY); } bindings.put(coid, be); oidKeys.add(coid); }