< prev index next >

core/org.openjdk.jmc.flightrecorder.rules.jdk/src/main/java/org/openjdk/jmc/flightrecorder/rules/jdk/latency/VMOperationRule.java

Print this page




  71         public static final TypedPreference<IQuantity> WARNING_LIMIT = new TypedPreference<>("vm.vmoperation.warning.limit", //$NON-NLS-1$
  72                         Messages.getString(Messages.VMOperationRule_CONFIG_WARNING_LIMIT),
  73                         Messages.getString(Messages.VMOperationRule_CONFIG_WARNING_LIMIT_LONG), UnitLookup.TIMESPAN,
  74                         UnitLookup.MILLISECOND.quantity(2000));
  75 
  76         private static final List<TypedPreference<?>> CONFIG_ATTRIBUTES = Arrays.<TypedPreference<?>> asList(WARNING_LIMIT);
  77 
  78         @Override
  79         public RunnableFuture<Result> evaluate(final IItemCollection items, final IPreferenceValueProvider vp) {
  80                 FutureTask<Result> evaluationTask = new FutureTask<>(new Callable<Result>() {
  81                         @Override
  82                         public Result call() throws Exception {
  83                                 return evaluate(items, vp.getPreferenceValue(WARNING_LIMIT));
  84                         }
  85                 });
  86                 return evaluationTask;
  87         }
  88 
  89         private Result evaluate(IItemCollection items, IQuantity warningLimit) {
  90                 EventAvailability eventAvailability = RulesToolkit.getEventAvailability(items, JdkTypeIDs.VM_OPERATIONS);
  91                 if (eventAvailability == EventAvailability.UNAVAILABLE || eventAvailability == EventAvailability.DISABLED) {
  92                         return RulesToolkit.getEventAvailabilityResult(this, items, eventAvailability, JdkTypeIDs.VM_OPERATIONS);
  93                 }
  94 
  95                 IQuantity infoLimit = warningLimit.multiply(0.5);
  96                 // Get the longest blocking VM operation
  97                 IItem longestEvent = items.apply(JdkFilters.VM_OPERATIONS_BLOCKING_OR_SAFEPOINT)
  98                                 .getAggregate(Aggregators.itemWithMax(JfrAttributes.DURATION));
  99 
 100                 if (longestEvent == null) {
 101                         String zeroDuration = UnitLookup.SECOND.quantity(0).displayUsing(IDisplayable.AUTO);
 102                         return new Result(this, 0,
 103                                         MessageFormat.format(Messages.getString(Messages.VMOperationRuleFactory_TEXT_OK), zeroDuration),
 104                                         null, JdkQueries.VM_OPERATIONS);
 105                 }
 106                 IQuantity longestDuration = RulesToolkit.getValue(longestEvent, JfrAttributes.DURATION);
 107                 String timeStr = RulesToolkit.getValue(longestEvent, JfrAttributes.START_TIME).displayUsing(IDisplayable.AUTO);
 108                 String peakDuration = longestDuration.displayUsing(IDisplayable.AUTO);
 109                 double score = RulesToolkit.mapExp100(longestDuration.doubleValueIn(UnitLookup.SECOND),
 110                                 infoLimit.doubleValueIn(UnitLookup.SECOND), warningLimit.doubleValueIn(UnitLookup.SECOND));
 111 




  71         public static final TypedPreference<IQuantity> WARNING_LIMIT = new TypedPreference<>("vm.vmoperation.warning.limit", //$NON-NLS-1$
  72                         Messages.getString(Messages.VMOperationRule_CONFIG_WARNING_LIMIT),
  73                         Messages.getString(Messages.VMOperationRule_CONFIG_WARNING_LIMIT_LONG), UnitLookup.TIMESPAN,
  74                         UnitLookup.MILLISECOND.quantity(2000));
  75 
  76         private static final List<TypedPreference<?>> CONFIG_ATTRIBUTES = Arrays.<TypedPreference<?>> asList(WARNING_LIMIT);
  77 
  78         @Override
  79         public RunnableFuture<Result> evaluate(final IItemCollection items, final IPreferenceValueProvider vp) {
  80                 FutureTask<Result> evaluationTask = new FutureTask<>(new Callable<Result>() {
  81                         @Override
  82                         public Result call() throws Exception {
  83                                 return evaluate(items, vp.getPreferenceValue(WARNING_LIMIT));
  84                         }
  85                 });
  86                 return evaluationTask;
  87         }
  88 
  89         private Result evaluate(IItemCollection items, IQuantity warningLimit) {
  90                 EventAvailability eventAvailability = RulesToolkit.getEventAvailability(items, JdkTypeIDs.VM_OPERATIONS);
  91                 if (eventAvailability == EventAvailability.UNKNOWN || eventAvailability == EventAvailability.DISABLED) {
  92                         return RulesToolkit.getEventAvailabilityResult(this, items, eventAvailability, JdkTypeIDs.VM_OPERATIONS);
  93                 }
  94 
  95                 IQuantity infoLimit = warningLimit.multiply(0.5);
  96                 // Get the longest blocking VM operation
  97                 IItem longestEvent = items.apply(JdkFilters.VM_OPERATIONS_BLOCKING_OR_SAFEPOINT)
  98                                 .getAggregate(Aggregators.itemWithMax(JfrAttributes.DURATION));
  99 
 100                 if (longestEvent == null) {
 101                         String zeroDuration = UnitLookup.SECOND.quantity(0).displayUsing(IDisplayable.AUTO);
 102                         return new Result(this, 0,
 103                                         MessageFormat.format(Messages.getString(Messages.VMOperationRuleFactory_TEXT_OK), zeroDuration),
 104                                         null, JdkQueries.VM_OPERATIONS);
 105                 }
 106                 IQuantity longestDuration = RulesToolkit.getValue(longestEvent, JfrAttributes.DURATION);
 107                 String timeStr = RulesToolkit.getValue(longestEvent, JfrAttributes.START_TIME).displayUsing(IDisplayable.AUTO);
 108                 String peakDuration = longestDuration.displayUsing(IDisplayable.AUTO);
 109                 double score = RulesToolkit.mapExp100(longestDuration.doubleValueIn(UnitLookup.SECOND),
 110                                 infoLimit.doubleValueIn(UnitLookup.SECOND), warningLimit.doubleValueIn(UnitLookup.SECOND));
 111 


< prev index next >