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();
}
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();
}
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");
}
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();
}
}
}
Aggregations