next up previous contents index
Next: Abkürzungsverzeichnis Up: No Title Previous: GkStatistics.idl

Implementierung der MIB-Gruppe ``GKStatistics''

 

package tis20.impl;

// Copyright (c) 07/24/98, by Sun Microsystems, Inc.
// All rights reserved.

// "@(#)SystemImpl.java 1.1 98/07/24 SMI"

import java.io.*;
import java.util.*;
i\chapter{Implementierung der MIB-Gruppe ``GKStatistics''}
\label{anhang_e}
\begin{verbatim}
package tis20.impl;

// Copyright (c) 07/24/98, by Sun Microsystems, Inc.
// All rights reserved.

// "@(#)SystemImpl.java 1.1 98/07/24 SMI"

import java.io.*;
import java.util.*;
import java.net.*;
import java.lang.*;
import java.text.*;

// Dependency on Java Dynamic Management Kit.
import com.sun.jaw.impl.adaptor.snmp.*;
import com.sun.jaw.reference.agent.cmf.*;
import com.sun.jaw.reference.common.*;
import com.sun.jaw.snmp.agent.*;
import com.sun.jaw.snmp.common.*;

// Dependency on Java Native Interface
import jni.*;

// Dependency on Generated Files
import tis20.mibgen.*;

// Other dependencies
import tools.*;
import trial.*;

public class GkStatisticsImpl extends GkStatistics {

   public GkStatisticsImpl(SnmpMib myMib, Framework cmf) {
      super(myMib);
      init(myMib, cmf);

      // Get these Objects to insert and remove Tableentries
      GkStatisticsMIB = myMib;
      GkStatisticsCMF = cmf;
   }

   private static GkStatEntryImpl GkStatEntry[] = new GkStatEntryImpl[10];

   private void init(SnmpMib myMib, Framework cmf) {
      // Initialize the system description using some system properties
      //
      try {
         GkStatsCurrentNoOfCalls = getGkStatsCurrentNoOfCalls();
         GkStatsCurrentBandwidth = getGkStatsCurrentBandwidth();
         initGkStatTable(myMib, cmf);
      } catch (SecurityException e) {
         // Do not process the exception
      } catch (SnmpStatusException e) {
         // Do not process the exception
      }
      startUpTime= java.lang.System.currentTimeMillis();
   }

   /**
   * Getter for the "GkStatsCurrentNoOfCalls" variable.
   */
   public Integer getGkStatsCurrentNoOfCalls() throws SnmpStatusException {
      String oid = "1.3.6.1.4.1.2206.5.1.3.4.1";
      //GkStatsCurrentNoOfCalls = new Integer(nativeBase.getIntNative(tools.ConvertTools.String2Int(oid)));
      return GkStatsCurrentNoOfCalls;
   }

   /**
    * Setter for the "GkStatsCurrentNoOfCalls" variable.
    */
   public  void setGkStatsCurrentNoOfCalls(Integer x) throws SnmpStatusException {
      String oid =  "1.3.6.1.4.1.2206.5.1.3.4.1.0";
      GkStatsCurrentNoOfCalls = x;
      //nativeBase.setNative(tools.ConvertTools.String2Int(oid), x.intValue());
   }

   /**
    * Checker for the "GkStatsCurrentNoOfCalls" variable.
    */
   public  void checkGkStatsCurrentNoOfCalls(Integer x) throws SnmpStatusException {
      //
      // Add your own checking policy.
      //
   }

   /**
   * Getter for the "GkStatsCurrentBandwidth" variable.
   */
   public Integer getGkStatsCurrentBandwidth() throws SnmpStatusException {
      //int[] mOIDintArray =  {1,3,6,1,4,1,2206,5,1,1,1,2,0};
      String oid =  "1.3.6.1.4.1.2206.5.1.3.4.2";
      //GkStatsCurrentBandwidth = new Integer(nativeBase.getStringNative(tools.ConvertTools.String2Int(oid)));
      return GkStatsCurrentBandwidth;
   }

   /**
    * Setter for the "GkStatsCurrentBandwidth" variable.
    */
   public  void setGkStatsCurrentBandwidth(Integer x) throws SnmpStatusException {
      //int[] mOIDintArray =  {1,3,6,1,4,1,2206,5,1,1,1,2,0};
      String oid =  "1.3.6.1.4.1.2206.5.1.3.4.2.0";
      GkStatsCurrentBandwidth = x;
      //nativeBase.setNative(tools.ConvertTools.String2Int(oid), x.intValue());
   }

