Search in sources :

Example 1 with ICapability

use of org.pentaho.capabilities.api.ICapability in project pentaho-kettle by pentaho.

the class SparkRunConfigurationExecutorTest method testExecuteWithNoAelSecurityInstalled.

@Test
public void testExecuteWithNoAelSecurityInstalled() {
    ICapability aelSecurityCapability = mock(ICapability.class);
    setCapability(aelSecurityCapability, SparkRunConfigurationExecutor.AEL_SECURITY_CAPABILITY_ID, false);
    ICapability jaasCapability = mock(ICapability.class);
    setCapability(jaasCapability, SparkRunConfigurationExecutor.JAAS_CAPABILITY_ID, false);
    SparkRunConfiguration sparkRunConfiguration = new SparkRunConfiguration();
    sparkRunConfiguration.setName("Spark Configuration");
    TransExecutionConfiguration transExecutionConfiguration = new TransExecutionConfiguration();
    sparkRunConfigurationExecutor.execute(sparkRunConfiguration, transExecutionConfiguration, abstractMeta, variableSpace, null);
    verify(jaasCapability, never()).isInstalled();
}
Also used : TransExecutionConfiguration(org.pentaho.di.trans.TransExecutionConfiguration) ICapability(org.pentaho.capabilities.api.ICapability) Test(org.junit.Test)

Example 2 with ICapability

use of org.pentaho.capabilities.api.ICapability in project pentaho-kettle by pentaho.

the class SparkRunConfigurationExecutorTest method testExecuteWithAelSecurityInstalled.

@Test
public void testExecuteWithAelSecurityInstalled() {
    ICapability aelSecurityCapability = mock(ICapability.class);
    setCapability(aelSecurityCapability, SparkRunConfigurationExecutor.AEL_SECURITY_CAPABILITY_ID, true);
    ICapability jaasCapability = mock(ICapability.class);
    setCapability(jaasCapability, SparkRunConfigurationExecutor.JAAS_CAPABILITY_ID, false);
    SparkRunConfiguration sparkRunConfiguration = new SparkRunConfiguration();
    sparkRunConfiguration.setName("Spark Configuration");
    TransExecutionConfiguration transExecutionConfiguration = new TransExecutionConfiguration();
    sparkRunConfigurationExecutor.execute(sparkRunConfiguration, transExecutionConfiguration, abstractMeta, variableSpace, null);
    verify(jaasCapability).isInstalled();
    verify(jaasCapability).install();
}
Also used : TransExecutionConfiguration(org.pentaho.di.trans.TransExecutionConfiguration) ICapability(org.pentaho.capabilities.api.ICapability) Test(org.junit.Test)

Example 3 with ICapability

use of org.pentaho.capabilities.api.ICapability in project pentaho-kettle by pentaho.

the class SparkRunConfigurationExecutor method execute.

/**
 * Installs the aries-rsa-discovery-zookeeper feature if not installed and sets the host and port for zookeeper.
 * Sets the appropriate variables on the transMeta for the spark engine
 *
 * @param runConfiguration The configuration for running on Spark
 * @param configuration    The configuration for executing a transformation
 * @param meta             Unused in this implementation
 * @param variableSpace    The variableSpace used to set the engine runtime values
 */
@Override
public void execute(RunConfiguration runConfiguration, ExecutionConfiguration configuration, AbstractMeta meta, VariableSpace variableSpace, Repository repository) {
    // Check to see if the ael-security feature is installed. If it is, then install the jaas capability if it is
    // not already installed
    ICapability securityCapability = capabilityManager.getCapabilityById(AEL_SECURITY_CAPABILITY_ID);
    ICapability jaasCapability = capabilityManager.getCapabilityById(JAAS_CAPABILITY_ID);
    if (securityCapability != null && securityCapability.isInstalled()) {
        if (jaasCapability != null && !jaasCapability.isInstalled()) {
            jaasCapability.install();
        }
    }
    SparkRunConfiguration sparkRunConfiguration = (SparkRunConfiguration) runConfiguration;
    String runConfigSchema = Const.NVL(sparkRunConfiguration.getSchema(), "");
    String runConfigURL = Const.NVL(sparkRunConfiguration.getUrl(), "");
    URI uri = URI.create(runConfigSchema.trim() + runConfigURL.trim());
    String protocol = uri.getScheme();
    String host = uri.getHost();
    String port = uri.getPort() == -1 ? null : String.valueOf(uri.getPort());
    // Variables for Websocket spark engine version
    variableSpace.setVariable("engine.protocol", Const.NVL(protocol, DEFAULT_PROTOCOL));
    variableSpace.setVariable("engine.host", Const.NVL(host, DEFAULT_HOST));
    variableSpace.setVariable("engine.port", Const.NVL(port, DEFAULT_WEBSOCKET_PORT));
    // Sets the appropriate variables on the transformation for the spark engine
    variableSpace.setVariable("engine", "remote");
    variableSpace.setVariable("engine.remote", "spark");
}
Also used : ICapability(org.pentaho.capabilities.api.ICapability) URI(java.net.URI)

Example 4 with ICapability

use of org.pentaho.capabilities.api.ICapability in project pentaho-kettle by pentaho.

the class CapabilityManagerDialog method open.

