/** {@inheritDoc} */
  @Override
  public void createPartControl(Composite parent, FormToolkit toolkit) {
    main = toolkit.createComposite(parent, SWT.BORDER);
    main.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    GridLayout gl = new GridLayout(8, false);
    main.setLayout(gl);

    toolkit
        .createLabel(main, null)
        .setImage(InspectIT.getDefault().getImage(InspectITImages.IMG_DATABASE));

    totalSql = toolkit.createFormText(main, false);
    totalSql.setToolTipText("Total amount of SQL Statements executed in the invocation");
    totalSql.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

    toolkit
        .createLabel(main, null)
        .setImage(InspectIT.getDefault().getImage(InspectITImages.IMG_TIME));

    totalDuration = toolkit.createFormText(main, false);
    totalDuration.setToolTipText("Duration sum of all SQL Statements executed in the invocation");
    totalDuration.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

    toolkit
        .createLabel(main, null)
        .setImage(InspectIT.getDefault().getImage(InspectITImages.IMG_INVOCATION));

    percentageOfDuration = toolkit.createFormText(main, false);
    percentageOfDuration.setToolTipText(
        "Percentage of the time spent in the invocation on SQL Statements execution");
    percentageOfDuration.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

    toolkit
        .createLabel(main, null)
        .setImage(InspectIT.getDefault().getImage(InspectITImages.IMG_HELP));

    slowestCount = toolkit.createFormText(main, false);
    slowestCount.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    slowestCount.setToolTipText(
        "Amount of slowest SQL Statements that take 80%/20% time of total SQL execution duration");

    // remove left and right margins from the parent
    Layout parentLayout = parent.getLayout();
    if (parentLayout instanceof GridLayout) {
      ((GridLayout) parentLayout).marginWidth = 0;
      ((GridLayout) parentLayout).marginHeight = 0;
    }

    setDefaultText();

    slowestHyperlinkSettings = new HyperlinkSettings(parent.getDisplay());
    slowestHyperlinkSettings.setHyperlinkUnderlineMode(HyperlinkSettings.UNDERLINE_HOVER);
    slowestCount.setHyperlinkSettings(slowestHyperlinkSettings);
    slowestCount.addHyperlinkListener(getHyperlinkAdapter());
  }
 /** {@inheritDoc} */
 @Override
 public void dispose() {
   cmrRepositoryManager.removeCmrRepositoryChangeListener(this);
   InspectIT.getDefault()
       .getInspectITConfigurationInterfaceManager()
       .removeProfileChangeListener(this);
   InspectIT.getDefault()
       .getInspectITConfigurationInterfaceManager()
       .removeEnvironmentChangeListener(this);
   super.dispose();
 }
  /** Default constructor. */
  public ConfigurationInterfaceManagerView() {
    cmrRepositoryManager = InspectIT.getDefault().getCmrRepositoryManager();
    cmrRepositoryManager.addCmrRepositoryChangeListener(this);
    selectDisplayedCmrRepositoryDefinition();

    InspectIT.getDefault()
        .getInspectITConfigurationInterfaceManager()
        .addProfileChangeListener(this);
    InspectIT.getDefault()
        .getInspectITConfigurationInterfaceManager()
        .addEnvironmentChangeListener(this);
  }
 /** {@inheritDoc} */
 @Override
 public void dispose() {
   InspectIT.getDefault()
       .getInspectITConfigurationInterfaceManager()
       .removeApplicationDefinitionChangeListener(this);
   super.dispose();
 }
 /** {@inheritDoc} */
 @Override
 protected void createHeadClient(Form form) {
   Composite infoComposite = new Composite(form.getHead(), SWT.NONE);
   infoComposite.setLayout(new GridLayout(2, false));
   Label infoLabel = new Label(infoComposite, SWT.NONE);
   infoLabel.setImage(InspectIT.getDefault().getImage(InspectITImages.IMG_INFORMATION));
   infoLabel.setToolTipText(BusinessContextManagerViewPart.APP_ORDER_INFO_TOOLTIP);
   Label infoLabelText = new Label(infoComposite, SWT.NONE);
   infoLabelText.setText("Pay attention to the order of application definitions!");
   infoLabelText.setToolTipText(BusinessContextManagerViewPart.APP_ORDER_INFO_TOOLTIP);
   form.setHeadClient(infoComposite);
 }
 /** {@inheritDoc} */
 @Override
 public void refresh() {
   // check the status of CMR, if it's online do update, if it's offline just fire update CMR
   // online status job
   if (null != displayedCmrRepositoryDefinition
       && OnlineStatus.OFFLINE != displayedCmrRepositoryDefinition.getOnlineStatus()) {
     performUpdate(true);
   } else if (null != displayedCmrRepositoryDefinition) {
     InspectIT.getDefault()
         .getCmrRepositoryManager()
         .forceCmrRepositoryOnlineStatusUpdate(displayedCmrRepositoryDefinition);
   }
 }
  /** {@inheritDoc} */
  @Override
  public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
    CmrRepositoryDefinition cmrRepositoryDefinition = null;
    if (receiver instanceof ICmrRepositoryProvider) {
      cmrRepositoryDefinition = ((ICmrRepositoryProvider) receiver).getCmrRepositoryDefinition();
    } else if (receiver instanceof ICmrRepositoryAndAgentProvider) {
      cmrRepositoryDefinition =
          ((ICmrRepositoryAndAgentProvider) receiver).getCmrRepositoryDefinition();
    } else if (receiver instanceof IStorageDataProvider) {
      cmrRepositoryDefinition = ((IStorageDataProvider) receiver).getCmrRepositoryDefinition();
    } else if (receiver instanceof IInputDefinitionProvider) {
      RepositoryDefinition repository =
          ((IInputDefinitionProvider) receiver).getInputDefinition().getRepositoryDefinition();
      if (repository instanceof CmrRepositoryDefinition) {
        cmrRepositoryDefinition = (CmrRepositoryDefinition) repository;
      } else {
        return false;
      }
    } else if ("anyOnline".equals(property)) {
      for (CmrRepositoryDefinition cmr :
          InspectIT.getDefault().getCmrRepositoryManager().getCmrRepositoryDefinitions()) {
        if (cmr.getOnlineStatus().equals(OnlineStatus.ONLINE)) {
          return true;
        }
      }
      return false;
    } else {
      return false;
    }

    if ("onlineStatus".equals(property)) {
      if ("ONLINE".equals(expectedValue)) {
        return cmrRepositoryDefinition.getOnlineStatus() == OnlineStatus.ONLINE;
      } else if ("OFFLINE".equals(expectedValue)) {
        return cmrRepositoryDefinition.getOnlineStatus() == OnlineStatus.OFFLINE;
      } else if ("CHECKING".equals(expectedValue)) {
        return cmrRepositoryDefinition.getOnlineStatus() == OnlineStatus.CHECKING;
      }
    } else if ("recordingActive".equals(property)) {
      if (expectedValue instanceof Boolean) {
        if (cmrRepositoryDefinition.getOnlineStatus() != OnlineStatus.OFFLINE) {
          boolean recordingActive =
              cmrRepositoryDefinition.getStorageService().getRecordingState() != RecordingState.OFF;
          return ((Boolean) expectedValue).booleanValue() == recordingActive;
        } else {
          return false;
        }
      }
    }
    return false;
  }
  /** {@inheritDoc} */
  @Override
  public Object execute(final ExecutionEvent event) throws ExecutionException {
    final StructuredSelection selection =
        (StructuredSelection) HandlerUtil.getCurrentSelection(event);

    if (selection.isEmpty()) {
      return null;
    }

    final int size = selection.size();
    MessageBox confirmDelete =
        new MessageBox(HandlerUtil.getActiveShell(event), SWT.OK | SWT.CANCEL | SWT.ICON_QUESTION);
    confirmDelete.setText("Confirm Delete");
    confirmDelete.setMessage(
        "Are you sure you want to delete the "
            + size
            + " selected environment"
            + ((size > 1) ? "s" : "")
            + "?");
    boolean confirmed = SWT.OK == confirmDelete.open();

    if (confirmed) {
      Job deleteEnvironmentsJob =
          new Job("Delete Environment(s) Job") {

            @Override
            protected IStatus run(IProgressMonitor monitor) {
              List<Status> statuses = new ArrayList<>();
              for (Iterator<?> it = selection.iterator(); it.hasNext(); ) {
                Object selected = it.next();
                if (selected instanceof IEnvironmentProvider) {
                  CmrRepositoryDefinition repositoryDefinition =
                      ((IEnvironmentProvider) selected).getCmrRepositoryDefinition();
                  Environment environment = ((IEnvironmentProvider) selected).getEnvironment();

                  try {
                    if (repositoryDefinition.getOnlineStatus() != OnlineStatus.OFFLINE) {
                      repositoryDefinition
                          .getConfigurationInterfaceService()
                          .deleteEnvironment(environment);

                      InspectIT.getDefault()
                          .getInspectITConfigurationInterfaceManager()
                          .environmentDeleted(environment, repositoryDefinition);
                    }
                  } catch (BusinessException e) {
                    statuses.add(
                        new Status(
                            IStatus.ERROR,
                            InspectIT.ID,
                            "Error deleting environment "
                                + environment.getName()
                                + " from the CMR.",
                            e));
                  }
                }
              }

              if (CollectionUtils.isNotEmpty(statuses)) {
                if (1 == statuses.size()) {
                  return statuses.iterator().next();
                } else {
                  return new MultiStatus(
                      InspectIT.ID,
                      IStatus.OK,
                      statuses.toArray(new Status[statuses.size()]),
                      "Delete of several environments failed.",
                      null);
                }
              } else {
                return Status.OK_STATUS;
              }
            }
          };
      deleteEnvironmentsJob.setUser(true);
      deleteEnvironmentsJob.setProperty(
          IProgressConstants.ICON_PROPERTY,
          InspectIT.getDefault().getImageDescriptor(InspectITImages.IMG_BLOCK));
      deleteEnvironmentsJob.schedule();
    }

    return null;
  }
 /**
  * Default constructor.
  *
  * @param workbenchPartSite The {@link IWorkbenchPartSite} the view is showed in.
  */
 BusinessContextManagerView(IWorkbenchPartSite workbenchPartSite) {
   super(workbenchPartSite);
   InspectIT.getDefault()
       .getInspectITConfigurationInterfaceManager()
       .addApplicationDefinitionChangeListener(this);
 }
