Skip to content

Commit

Permalink
update ExecutionService and related, use as framework support service
Browse files Browse the repository at this point in the history
  • Loading branch information
gschueler committed Mar 24, 2011
1 parent b7e9b9d commit 9c8441c
Show file tree
Hide file tree
Showing 11 changed files with 140 additions and 270 deletions.
20 changes: 19 additions & 1 deletion core/core.ipr
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,20 @@
<setting name="root" />
</component>
<component name="GradleUISettings2">
<setting name="root" />
<setting name="root">
<setting name="task-tab">
<setting name="show-description" value="true" />
</setting>
<setting name="favorites-tab" />
<setting name="command_line-tab" />
<setting name="setup-tab">
<setting name="setup">
<setting name="custom-gradle-executor" />
<setting name="current-directory" value="$PROJECT_DIR$" />
<setting name="log-level" value="LIFECYCLE" />
</setting>
</setting>
</setting>
</component>
<component name="IdProvider" IDEtalkID="48BED7A3BBCF3323B91068465D3FF55D" />
<component name="InspectionProjectProfileManager">
Expand Down Expand Up @@ -137,6 +150,11 @@
<inspection_tool class="RequiredAttributes" enabled="true" level="WARNING" enabled_by_default="true">
<option name="myAdditionalRequiredHtmlAttributes" value="type" />
</inspection_tool>
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
<option name="processCode" value="true" />
<option name="processLiterals" value="true" />
<option name="processComments" value="true" />
</inspection_tool>
</profile>
</profiles>
<option name="PROJECT_PROFILE" value="Project Default" />
Expand Down
10 changes: 3 additions & 7 deletions core/src/java/com/dtolabs/rundeck/core/cli/ExecTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.apache.tools.ant.BuildEvent;
import org.apache.tools.ant.BuildListener;
import org.apache.tools.ant.Project;
import org.yaml.snakeyaml.Yaml;

import java.io.*;
import java.util.*;
Expand Down Expand Up @@ -491,7 +490,7 @@ private void runAction() throws Exception {
public static final String FRAMEWORK_LOG_RUNDECK_EXEC_CONSOLE_FORMAT = "framework.log.dispatch.console.format";

public ExecutionListener getExecutionListener() {
return getExecutionListener(null);
return getExecutionListener(createExecToolCommandLogger(getAntLoglevel(), null));
}
public ExecutionListener getExecutionListener(BuildListener blistener) {

Expand Down Expand Up @@ -527,6 +526,7 @@ void runAction(final BuildListener listener) throws Exception {
map.put(Project.MSG_INFO, Project.MSG_WARN);
blistener=new LogLevelConvertBuildListener(listener, map);
}else {
//XXX need this in exec listener?
blistener = createExecToolCommandLogger(getAntLoglevel(), null);
}
//store inline script content (via STDIN or script property) to a temp file
Expand All @@ -542,12 +542,8 @@ void runAction(final BuildListener listener) throws Exception {
}else if(null!=scriptpath){
setScriptAsStream(new FileInputStream(getScriptpath()));
}
//configure execution listener
final ExecutionListener executionListener = getExecutionListener(blistener);

//acquire ExecutionService object
final ExecutionService service = ExecutionServiceFactory.instance().createExecutionService(framework,
executionListener);
final ExecutionService service = framework.getExecutionService();

//submit the execution request to the service layer
result = service.executeItem(this, createExecutionItem());
Expand Down
6 changes: 6 additions & 0 deletions core/src/java/com/dtolabs/rundeck/core/common/Framework.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import com.dtolabs.rundeck.core.dispatcher.NoCentralDispatcher;
import com.dtolabs.rundeck.core.execution.ExecutionContext;
import com.dtolabs.rundeck.core.execution.ExecutionItem;
import com.dtolabs.rundeck.core.execution.ExecutionService;
import com.dtolabs.rundeck.core.execution.ExecutionServiceFactory;
import com.dtolabs.rundeck.core.execution.commands.CommandInterpreter;
import com.dtolabs.rundeck.core.execution.commands.CommandInterpreterService;
import com.dtolabs.rundeck.core.execution.dispatch.NodeDispatcher;
Expand Down Expand Up @@ -278,6 +280,7 @@ private Framework(final String rdeck_base_dir,
NodeExecutorService.getInstanceForFramework(this);
FileCopierService.getInstanceForFramework(this);
NodeDispatcherService.getInstanceForFramework(this);
ExecutionServiceFactory.getInstanceForFramework(this);

}

Expand All @@ -293,6 +296,9 @@ public void setService(String name, FrameworkSupportService service){
}
}
}
public ExecutionService getExecutionService() {
return ExecutionServiceFactory.getInstanceForFramework(this);
}

public FileCopier getFileCopierForNode(INodeEntry node) throws ExecutionServiceException {
return FileCopierService.getInstanceForFramework(this).getProviderForNode(node);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* Copyright 2011 DTO Solutions, Inc. (http://dtosolutions.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* ExecutionContextImpl.java
*
* User: Greg Schueler <a href="mailto:greg@dtosolutions.com">greg@dtosolutions.com</a>
* Created: 3/23/11 1:47 PM
*
*/
package com.dtolabs.rundeck.core.execution;

import com.dtolabs.rundeck.core.utils.NodeSet;

import java.util.*;

/**
* ExecutionContextImpl is ...
*
* @author Greg Schueler <a href="mailto:greg@dtosolutions.com">greg@dtosolutions.com</a>
*/
public class ExecutionContextImpl implements ExecutionContext {
private String frameworkProject;
private String user;
private NodeSet nodeSet;
private String[] args;
private int loglevel;
private Map<String,Map<String,String>> dataContext;
private ExecutionListener executionListener;

private ExecutionContextImpl(String frameworkProject, String user, NodeSet nodeSet, String[] args, int loglevel,
Map<String, Map<String, String>> dataContext, ExecutionListener executionListener) {
this.frameworkProject = frameworkProject;
this.user = user;
this.nodeSet = nodeSet;
this.args = args;
this.loglevel = loglevel;
this.dataContext = dataContext;
this.executionListener = executionListener;
}

public static ExecutionContextImpl createExecutionContextImpl(String frameworkProject, String user, NodeSet nodeSet,
String[] args, int loglevel,
Map<String, Map<String, String>> dataContext,
ExecutionListener executionListener) {
return new ExecutionContextImpl(frameworkProject, user, nodeSet, args, loglevel, dataContext,
executionListener);
}

public String getFrameworkProject() {
return frameworkProject;
}

public String getUser() {
return user;
}

public NodeSet getNodeSet() {
return nodeSet;
}

public String[] getArgs() {
return args;
}

public int getLoglevel() {
return loglevel;
}

public Map<String, Map<String, String>> getDataContext() {
return dataContext;
}

public ExecutionListener getExecutionListener() {
return executionListener;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,21 @@
*/
package com.dtolabs.rundeck.core.execution;

import com.dtolabs.rundeck.core.common.FrameworkSupportService;

/**
* ExecutionService is ...
*
* @author Greg Schueler <a href="mailto:greg@dtosolutions.com">greg@dtosolutions.com</a>
* @version $Revision$
*/
public interface ExecutionService {
public interface ExecutionService extends FrameworkSupportService{
public static final String SERVICE_NAME = "ExecutionService";
/**
* Execute the item and return the result.
* @param item item
* @return result
*/
public ExecutionResult executeItem(ExecutionContext context, ExecutionItem item) throws ExecutionException;

/**
* Return the execution listener if any
* @return
*/
public ExecutionListener getListener();
}

0 comments on commit 9c8441c

Please sign in to comment.