public void open() {
    final Display display = parent.getDisplay();
    shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
    props.setLook(shell);
    shell.setImage(GUIResource.getInstance().getImageSpoon());
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;
    shell.setLayout(formLayout);
    shell.setText(BaseMessages.getString(getClass(), "CapabilityManager.Dialog.Title"));
    int margin = Const.MARGIN;
    Button closeButton = new Button(shell, SWT.PUSH);
    closeButton.setText(BaseMessages.getString(getClass(), "System.Button.Close"));
    BaseStepDialog.positionBottomButtons(shell, new Button[] { closeButton }, margin, null);
    // Add listeners
    closeButton.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            shell.dispose();
        }
    });
    ScrolledComposite scrollpane = new ScrolledComposite(shell, SWT.BORDER | SWT.V_SCROLL);
    FormData treeFormData = new FormData();
    // To the right of the label
    treeFormData.left = new FormAttachment(0, 0);
    treeFormData.top = new FormAttachment(0, 0);
    treeFormData.right = new FormAttachment(100, 0);
    Label label = new Label(shell, SWT.NONE);
    label.setText("Capabilities:");
    label.setLayoutData(treeFormData);
    treeFormData = new FormData();
    // To the right of the label
    treeFormData.left = new FormAttachment(0, 0);
    treeFormData.top = new FormAttachment(label, 0);
    treeFormData.right = new FormAttachment(100, 0);
    treeFormData.bottom = new FormAttachment(closeButton, -margin * 2);
    scrollpane.setLayoutData(treeFormData);
    scrollpane.setExpandVertical(true);
    scrollpane.setExpandHorizontal(true);
    scrollpane.setAlwaysShowScrollBars(true);
    Composite mainPanel = new Composite(scrollpane, SWT.NONE);
    scrollpane.setContent(mainPanel);
    scrollpane.setSize(250, 400);
    mainPanel.setLayout(new GridLayout(1, false));
    Set<ICapability> allCapabilities = DefaultCapabilityManager.getInstance().getAllCapabilities();
    SortedSet<ICapability> capabilitySortedSet = new TreeSet<ICapability>(allCapabilities);
    for (final ICapability capability : capabilitySortedSet) {
        final Button button = new Button(mainPanel, SWT.CHECK);
        button.setLayoutData(new GridData(GridData.FILL_BOTH, SWT.BEGINNING, false, false));
        button.setSelection(capability.isInstalled());
        button.setText(capability.getId());
        buttons.add(button);
        button.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent selectionEvent) {
                final boolean selected = ((Button) selectionEvent.widget).getSelection();
                new Thread(new Runnable() {

                    @Override
                    public void run() {
                        final Future<Boolean> future = (selected) ? capability.install() : capability.uninstall();
                        try {
                            final Boolean successful = future.get();
                            display.asyncExec(new Runnable() {

                                @Override
                                public void run() {
                                    button.setSelection(successful);
                                    if (!successful) {
                                        MessageDialog dialog = new MessageDialog(shell, "Capability Install Error", null, "Error Installing Capability:\n\n" + capability.getId(), MessageDialog.ERROR, new String[] { "OK" }, 0);
                                        dialog.open();
                                    } else {
                                        MessageDialog dialog = new MessageDialog(shell, "Capability Install Success", null, capability.getId() + " " + ((!selected) ? "un" : "") + "installed successfully", MessageDialog.INFORMATION, new String[] { "OK" }, 0);
                                        dialog.open();
                                    }
                                    updateAllCheckboxes();
                                }
                            });
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        } catch (ExecutionException e) {
                            e.printStackTrace();
                        }
                    }
                }).run();
            }
        });
    }
    mainPanel.setSize(mainPanel.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    scrollpane.setMinSize(mainPanel.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    BaseStepDialog.setSize(shell, 250, 400, false);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
}
Also used : Listener(org.eclipse.swt.widgets.Listener) Label(org.eclipse.swt.widgets.Label) Shell(org.eclipse.swt.widgets.Shell) GridLayout(org.eclipse.swt.layout.GridLayout) ICapability(org.pentaho.capabilities.api.ICapability) Button(org.eclipse.swt.widgets.Button) TreeSet(java.util.TreeSet) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) ExecutionException(java.util.concurrent.ExecutionException) FormAttachment(org.eclipse.swt.layout.FormAttachment) FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Future(java.util.concurrent.Future) Display(org.eclipse.swt.widgets.Display)

Aggregations

ICapability (org.pentaho.capabilities.api.ICapability)4 Test (org.junit.Test)2 TransExecutionConfiguration (org.pentaho.di.trans.TransExecutionConfiguration)2 URI (java.net.URI)1 TreeSet (java.util.TreeSet)1 ExecutionException (java.util.concurrent.ExecutionException)1 Future (java.util.concurrent.Future)1 MessageDialog (org.eclipse.jface.dialogs.MessageDialog)1 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 FormAttachment (org.eclipse.swt.layout.FormAttachment)1 FormData (org.eclipse.swt.layout.FormData)1 FormLayout (org.eclipse.swt.layout.FormLayout)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 Display (org.eclipse.swt.widgets.Display)1 Event (org.eclipse.swt.widgets.Event)1