예제 #10
0
  /**
   * This method has the ability to load the data via the HTTP and aggregate the data if the {@link
   * IAggregator} is provided. If the {@link IAggregator} is not provided, the data will be returned
   * not aggregated.
   *
   * <p>This method should be used by all subclasses, because it guards against massive data loading
   * that can make out of memory exceptions on the UI.
   *
   * @param storageIndexQuery Query.
   * @param aggregator {@link IAggregator}
   * @return Return results of a query.
   */
  private List<E> loadData(StorageIndexQuery storageIndexQuery, IAggregator<E> aggregator) {
    List<IStorageDescriptor> descriptors = getIndexingTree().query(storageIndexQuery);
    // sort the descriptors to optimize the number of read operations
    Collections.sort(
        descriptors,
        new Comparator<IStorageDescriptor>() {
          @Override
          public int compare(IStorageDescriptor o1, IStorageDescriptor o2) {
            int channelCompare = Integer.compare(o1.getChannelId(), o2.getChannelId());
            if (channelCompare != 0) {
              return channelCompare;
            } else {
              return Long.compare(o1.getPosition(), o2.getPosition());
            }
          }
        });

    AggregationPerformer<E> aggregationPerformer = null;
    if (null != aggregator) {
      aggregationPerformer = new AggregationPerformer<>(aggregator);
    }
    List<E> returnList = new ArrayList<>();

    int size = 0;
    int count = 0;
    List<IStorageDescriptor> limitedDescriptors = new ArrayList<>();
    for (IStorageDescriptor storageDescriptor : descriptors) {
      // increase count, add descriptor size and update current list
      count++;
      size += storageDescriptor.getSize();
      limitedDescriptors.add(storageDescriptor);

      // if the size is already to big, or we reached end do query
      if ((size > MAX_QUERY_SIZE) || (count == descriptors.size())) {
        // load data and filter with restrictions
        List<E> allData;
        if (localStorageData.isFullyDownloaded()) {
          try {
            allData = dataRetriever.getDataLocally(localStorageData, descriptors);
          } catch (SerializationException e) {
            String msg =
                "Data in the downloaded storage "
                    + localStorageData
                    + " can not be loaded with this version of the inspectIT. Version of the CMR where storage was created is "
                    + localStorageData.getCmrVersion()
                    + ".";
            InspectIT.getDefault().createErrorDialog(msg, e, -1);
            return Collections.emptyList();
          } catch (IOException e) {
            InspectIT.getDefault()
                .createErrorDialog("Exception occurred trying to load the data.", e, -1);
            return Collections.emptyList();
          }
        } else {
          try {
            allData =
                dataRetriever.getDataViaHttp(
                    getCmrRepositoryDefinition(), localStorageData, limitedDescriptors);
          } catch (SerializationException e) {
            String msg =
                "Data in the remote storage "
                    + localStorageData
                    + " can not be loaded with this version of the inspectIT. Version of the CMR where storage was created is "
                    + localStorageData.getCmrVersion()
                    + ".";
            InspectIT.getDefault().createErrorDialog(msg, e, -1);
            return Collections.emptyList();
          } catch (IOException e) {
            InspectIT.getDefault()
                .createErrorDialog("Exception occurred trying to load the data.", e, -1);
            return Collections.emptyList();
          }
        }
        List<E> passedData = getRestrictionsPassedList(allData, storageIndexQuery);

        // if we need to aggregate then do so, otherwise just add to result list
        if (null != aggregationPerformer) {
          aggregationPerformer.processCollection(passedData);
        } else {
          returnList.addAll(passedData);
        }

        // reset the size and current list
        size = 0;
        limitedDescriptors.clear();
      }
    }

    // aggregate if needed
    if (null != aggregator) {
      returnList = aggregationPerformer.getResultList();
    }

    return returnList;
  }