[jboss-cvs] JBossAS SVN: r110460 - branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jan 26 17:26:56 EST 2011


Author: thauser at redhat.com
Date: 2011-01-26 17:26:56 -0500 (Wed, 26 Jan 2011)
New Revision: 110460

Modified:
   branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/AttributeMappingsBinding.java
   branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/RequestHandlerImpl.java
Log:
more RFC-3416 adjustments. 

Modified: branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/AttributeMappingsBinding.java
===================================================================
--- branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/AttributeMappingsBinding.java	2011-01-26 20:51:35 UTC (rev 110459)
+++ branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/AttributeMappingsBinding.java	2011-01-26 22:26:56 UTC (rev 110460)
@@ -88,33 +88,20 @@
 	public Object newChild(ManagedBean mbean, UnmarshallingContext navigator,
 			String namespaceUri, String localName, Attributes attrs)
 	{
-		Object placeholder = null;
+		MappedAttribute attribute = null;
 		
 		if ("attribute".equals(localName)) {
-			MappedAttribute attribute = null;
+			attribute = new MappedAttribute();
 			String oid = attrs.getValue("oid");
 			String name = attrs.getValue("name");
 			String mode = attrs.getValue("mode");
-			attribute = new MappedAttribute();
 			if ("rw".equalsIgnoreCase(mode))
-            attribute.setReadWrite(true);
+				attribute.setReadWrite(true);
 			attribute.setName(name);
 			attribute.setOid(oid);
-			return attribute;
 		}
-		else if ("table".equals(localName)){
-			MappedTable attribute = null;
-			String oidPrefix = attrs.getValue("oid-prefix");
-			String name = attrs.getValue("name");
-			int size = Integer.parseInt(attrs.getValue("size"));
-			attribute = new MappedTable();
-			attribute.setName(name);
-			attribute.setPrefix(oidPrefix);
-			attribute.setSize(size);
-			return attribute;
-		}
 
-		return placeholder;
+		return attribute;
 	
 	}
 	

Modified: branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/RequestHandlerImpl.java
===================================================================
--- branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/RequestHandlerImpl.java	2011-01-26 20:51:35 UTC (rev 110459)
+++ branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/RequestHandlerImpl.java	2011-01-26 22:26:56 UTC (rev 110460)
@@ -84,6 +84,7 @@
 	protected SortedMap bindings = new TreeMap();
 
 	private SortedSet oidKeys = null;
+	private SortedSet objectKeys = null;
 
 	/** Has this RequestHandler instance been initialized? */
 	private boolean initialized = false;
@@ -98,6 +99,7 @@
 	{
 		bindings = new TreeMap();
 		oidKeys = new TreeSet();
+		objectKeys = new TreeSet();
 	}
 
 	// RequestHandler Implementation ---------------------------------
@@ -190,8 +192,7 @@
 			response = new PDU();
 		} 
 		response.setType(PDU.RESPONSE);
-		response.setRequestID(pdu.getRequestID());
-		
+
 		final boolean trace = log.isTraceEnabled();
 			
 		if (trace) {
@@ -326,7 +327,6 @@
 		} 
 		response.setType(PDU.RESPONSE);
 		//indicate by copying the Req ID that this response is for the PDU sent with that ReqID.
-		response.setRequestID(pdu.getRequestID());
 		
 		final boolean trace = log.isTraceEnabled();
 		
@@ -504,7 +504,7 @@
 					return response;
 				}
 				catch (Exception e){
-					log.debug("snmpReceivedSet: catastrophe!!! General variable validation error.");
+					log.debug("snmpReceivedSet: catastrophe!!! General variable validation error." + e);
 					undoSets(modified);
 					makeErrorPdu(response, pdu, counter, PDU.genErr);
 					return response;
@@ -689,43 +689,40 @@
 		   while (aIt.hasNext())
 		   {
 			  Object check = aIt.next();
-			  if (check instanceof MappedTable){
-				  MappedTable ma = (MappedTable)check;
-				  int size = ma.getSize(); 
-				  String tablePrefix = ma.getPrefix();
-				  // the next size attributes in the list are part of this table. 				  
-				  for (int i = 0; i < size; i++){
-					 MappedAttribute mat = (MappedAttribute)aIt.next();
-			         String oid;
-					 if (oidPrefix != null && tablePrefix != null){
-						 oid = oidPrefix + tablePrefix + mat.getOid();
-					 }
-					 else{
-						 oid = mat.getOid();
-					 }
-					 // we shouldn't be using this, because we aren't mapping a table row to a JMX attribute.
-					 // we should just be storing the name of the table, since it's just a conceptual ordering anyways.
-					 addBindEntry(oid,mmb.getName(),mat.getName(),mat.isReadWrite()); 
-				  }
-			  } 
+ 
 			  
-			  else {
-				  MappedAttribute ma = (MappedAttribute)check;
+			  MappedAttribute ma = (MappedAttribute)check;
 			  		  
-				  String oid;
-				  if (oidPrefix != null)
-					  oid = oidPrefix + ma.getOid();
-				  else
-					  oid = ma.getOid();
-				  
-				  addBindEntry(oid, mmb.getName(), ma.getName(),ma.isReadWrite());
-
+			  String oid;
+			  if (oidPrefix != null){
+				  oid = oidPrefix + ma.getOid();
+				  addObjectEntry(oidPrefix);
 			  }
+			  else{
+				  oid = ma.getOid();
+				  OID trimOID = new OID(oid);
+				  trimOID = trimOID.trim();
+      			  addObjectEntry(trimOID.toString());
+			  }
+			 
+			  addBindEntry(oid, mmb.getName(), ma.getName(),ma.isReadWrite());
 
+			  
   		   }
       }
    }
 	
+	/** test method **/
+	private void addObjectEntry(String oid){
+		if (objectKeys.contains(oid))
+			log.debug("duplicate object " + oid + SKIP_ENTRY);
+		
+		if (oid == null)
+			log.debug("null oid for object");
+		objectKeys.add(oid);
+				
+	}
+	
 	/** 
 	 * 
 	 * @param oid The OID bound to this particular attribute
@@ -769,9 +766,8 @@
 	 */
 	
 	private boolean checkObject(final OID oid) {
-		OID coid = oid; 
-		coid.removeLast();
-		return oidKeys.contains(coid);
+		OID coid = oid.trim(); 
+		return objectKeys.contains(coid);
 	}	
 	
 	/**



More information about the jboss-cvs-commits mailing list