src/share/classes/sun/management/snmp/jvminstr/JvmMemPoolEntryImpl.java

Print this page
rev 10195 : 8048267: Replace uses of 'new Long()' with appropriate alternative across core classes
Reviewed-by: chegar, psandoz
Contributed-by: otaviojava@java.net


 174     }
 175 
 176     final MemoryPoolMXBean pool;
 177 
 178     /**
 179      * Constructor for the "JvmMemPoolEntry" group.
 180      */
 181     public JvmMemPoolEntryImpl(MemoryPoolMXBean mp, final int index) {
 182         this.pool=mp;
 183         this.jvmMemPoolIndex = index;
 184         this.entryMemoryTag = memoryTag + "." + index;
 185         this.entryPeakMemoryTag = peakMemoryTag + "." + index;
 186         this.entryCollectMemoryTag = collectMemoryTag + "." + index;
 187     }
 188 
 189     /**
 190      * Getter for the "JvmMemPoolMaxSize" variable.
 191      */
 192     public Long getJvmMemPoolMaxSize() throws SnmpStatusException {
 193         final long val = getMemoryUsage().getMax();
 194         if (val > -1) return  new Long(val);
 195         else return JvmMemoryImpl.Long0;
 196     }
 197 
 198     /**
 199      * Getter for the "JvmMemPoolUsed" variable.
 200      */
 201     public Long getJvmMemPoolUsed() throws SnmpStatusException {
 202         final long val = getMemoryUsage().getUsed();
 203         if (val > -1) return  new Long(val);
 204         else return JvmMemoryImpl.Long0;
 205     }
 206 
 207     /**
 208      * Getter for the "JvmMemPoolInitSize" variable.
 209      */
 210     public Long getJvmMemPoolInitSize() throws SnmpStatusException {
 211         final long val = getMemoryUsage().getInit();
 212         if (val > -1) return  new Long(val);
 213         else return JvmMemoryImpl.Long0;
 214     }
 215 
 216     /**
 217      * Getter for the "JvmMemPoolCommitted" variable.
 218      */
 219     public Long getJvmMemPoolCommitted() throws SnmpStatusException {
 220         final long val = getMemoryUsage().getCommitted();
 221         if (val > -1) return  new Long(val);
 222         else return JvmMemoryImpl.Long0;
 223     }
 224 
 225     /**
 226      * Getter for the "JvmMemPoolPeakMaxSize" variable.
 227      */
 228     public Long getJvmMemPoolPeakMaxSize() throws SnmpStatusException {
 229         final long val = getPeakMemoryUsage().getMax();
 230         if (val > -1) return  new Long(val);
 231         else return JvmMemoryImpl.Long0;
 232     }
 233 
 234     /**
 235      * Getter for the "JvmMemPoolPeakUsed" variable.
 236      */
 237     public Long getJvmMemPoolPeakUsed() throws SnmpStatusException {
 238         final long val = getPeakMemoryUsage().getUsed();
 239         if (val > -1) return  new Long(val);
 240         else return JvmMemoryImpl.Long0;
 241     }
 242 
 243     /**
 244      * Getter for the "JvmMemPoolPeakCommitted" variable.
 245      */
 246     public Long getJvmMemPoolPeakCommitted() throws SnmpStatusException {
 247         final long val = getPeakMemoryUsage().getCommitted();
 248         if (val > -1) return  new Long(val);
 249         else return JvmMemoryImpl.Long0;
 250     }
 251 
 252     /**
 253      * Getter for the "JvmMemPoolCollectMaxSize" variable.
 254      */
 255     public Long getJvmMemPoolCollectMaxSize() throws SnmpStatusException {
 256         final long val = getCollectMemoryUsage().getMax();
 257         if (val > -1) return  new Long(val);
 258         else return JvmMemoryImpl.Long0;
 259     }
 260 
 261     /**
 262      * Getter for the "JvmMemPoolCollectUsed" variable.
 263      */
 264     public Long getJvmMemPoolCollectUsed() throws SnmpStatusException {
 265         final long val = getCollectMemoryUsage().getUsed();
 266         if (val > -1) return  new Long(val);
 267         else return JvmMemoryImpl.Long0;
 268     }
 269 
 270     /**
 271      * Getter for the "JvmMemPoolCollectCommitted" variable.
 272      */
 273     public Long getJvmMemPoolCollectCommitted() throws SnmpStatusException {
 274         final long val = getCollectMemoryUsage().getCommitted();
 275         if (val > -1) return  new Long(val);
 276         else return JvmMemoryImpl.Long0;
 277     }
 278 
 279     /**
 280      * Getter for the "JvmMemPoolThreshold" variable.
 281      */
 282     public Long getJvmMemPoolThreshold() throws SnmpStatusException {
 283         if (!pool.isUsageThresholdSupported())
 284             return JvmMemoryImpl.Long0;
 285         final long val = pool.getUsageThreshold();
 286         if (val > -1) return  new Long(val);
 287         else return JvmMemoryImpl.Long0;
 288     }
 289 
 290     /**
 291      * Setter for the "JvmMemPoolThreshold" variable.
 292      */
 293     public void setJvmMemPoolThreshold(Long x) throws SnmpStatusException {
 294         final long val = x.longValue();
 295         if (val < 0 )
 296             throw new SnmpStatusException(SnmpDefinitions.snmpRspWrongValue);
 297         // This should never throw an exception has the checks have
 298         // already been performed in checkJvmMemPoolThreshold().
 299         //
 300         pool.setUsageThreshold(val);
 301     }
 302 
 303     /**
 304      * Checker for the "JvmMemPoolThreshold" variable.
 305      */
 306     public void checkJvmMemPoolThreshold(Long x) throws SnmpStatusException {


 317 
 318     /**
 319      * Getter for the "JvmMemPoolThreshdSupport" variable.
 320      */
 321     public EnumJvmMemPoolThreshdSupport getJvmMemPoolThreshdSupport()
 322         throws SnmpStatusException {
 323         if (pool.isUsageThresholdSupported())
 324             return EnumJvmMemPoolThreshdSupported;
 325         else
 326             return EnumJvmMemPoolThreshdUnsupported;
 327     }
 328 
 329     /**
 330      * Getter for the "JvmMemPoolThreshdCount" variable.
 331      */
 332     public Long getJvmMemPoolThreshdCount()
 333         throws SnmpStatusException {
 334         if (!pool.isUsageThresholdSupported())
 335             return JvmMemoryImpl.Long0;
 336         final long val = pool.getUsageThresholdCount();
 337         if (val > -1) return  new Long(val);
 338         else return JvmMemoryImpl.Long0;
 339     }
 340 
 341     /**
 342      * Getter for the "JvmMemPoolCollectThreshold" variable.
 343      */
 344     public Long getJvmMemPoolCollectThreshold() throws SnmpStatusException {
 345         if (!pool.isCollectionUsageThresholdSupported())
 346             return JvmMemoryImpl.Long0;
 347         final long val = pool.getCollectionUsageThreshold();
 348         if (val > -1) return  new Long(val);
 349         else return JvmMemoryImpl.Long0;
 350     }
 351 
 352     /**
 353      * Setter for the "JvmMemPoolCollectThreshold" variable.
 354      */
 355     public void setJvmMemPoolCollectThreshold(Long x)
 356         throws SnmpStatusException {
 357         final long val = x.longValue();
 358         if (val < 0 )
 359             throw new SnmpStatusException(SnmpDefinitions.snmpRspWrongValue);
 360         // This should never throw an exception has the checks have
 361         // already been performed in checkJvmMemPoolCollectThreshold().
 362         //
 363         pool.setCollectionUsageThreshold(val);
 364     }
 365 
 366     /**
 367      * Checker for the "JvmMemPoolCollectThreshold" variable.
 368      */


 382     /**
 383      * Getter for the "JvmMemPoolThreshdSupport" variable.
 384      */
 385     public EnumJvmMemPoolCollectThreshdSupport
 386         getJvmMemPoolCollectThreshdSupport()
 387         throws SnmpStatusException {
 388         if (pool.isCollectionUsageThresholdSupported())
 389             return EnumJvmMemPoolCollectThreshdSupported;
 390         else
 391             return EnumJvmMemPoolCollectThreshdUnsupported;
 392     }
 393 
 394     /**
 395      * Getter for the "JvmMemPoolCollectThreshdCount" variable.
 396      */
 397     public Long getJvmMemPoolCollectThreshdCount()
 398         throws SnmpStatusException {
 399         if (!pool.isCollectionUsageThresholdSupported())
 400             return JvmMemoryImpl.Long0;
 401         final long val = pool.getCollectionUsageThresholdCount();
 402         if (val > -1) return  new Long(val);
 403         else return JvmMemoryImpl.Long0;
 404     }
 405 
 406     public static EnumJvmMemPoolType jvmMemPoolType(MemoryType type)
 407         throws SnmpStatusException {
 408         if (type.equals(MemoryType.HEAP))
 409             return  EnumJvmMemPoolTypeHeap;
 410         else if (type.equals(MemoryType.NON_HEAP))
 411             return EnumJvmMemPoolTypeNonHeap;
 412         throw new SnmpStatusException(SnmpStatusException.snmpRspWrongValue);
 413     }
 414 
 415     /**
 416      * Getter for the "JvmMemPoolType" variable.
 417      */
 418     public EnumJvmMemPoolType getJvmMemPoolType() throws SnmpStatusException {
 419         return jvmMemPoolType(pool.getType());
 420     }
 421 
 422     /**


 433         return new Integer(jvmMemPoolIndex);
 434     }
 435 
 436 
 437     /**
 438      * Getter for the "JvmMemPoolState" variable.
 439      */
 440     public EnumJvmMemPoolState getJvmMemPoolState()
 441         throws SnmpStatusException {
 442         if (pool.isValid())
 443             return JvmMemPoolStateValid;
 444         else
 445             return JvmMemPoolStateInvalid;
 446     }
 447 
 448     /**
 449      * Getter for the "JvmMemPoolPeakReset" variable.
 450      */
 451     public synchronized Long getJvmMemPoolPeakReset()
 452         throws SnmpStatusException {
 453         return new Long(jvmMemPoolPeakReset);
 454     }
 455 
 456     /**
 457      * Setter for the "JvmMemPoolPeakReset" variable.
 458      */
 459     public synchronized void setJvmMemPoolPeakReset(Long x)
 460         throws SnmpStatusException {
 461         final long l = x.longValue();
 462         if (l > jvmMemPoolPeakReset) {
 463             final long stamp = System.currentTimeMillis();
 464             pool.resetPeakUsage();
 465             jvmMemPoolPeakReset = stamp;
 466             log.debug("setJvmMemPoolPeakReset",
 467                       "jvmMemPoolPeakReset="+stamp);
 468         }
 469     }
 470 
 471     /**
 472      * Checker for the "JvmMemPoolPeakReset" variable.
 473      */




 174     }
 175 
 176     final MemoryPoolMXBean pool;
 177 
 178     /**
 179      * Constructor for the "JvmMemPoolEntry" group.
 180      */
 181     public JvmMemPoolEntryImpl(MemoryPoolMXBean mp, final int index) {
 182         this.pool=mp;
 183         this.jvmMemPoolIndex = index;
 184         this.entryMemoryTag = memoryTag + "." + index;
 185         this.entryPeakMemoryTag = peakMemoryTag + "." + index;
 186         this.entryCollectMemoryTag = collectMemoryTag + "." + index;
 187     }
 188 
 189     /**
 190      * Getter for the "JvmMemPoolMaxSize" variable.
 191      */
 192     public Long getJvmMemPoolMaxSize() throws SnmpStatusException {
 193         final long val = getMemoryUsage().getMax();
 194         if (val > -1) return  val;
 195         else return JvmMemoryImpl.Long0;
 196     }
 197 
 198     /**
 199      * Getter for the "JvmMemPoolUsed" variable.
 200      */
 201     public Long getJvmMemPoolUsed() throws SnmpStatusException {
 202         final long val = getMemoryUsage().getUsed();
 203         if (val > -1) return  val;
 204         else return JvmMemoryImpl.Long0;
 205     }
 206 
 207     /**
 208      * Getter for the "JvmMemPoolInitSize" variable.
 209      */
 210     public Long getJvmMemPoolInitSize() throws SnmpStatusException {
 211         final long val = getMemoryUsage().getInit();
 212         if (val > -1) return  val;
 213         else return JvmMemoryImpl.Long0;
 214     }
 215 
 216     /**
 217      * Getter for the "JvmMemPoolCommitted" variable.
 218      */
 219     public Long getJvmMemPoolCommitted() throws SnmpStatusException {
 220         final long val = getMemoryUsage().getCommitted();
 221         if (val > -1) return  val;
 222         else return JvmMemoryImpl.Long0;
 223     }
 224 
 225     /**
 226      * Getter for the "JvmMemPoolPeakMaxSize" variable.
 227      */
 228     public Long getJvmMemPoolPeakMaxSize() throws SnmpStatusException {
 229         final long val = getPeakMemoryUsage().getMax();
 230         if (val > -1) return  val;
 231         else return JvmMemoryImpl.Long0;
 232     }
 233 
 234     /**
 235      * Getter for the "JvmMemPoolPeakUsed" variable.
 236      */
 237     public Long getJvmMemPoolPeakUsed() throws SnmpStatusException {
 238         final long val = getPeakMemoryUsage().getUsed();
 239         if (val > -1) return  val;
 240         else return JvmMemoryImpl.Long0;
 241     }
 242 
 243     /**
 244      * Getter for the "JvmMemPoolPeakCommitted" variable.
 245      */
 246     public Long getJvmMemPoolPeakCommitted() throws SnmpStatusException {
 247         final long val = getPeakMemoryUsage().getCommitted();
 248         if (val > -1) return  val;
 249         else return JvmMemoryImpl.Long0;
 250     }
 251 
 252     /**
 253      * Getter for the "JvmMemPoolCollectMaxSize" variable.
 254      */
 255     public Long getJvmMemPoolCollectMaxSize() throws SnmpStatusException {
 256         final long val = getCollectMemoryUsage().getMax();
 257         if (val > -1) return  val;
 258         else return JvmMemoryImpl.Long0;
 259     }
 260 
 261     /**
 262      * Getter for the "JvmMemPoolCollectUsed" variable.
 263      */
 264     public Long getJvmMemPoolCollectUsed() throws SnmpStatusException {
 265         final long val = getCollectMemoryUsage().getUsed();
 266         if (val > -1) return  val;
 267         else return JvmMemoryImpl.Long0;
 268     }
 269 
 270     /**
 271      * Getter for the "JvmMemPoolCollectCommitted" variable.
 272      */
 273     public Long getJvmMemPoolCollectCommitted() throws SnmpStatusException {
 274         final long val = getCollectMemoryUsage().getCommitted();
 275         if (val > -1) return  val;
 276         else return JvmMemoryImpl.Long0;
 277     }
 278 
 279     /**
 280      * Getter for the "JvmMemPoolThreshold" variable.
 281      */
 282     public Long getJvmMemPoolThreshold() throws SnmpStatusException {
 283         if (!pool.isUsageThresholdSupported())
 284             return JvmMemoryImpl.Long0;
 285         final long val = pool.getUsageThreshold();
 286         if (val > -1) return  val;
 287         else return JvmMemoryImpl.Long0;
 288     }
 289 
 290     /**
 291      * Setter for the "JvmMemPoolThreshold" variable.
 292      */
 293     public void setJvmMemPoolThreshold(Long x) throws SnmpStatusException {
 294         final long val = x.longValue();
 295         if (val < 0 )
 296             throw new SnmpStatusException(SnmpDefinitions.snmpRspWrongValue);
 297         // This should never throw an exception has the checks have
 298         // already been performed in checkJvmMemPoolThreshold().
 299         //
 300         pool.setUsageThreshold(val);
 301     }
 302 
 303     /**
 304      * Checker for the "JvmMemPoolThreshold" variable.
 305      */
 306     public void checkJvmMemPoolThreshold(Long x) throws SnmpStatusException {


 317 
 318     /**
 319      * Getter for the "JvmMemPoolThreshdSupport" variable.
 320      */
 321     public EnumJvmMemPoolThreshdSupport getJvmMemPoolThreshdSupport()
 322         throws SnmpStatusException {
 323         if (pool.isUsageThresholdSupported())
 324             return EnumJvmMemPoolThreshdSupported;
 325         else
 326             return EnumJvmMemPoolThreshdUnsupported;
 327     }
 328 
 329     /**
 330      * Getter for the "JvmMemPoolThreshdCount" variable.
 331      */
 332     public Long getJvmMemPoolThreshdCount()
 333         throws SnmpStatusException {
 334         if (!pool.isUsageThresholdSupported())
 335             return JvmMemoryImpl.Long0;
 336         final long val = pool.getUsageThresholdCount();
 337         if (val > -1) return  val;
 338         else return JvmMemoryImpl.Long0;
 339     }
 340 
 341     /**
 342      * Getter for the "JvmMemPoolCollectThreshold" variable.
 343      */
 344     public Long getJvmMemPoolCollectThreshold() throws SnmpStatusException {
 345         if (!pool.isCollectionUsageThresholdSupported())
 346             return JvmMemoryImpl.Long0;
 347         final long val = pool.getCollectionUsageThreshold();
 348         if (val > -1) return  val;
 349         else return JvmMemoryImpl.Long0;
 350     }
 351 
 352     /**
 353      * Setter for the "JvmMemPoolCollectThreshold" variable.
 354      */
 355     public void setJvmMemPoolCollectThreshold(Long x)
 356         throws SnmpStatusException {
 357         final long val = x.longValue();
 358         if (val < 0 )
 359             throw new SnmpStatusException(SnmpDefinitions.snmpRspWrongValue);
 360         // This should never throw an exception has the checks have
 361         // already been performed in checkJvmMemPoolCollectThreshold().
 362         //
 363         pool.setCollectionUsageThreshold(val);
 364     }
 365 
 366     /**
 367      * Checker for the "JvmMemPoolCollectThreshold" variable.
 368      */


 382     /**
 383      * Getter for the "JvmMemPoolThreshdSupport" variable.
 384      */
 385     public EnumJvmMemPoolCollectThreshdSupport
 386         getJvmMemPoolCollectThreshdSupport()
 387         throws SnmpStatusException {
 388         if (pool.isCollectionUsageThresholdSupported())
 389             return EnumJvmMemPoolCollectThreshdSupported;
 390         else
 391             return EnumJvmMemPoolCollectThreshdUnsupported;
 392     }
 393 
 394     /**
 395      * Getter for the "JvmMemPoolCollectThreshdCount" variable.
 396      */
 397     public Long getJvmMemPoolCollectThreshdCount()
 398         throws SnmpStatusException {
 399         if (!pool.isCollectionUsageThresholdSupported())
 400             return JvmMemoryImpl.Long0;
 401         final long val = pool.getCollectionUsageThresholdCount();
 402         if (val > -1) return  val;
 403         else return JvmMemoryImpl.Long0;
 404     }
 405 
 406     public static EnumJvmMemPoolType jvmMemPoolType(MemoryType type)
 407         throws SnmpStatusException {
 408         if (type.equals(MemoryType.HEAP))
 409             return  EnumJvmMemPoolTypeHeap;
 410         else if (type.equals(MemoryType.NON_HEAP))
 411             return EnumJvmMemPoolTypeNonHeap;
 412         throw new SnmpStatusException(SnmpStatusException.snmpRspWrongValue);
 413     }
 414 
 415     /**
 416      * Getter for the "JvmMemPoolType" variable.
 417      */
 418     public EnumJvmMemPoolType getJvmMemPoolType() throws SnmpStatusException {
 419         return jvmMemPoolType(pool.getType());
 420     }
 421 
 422     /**


 433         return new Integer(jvmMemPoolIndex);
 434     }
 435 
 436 
 437     /**
 438      * Getter for the "JvmMemPoolState" variable.
 439      */
 440     public EnumJvmMemPoolState getJvmMemPoolState()
 441         throws SnmpStatusException {
 442         if (pool.isValid())
 443             return JvmMemPoolStateValid;
 444         else
 445             return JvmMemPoolStateInvalid;
 446     }
 447 
 448     /**
 449      * Getter for the "JvmMemPoolPeakReset" variable.
 450      */
 451     public synchronized Long getJvmMemPoolPeakReset()
 452         throws SnmpStatusException {
 453         return jvmMemPoolPeakReset;
 454     }
 455 
 456     /**
 457      * Setter for the "JvmMemPoolPeakReset" variable.
 458      */
 459     public synchronized void setJvmMemPoolPeakReset(Long x)
 460         throws SnmpStatusException {
 461         final long l = x.longValue();
 462         if (l > jvmMemPoolPeakReset) {
 463             final long stamp = System.currentTimeMillis();
 464             pool.resetPeakUsage();
 465             jvmMemPoolPeakReset = stamp;
 466             log.debug("setJvmMemPoolPeakReset",
 467                       "jvmMemPoolPeakReset="+stamp);
 468         }
 469     }
 470 
 471     /**
 472      * Checker for the "JvmMemPoolPeakReset" variable.
 473      */