   /**
    * Checker for the "GkStatsCurrentBandwidth" variable.
    */
   public  void checkGkStatsCurrentBandwidth(Integer x) throws SnmpStatusException {
      //
      // Add your own checking policy.
      //
   }

   private void initGkStatTable(SnmpMib myMib, Framework cmf) {

      //Loading the GkStatTable
      //to initialize, it's better to use the oid as an integer-array
      int[][] oid = {{1,3,6,1,4,1,2206,5,1,3,4,4,1,1}, {1,3,6,1,4,1,2206,5,1,3,4,4,1,2}
         ,{1,3,6,1,4,1,2206,5,1,3,4,4,1,3}, {1,3,6,1,4,1,2206,5,1,3,4,4,1,4}
         ,{1,3,6,1,4,1,2206,5,1,3,4,4,1,5}};
      String[] StartOid = {"1.3.6.1.4.1.2206.5.1.3.4.4.1.1", "1.3.6.1.4.1.2206.5.1.3.4.4.1.2"
         ,"1.3.6.1.4.1.2206.5.1.3.4.4.1.3", "1.3.6.1.4.1.2206.5.1.3.4.4.1.4"
         ,"1.3.6.1.4.1.2206.5.1.3.4.4.1.5"};

      int entries = 0;
      int NrOfRows;
      int tempInt = 0;

      GkStatEntry[entries] = new GkStatEntryImpl(myMib, cmf, GkStatTable);

      boolean NoMoreRows = false;

      // Get the GkStatIndex
      try {
         //tempInt = nativeBase.getNextIntNative(oid,0);
         GkStatEntry[entries].setGkStatIndex(new Integer(tempInt));
         NoMoreRows = (StartOid[0].equals(tools.ConvertTools.Int2String(oid)[0]));
      } catch (Exception e) {
         e.printStackTrace();
      }

      while (!NoMoreRows) {
         entries++;
         GkStatEntry[entries] = new GkStatEntryImpl(myMib);
         try {
            //tempInt = nativeBase.getNextIntNative(oid,0);
            GkStatEntry[entries].setGkStatIndex(new Integer(tempInt));
            NoMoreRows = (StartOid[0].equals(tools.ConvertTools.Int2String(oid)[0]));
         } catch (IllegalArgumentException iae) {
            // no more rows !??
            NoMoreRows = true;
         } catch (Exception e) {
            e.printStackTrace();
         }
      }

      NrOfRows = entries;

      // Get the GkStatNoOfCalls
      // inputOID now at first Element of second column
      entries = 0;
      while (entries != NrOfRows) {
         int tempGkStatNoOfCalls = 0;
         try {
            //tempGkStatNoOfCalls = nativeBase.getNextIntNative(oid,1);
            //GkStatEntry[entries].setGkStatNoOfCalls(new Integer(tempGkStatNoOfCalls));
         } catch (Exception e) {
            e.printStackTrace();
         }
         entries++;
      }

      // Get the GkStatMaxNoOfCalls
      // inputOID now at first Element of third column
      entries = 0;
      while (entries != NrOfRows) {
         int tempGkStatMaxNoOfCalls = 0;
         try {
            //tempGkStatMaxNoOfCalls = nativeBase.getNextIntNative(oid,2);
            //GkStatEntry[entries].setGkStatMaxNoOfCalls(new Integer(tempGkStatMaxNoOfCalls));
         } catch (Exception e) {
            e.printStackTrace();
         }
         entries++;
      }

      // Get the GkStatAverageLength
      // inputOID now at first Element of fourth column
      entries = 0;
      while (entries != NrOfRows) {
         int tempGkStatAverageLength = 0;
         try {
            //tempGkStatAverageLength = nativeBase.getNextIntNative(oid,3);
            //GkStatEntry[entries].setGkStatAverageLength(new Integer(tempGkStatAverageLength));
         } catch (Exception e) {
            e.printStackTrace();
         }
         entries++;
      }

      // Get the GkStatPeakBandwidth
      // inputOID now at first Element of fifth column
      entries = 0;
      while (entries != NrOfRows) {
         int tempGkStatPeakBandwidth = 0;
         try {
            //tempGkStatPeakBandwidth = nativeBase.getNextIntNative(oid,4);
            //GkStatEntry[entries].setGkStatPeakBandwidth(new Integer(tempGkStatPeakBandwidth));
         } catch (Exception e) {
            e.printStackTrace();
         }
         entries++;
      }

      entries = 0;
      while (entries != NrOfRows) {
         try {
            //Register in GkStatTable
            GkStatTable.addEntry(GkStatEntry[entries]);
         } catch (Exception e) {
            e.printStackTrace();
         }
         try {
            //Register in Core management Framework
            GkStatEntry[entries].addInCmf(cmf);
         } catch (Exception e) {
            e.printStackTrace();
         }
         entries++;
      }

      // Only for test without running gatekeeper !!!
      try {
         GkStatEntry[0].setGkStatIndex(new Integer(1));
         /*
         GkStatEntry[0].setGkStatNoOfCalls(new Integer(0));
         GkStatEntry[0].setGkStatMaxNoOfCalls(new Integer(0));
         GkStatEntry[0].setGkStatAverageLength(new Integer(0));
         GkStatEntry[0].setGkStatPeakBandwidth(new Integer(0));
         */
         try {
            //Register in GkStatTable
            GkStatTable.addEntry(GkStatEntry[entries]);
         } catch (Exception e) {
            e.printStackTrace();
         }
         try {
            //Register in Core management Framework
            GkStatEntry[entries].addInCmf(cmf);
         } catch (Exception e) {
            e.printStackTrace();
         }
      } catch (SnmpStatusException e) {
         // Proceed ?
      }
   }

