Search in sources :

Example 1 with NodeAndBundleInformation

use of org.knime.core.node.NodeAndBundleInformation in project knime-core by knime.

the class InstallMissingNodesJob method findExtensions.

private IStatus findExtensions(final IProgressMonitor monitor, final List<NodeAndBundleInformation> missingNodes, final Set<IInstallableUnit> featuresToInstall) {
    ProvisioningSession session = ProvisioningUI.getDefaultUI().getSession();
    Bundle myself = FrameworkUtil.getBundle(getClass());
    try {
        IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) session.getProvisioningAgent().getService(IMetadataRepositoryManager.SERVICE_NAME);
        for (URI uri : metadataManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL)) {
            if (!missingNodes.isEmpty()) {
                IMetadataRepository repo = metadataManager.loadRepository(uri, monitor);
                for (Iterator<NodeAndBundleInformation> it = missingNodes.iterator(); it.hasNext(); ) {
                    NodeAndBundleInformation info = it.next();
                    if (searchInRepository(repo, info, metadataManager, monitor, featuresToInstall)) {
                        it.remove();
                    }
                }
            }
        }
        return Status.OK_STATUS;
    } catch (ProvisionException ex) {
        NodeLogger.getLogger(getClass()).error("Could not create provisioning agent: " + ex.getMessage(), ex);
        return new Status(IStatus.ERROR, myself.getSymbolicName(), "Could not query updates site for missing extensions", ex);
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) ProvisioningSession(org.eclipse.equinox.p2.operations.ProvisioningSession) IMetadataRepositoryManager(org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager) NodeAndBundleInformation(org.knime.core.node.NodeAndBundleInformation) ProvisionException(org.eclipse.equinox.p2.core.ProvisionException) Bundle(org.osgi.framework.Bundle) IMetadataRepository(org.eclipse.equinox.p2.repository.metadata.IMetadataRepository) URI(java.net.URI)

Example 2 with NodeAndBundleInformation

use of org.knime.core.node.NodeAndBundleInformation in project knime-core by knime.

the class NativeNodeContainer method performStateTransitionEXECUTED.

/**
 * {@inheritDoc}
 */
@Override
void performStateTransitionEXECUTED(final NodeContainerExecutionStatus status) {
    synchronized (m_nodeMutex) {
        switch(getInternalState()) {
            case POSTEXECUTE:
                closeFileStoreHandlerAfterExecute(status.isSuccess());
                if (status.isSuccess()) {
                    if (this.getNode().getLoopContext() != null) {
                        // loop not yet done - "stay" configured until done.
                        assert this.getLoopStatus().equals(LoopStatus.RUNNING);
                        setInternalState(InternalNodeContainerState.CONFIGURED_MARKEDFOREXEC);
                    } else {
                        setInternalState(InternalNodeContainerState.EXECUTED);
                        m_nodeAndBundleInformation = new NodeAndBundleInformation(m_node);
                        setExecutionEnvironment(null);
                    }
                } else {
                    // node will be configured in doAfterExecute.
                    // for now we assume complete failure and clean up (reset)
                    // We do keep the message, though.
                    NodeMessage oldMessage = getNodeMessage();
                    NodeContext.pushContext(this);
                    try {
                        performReset();
                    } finally {
                        NodeContext.removeLastContext();
                    }
                    this.clearFileStoreHandler();
                    setNodeMessage(oldMessage);
                    setInternalState(InternalNodeContainerState.IDLE);
                    setExecutionEnvironment(null);
                }
                setExecutionJob(null);
                break;
            default:
                throwIllegalStateException();
        }
    }
}
Also used : NodeAndBundleInformation(org.knime.core.node.NodeAndBundleInformation)

Example 3 with NodeAndBundleInformation

use of org.knime.core.node.NodeAndBundleInformation in project knime-core by knime.

the class InstallMissingNodesJob method run.

@Override
protected IStatus run(final IProgressMonitor monitor) {
    List<NodeAndBundleInformation> missingNodes = m_missingNodes.stream().filter(distinctByKey(i -> i.getFactoryClass())).collect(Collectors.toList());
    Set<IInstallableUnit> featuresToInstall = new HashSet<>();
    IStatus status = findExtensions(monitor, missingNodes, featuresToInstall);
    if (!status.isOK()) {
        return status;
    } else if (featuresToInstall.isEmpty()) {
        Display.getDefault().asyncExec(() -> {
            MessageDialog.openWarning(Display.getCurrent().getActiveShell(), "No suitable extension found", "Could not find any extension(s) that provides the missing node(s).");
        });
        return Status.OK_STATUS;
    } else {
        if (!missingNodes.isEmpty()) {
            Display.getDefault().syncExec(() -> {
                MessageDialog.openWarning(Display.getCurrent().getActiveShell(), "Not all extension found", "No extensions for the following nodes were found: " + missingNodes.stream().map(i -> i.getNodeNameNotNull()).collect(Collectors.joining(", ")));
            });
        }
        startInstallJob(featuresToInstall);
        return Status.OK_STATUS;
    }
}
Also used : NodeAndBundleInformation(org.knime.core.node.NodeAndBundleInformation) IStatus(org.eclipse.core.runtime.IStatus) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) HashSet(java.util.HashSet)

Aggregations

NodeAndBundleInformation (org.knime.core.node.NodeAndBundleInformation)3 IStatus (org.eclipse.core.runtime.IStatus)2 URI (java.net.URI)1 HashSet (java.util.HashSet)1 Status (org.eclipse.core.runtime.Status)1 ProvisionException (org.eclipse.equinox.p2.core.ProvisionException)1 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)1 ProvisioningSession (org.eclipse.equinox.p2.operations.ProvisioningSession)1 IMetadataRepository (org.eclipse.equinox.p2.repository.metadata.IMetadataRepository)1 IMetadataRepositoryManager (org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager)1 Bundle (org.osgi.framework.Bundle)1