   public void performCreateGkStatEntry(int NewGkStatIndex)
   {
      String[] oid = {"1.3.6.1.4.1.2206.5.1.3.4.4.1.1", "1.3.6.1.4.1.2206.5.1.3.4.4.1.2"
         ,"1.3.6.1.4.1.2206.5.1.3.4.4.1.3", "1.3.6.1.4.1.2206.5.1.3.4.4.1.4"
         ,"1.3.6.1.4.1.2206.5.1.3.4.4.1.5"};

      GkStatEntryImpl GkStatEntry = 
      new GkStatEntryImpl(GkStatisticsMIB, GkStatisticsCMF, GkStatTable);

      int NewGkStatNoOfCalls = 0;
      int NewGkStatMaxNoOfCalls = 0;
      int NewGkStatAverageLength = 0;
      int NewGkStatPeakBandwidth = 0;

      try {
         int[] LegalGkStatIndex = new int[48];
         for (int i = 0; i<LegalGkStatIndex.length; i++) {
            LegalGkStatIndex[i] = i+1;
         }

         // Check index range
         if (!tools.ArrayTools.isElement(NewGkStatIndex, LegalGkStatIndex)) {
            throw new ArrayIndexOutOfBoundsException();
         }


         // Set the M-bean properties
         GkStatEntry.setGkStatIndex(new Integer(NewGkStatIndex));

         // get the Index and oid
         SnmpIndex testIndex = GkStatTable.buildSnmpIndex(GkStatEntry);
         SnmpOid testOid = GkStatTable.buildOidFromIndex(testIndex);

         // concatenate base-oid with index
         oid[0] = oid[0] + "." + testOid.toString();
         oid[1] = oid[1] + "." + testOid.toString();
         oid[2] = oid[2] + "." + testOid.toString();
         oid[3] = oid[3] + "." + testOid.toString();
         oid[4] = oid[4] + "." + testOid.toString();

         // convert in useable format for the native interface
         int[][] tempOid = tools.ConvertTools.String2Int(oid);

         // set values in gatekeeper
         nativeBase.setNative(tempOid[0], NewGkStatIndex);

         //Register in PlatformMiscUserTable
         System.out.print("Register entry in GkStatTable ...");
         GkStatTable.addEntry(GkStatEntry);
         System.out.println(" done.");

         //Register in Core Management Framework
         System.out.print("Register entry in CMF ...");
         GkStatEntry.addInCmf(GkStatisticsCMF);
         System.out.println(" done.");
      } catch (SnmpStatusException snmpe) {
         System.out.println("Index already used, please check entries for free index!");
      } catch (ArrayIndexOutOfBoundsException aioobe) {
         System.out.println("Wrong index (must be between 1..48), please retry");
      } catch (NullPointerException npe) {
         System.out.println("Entries not complete, please retry");
      } catch (Exception e) {
         e.printStackTrace();
      }
   }

   // Private variables.
   //
   private SnmpMib GkStatisticsMIB;
   private Framework GkStatisticsCMF;
}


next up previous contents index
Next: Abkürzungsverzeichnis Up: No Title Previous: GkStatistics.idl

Beispielbenutzer SuSE Linux 6.0
Sun May 9 21:16:36 MEST 1999